アプリでユーザーの入力音声を録音するために AVAudioRecorder クラスを使用しています。音声の録音と再生ができます。しかし、出力の品質は非常に低いです。録音したオーディオを再生しようとすると、バックグラウンドで多くのノイズが発生します。豊かな品質のオーディオ出力を得るにはどうすればよいですか。サウンドを録音するために、次の設定(コード)を使用しています。
NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatAppleLossless] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; // previously i'v used 8400
[recordSetting setValue:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey];
およびオーディオを再生するための以下のコード
[[AVAudioSession sharedInstance] setCategory:
AVAudioSessionCategoryPlayback error:NULL];
NSURL *fileTobePlayed = [NSURL fileURLWithPath:[[[[UIApplication sharedApplication]delegate] applicationDocumentsDirectory] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",currentPage]]];
//AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:recordedTmpFile error:&error];
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileTobePlayed error:&error];
NSLog(@"The file being played is %@",fileTobePlayed);
[audioPlayer prepareToPlay];
[audioPlayer play];
audioPlayer.volume = 4.0;
ありがとう..