AudioQueueLevelMeterState 出现在 AudioQueueBuffer 中的什么位置?
我想做一些像节拍切片这样的事情。
我可以设置一个计时器来定期获取 AudioQueueLevelMeterState。
但是,似乎没有办法将查询 AudioQueueLevelMeterState 的时间与 AudioQueueBuffer 的内容联系起来?
例如,假设我的缓冲区长度为 1 秒。我运行一个计时器,每秒查询仪表状态 60 次。 0.5 秒后我就达到了我想要的水平。因此,我想从获得级别开始(即剩余的 0.5 秒)获取该音频缓冲区的一部分。
有什么想法吗?可以说有什么方法可以在缓冲区中完成这一切吗?
非常感谢任何建议。
非常感谢,xj
I want to do something like beat slicing.
I can set up a timer to get the AudioQueueLevelMeterState periodically.
However, there doesn't seem to be a way to relate the time that the AudioQueueLevelMeterState is queried with the contents of the AudioQueueBuffer?
For example, let's say that my buffer is 1 second long. I run a timer that queries the meter state 60 times per second. At 0.5 seconds I get the level I want. Consequently, I want to take a chunk of that audio buffer from the point I get the level onwards, i.e. the remaining 0.5 seconds.
Any ideas? Any ways to do it all in the buffer so to speak?
Any advice much appreciated.
Many thanks, xj
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最终解决了这个问题。我放弃了使用 AudioQueue 作为录制音频的方式,转而使用 AudioUnit。 AudioQueue 是如此困难,最终我不得不认真质疑它是否是用于我想做的事情的正确 API。在一些论坛上,人们说 AudioUnit 很难使用,但说实话,在我经历过 AudioQueue 的所有操作之后,AudioUnit 非常简单。
无论如何,回答我自己的问题。最终我必须解决计量和录音的同步问题,因此我放弃了计时器机制来对电平进行采样。我仍然使用 AudioQueue,但只是为了计量。在录音回调中,我从 AudioQueue 中获取
kAudioQueueProperty_CurrentLevelMeter
。录制回调接收帧计数,这样我就可以将帧位置与仪表样本完美同步。Got this sorted eventually. I ditched AudioQueue as a way to record the audio and instead went for an AudioUnit. AudioQueue was so difficult that eventually I had to seriously question if it was the correct API to use for what I wanted to do. In some forums people had said that AudioUnits were hard to work with, but to be honest after everything I'd been through with AudioQueue, AudioUnit was pretty straightforward.
Anyway, to answer my own question. Eventually I had to resolve synchronisation issues with the metering and recording, so I ditched the timer mechanism to sample the levels. I still use AudioQueue but just for the metering. In the recording callback I grab the
kAudioQueueProperty_CurrentLevelMeter
from the AudioQueue. The recording callback receives the frame count, so that way I can perfectly synchronise the frame position with the meter sample.查看 Apples Speak Here 示例项目。他们有类似的设置,你也许可以破解。
Check out Apples Speak Here example project. They have something similar set up that you maybe be able to hack.