Sound in AGI are controlled by a handful of flags, variables and commands:
discard.sound(n)- only on Amiga v3 interpreters
Where 'n' is the number of the sound and 'f' is the flag
The interpreter looks for two flags whenever you play a sound. Flag 9 which defines whether or not to actually play sounds and then the flag you define when you play a sound.
- Flag 9: If this is set, then sounds will play. If it is not set. then.. hey, sounds won't play.
- Done flag: Whenever you play a sound, this flag is cleared. This is always done, even if flag 9 is not set. When it gets to playing the sound itself, when the sound is finished, or it discovers flag 9 is set (even whilst in the middle of a song), it will stop the sound and set the done flag. So if sound is disabled, the done flag will appear to have been set instantaneously.
There are three variables that dictate how the sound works.
- Sound type (var 22)- defines how many tone channels are available to play. PC interpreters set this to 1. Amiga, Mac and PCjr set this to 3.
- Sound volume (var 23) - defines the overall volume of games. The volume in agi sounds go from 0 (maximum volume) to 15 (silent). Notice how 0 is the MAXIMUM volume and not 15. It seems like it is in reverse, but just think of it as a value subtracted from the max volume. A lot of fan made games incorrectly set this value wrong, so their music comes out silent on interpreters that properly handle the volume variable.