2011-01-31 87 views
1
bool b; 
NSLog(@"url"); 
NSURL *url = [NSURL fileURLWithPath:@"/dev/null"]; 
NSLog(@"dizionario"); 
NSDictionary *audioSettings = [NSDictionary dictionaryWithObjectsAndKeys: 
[NSNumber numberWithFloat: 44100.0],     AVSampleRateKey, 
[NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey, 
[NSNumber numberWithInt: 1],       AVNumberOfChannelsKey, 
[NSNumber numberWithInt: AVAudioQualityMax],   AVEncoderAudioQualityKey, 
nil]; 

NSError *error; 

recorder = [[AVAudioRecorder alloc] initWithURL:url settings:audioSettings error:&error]; 
NSLog(@"audio"); 
if (recorder) { 
[recorder prepareToRecord]; 
recorder.meteringEnabled = YES; 
b=[recorder record]; 
} else { 
NSLog(@"ERRORE:"); 
NSLog([error description]); 
} 

IOS AVAudioRecorder updatemeters似乎不是在設備更新,工作在模擬器

[recorder updatemeters]; 
NSLog(@"%f",[recorder peakPowerForChannel:0]); 

麥克風檢測發現冷杉(我認爲),因爲每一個新的運行顯示的值是不同的,但在同一運行的價值是不是完全改變 有什麼想法?

回答

1

找到解決方案。 with audioSession = [[AVAudioSession sharedInstance] retain]; [audioSession setCategory:AVAudioSessionCategoryRecord error:nil]; [audioSession setActive:YES error:nil];