| Q:
	
I'm importing AIFF files containing 24-bit audio ( k24BitFormat). However, when I examine the sound mediaSoundDescription,sampleSizealways says 16. How can I find the actual audio bit depth without having to check thedataFormatfield?A: The value reflected in the sampleSizefield is a remnant of the old Sound Manager where the native resolution was 16-bit integer samples through the processing chain, and all formats reported a sample size of either 8-bit or 16-bit. In order to find the true sample size, you'll need to retrieve the AudioStreamBasicDescriptionfrom theSoundDescriptionHandleby callingQTSoundDescriptionGetPropertyusing thekQTSoundDescriptionPropertyID_AudioStreamBasicDescriptionproperty. Listing 1: Retrieving the ASBD from a SoundDescriptionHandlesnippet.  SoundDescriptionHandle hSoundDescription = (SoundDescriptionHandle)NewHandle(0);
    AudioStreamBasicDescription asbd = {0};
    OSStatus err;
    ...
    GetMediaSampleDescription(aSoundMedia, index, (SoundDescriptionHandle)hSoundDescription);
    if (err = GetMoviesError()) goto bail;
    err = QTSoundDescriptionGetProperty(hSoundDescription, kQTPropertyClass_SoundDescription,
                  kQTSoundDescriptionPropertyID_AudioStreamBasicDescription, sizeof(asbd), &asbd, NULL);
    ...
bail:
    If (hSoundDescription) DisposeHandle((Handle) hSoundDescription);In the returned AudioStreamBasicDescription, check themBitsPerChannelfield. This is the number of bits of sample data for each channel in a frame of data. If mBitsPerChannelis zero, you're dealing with a compressed format. ThemFormatIDfield of theAudioStreamBasicDescriptionindicates the general kind of data in the stream. Some compressed formats have the ability to indicate the precision of the original source data. Apple Lossless for example ( mFormatIDfield ==kAudioFormatAppleLossless) performs true lossless compression and reports the precision of the original source data though flags set in themFormatFlagsfield of theAudioStreamBasicDescription. The kAppleLosslessFormatFlags_xxxflags are located inCoreAudioTypes.h kAppleLosslessFormatFlag_16BitSourceData - This flag is set for Apple Lossless data that was sourced
from 16 bit native endian signed integer data.
kAppleLosslessFormatFlag_20BitSourceData - This flag is set for Apple Lossless data that was sourced
from 20 bit native endian signed integer data aligned high in 24 bits.
kAppleLosslessFormatFlag_24BitSourceData - This flag is set for Apple Lossless data that was sourced
from 24 bit native endian signed integer data.
kAppleLosslessFormatFlag_32BitSourceData - This flag is set for Apple Lossless data that was sourced
from 32 bit native endian signed integer data. ReferenceAudioStreamBasicDescription- Contains all the information needed for describing streams of audio data.
 Back to Top  Document Revision History
| Date | Notes |  
| 2008-11-05 | editorial |  
| 2006-05-17 | Discusses how to retrieve accurate audio format bit depth. |  Posted: 2008-11-05 |