2

I am creating a convolution reverb plugin for university and I have managed to get a simple plugin working, where the output is the input through an impulse response. I am wondering how I can alter the code to make a wet/dry parameter.

I have added a "blend" parameter for this:

const float defaultBlend = 0.5f;
addParameter(blendParam = new FloatParameter (defaultBlend, "Blend"));

the convolver is then initialised:

convolver.init (512, buffer.getReadPointer(0), buffer.getNumSamples());

and processed here:

 for (int channel = 0; channel < getNumInputChannels(); ++channel)
    {
        float* channelData = buffer.getWritePointer (channel);
        const float* inputData = buffer.getReadPointer(channel);

        for (int i = 0; i < buffer.getNumSamples(); ++i)
            channelData[i] = inputData[i] * level / 20;

        //convolver stuff
        convolver.process (inputData, channelData, buffer.getNumSamples());

    }

any ideas?

willfo
  • 241
  • 1
  • 2
  • 12
  • What have you tried so far? You show that you've added the parameter, but not what you've tried to do with it. – OMGtechy Oct 26 '15 at 13:45
  • I'm not sure what to do with it. – willfo Oct 26 '15 at 13:49
  • You should spend some time thinking about what you want it to do; i.e. given a certain input and "blend", what would you expect to happen? [Rubber ducking](https://en.wikipedia.org/wiki/Rubber_duck_debugging) can help with this too. After you've done that, you'll probably find you have a clearer understanding of what it is you need to do. – OMGtechy Oct 26 '15 at 13:52
  • I know that when "blend" is at its minimum value, the output will be completely dry, and when blend is at its maximum value, you will only hear the reverb and no dry signal at all. I've given it some thought and I'm not sure how to implement this. I know I need the input date and the reverb data to be two separate variables, and use the blend parameter to move between these variables, and thats about as far as i got. – willfo Oct 26 '15 at 14:27

1 Answers1

1

Thinking about your problem, it appears that you are looking for the following properties:

  1. Given a blendParam of 0.0f, just pass on the audio unchanged.
  2. Given a blendParam of 1.0f, process the audio to its maximum capacity.
  3. Given a blendParam of 0.5f, mix half unprocessed audio with processed audio.

I advise you write some unit tests for the above (and more) before proceeding.

The following code appears to satisfy these properties:

channelData[i] = level * (inputData[i] * (1.0f - blendValue) + convolvedData[i] * blendValue);
  • convolvedData is your "fully processed" data.
  • blendValue is the cached value of blendParam.getValue()

You can obtain convolvedData by calling convolver.process as you currently do, with a separate array called convolvedData as your output parameter.

Note that this doesn't account for clamping the resulting number into the range [-1.0f, 1.0f], and there is likely a more efficient way of doing this, but it's a starting point for you.

OMGtechy
  • 7,935
  • 8
  • 48
  • 83
  • I am not sure how to use the result of: 'convolver.process (inputData, channelData, buffer.getNumSamples());' as a variable called convolvedData. Could you explain? – willfo Oct 27 '15 at 15:15
  • Looking at the code I put in the question, at what point to i implement the line of code you wrote and where do I call convolver.process? – willfo Oct 27 '15 at 18:30
  • @willfo I don't think I'd be helping you if I did that; this is for uni and requires you to work some things out for yourself so that you learn. If you found this helpful, please mark as accepted. – OMGtechy Oct 27 '15 at 19:50
  • 1
    @willfo I don't want to give you the answer either but here's a hint: have convolver's process function return a certain variable... Hope it works out! juce is fun :) – yun Nov 06 '15 at 15:05