views:

18

answers:

1

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 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?

A: 

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.

lucius