2011-07-11 4 views
1

私のアプリでユーザの音声を録音するためにAVAudioRecorderクラスを使用しています。私は音を録音して再生することができます。しかし、出力の品質は非常に低いです。私は、録音されたオーディオを再生しようとしている間、バックグラウンドで多くのノイズを受けています。 豊富な品質のオーディオ出力を得るにはどうすればよいですか私は以下の設定(コード)を使用して録音されたサウンドを取得しています。このコードを使用してiPhoneでオーディオを録音しようとしたときに音質が悪い

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; 

おかげでオーディオを再生するための以下のコードは、..

答えて

2

これを追加しました。

UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;  

      AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,   
            sizeof (audioRouteOverride),&audioRouteOverride); 
関連する問題