Reading audio with Extended Audio File Services (ExtAudioFileRead)

匆匆过客 提交于 2019-12-03 08:31:57

I think you're misunderstanding the purpose of the mNumberBuffers field. It's typically 1 for mono and interleaved stereo data. The only reason you would set it to something else is for multi-track data where each channel is in a separate data buffer.

If you want to read a part of a file, you would set dataByteSize of the buffer to a reasonable size, and when you read the file, tell the API only to give you that many bytes, and loop over it.

I also had the same problem with mNumberBuffers > 1,,... My work around involved creating my own internal buffer:

something like:

char buffer1[byteSize]; char buffer2[byteSize]; ......

you could also use pointers to make things easier,..like:

buffer[index][byteSize];

then you would have to iterate through them manually and fill them up on the main thread to avoid glitches in audio.

ExtAudioFileRead will only fill buffer[0] in the AudioBufferList, you could then have that pointing to different manually allocated buffers as the audio plays.

hope this helps.

mNumberBuffers == 2 when you're dealing with non-interleaved stereo. It is the number of audio channels when not interleaved.

Cocoa simply seems to not accept mNumberBuffers > 1. Which is a shame as it makes the whole structure useless. (I hope this is right...)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!