Previous Book Contents Book Index Next

Inside Macintosh: Sound /
Chapter 5 - Sound Components / Sound Components 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 Component Data Records

The flow of data from one sound component to another is managed using a sound component data record. This record indicates to other sound components the format of the data that a particular component is generating, together with the location and length of the buffer containing that data. This allows other sound components to access data from that component as needed. A sound component data record is defined by the SoundComponentData data type.

typedef struct {
   long           flags;               /*sound component flags*/
   OSType         format;              /*data format*/
   short          numChannels;         /*number of channels in data*/
   short          sampleSize;          /*size of a sample*/
   UnsignedFixed  sampleRate;          /*sample rate*/
   long           sampleCount;         /*number of samples in buffer*/
   Byte           *buffer;             /*location of data*/
   long           reserved;            /*reserved*/
} SoundComponentData, *SoundComponentDataPtr;
Field Description
flags
A set of bit flags whose meanings are specific to a particular sound component.
format
The format of the data a sound component is producing. The following formats are defined by Apple:
               #define kOffsetBinary         'raw '
               #define kTwosComplement       'twos'
               #define kMACE3Compression     'MAC3'
               #define kMACE6Compression     'MAC6'
See "Audio Data Types" on page 5-26 for a description of these formats. You can define additional format types, which are currently assumed to be the types of proprietary compression algorithms.
numChannels
The number of channels of sound in the output data stream. If this field contains the value 1, the data is monophonic. If this field contains 2, the data is stereophonic. Stereo data is stored as interleaved samples, in a left-to-right ordering.
sampleSize
The size, in bits, of each sample in the output data stream. Typically this field contains the values 8 or 16. For compressed sound data, this field indicates the size of the samples after the data has been expanded.
sampleRate
The sample rate for the audio data. The sample rate is expressed as an unsigned, fixed-point number in the range 0 to 65536.0 samples per second.
sampleCount
The number of samples in the buffer pointed to by the buffer field. For compressed sounds, this field indicates the number of compressed samples in the sound, not the size of the buffer.
buffer
The location of the buffer that contains the sound data.
reserved
Reserved for future use. You should set this field to 0.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996