Reputation: 416
I am new to iOS world . I have a doubt . I would like to achieve the dB SPL meter .I have two buttons 1. play song 2. display decibel value . When I click on the Play song button it is playing the song. My question is while playing the sound I have to display the sound value in decibels which comes from iPhone . I have searched in the google . But I am not getting any basic ideas to start this app . Please give me idea to do this . Let me know if my question not clear .
Upvotes: 2
Views: 3421
Reputation: 4747
A possible solution to your problem could be to convert it from a logarithmic to a linear scale:
CGFloar linearScale = powf(10.f, logarithmicScale) * 20.f;
where logarithmicScale
is the value you get from AVFoundation. The linear scale should be much easier to visualize!
Upvotes: 0
Reputation: 34253
You didn't specify which framework you are using for playback. But assuming you are using AVFoundation, you could use AVCaptureAudioChannel averagePowerLevel
or peakHoldLevel
.
The relevant property for your problem seems to be averagePowerLevel
, which is (from the docs):
The instantaneous average power level, in dB. (read-only)
For details, see Apple's AVFoundation Programming Guide, which includes a section about audio previews.
Upvotes: 3