title: AVAudioRecorder meter delay on iPad
body: <p>I am having trouble getting an accurate meter reading from the AVAudioRecorder (testing on iPad). </p>
  
  <p>It seems to work fine while the volume is rising, however a delay happens when the volume drops. For example: I speak into the mic and slowly raise my voice. The readings increment from -35.567 to -34.678 up to -10.579 as I would hope, but when I stop talking there is a delay of 1 - 2 seconds before it drops back down to -35.567 (or whatever it happens to be).
  The NSLog continues to update from the loop but the meter number stays the same during the delay even though the sound has long ended.</p>
  
  <p>I have added the gist of the code below and would be happy to supply full code if need be.</p>
  
  <p>I initialize the recorder like so:</p>
  
  <pre><code>AVAudioSession * audioSession = [AVAudioSession sharedInstance];
  [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: &amp;error];
  [audioSession setActive:YES error: &amp;error];
  
  NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
  [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
  [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; 
  [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
  
  recordedTmpFile = [NSURL fileURLWithPath:[NSTemporaryDirectory()  stringByAppendingPathComponent: [NSString stringWithString: @"Recording.caf"]]];
  
  recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&amp;error];
  [recorder setDelegate:self];
  [recorder prepareToRecord];
  [recorder setMeteringEnabled:YES];
  
  [recorder record];
  </code></pre>
  
  <p>and update the meter in a loop:</p>
  
  <pre><code>-(void) loop:(ccTime)dt 
  {
      if(isRecording == YES)
      {        
          //get volume levels
          [recorder updateMeters];
          float level = [recorder peakPowerForChannel:0];
          NSLog(@"Vol: %f", level);
      }
  }
  </code></pre>
  
  <p><em>edited:</em> I should also mention that I am using the Cocos2d schedule for the loop:</p>
  
  <pre><code>[self schedule:@selector(loop:)];
  </code></pre>
  
  <p>Any ideas why there would be such a long delay?</p>
  
  <p><em>edited:</em> I have tried using the average peak power and this has no delay. So I could possibly use that as a work around. However I would rather not use and averaged peak power and it would be nice to understand what is going on.</p>