Home | AGI Documentation | AGI Tutorials | AGI Tools | AGI Wiki | Community

AGI Sound Tutorial v1.0

by Nick Sonneveld
Last Updated 4th March, 2002

Page: 1 2 3 4 5 6 7 8 [ 9 ] 10 11 12 13

9. Sound in your game

JukeboxHere'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:

Sample code:  Here is a basic logic template for a room which plays a sound:

Code:
// only true if a new room (flag 5)
if (isset(f5))
{
    // init code
    // ...
    
    // load up the new sound
    load.sound(10);

    // more init code
    // ...
    
    // go through logic 0 again before doing anything else.
    return();
}

if (/*certain event occurs*/)
{
    // event code
    // ...
    
    // play a sound, set flag 240 when finished
    sound(10,f240);
}

// the sound is finished, so clean up
if (isset(f240))
{
    // another action
    // ...
}

// in case we have to stop the sound early
if (/*another event occurs*/)
{
    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.

Variables:  There are three variables that dictate how the sound works.
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:
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
 


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.
pixe
Top

© 2013 to present The Sierra Help Pages. All rights reserved. All Sierra games, artwork and music © Sierra.

 �