Music by Daniel Stelzer


This is a very simple sound and music library for Glulx. There are three sound channels: foreground, background, and midground. (More can be created, but it requires editing the extension.) Sounds are initialized as described in Writing with Inform, but the process of controlling them has changed.

loop (sound name)
loop (sound name) on (sound channel)
play (sound name) repeating (number) times
play (sound name) on (sound channel)
play (sound name) on (sound channel) repeating (number) times
stop (sound name)

If no channel is specified, it defaults to the foreground.

You can also fade a channel in or out, or crossfade them, although only one fade can be running at a time.

fade (sound channel) from (volume) to (volume) over (number) milliseconds/ms
start a crossfade with (sound channel) going from (volume) to (volume) and (sound channel) going from (volume) to (volume) over (number) milliseconds/ms

Volumes are specified as numbers between 0 (silent) and 65535 (maximum volume). All sounds start at 65535 unless otherwise specified.

To make crossfades easier in the most common usage case, there is a simpler phrase as well.

introduce (sound name)

This starts a new soundtrack looping on either the foreground or the background channel and crossfades it in over two seconds, sending the opposite channel to zero. NB: If you attempt to introduce a new sound while a different one is still being faded in, the older one will take precedence! To prevent that, you can use this check.

if a crossfade is in progress...

Depending on your usage, you could add a simple do-nothing loop until the fade is finished, or modify the "calculate the crossfade rule" to switch tracks in the middle of the fade.