COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > Other Software Discussion > WDL users forum

Reply
 
Thread Tools Display Modes
Old 03-14-2015, 12:49 PM   #1
alex_
Human being with feelings
 
Join Date: Mar 2015
Posts: 29
Default 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
alex_ is offline   Reply With Quote
Old 03-15-2015, 01:08 AM   #2
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

Quote:
Originally Posted by alex_ View Post
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.
Tale is offline   Reply With Quote
Old 03-15-2015, 02:22 AM   #3
alex_
Human being with feelings
 
Join Date: Mar 2015
Posts: 29
Default

Hey Tale, thanks for your reply!

with "kinda weird" i mean it´s not distorting how it´s supposed to do
you´ll see, I´ll provide some bounces...

The distortion on it´s own works well, same for the convolution on it´s own.
I also tried to convolute it with a ir loader on the insert, this works well too!

Here are some examples:

distorted signal:
https://www.dropbox.com/s/d60w9bbr4n...rtion.wav?dl=0

distorted signal - convolution from another plugin:
https://www.dropbox.com/s/05a29y19jz...ution.wav?dl=0
thats how it should sound!

my outcome:
https://www.dropbox.com/s/vyejiywbr3...lugin.wav?dl=0
alex_ is offline   Reply With Quote
Old 03-16-2015, 08:59 AM   #4
sstillwell
Human being with feelings
 
Join Date: Jul 2006
Location: Cowtown
Posts: 1,562
Default

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
__________________
https://www.stillwellaudio.com/
sstillwell is offline   Reply With Quote
Old 03-17-2015, 02:52 AM   #5
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

Quote:
Originally Posted by alex_ View Post
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.
Tale is offline   Reply With Quote
Old 03-17-2015, 12:17 PM   #6
alex_
Human being with feelings
 
Join Date: Mar 2015
Posts: 29
Default

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);
    
  }
}
alex_ is offline   Reply With Quote
Old 03-17-2015, 01:23 PM   #7
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

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.
Tale is offline   Reply With Quote
Old 03-17-2015, 02:43 PM   #8
alex_
Human being with feelings
 
Join Date: Mar 2015
Posts: 29
Default

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!
alex_ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.