开发者

How to get volume data from an input device in Core-Audio?

I am trying to get the volume of the audio heard by an input device using Core-Audio.

So far I have used AudioDeviceAddIOProc and AudioDeviceStart with my AudioDeviceIOProc function to get the开发者_如何学Go input data in the form of an AudioBufferList containing AudioBuffers.

How do I get the volume of the data from the AudioBuffer? Or am I going about this completely the wrong way?


On Mac OS X 10.5, the APIs you mentioned are deprecated and you should read Tech Note TN2223.

Anyway, assuming that you are getting buffers of linear PCM sample data in 32-bit float format, you just need to write a for loop that determines the fabs(y) of each sample and then takes the max of all those values. Then you can save that value or convert it to decibels.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜