我开发一个iPhone应用程序记录了以.wav格式的音频。
这里是代码
NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc]init];
[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:11025.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 1] forKey:AVNumberOfChannelsKey];
[recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [path objectAtIndex:0];
NSString *myDBnew = [documentsDirectory stringByAppendingPathComponent:@"test.wav"];
recordedTmpFile = [NSURL fileURLWithPath:myDBnew];
NSLog(@"Using File called: %@",recordedTmpFile);
recorder = [[ AVAudioRecorder alloc] initWithURL:recordedTmpFile settings:recordSetting error:&error];
[recorder setDelegate:self];
[recorder prepareToRecord];
[recorder record];
上面的代码记录以.wav格式的音频。 如果我想记录的,而不是kAudioFormatLinearPCM(.WAV)我需要什么其他的变化,使在用钥匙kAudioFormatMPEGLayer3(MP3)MP3音频? 变化recordSetting字典像的采样率,信道和所有
或推荐的任何音频格式在尺寸上与两个iPhone和Android兼容,更小,可以直接从iPhone应用程序记录
请帮助和建议。
谢谢。