Previous Book Contents Book Index Next

Inside Macintosh: Sound /
Chapter 2 - Sound Manager / Sound Manager Reference
Data Structures


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 Double Buffer Header Records

You must fill in a sound double buffer header record and two sound double buffer records if you wish to manage your own double buffers. The SndDoubleBufferHeader data type defines a sound double buffer header.

TYPE SndDoubleBufferHeader =
PACKED RECORD
   dbhNumChannels:      Integer;       {number of sound channels}
   dbhSampleSize:       Integer;       {sample size, if noncompressed}
   dbhCompressionID:    Integer;       {ID of compression algorithm}
   dbhPacketSize:       Integer;       {number of bits per packet}
   dbhSampleRate:       Fixed;         {sample rate}
   dbhBufferPtr:        ARRAY[0..1] OF SndDoubleBufferPtr;
                                       {pointers to SndDoubleBuffer}
   dbhDoubleBack:       ProcPtr;       {pointer to doubleback procedure}
END;
Sound Manager versions 3.0 and later support custom compression and decompression algorithms by defining the revised sound double buffer header record, of type SndDoubleBufferHeader2. It's identical to the SndDoubleBufferHeader data type except that it contains the dbhFormat field at the end.

TYPE SndDoubleBufferHeader2 =
PACKED RECORD
   dbhNumChannels:      Integer;       {number of sound channels}
   dbhSampleSize:       Integer;       {sample size, if noncompressed}
   dbhCompressionID:    Integer;       {ID of compression algorithm}
   dbhPacketSize:       Integer;       {number of bits per packet}
   dbhSampleRate:       Fixed;         {sample rate}
   dbhBufferPtr:        ARRAY[0..1] OF SndDoubleBufferPtr;
                                       {pointers to SndDoubleBuffer}
   dbhDoubleBack:       ProcPtr;       {pointer to doubleback procedure}
   dbhFormat:           OSType;        {signature of codec}
END;
Field Description
dbhNumChannels
The number of channels for the sound (1 for monophonic sound, 2 for stereo).
dbhSampleSize
The sample size for the sound if the sound is not compressed. If the sound is compressed, dbhSampleSize should be set to 0. Samples that are 1-8 bits have a dbhSampleSize value of 8; samples that are 9-16 bits have a dbhSampleSize value of 16. Currently, only 8-bit samples are supported. For further information on sample sizes, refer to the AIFF specification.
dbhCompressionID
The compression identification number of the compression algorithm, if the sound is compressed. If the sound is not compressed, dbhCompressionID should be set to 0.
dbhPacketSize
The packet size in bits for the compression algorithm specified by dbhCompressionID, if the sound is compressed.
dbhSampleRate
The sample rate for the sound. Note that the sample rate is declared as a Fixed data type, but the most significant bit is not treated as a sign bit; instead, that bit is interpreted as having the value 32,768.
dbhBufferPtr
An array of two pointers, each of which should point to a valid SndDoubleBuffer record.
dbhDoubleBack
A pointer to the application-defined routine that is called when the double buffers are switched and the exhausted buffer needs to be refilled.
dbhFormat
The data format type. This field contains a value of type OSType that defines the compression algorithm, if any, to be used to decompress the audio data. For example, for data generated using MACE 3:1 compression, this field should contain the value 'MAC3'. See page 2-86 for a list of the format types defined by Apple. This field is used only if the dbhCompressionID field contains the value fixedCompression.
The dbhBufferPtr array contains pointers to two sound double buffer records, whose format is defined below. These are the two buffers between which the Sound Manager switches until all the sound data has been sent into the sound channel. When you make the call to SndPlayDoubleBuffer, the two buffers should both already contain a nonzero number of frames of data.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996