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

前端 未结 1 1179
夕颜
夕颜 2020-12-08 08:52

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

How can I do it?

Is there any example or tutorial?

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 09:27

    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.

    0 讨论(0)
提交回复
热议问题