【问题标题】:Unwanted click when using SoXR Library to do variable rate resampling使用 SoXR 库进行可变速率重采样时出现不需要的点击
【发布时间】:2014-07-09 04:37:37
【问题描述】:

我正在使用SoXR 库的可变速率功能来实时动态更改音频流的采样率。不幸的是,我注意到在使用正弦波进行测试时,将速率从 1.0 更改为更大的值(例如:1.01)时会出现不需要的咔嗒声。从大于 1.0 的值更改为 1.0 时,我没有注意到任何不需要的伪影。我查看了它产生的波形,它看起来好像有几个样本正处于速率变化时被错误地转置了。

这是使用带符号的 16 位交错样本存储的立体声 440Hz 正弦波示例的图片:

除了第五个代码示例之外,我也找不到任何涵盖可变速率功能的文档。这是我的初始化代码:

bool DynamicRateAudioFrameQueue::intialize(uint32_t sampleRate, uint32_t numChannels)
{
    mSampleRate = sampleRate;
    mNumChannels = numChannels;
    mRate = 1.0;
    mGlideTimeInMs = 0;

    // Intialize buffer
    size_t intialBufferSize = 100 * sampleRate * numChannels / 1000; // 100 ms
    pFifoSampleBuffer = new FiFoBuffer<int16_t>(intialBufferSize);

    soxr_error_t error;

    // Use signed int16 with interleaved channels
    soxr_io_spec_t ioSpec = soxr_io_spec(SOXR_INT16_I, SOXR_INT16_I);

    // "When creating a var-rate resampler, q_spec must be set as follows:" - example code
    // Using SOXR_VR makes sense, but I'm not sure if the quality can be altered when using var-rate
    soxr_quality_spec_t qualitySpec = soxr_quality_spec(SOXR_HQ, SOXR_VR);


    // Using the var-rate io-spec is undocumented beyond a single code example which states
    // "The ratio of the given input rate and ouput rates must equate to the
    // maximum I/O ratio that will be used: "
    // My tests show this is not true
    double inRate = 1.0;
    double outRate = 1.0;

    mSoxrHandle = soxr_create(inRate, outRate, mNumChannels, &error, &ioSpec, &qualitySpec, NULL);

    if (error == 0) // soxr_error_t == 0; no error
    {
        mIntialized = true;
        return true;
    }
    else 
    {
        return false;
    }

}

知道是什么原因导致这种情况发生吗?或者对能够实时进行可变速率音频重采样的替代库有什么建议?

【问题讨论】:

    标签: variables audio rate resampling


    【解决方案1】:

    在与 SoXR 库的开发人员交谈后,我能够通过调整 soxr_create 方法调用中的最大比率参数来解决此问题。开发者回复可见here。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-31
      • 2015-01-02
      • 1970-01-01
      • 1970-01-01
      • 2012-07-31
      • 1970-01-01
      • 1970-01-01
      • 2017-11-21
      相关资源
      最近更新 更多