开发者

Detect amplitude of audio file per second?

开发者 https://www.devze.com 2023-03-19 17:06 出处:网络
I want to detect the amplitude in dB of an audio file per second using iPhone SDK. I need this functionality for the mouth an开发者_如何学Pythonimation of an object according to the dB magnitude of th

I want to detect the amplitude in dB of an audio file per second using iPhone SDK. I need this functionality for the mouth an开发者_如何学Pythonimation of an object according to the dB magnitude of the sound file per second. How can I do this ? With which audio framework is it possible ? Do you have any links to any examples ?


I Have found the solution over this problem

I have used the AVAudioPlayer's peakPowerForChannel and averagePowerForChannel method for getting the decibles

  AVAudioPlayer *avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:recordedTmpFile error:&error];
    avPlayer.delegate = self;

    avPlayer.meteringEnabled = YES;
     [avPlayer prepareToPlay];
     [avPlayer play];


 NSTimer *levelTimer = [NSTimer scheduledTimerWithTimeInterval: 0.03 target: self selector: @selector(levelTimerCallback:) userInfo: nil repeats: YES];

This method is return the peakPowerForChannel and averagePowerForChannel

- (void)levelTimerCallback:(NSTimer *)timer {

    [avPlayer updateMeters];
    NSLog(@"Peak left: %f Avg right: %f", [avPlayer peakPowerForChannel:0],[avPlayer averagePowerForChannel:0]);


}


Seems good, don't know any iPhone programming though sorry: http://www.politepix.com/2010/06/18/decibel-metering-from-an-iphone-audio-unit/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号