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.
Extended Sound Header Records
For sampled-sound data that is more complex than a standard sound header can describe, the Sound Manager uses an extended sound header record. Sound data described by such a header can be monophonic or stereo, but it cannot be compressed.Most of the fields of the extended sound header correspond to fields of the sampled sound header. However, the extended sound header allows the encoding of stereo sound. The
numChannels
field contains the number of channels of sound recorded, and thenumFrames
field contains the number of frames of sound recorded in each channel. For more information on the format of sampled sound frames, see "Sound Files" on page 2-81.
- Note
- The word "channel" can be confusing in this context, because a sound resource containing polyphonic sound (that is, multichannel sound) can be played on a single Sound Manager sound channel. Channel is a general term for the portion of sound data that can be described by a single sound wave. Monophonic sound is composed of a single channel. Stereo sound (also called polyphonic sound) is composed of several channels of sound played simultaneously. "Sound channel" is a term specific to the Sound Manager.
TYPE ExtSoundHeader = PACKED RECORD samplePtr: Ptr; {if NIL, samples in sampleArea} numChannels: LongInt; {number of channels in sample} sampleRate: Fixed; {rate of original sample} loopStart: LongInt; {loop point beginning} loopEnd: LongInt; {loop point ending} encode: Byte; {sample's encoding option} baseFrequency: Byte; {base freq. of original sample} numFrames: LongInt; {total number of frames} AIFFSampleRate: Extended80; {rate of original sample} markerChunk: Ptr; {reserved} instrumentChunks: Ptr; {pointer to instrument info} AESRecording: Ptr; {pointer to audio info} sampleSize: Integer; {number of bits per sample} futureUse1: Integer; {reserved} futureUse2: LongInt; {reserved} futureUse3: LongInt; {reserved} futureUse4: LongInt; {reserved} sampleArea: PACKED ARRAY[0..0] OF Byte; END;To compute the total number of bytes of a sample, multiply the values in the
Field Description
samplePtr
- A pointer to the sampled-sound data. If the sampled sound is located in memory immediately after the
futureUse4
field, then this field should be set toNIL
. Otherwise, this field is a pointer to the memory location of the sampled-sound data.numChannels
- The number of channels in the sampled-sound data.
sampleRate
- The rate at which the sample was originally recorded. The approximate sample rates are shown in Table 2-1 on page 2-16. 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.loopStart
- The starting point of the portion of the extended sampled sound header that is to be used by the Sound Manager when determining the duration of
freqDurationCmd
. These loop points specify the byte numbers in the sampled data to be used as the beginning and end points to cycle through when playing the sound. The loop starting and ending points are 0-based.loopEnd
- The end point of the portion of the extended sampled sound header that is to be used by the Sound Manager when determining the duration of
freqDurationCmd
.encode
- The method of encoding used to generate the sampled-sound data. For an extended sound header, you should specify the constant
extSH
. Encode option values in the ranges 0 through 63 and 128 to 255 are reserved for use by Apple. You are free to use numbers in the range 64 through 127 for your own encode options.baseFrequency
- The pitch at which the original sample was taken. This value must be in the range 1 through 127. Table 2-2 on page 2-43 lists the possible
baseFrequency
values. ThebaseFrequency
value allows the Sound Manager to calculate the proper playback rate of the sample when an application uses thefreqDurationCmd
command. Applications should not alter thebaseFrequency
field of a sampled sound; to play the sample at different pitches, usefreqDurationCmd
orfreqCmd
.numFrames
- The number of frames in the sampled-sound data. Each frame contains
numChannels
bytes for 8-bit sound data.AIFFSampleRate
- The sample rate at which the frames were sampled before compression, as expressed in the 80-bit extended data type representation.
markerChunk
- Synchronization information. The
markerChunk
field is not presently used and should be set toNIL
.instrumentChunks
- Instrument information.
AESRecording
- Information related to audio recording devices.
sampleSize
- The number of bits in each sample frame.
futureUse1
- Reserved.
futureUse2
- Reserved.
futureUse3
- Reserved.
futureUse4
- The four
futureUse
fields are reserved for use by Apple. To maintain compatibility with future releases of system software, you should always set these fields to 0.sampleArea
- An array of interleaved sample points, each of which contains a value similar to the values in a wave-table description. For 8-bit sampled-sound data, these values are interpreted as offset values, where $80 represents an amplitude of 0. The value $00 is the largest negative amplitude, and $FF is the largest positive amplitude.
numChannels
,numFrames
, andsampleSize
fields and divide by the number of bytes per sample (typically 8 or 16).
- Note
- Although extended sound headers (and compressed sound headers, described next) support the storage of 16-bit sound, only versions 3.0 and later of the Sound Manager can play 16-bit sounds. If your application uses 16-bit sound, you must convert it to 8-bit sound before earlier versions of the Sound Manager can play it.