1
votes

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.

1

1 Answers

0
votes

The average and peak power levels are not writable; they are calculated characteristics of the sample data.

player.volume = x where x is greater than 1.0 will amplify the sound level before it comes out of the speakers. If you set it to a stupidly high number like 20 or 100, it will end up sounding pretty funny!

If you want to do any more funny stuff to the samples, I think you'll have to use a low level API like RemoteIO or AudioQueue.