Previous Book Contents Book Index Next

Inside Macintosh: Sound /
Chapter 2 - Sound Manager / About the Sound Manager


Legacy Documentclose button

Important: Inside Macintosh: Sound is deprecated as of Mac OS X v10.5. For new audio development in Mac OS X, use Core Audio. See the Audio page in the ADC Reference Library.

Sound Channels

A sound channel is a queue of sound commands that is managed by the Sound Manager, together with other information about the sounds to be played in that channel. The commands placed into the channel might originate from an application or from the Sound Manager itself. The commands in the queue are passed one by one, in a first-in, first-out (FIFO) manner, to the Sound Manager for interpretation and processing.

The Sound Manager uses the SndChannel data type to define a sound channel.

TYPE SndChannel =
PACKED RECORD
   nextChan:      SndChannelPtr; {pointer to next channel}
   firstMod:      Ptr;           {used internally}
   callBack:      ProcPtr;       {pointer to callback procedure}
   userInfo:      LongInt;       {free for application's use}
   wait:          LongInt;       {used internally}
   cmdInProgress: SndCommand;    {used internally}
   flags:         Integer;       {used internally}
   qLength:       Integer;       {used internally}
   qHead:         Integer;       {used internally}
   qTail:         Integer;       {used internally}
   queue:         ARRAY[0..stdQLength-1] OF SndCommand;
END; 
Most of the fields of the sound channel record are used internally by the Sound Manager, and you should not access or change them. However, your application is free to use the userInfo field to store any information that you wish to associate with a sound channel. For example, you might store a handle to an application-defined record that contains information about how your application is using the channel.

Some applications do not need to worry about creating or disposing of sound channels because the high-level Sound Manager routines take care of these automatically. However, if you wish to customize sound output or play sounds asynchronously, you must create your own sound channels (with the SndNewChannel function).

The enhanced Sound Manager included in system software versions 6.0.7 and later provides the ability to have multiple channels of sampled sound produce output on the Macintosh audio hardware concurrently. (Previous versions of the Sound Manager could play only a single channel of sampled sound at a time.) This allows a layering of sound that can bring a touch of reality to a simulation or presentation and permits applications to incorporate synthesized speech output with any other kind of Macintosh-generated sound. Sound Manager version 3.0 extended this capability to allow multiple channels of any kind of sound data to play simultaneously.

Your application can open several channels of sound for concurrent output on the available audio hardware. Similarly, multiple applications can each open channels of sound. The number and quality of concurrent channels of sound are limited only by the abilities of the machine, particularly by the speed of the CPU. Different Macintosh computers have different CPU clock speeds and execute instructions at quite different rates. This means that some machines can manage more channels of sound and produce higher-quality sound than other machines. For example, a Macintosh Quadra might be able to support several channels of high-quality stereo sound without significant impact on other processing, whereas a Macintosh Plus might be able to support only a single channel of monophonic sound before other processing slows significantly.

The Sound Manager currently supports multiple channels of sound only on machines equipped with an Apple Sound Chip or equivalent hardware. To maintain maximum compatibility between machines for your applications, you should always check the operating environment to make sure that the ability to play multiple channels of sampled sound is present before attempting to do so. A technique for determining whether your application can play multiple channels of sound is described in "Testing for Multichannel Sound and Play-From-Disk Capabilities" on page 2-35.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996