Carbon


SoundHeader

Header: Sound.h

struct SoundHeader {
    Ptr samplePtr; 
    UInt32 length; 
    UnsignedFixed sampleRate; 
    UInt32 loopStart; 
    UInt32 loopEnd; 
    UInt8 encode; 
    UInt8 baseFrequency; 
    UInt8 sampleArea[1];
};
typedef SoundHeader SoundHeaderPtr;

Field descriptions

samplePtr

A pointer to the sampled-sound data. If the sampled sound is located in memory immediately after the baseFrequency field, then this field should be set to NULL. Otherwise, this field is a pointer to the memory location of the sampled-sound data. (This might be useful if you want to change some fields of a sound header but do not want to modify a handle to a sound resource directly.)

length

The number of bytes of sound data.

sampleRate

The rate at which the sample was originally recorded. See “Sample Rate Constants”.

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 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 sampled sound header that is to be used by the Sound Manager when determining the duration of freqDurationCmd. If no looping is desired, set both loopStart and loopEnd to 0.

encode

The method of encoding used to generate the sampled-sound data. The current encoding option values are stdSH, extSH, and cmpSH. See “Encoding Constants”. For a standard sound header, you should specify the constant stdSH. 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. The baseFrequency value allows the Sound Manager to calculate the proper playback rate of the sample when an application uses the freqDurationCmd command. Applications should not alter the baseFrequency field of a sampled sound; to play the sample at different pitches, use freqDurationCmd or freqCmd.

sampleArea

If the value of samplePtr is NULL, this field is an array of bytes, each of which contains a value similar to the values in a wave-table description. These values are interpreted as offset values, where $80 represents an amplitude of 0. The value $00 is the most negative amplitude, and $FF is the largest positive amplitude. The samples are numbered 1 through the value in the length parameter.

Sound resources often contain sampled-sound data as well as sound commands. The sound data is contained in the last field of the sound header. You can access a sound header structure to find information about sampled-sound data. The standard sound header is used only for simple monophonic sounds. The SoundHeader data type defines a sampled sound header structure.

If you need to create a sound header for sampled-sound data that your application has recorded, then you should use the SetupSndHeader function.

You should use this data structure only if you need to access this information or to customize sound play.


© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)