|
03-14-2015, 12:49 PM
|
#1
|
Human being with feelings
Join Date: Mar 2015
Posts: 29
|
convolve distorted Signal - IPlugConvoEngine
Hey!
I´m a little confused about the ConvoEngine.
I have made a Distortion Plugin and i want to convolve the distorted signal with the an IR.
The ConvoEngine is working so far, but when implementing the distortion before the convolution in ProcessDoubleReplacing the outcome gets kind of weird...
What am I doing wrong?
Code:
void DigitalDistortion_B::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
// Send input samples to the convolution engine.
#if WDL_FFT_REALSIZE == 8
mEngine.Add(inputs, nFrames, 1);
#else
{
// Convert the input samples from doubles to WDL_FFT_REALs.
double* in = inputs[0];
// Use outputs[0] as a temporary buffer.
WDL_FFT_REAL* tmp = (WDL_FFT_REAL*)outputs[0];
for (int i = 0; i < nFrames; ++i) *tmp++ = (WDL_FFT_REAL)*in++;
mEngine.Add((WDL_FFT_REAL**)outputs, nFrames, 1);
}
#endif
double* in = inputs[0];
double *out_l = outputs[0];
double *out_r = outputs[1];
Distort(*in);
int nAvail = MIN(mEngine.Avail(nFrames), nFrames);
// If not enough samples are available yet, then only output the dry
// signal.
//for (int i = 0; i < nFrames - nAvail; ++i) *out_l++ = *out_r++ = mDry * *in++;
// Output samples from the convolution engine.
if (nAvail > 0)
{
// Apply the dry/wet mix (and convert from WDL_FFT_REALs back to
// doubles).
WDL_FFT_REAL* convo = mEngine.Get()[0];
for (int i = 0; i < nAvail; ++i) *out_l++ = *out_r++ = *in++ + mWet * *convo++;
// Remove the sample block from the convolution engine's buffer.
mEngine.Advance(nAvail);
}
}
I´m trying to implement this distortion code into the convoengine
Code:
int const channelCount = 2;
for (int i = 0; i < channelCount; i++){
double* in = inputs[i];
double* output = outputs[i];
for (int s = 0; s < nFrames; ++s, ++in, ++output)
{
double sig = *in;
double orig_sig = sig;
Distort(sig);
double dist_sig = sig;
sig = sig * mBypass + orig_sig *(1-mBypass);
sig = sig * mDryWet + orig_sig *(1-mDryWet);
*output = sig * mGain;
}
}
any suggestions?
Greetings
Alex
|
|
|
03-15-2015, 01:08 AM
|
#2
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
Quote:
Originally Posted by alex_
The ConvoEngine is working so far, but when implementing the distortion before the convolution in ProcessDoubleReplacing the outcome gets kind of weird...
What am I doing wrong?
|
What exactly do you mean with "kind of weird"?
Anyway, if your distortion is already working correctly without ConvoEngine, then you could try to add another convolution plug-in after it (e.g. ReaVerb), to see if this also "gets weird". This might help you localise the problem.
|
|
|
03-16-2015, 08:59 AM
|
#4
|
Human being with feelings
Join Date: Jul 2006
Location: Cowtown
Posts: 1,562
|
Either I'm missing something or your first code example is only distorting the first sample of each block, but you're convolving the entire block.
Scott
|
|
|
03-17-2015, 02:52 AM
|
#5
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
Quote:
Originally Posted by alex_
|
Yeah, that does sound kinda weird... I noticed that this seems to only contain every 1 out of 16 samples. If you buffer size happens to be 16 samples, then I guess Scott may well be on to something. If so then you should probably first distort all samples in a loop, and then use the output from the distortion as input for the convolution engine.
|
|
|
03-17-2015, 12:17 PM
|
#6
|
Human being with feelings
Join Date: Mar 2015
Posts: 29
|
Ok, guys.
Did that, now the signal first gets distorted in a loop and then enters the convolution process.
so now the distorted signal goes through the IR but the sound of the distorted signal sounds same as before. that´s really odd...
Maybe it is a resampling issue or something?
it definitely sounds like there is a lack of samples to reproduce the signal.
thats what i ended up with
Code:
void DigitalDistortion_B::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
double* in = inputs[0];
double *out_l = outputs[0];
double *out_r = outputs[1];
double dist_sig;
for (int s = 0; s < nFrames; ++s, ++in, ++dist_sig)
{
double sig = *in;
Distort(sig);
dist_sig = sig * mGain;
}
// Send input samples to the convolution engine.
#if WDL_FFT_REALSIZE == 8
mEngine.Add(inputs, nFrames, 1);
#else
{
// Convert the input samples from doubles to WDL_FFT_REALs.
//double* in = inputs[0];
// Use outputs[0] as a temporary buffer.
WDL_FFT_REAL* tmp = (WDL_FFT_REAL*)outputs[0];
for (int i = 0; i < nFrames; ++i) *tmp++ = (WDL_FFT_REAL) dist_sig;
mEngine.Add((WDL_FFT_REAL**)outputs, nFrames, 1);
}
#endif
int nAvail = MIN(mEngine.Avail(nFrames), nFrames);
// If not enough samples are available yet, then only output the dry
// signal.
for (int i = 0; i < nFrames - nAvail; ++i) *out_l++ = *out_r++ = mDry * dist_sig;
// Output samples from the convolution engine.
if (nAvail > 0)
{
// Apply the dry/wet mix (and convert from WDL_FFT_REALs back to
// doubles).
WDL_FFT_REAL* convo = mEngine.Get()[0];
for (int i = 0; i < nAvail; ++i) *out_l++ = *out_r++ = mDry * dist_sig + mWet * *convo++;
// Remove the sample block from the convolution engine's buffer.
mEngine.Advance(nAvail);
}
}
|
|
|
03-17-2015, 01:23 PM
|
#7
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
Your dist_sig is only a single variable, but it should be a nFrames-sized array. I would suggest to let the distortion loop read from inputs and write to outputs, then feed outputs into the convolution engine, and then finally replace the output with whatever comes out of the convolution engine.
|
|
|
03-17-2015, 02:43 PM
|
#8
|
Human being with feelings
Join Date: Mar 2015
Posts: 29
|
I am not sure if I completely understand your suggestion, but i´ll give it a try.
Reading from inputs and writing to outputs like that?
Code:
for (int s = 0; s < nFrames; ++s, ++in, ++out_l, ++out_r)
{
Distort(*in);
*out_l = *in * mGain;
*out_r = *in * mGain;
}
How is it possible to feed the outputs to the convolution engine since thats my audio out? What can I use instead of dist_sig?
Code:
for (int i = 0; i < nFrames; ++i) *tmp++ = (WDL_FFT_REAL) dist_sig;
mEngine.Add((WDL_FFT_REAL**)outputs, nFrames, 1);
Sry for bothering you guys with such questions, i´m just getting into programming plugins.
Thanks for your help!
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:12 AM.
|