简体   繁体   English

AudioFileReadPackets到数组?

[英]AudioFileReadPackets to an array?

I'd 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. 如果使用的是Audio Queue Services,则在此处放置AudioQueueBuffer的mAudioData指针。 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. 您可以通过使用文件中dataFormat的部分来推断缓冲区必要大小的上限。

An example of this computation is provided in the Audio Queue Services Programming Guide ; 音频队列服务编程指南》中提供了这种计算的示例。 grep for DeriveBufferSize. 用于DeriveBufferSize的grep。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM