1

What is Audio level metering in iPhone Audio Tool box? What is the use of it?

Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167
RK-
  • 12,099
  • 23
  • 89
  • 155

1 Answers1

4

Metering helps us to get audio gain in decibel (dB) during playing and recoring..To use it you first enable metering for the player (or recorder)

audioPlayer.meteringEnabled  = TRUE;
[audioPlayer prepareToPlay];
[audioPlayer play];
[NSTimer scheduledTimerWithTimeInterval:1.0 
      target:self 
      selector:@selector(getGain:) 
      userInfo:nil 
      repeats:YES];

and whenever you want gain Values you first call updateMeters and get the dB value. Here I am using a timer to log audio gain for every second of its playing time.

-(void)getGain:(NSTimer*)sender{
   [audioPlayer updateMeters];
   float avgPower = [audioPlayer averagePowerForChannel:0];
   NSLog(@"avgPower : %f",avgPower);
   float peakPower = [audioPlayer peakPowerForChannel:0];
   NSLog(@"peakPower : %f",peakPower);
}

You can use these value for drawing audio waveforms etc..See this link for some help for that..

Community
  • 1
  • 1
Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167