Le 25 août 08 à 16:02, Joseph Ayers a écrit :
I am interested in doing some signal processing on the audio
channels of a QuickTime Movie. I can retrieve the
buffer using MovieAudioExtractionFillBuffer, but the available
examples specify the buffer as type Byte*. I am
interested in decomposing the buffer into the left and right channel
data sample arrays. I assume that these are 16 bit
audio samples,
Assumptions are evil. It should be either documented as the default
value, or you have to force it to this format. Personnaly, I use the
second choice.
but I have yet to find a method that returns the two separate (left
and right) arrays or the appropriate
Cocoa data type to use with such sample data. Any ideas or examples?
Thanks,
AFAK, there is no Cocoa API to do audio processing.
You can have stereo channels by setting the appropriate "output
format" and "channel layout format" on your session:
MovieAudioExtractionSetProperty(ay_session,
kQTPropertyClass_MovieAudioExtraction_Audio,
kQTMovieAudioExtractionAudioPropertyID_AudioStreamBasicDescription,
sizeof(*aFormat), aFormat);
MovieAudioExtractionSetProperty(ay_session,
kQTPropertyClass_MovieAudioExtraction_Audio,
kQTMovieAudioExtractionAudioPropertyID_AudioChannelLayout,
bytes, aLayout);
Your format should have two channels:
AudioStreamBasicDescription inasbd;
inasbd.mChannelsPerFrame = 2; // stereo
/* 16 bits linear PCM interleaved */
inasbd.mBitsPerChannel = 16;
inasbd.mFormatID = kAudioFormatLinearPCM;
inasbd.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger;
#if TARGET_RT_BIG_ENDIAN
inasbd.mFormatFlags |= kAudioFormatFlagIsBigEndian;
#else
inasbd.mFormatFlags &= ~kAudioFormatFlagIsBigEndian;
#endif
/* 1 frame = 1 packet when using PCM */
inasbd.mFramesPerPacket = inasbd.mChannelsPerFrame;
inasbd.mBytesPerFrame = inasbd.mBytesPerPacket = 2 *
inasbd.mChannelsPerFrame;
inasbd.mSampleRate = 44100; // choose whatever you want, or
retreive the default value from your session.
and your layout format should describe a stereo layout:
AudioChannelLayout layout;
layout.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo;
Your output buffer will contains interleaved audio data, that is one
integer for the first channel, one integer for the second channel, one
for the first, …
Note that you have to set the output format before setting the layout
format. I think it will failed if you do it otherwise.
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]