我正在开发一个应用程序,我用AVAudioRecorder录制声音与.CAF格式,一切都很好,但我的问题是,当我播放录制的声音,然后播放在很低的数量。不知何故声音的音量最低。尝试了很多解决方案,但没有找到解决方案的解决方案,如果有人有任何想法,请告诉我,这对我来说非常重要。 下面是摘录的代码音量正在下降,同时在IOS中录制声音与AVAudioRecorder
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
[session setActive:YES error:nil];
// Define the recorder setting
recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
NSArray *pathComponents = [NSArray arrayWithObjects:
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject],
[NSString stringWithFormat:@"%@.caf",@"temp"],
nil];
NSURL *outputFileURL = [NSURL fileURLWithPathComponents:pathComponents];
recorder = [[AVAudioRecorder alloc]initWithURL:outputFileURL settings:recordSetting error:nil];
recorder.delegate = self;
recorder.meteringEnabled = YES;
[recorder recordForDuration:5];
[recorder prepareToRecord];
[recorder record];
谢谢.. 它的工作。 –
我刚试过这个,并得到链接错误。我正在使用xcode 5.1未定义的符号体系结构i386: “_AudioSessionSetProperty”,引用自: - ViewController.o中的[ViewController viewDidLoad] ld:找不到体系结构i386的符号 clang:error:linker命令失败退出代码1(使用-v查看调用) – vboombatz