Reputation: 249
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?
Upvotes: 2
Views: 1854
Reputation: 8220
Thinking about your problem, it appears that you are looking for the following properties:
blendParam
of 0.0f
, just pass on the audio unchanged.blendParam
of 1.0f
, process the audio to its maximum capacity.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.
Upvotes: 1