-->

iphone - AVAudioRecorder给单声道播放(声音在短短的一个通道播放)(iph

2019-09-19 07:04发布

我使用AVAudioRecorder进行录音并保存为WAV文件(使用SDK 3.0)的设置字典包含下列值

    NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];

    [recordSetting setValue :[NSNumber numberWithInt:kAudioFormatLinearPCM] forKey:AVFormatIDKey];
    [recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey]; 
    [recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];

    [recordSetting setValue :[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
    [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
    [recordSetting setValue :[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];

即使指定信道作为2的数量后,回放是单声道(即,在仅1个耳机插孔,而不是两个通道播放)。

有没有其他人遇到这个问题? 这有什么不对的recordSetting字典中的值?

谢谢

任何人都可以请帮我这...如果我指定通道的2号,则播放为什么会在短短的一个插孔? (我使用耳机测试 - 它带着我的iPhone的那些)

Answer 1:

没有,没有什么是错在你的设置。 如果你试图在模拟器上你的应用程序,将记录和两个通道上播放。 然而,iPhone 3G和3GS只记录音频使用一个通道。 这也适用于拍摄的3GS电影的音频。

因此,它是不是一个错误。



Answer 2:

注释掉以下行

[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];

默认设置应该工作。

这部作品的原因是,现在将记录单声道文件,而当这是回放音频将在每个扬声器播放的是一个单一的文件正常行为。 如果包括这一行,你最终会记录一个通道完全静音立体声文件,这样当你打回来,你只使用一只耳朵获得音频。



文章来源: iphone - AVAudioRecorder gives mono playback (sound playing in just one channel)