Hi I am trying to use an AVAudioRecorder instance to record sound, the whole recording progress runs well, except that when I call [recorder peakPowerForChannel:0] trying to get the volume, the return value is always 0, that's pretty odd..
I have checked the recorded audio file, it's totally fine. Then I use AVAudioPlayer to play it, and during playing, i call [player peakPowerForChannel:0], the return value seems to be right and make sense.
How can I get the right value ? I have set that: recoder.meteringEnabled = YES, and called [recorder updateMeters] every time I call [recorder peakPowerForChannel:0]. The initial of recorder is as follows:
NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];
//General Audio Format Settings
[recordSetting setValue:[NSNumber numberWithInt: 'ima4'] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
//Linear PCM Format Settings
[recordSetting setValue:[NSNumber numberWithInt: 32] forKey:AVLinearPCMBitDepthKey];
[recordSetting setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
[recordSetting setValue:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];
//Encoder Settings
[recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityMedium] forKey:AVEncoderAudioQualityKey];
[recordSetting setValue:[NSNumber numberWithInt:96] forKey:AVEncoderBitRateKey];
[recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVEncoderBitDepthHintKey];
//Sample Rate Conversion Settings
[recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityHigh] forKey:AVSampleRateConverterAudioQualityKey];
recorder = [[AVAudioRecorder alloc] initWithURL:url settings:recordSetting error:nil];
recorder.meteringEnabled = YES;