Re: Data Types for Extracting samples from Audio Buffer
Re: Data Types for Extracting samples from Audio Buffer
- Subject: Re: Data Types for Extracting samples from Audio Buffer
- From: David Duncan <email@hidden>
- Date: Mon, 6 Oct 2008 09:24:09 -0700
"In audio data a frame is one sample across all channels. If the
ASBD describes non-interleaved audio, the byte and frame count
fields describe one channel (mBytesPerPacket would be 2 for non-
interleaved stereo 16-bit PCM). For interleaved audio, the fields
describe the set of n channels (mBytesPerPacket would be 4 for
interleaved stereo 16-bit PCM). In uncompressed audio, a packet is
one frame, (mFramesPerPacket == 1)."
To be honest this paragraph is less than illuminating, since it
states if the audio is interleaved it is interpreted one way, if
not, then in another way, but doesn't say whether you can tell if it
is interleaved or not - presumably you can using the format flags.
Also, 32-bit floating point samples are another possibility, so you
need to examine the flags to find out exactly what it is you've got
and then use the remainder of the information to determine how to
turn that into individual samples. I notice that you can also set
fields in an ASBD then call MovieAudioExtractionSetProperty followed
by MovieAudioExtractionFillBuffer to convert to your chosen format.
So if you always do want 16-bit samples, then you need to carry out
this conversion step.
Graham is correct in his interpretation of the docs. The Core Audio
SDK had sample code to assist in interpreting many of its structures,
including the ASBD that is used so commonly. These are C++ classes,
but they should be easily incorporated into any Cocoa application
(just change your source files to .mm).
You can find them in /Developer/Examples/CoreAudio/PublicUtility/. The
helper for ASBDs is the CAStreamBasicDescription class.
Also, if you have significant Core Audio questions, I would recommend
asking them on the Core-Audio list rather than on Cocoa-Dev, as I'm
not aware of any Core Audio engineers lurking on this list.
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden