1

I am playing the .mp3 file by using AVaudioplayer:-

 NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"Speech"ofType:@"mp3"]];    
    NSError *error;
    audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:url error:&error];    
    if (error)
    {
        NSLog(@"Error in audioPlayer: %@",
              [error localizedDescription]);
    } else {
        audioPlayer.delegate = self;
        audioPlayer.numberOfLoops=-1;
        [audioPlayer prepareToPlay];
        [audioPlayer play];
    }
    audioPlayer.meteringEnabled = YES;
    audioPlayer.volume=0;
    NSTimer *playerTimer = nil;
    if (!playerTimer)
    {
        playerTimer = [NSTimer scheduledTimerWithTimeInterval:0.001
                                                       target:self selector:@selector(monitorAudioPlayer)
                                                     userInfo:nil
                                                      repeats:YES];
    }

    [audioPlayer updateMeters];

-(void)monitorAudioPlayer{


    [audioPlayer updateMeters];

    for (int i=0; i<audioPlayer.numberOfChannels; i++)
    {        
        float power = [ audioPlayer averagePowerForChannel: i ];
        float peak = [ audioPlayer peakPowerForChannel: i ];
}
}

And in written i get the float number of power for that audioplayer. Is there any way to change the power of peak value of this audio player so that the sound get change to some funnysound or something other. It is possible by using audiosession or some other thing. I had done this by using DIRAC. But in that i am not able to get the powervalue.AS it always return the static powervalue.

Thanks in advance.

4

1 回答 1

0

平均和峰值功率电平不可写;它们是样本数据的计算特征。

player.volume = x其中 x 大于 1.0 将在声音从扬声器中出来之前放大声级。如果你把它设置为一个像 20 或 100 这样愚蠢的高数字,它最终会听起来很有趣!

如果你想对样本做更多有趣的事情,我认为你必须使用像 RemoteIO 或 AudioQueue 这样的低级 API。

于 2013-04-24T20:37:10.367 回答