【问题标题】:How to programmatically normalize a PCM audio sample on iOS 5?如何在 iOS 5 上以编程方式规范化 PCM 音频样本?
【发布时间】:2012-01-19 15:49:26
【问题描述】:

我正在使用AVAudioRecorder 录制一个 16 位线性 PCM 文件,并将其保存到 CAF 文件中。

现在我想标准化我录制的音频。 我只是找不到任何可以让我为 iPhone 执行此操作的库,无论是 Apple 还是第 3 方!

【问题讨论】:

    标签: iphone ios audio normalization


    【解决方案1】:

    峰值归一化采用这种通用形式,您需要为 16 位信号添加一些转换、优化和错误检查:

    double* const buffer(...);
    const size_t length(...);
    
    double max(0);
    // find the peak
    for (size_t idx(0); idx < length; ++idx)
      max = std::max(max, buffer[idx]);
    // process
    double mul(1.0/max);
    for (size_t idx(0); idx < length; ++idx)
      buffer[idx] *= mul;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-18
      • 2012-02-23
      • 1970-01-01
      • 1970-01-01
      • 2011-07-06
      • 1970-01-01
      • 2010-09-12
      • 2021-02-21
      相关资源
      最近更新 更多