AGI Sound Tutorial v1.0
Page: 1 2 3 4 5 6
7 8 [ 9 ] 10 11 12
13
9. Sound in your game
Here's the section where you get
to find out how to play a sound in your game.
Most of this is probably obvious to the veteran AGI developer, but at least it's all laid out. The interpreter's sound system is fairly simple:
only letting you play one sound at a time, and lets you set a flag when the sound is done. Sounds cannot be played across rooms, games, if you
quit or pause. The sound must exist in the volume resources or the interpreter will just print an error and quit.
Sound in AGI are controlled by a handful of flags, variables and commands:
- command - "load.sound(sound number)"
- command - "sound(sound number, done flag)"
- command - "stop.sound()"
- command - "discard.sound(sound number)' (only on Amiga v3 interpreters)
- flag 9 - sound state
- done flag (variable) - flag which is reset when the sound is playing, set when it is finished.
- variable 22 - sound type
- variable 23 - sound volume.
Sample code: Here is a basic logic template for a room which plays a sound:
if (isset(f5))
{
load.sound(10);
return();
}
if ()
{
sound(10,f240);
}
if (isset(f240))
{
}
if ()
{
stop.sound();
}
return();
Flags: The interpreter looks at 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.
Variables: 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.
Interpreter Capabilities: The capabilities of different AGI interpreters differ from interpreter to interpreter. Hopefully this table
will help you pick the interpreter you wish to use for your game:
- PC - supports only the first channel for music out of the pc speaker. Old reliable. You have to make sure the music sounds semi-good
on this interpreter at least.
- Amiga, Macintosh, PCjr - supports the 3 channels and the noise channel. Amiga v3 interpreters allow you to discard games. Will require
you to use an emulator to run the interpreter however.pre envelope interpreters
- AGIL - Supports the full 3 channels and proper noise support (different noise frequencies). I've noticed with one sound it missed the first
note but otherwise it's great. Don't know how it supports the done flag.
- NAGI - Supports the full 3 channels, proper noise and envelopes for notes add a bit more emphasis. Properly supports the done flag.
- Sarien - Supports the full 3 channels, basic noise support and envelopes as well. Sarien was the first interpreter to have all of these features. The
noise support is only white noise and does not support the different frequencies. Earlier versions had problems with not resetting the done
flag, but recent version have this fixed.
- Interpreter patches - patches to the original PC interpreter to support Soundblaster or MIDI. Full 3 channels but no noise support.
Patches: Through the ingenuity of the AGI community, some people managed to patch onto the original interpreter the ability to play sounds through
the sound blaster or a midi device. Considering the pc interpreter was designed to only use the pc or pcjr speaker, this is pretty amazing. The
two known sound patches available are "agisb" and "agimidi". Unless you have a midi device connected to your soundcard, I would
reccomend using "agisb". The command to call either of these programs is pretty easy. Call it in the same directory as your interpreter:
agisb <infile> <outfile>
agimidi <infile> <outfile>
where infile and outfile are exectuable names.
Page: 1 2 3 4 5 6
7 8 [ 9 ] 10 11 12
13
You can help keep The Sierra Help Pages and its affiliates alive by helping to defray some of the
costs of hosting this site. If it has been of help to you, please consider contributing to help keep it online.
Thank you.
Top
The Sierra Help Pages | Sierra
Game Help | Walkthroughs | Hints,
Tips & Spoilers | Utilities | Links | SHP
Forums | Search
© 2013 to present The Sierra Help Pages. All rights reserved. All Sierra games, artwork and music © Sierra.
�