# Suggestions for removing dry signal from delay buffer

**URL:** <https://forum.juce.com/t/suggestions-for-removing-dry-signal-from-delay-buffer/60125>\
**Category:** Audio Plugins\
**Created:** [February 22, 2024, 9:13pm UTC](https://forum.juce.com/t/suggestions-for-removing-dry-signal-from-delay-buffer/60125 "2024-02-22T21:13:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![noddy-oer](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/noddy-oer/32/20900_2.png) [@noddy-oer](https://forum.juce.com/u/noddy-oer)\
**Post date:** [February 22, 2024, 9:13pm UTC](https://forum.juce.com/t/suggestions-for-removing-dry-signal-from-delay-buffer/60125/1 "2024-02-22T21:13:44Z")

</div>

Hello!

I’m working on a Delay plugin based on the ffAudio [ffTapeDelay](https://github.com/ffAudio/ffTapeDelay), and wanted some help figuring out an issue with my dry and wet gain controls.

Currently my dry buffer is the **buffer** parameter from processBlock, which I then copy into **wetBuffer** , and set aside till the end. I use **wetBuffer** to perform the circular delay processing, and then finally copy it back into **buffer**.

Logically, because the **wetBuffer** starts as a complete copy of the dry **buffer** , it will ultimately contain the wet signal and the dry signal, instead of just the wet signal.

Does anyone have any ideas for how I could remove the dry signal from the wet buffer? I’ve attached my **processBlock** code below. Any advice would be greatly appreciated!

```auto
void BitDelayAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
    juce::ScopedNoDenormals noDenormals;
    auto totalNumInputChannels = getTotalNumInputChannels();
    auto totalNumOutputChannels = getTotalNumOutputChannels();

    juce::AudioBuffer<float> wetBuffer;
    wetBuffer.makeCopyOf(buffer);

    for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
        buffer.clear(i, 0, buffer.getNumSamples());

    const int bufferLength = buffer.getNumSamples();
    const int delayBufferLength = mDelayBuffer.getNumSamples();

    for (int channel = 0; channel < totalNumInputChannels; ++channel)
    {
        auto* bufferData = wetBuffer.getWritePointer(channel);

        wetBuffer.applyGainRamp(channel, 0, buffer.getNumSamples(), lastInputGain, volume->getValue());
        lastInputGain = volume->getValue();

        fillBuffer(channel, bufferLength, delayBufferLength, bufferData);

        readFromBuffer(channel, bufferLength, delayBufferLength, wetBuffer);

        fillBuffer(channel, bufferLength, delayBufferLength, bufferData);

        wetBuffer.applyGainRamp(channel, 0, bufferLength, lastWetGain, wet->getValue());
        lastWetGain = wet->getValue();

        buffer.applyGainRamp(channel, 0, bufferLength, lastDryGain, dry->getValue());
        lastDryGain = dry->getValue();

        buffer.addFrom(channel, 0, bufferData, bufferLength);
    }

    mWritePosition += bufferLength;
    mWritePosition %= delayBufferLength;
}

```

---

<div class="post-metadata">

**Author:** ![HowardAntares](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/howardantares/32/4629_2.png) [@HowardAntares](https://forum.juce.com/u/HowardAntares)\
**Post date:** [February 23, 2024, 2:06am UTC](https://forum.juce.com/t/suggestions-for-removing-dry-signal-from-delay-buffer/60125/2 "2024-02-23T02:06:48Z")

</div>

Could you use addFrom the other way first, adding buffer to wetBuffer, with the gain set to -1? I don’t see a subtractFrom.

---

<div class="post-metadata">

**Author:** ![noddy-oer](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/noddy-oer/32/20900_2.png) [@noddy-oer](https://forum.juce.com/u/noddy-oer)\
**Post date:** [February 23, 2024, 2:00pm UTC](https://forum.juce.com/t/suggestions-for-removing-dry-signal-from-delay-buffer/60125/3 "2024-02-23T14:00:09Z")

</div>

I’ll try this! Thanks!

---

<div class="post-metadata">

**Author:** ![Mrugalla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mrugalla/32/13092_2.png) [@Mrugalla](https://forum.juce.com/u/Mrugalla)\
**Post date:** [February 23, 2024, 5:03pm UTC](https://forum.juce.com/t/suggestions-for-removing-dry-signal-from-delay-buffer/60125/4 "2024-02-23T17:03:30Z")

</div>

instead of adding to the ringbuffer, you could just replace what’s in there

---

<div class="post-metadata">

**Author:** ![noddy-oer](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/noddy-oer/32/20900_2.png) [@noddy-oer](https://forum.juce.com/u/noddy-oer)\
**Post date:** [February 23, 2024, 5:09pm UTC](https://forum.juce.com/t/suggestions-for-removing-dry-signal-from-delay-buffer/60125/5 "2024-02-23T17:09:35Z")

</div>

The issue is that if I clear or replace the **wetBuffer** at any point after the first **fillBuffer** , it basically zeroes the wet output and breaks my feedback loop.

---

<div class="post-metadata">

**Author:** ![Mrugalla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mrugalla/32/13092_2.png) [@Mrugalla](https://forum.juce.com/u/Mrugalla)\
**Post date:** [February 23, 2024, 5:13pm UTC](https://forum.juce.com/t/suggestions-for-removing-dry-signal-from-delay-buffer/60125/6 "2024-02-23T17:13:25Z")

</div>

oh yeah, understandable. replacing parts of the buffer only works for feed forward delays. in that case what about just copying the dry signal into another buffer at the beginning, so at the end you can just subtract them from each other?

---

<div class="post-metadata">

**Author:** ![noddy-oer](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/noddy-oer/32/20900_2.png) [@noddy-oer](https://forum.juce.com/u/noddy-oer)\
**Post date:** [February 23, 2024, 5:31pm UTC](https://forum.juce.com/t/suggestions-for-removing-dry-signal-from-delay-buffer/60125/7 "2024-02-23T17:31:58Z")

</div>

So I would copy my input buffer, then once the circular buffer processing is done subtract the **dryCopyBuffer** from **wetBuffer**?

Is there a function I could use for this, or would I have to iterate sample by sample and subtract manually?

Thanks!

---

<div class="post-metadata">

**Author:** ![Mrugalla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mrugalla/32/13092_2.png) [@Mrugalla](https://forum.juce.com/u/Mrugalla)\
**Post date:** [February 23, 2024, 7:42pm UTC](https://forum.juce.com/t/suggestions-for-removing-dry-signal-from-delay-buffer/60125/8 "2024-02-23T19:42:23Z")

</div>

the function would do just that. i guess you could use some FloatVectorOperations method for that

---

<div class="post-metadata">

**Author:** ![noddy-oer](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/noddy-oer/32/20900_2.png) [@noddy-oer](https://forum.juce.com/u/noddy-oer)\
**Post date:** [February 23, 2024, 9:34pm UTC](https://forum.juce.com/t/suggestions-for-removing-dry-signal-from-delay-buffer/60125/9 "2024-02-23T21:34:53Z")

</div>

Using FloatVectorOperations::subtract worked. I had to fix an issue where I was hard-coding the gain on the buffers so the subtraction was producing weird results, but once that was fixed, it worked perfectly. My dry/wet controls are working as intended. Thanks!
