0

我正在编写一个卷积混响插件,并想添加一个预延迟滑块。我在两个单独的缓冲区中有“干”信号和“湿”信号用于播放,如下面的代码所示:

 // copy the original signal into a "dry signal" buffer that we'll use later
AudioSampleBuffer dryBuffer(buffer.getNumChannels(), buffer.getNumSamples());

// now apply convolution to the buffer
for (int i = 0; i < buffer.getNumChannels(); ++i)
{
    float* writePointer = buffer.getWritePointer (i % getNumOutputChannels());
    const float* readPointer = buffer.getReadPointer (i % getNumInputChannels());

    dryBuffer.copyFrom(
                       i, // destChannel
                       0, //destStartSample
                       buffer, // sourceBuffer
                       i, // sourceChannel
                       0, // sourceStartSample,
                       buffer.getNumSamples()
   );

    convolvers.getUnchecked(i % convolvers.size())->process (readPointer, writePointer, buffer.getNumSamples());

    //WET MIX
    buffer.applyGain(i, // channel
                     0, // startSample
                     buffer.getNumSamples(),
                     wetLevel->getValue() // gain
                     );

    //DRY MIX
    dryBuffer.applyGain(i,
                        0,
                        dryBuffer.getNumSamples(),
                        dryLevel->getValue()
                        );

    buffer.addFrom(
                   i, // destChannel
                   0, // destStartSample
                   dryBuffer, // sourceBuffer
                   i, // sourceChannel
                   0, // soucreStartSample,
                   buffer.getNumSamples(),
                   1.0 // gain
                   );


}

dryBuffer 是干 AudioSampleBuffer,缓冲区是应用卷积的湿信号。如何延迟湿缓冲区的播放?

4

1 回答 1

2

您可以通过移动样本来延迟湿缓冲区。例如,如果您想要 2 秒的延迟,您会想要增加湿缓冲区2*sample_rate并逐个移动所有sample_rate*2*delay_amt样本。您必须在convolvers->process方法中应用这些更改

于 2016-03-17T14:38:59.680 回答