开发者

AudioFileReadPackets to an array?

开发者 https://www.devze.com 2022-12-26 15:02 出处:网络
I\'d开发者_StackOverflow社区 like to read packets from an audio file, but I don\'t want to send them to a playback buffer. I just want to get an array of the packets, ideally as floats. I\'ve prepped

I'd开发者_StackOverflow社区 like to read packets from an audio file, but I don't want to send them to a playback buffer. I just want to get an array of the packets, ideally as floats. I've prepped the audio and then want to call:

OSStatus err = AudioFileReadPackets (audioFileID,FALSE,outBytes,NULL,0,numPackets,whatGoesHere?);

But what goes in that last argument?

Thanks.


If you were using Audio Queue Services, that's where you'd put the mAudioData pointer of an AudioQueueBuffer. But since you just want the bits, you can pass a pointer to a preallocated buffer (static or dynamic) of your choosing. You can infer an upper bound on the necessary size of the buffer by using portions of the dataFormat from your file.

An example of this computation is provided in the Audio Queue Services Programming Guide; grep for DeriveBufferSize.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号