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: Graham Cox <email@hidden>
- Date: Tue, 7 Oct 2008 00:34:42 +1100
On 7 Oct 2008, at 12:12 am, Joseph Ayers wrote:
2008-10-06 09:08:03.109 Roboplasm[33253:813] format flags = 41
2008-10-06 09:08:03.110 Roboplasm[33253:813] sample rate =
48000.000000
2008-10-06 09:08:03.110 Roboplasm[33253:813] bytes/packet = 4
2008-10-06 09:08:03.110 Roboplasm[33253:813] frames/packet = 1
2008-10-06 09:08:03.110 Roboplasm[33253:813] bytes/frame = 4
2008-10-06 09:08:03.111 Roboplasm[33253:813] channels/frame = 2
2008-10-06 09:08:03.111 Roboplasm[33253:813] bits/channel = 32
Indicating that there are two bytes per channel.
No, I read this as there are 4 bytes (32-bits per sample) per channel.
From the Audio Extraction Docs:
"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.
Note: Don't take this as gospel, I've never done this, I'm just trying
to make sense of the docs.
hth, Graham
_______________________________________________
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