简体   繁体   中英

Detect amplitude of audio file per second?

I want to detect the amplitude in dB of an audio file per second using iPhone SDK. I need this functionality for the mouth animation 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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM