From IFWiki

Note: For the IF Comp 2020 game, see SOUND (by CynthiaP).

Sound is an auditory stimulus. Almost all IF games and programming systems have a method to support noises and music.

For Authors: Code Compare

First steps

  • ADRIFT 4: You will need to first enable the sound anchor points within the ADRIFT Generator. Select
Adventure > Options... > (checked) Enable Sound in games
to enable them. Sound anchor points are places in the program where you can start or stop a sound from playing.
  • Hugo: Sound and music files (along with images and video files) must be first declared as part of a resource file, for example:
resource "RES1"
   "c:\hugo\sounds\squeaky door.wav"
   "c:\hugo\music\trippy intro.mod"
The name of the resource file must be limited to 8 alphanumeric characters, and the original filenames after being stripped of their paths and extensions must be unique (so your code can unambiguously refer to "squeaky door", "doorbell" and "trippy intro", for example).
  • Inform 7: Create a Sounds subfolder in your project's Materials folder. Put sound files in the Sounds folder so Inform 7 can find them. Sounds must first be declared in your code before they can be used; e.g.:
Sound of squeaky door is the file "Squeaky door.ogg".
Sound names (e.g. Sound of squeaky door) must begin with the word "Sound".
  • TADS: TADS 2 authors must first enable HTML TADS; TADS 3 authors get HTML TADS by default.

Supported sound formats

  • ADRIFT 4 supports MIDI, MP3, and WAV formats via the Microsoft MediaPlayer.
  • Hugo supports RIFF and WAV formats for sounds, and MOD, S3M, and XM formats for music.
  • Inform 7, when compiled to Glulx, supports AIFF and OGG formats. OGG is preferred. Inform 7 does not provide any sound support for games compiled for the Z-machine.
  • HTML TADS supports MIDI, MPG, MP2, MP3, OGG, and WAV formats.

Audio Tracks

  • ADRIFT 4 and Inform 7 are both currently limited to 1 track. They can only play one sound at a time.
  • Hugo has 2 tracks: "sound" and "music".
  • HTML TADS has 4 audio tracks which it calls "layers": "background" (for continuous background music), "bgambient" (for continuous non-musical sounds), "ambient" (for non-continuous sounds), and "foreground" (for immediate one-time sounds in direct response to a game event).

Playing sounds and music

  • ADRIFT 4: Click on a sound anchor point and fill in the Sound dialog box as appropriate. Sounds can be played (or stopped) when the player examines a room, object, or character; when a task is completed; at all five stages of an event; and whenever a character enters or leaves the PC's current location.
  • Hugo: To play a sound or music, use either the sound or music statement as appropriate:
sound (repeat) resourcefile, resource (, volume)
music (repeat) resourcefile, resource (, volume)

If using resource.h, you can use the wrapper functions PlaySound and PlayMusic instead:

PlaySound( resourcefile, sample, loop, force )
PlayMusic( resourcefile, song, loop, force )
  • Inform 7: Sounds are played via the play phrase, for example:
play the sound of squeaky door;

The only option currently available for a play phrase is "one time only", which will prevent a sound from playing more than once during a game session.

  • HTML TADS: Use the <SOUND> tag to play or cancel sounds or music. The <SOUND> tag must be sent as text to the game's main window in order to work; it will be ignored if sent to a subwindow. A summary of this tag's options:
<SOUND SRC = "file"
       RANDOM = 1..100
       REPEAT = integer|LOOP
       CANCEL (= layername)
       ALT = "text-description"
       FADEIN = (CROSSFADE,) time-in-seconds
       FADEOUT = (CROSSFADE,) time-in-seconds
       VOLUME = 1..100


This article is a stub. You can help IFWiki by expanding it.
TODO: More details including style, appropriateness, concerns, pros/cons, tips, sound editing tools. I've never used sounds myself so if I've misrepresented an authoring system's capabilities, please fix the article!