iphone - 录音音质不好

标签 iphone

// Init audio with record capability
audioSession = [AVAudioSession sharedInstance];
[audioSession setActive:YES error:nil];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];

NSMutableDictionary *recordSettings = [[NSMutableDictionary alloc] initWithCapacity:10];
if(recordEncoding == ENC_PCM)
{
    [recordSettings setObject:[NSNumber numberWithInt: kAudioFormatLinearPCM] forKey: AVFormatIDKey];
    [recordSettings setObject:[NSNumber numberWithFloat:44100.0] forKey: AVSampleRateKey];
    [recordSettings setObject:[NSNumber numberWithInt:2] forKey:AVNumberOfChannelsKey];
    [recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
    [recordSettings setObject:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsBigEndianKey];
    [recordSettings setObject:[NSNumber numberWithBool:NO] forKey:AVLinearPCMIsFloatKey];   
}
else
{
    NSNumber *formatObject;

    switch (recordEncoding) {
        case (ENC_AAC): 
            formatObject = [NSNumber numberWithInt: kAudioFormatMPEG4AAC];
            break;
        case (ENC_ALAC):
            formatObject = [NSNumber numberWithInt: kAudioFormatAppleLossless];
            break;
        case (ENC_IMA4):
            formatObject = [NSNumber numberWithInt: kAudioFormatAppleIMA4];
            break;
        case (ENC_ILBC):
            formatObject = [NSNumber numberWithInt: kAudioFormatiLBC];
            break;
        case (ENC_ULAW):
            formatObject = [NSNumber numberWithInt: kAudioFormatULaw];
            break;
        default:
            formatObject = [NSNumber numberWithInt: kAudioFormatAppleIMA4];
    }

    [recordSettings setObject:formatObject forKey: AVFormatIDKey];
    [recordSettings setObject:[NSNumber numberWithFloat:44100.0] forKey: AVSampleRateKey];
    [recordSettings setObject:[NSNumber numberWithInt:2] forKey:AVNumberOfChannelsKey];
    [recordSettings setObject:[NSNumber numberWithInt:12800] forKey:AVEncoderBitRateKey];
    [recordSettings setObject:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey];
    [recordSettings setObject:[NSNumber numberWithInt: AVAudioQualityHigh] forKey: AVEncoderAudioQualityKey];
}

最佳答案

尝试使用此问题中的设置进行录制:

iphone-peakPowerForChannel function in AVAudioRecorder doesn't work

那里使用的设置似乎与您正在使用的设置有点不同。

关于iphone - 录音音质不好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5919097/

相关文章:

iPhone:按钮触摸事件 - 释放不触发?

iphone - 如何阅读 YouTube channel ?

iphone - 如何格式化要使用 arrayWithContentsOfFile 读取的文本文件

iphone - 是否可以通过iPhone SDK获取GPS卫星号码?

ios - 如何停止从 iOS 中的 NSURL 获取数据?

ios - 无需上路行驶即可测试 GPS 路线追踪器

ios - 添加白色状态栏

iphone - 使用整数范围填充选择器 View 的最有效方法?

iphone - 是否可以找到 iPhone 的刷新率?

iphone - 有类似 Haskell/ML 的 C 编译器吗?