How to detect ambient sound level on the iPhone?
I need to create an audio loudness (decibel) detector. To clarify, I am not trying to find the volume at which the iPhone is playing, but instead the volume of its surro开发者_开发百科unding in decibels. How can I do this?
It can be done using AVAudioRecorder: http://b2cloud.com.au/tutorial/obtaining-decibels-from-the-ios-microphone
Use one of the Audio Queue or Audio Unit APIs to record low latency audio, run the samples through a DSP filter to weight the spectrum for the particular type or color of loudness you want to measure, then calibrate the mic on all the particular models of iOS devices you want to run your detector on against calibrated sound sources, perhaps in an anechoic chamber.
精彩评论