After Dark modules

Using Sound

After Dark allows modules to play sounds while saving the screen. To use sound in your module you must have a resource of type 'Chnl' (described in the section "Sound Resources"). You also need to use two libraries on the After Dark disk, Sound and EntryPoints. The Sound library sends the sound calls your module makes on to After Dark (which carries them out). The EntryPoints library coordinates the communication between the Sound library and After Dark. If you are using MPW C, MPW Pascal or Think Pascal use the libraries Sound.o and EntryPoints.o. If you are using Think C use the libraries Sound.pi and EntryPoints.pi.

This schema for handling sound is different from previous versions of After Dark and will only work with After Dark 2.0u or later. You must check for the presence of the sound routines in After Dark. To do this we have defined a bit in the systemConfig field of GMParamBlock. Bit 14 is set to 1 if the sound routines are present. In DoInitialize() your module should check this bit before attempting to play sound.

The sound routines support the playing of 'snd ' resources (also known as sampledSynth type sounds). There are four routines used to play sound. All of the routines take the parameter "sndChannel" (OpenSound() also takes "params" as a parameter). The routines are: OpenSound(), PlaySound(), QuietSound(), and CloseSound(). Call OpenSound() in your module's DoInitialize() routine to setup the playing of sound. To play a sound, call PlaySound() with a handle to a 'snd ' resource. If you want to stop a sound being played, call QuietSound(). Call CloseSound() in you module's DoClose() routine to shutdown sound playing.

For more information about sound, see the Sound Manager chapter in Inside Macintosh Volume 6.


Begin | Introduction | Getting Started | main() | Advanced | Parameters | Sound | Resources | Hints & Tips | Further Info