Tutorial : Embedding Twine Audio

Packaging your twine game with the audio it uses!

Step 1 : Gather Your Sound Files

Before we can place our sounds into our game, we need to identify and download some audio files (typically as MP3s, WAVs, etc).

Consider visiting–

Step 2 : Cache Your Sound Files

Before we can make a sound / music file play within our Twine game, we need to “cache” or “prepare” the file to be played.

  • Create a new folder for your game. Place all of your audio files into it, like so.
  • Locate the “Start” passage in your twine game (it is the first one we visit when the game begins).
  • “Cache” your audio file using the “«cacheaudio»” command, like what you see here.
    • NOTE : For every audio file you have, you must write “«cacheaudio (your audio file here) (your audio file here)». In other words, you write the name of your file twice. Don’t forget the “.wav” or “.mp3” on the end!
    • NOTE : You should NOT attempt to play these files in the same passage in which they are cached, as this may cause audio to fail (the cache commands need a moment or two to finish).

Step 3 : Play Your Sound Files

Now that your audio files have been “cached” (or prepared), we need to tell our game when to play them!

  • Open a passage in your twine game and add an “«audio» command, like what you see here.
    • Note : You need to replace the “evil_laugh.wav” you see with your own file’s name. This tells Twine which audio file to play when this passage is reached.
    • Note : Repeat– Do not place an «audio» command into the same passage as your «cacheaudio» commands.
    • Note : If an audio file fails to play, or twine cannot find it, there is a chance the name of your file isn’t what you think it is. Look at your files closely (Use the right-click “Properties” or “Get Info” button) to see the file’s full name.

Step 4 : Test Your Game

NOTE : With audio, the typical way to playtest (by clicking this button) WILL NOT WORK. Instead…

  • Publish your game file into THE SAME FOLDER AS YOUR AUDIO FILES.
  • Rename your html file to “index.html”
  • Test your game to make sure it works by double-clicking your new index.html file.

Step 5 : Upload Your Game

We can now upload your game to itch.io, and the audio should work consistently.

Bonus : Review example game

The staff-created “Audio Adventure” sample game may be played online here, and downloaded / studied here.

Updated: