Mitul Nakum
Mitul Nakum

Reputation: 5584

How to measure noise or sound and displays in dB(A) in iphone?

I want to measure sound in dB(A) in iPhone.

How can I do it?

Is there any example or tutorial?

Upvotes: 8

Views: 8889

Answers (1)

tuoxie007
tuoxie007

Reputation: 1236

If you use AVAudioPlayer, you can use this method

AVAudioPlayer *avPlayer = ...
[avPlayer play...];
[avPlayer averagePowerForChannel:0];
[avPlayer averagePowerForChannel:1];

From Apple's doc

- (float)averagePowerForChannel:(NSUInteger)channelNumber

Description
Returns the average power for a given channel, in decibels, for the sound being played.

Upvotes: 1

Related Questions