COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 02-15-2018, 08:06 AM   #1
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default Size of input (need help)

Hi,

I'm working on WDF.I need size of input.But i can't figure it out.Here is my code...

Code:
    int max=input.size(); // Where i need help about it.
    for (int n=0; n<max; ++n)
    {
        Vin.Vs = input*Res;					    // read the input signal for the voltage source
        b = root.reflected ();				// get the waves up to the root
        // ** VALVE RESISTOR **
        Rdiode = Is * exp(-Vt * Vdiode);	// the nonlinear resistance of the diode
        r = (Rdiode - root.R)				// update scattering coefficient (KCL)
        / (Rdiode + root.R);
        root.incident (r * b);				// evaluate the wave leaving the diode (root element)
        // ** UPDATE **
        Vdiode = root.voltage ();			// update the diode voltage for next time sample
        output = (R1.voltage());			// the output is the voltage over the resistor R1
    }
    return output;
I need to figure "int max=input.size();".How can i do that?

Thanks.
Tunca is offline   Reply With Quote
Old 02-15-2018, 08:22 AM   #2
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Also if i use nFrames,plugin does not work properly.Hearing slow sound and glitches.
Tunca is offline   Reply With Quote
Old 02-15-2018, 09:08 AM   #3
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Tunca View Post
Also if i use nFrames,plugin does not work properly.Hearing slow sound and glitches.
You must make it work with the nFrames value. That is the amount of audio the host is giving you and expecting to get out from your plugin. If your algorithm depends on being given a different amount, you will have to work around that with some buffering scheme of your own.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 02-15-2018, 09:44 AM   #4
Tunca
Human being with feelings
 
Join Date: Apr 2016
Posts: 264
Default

Quote:
Originally Posted by Xenakios View Post
You must make it work with the nFrames value. That is the amount of audio the host is giving you and expecting to get out from your plugin. If your algorithm depends on being given a different amount, you will have to work around that with some buffering scheme of your own.
Thanks but i can't figure it out with nFrames.

Any example or code to solve this?
Tunca is offline   Reply With Quote
Old 02-16-2018, 01:22 AM   #5
Qrchack
Human being with feelings
 
Qrchack's Avatar
 
Join Date: May 2016
Location: Poland
Posts: 7
Default

You don't need int max as you're using it only once. Actually you don't need it at all, since nFrames is exactly what you need. ProcessDoubleReplacing is defined like so:

Code:
void IPlugEffect::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
inputs is just an array of arrays of doubles. It doesn't have ".size()", because it's just a dumb array. That's why you get int nFrames as well. That said, I believe you're using the first sample over and over. Remember input is an array! Have a look at the example project:

Code:
void IPlugEffect::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
  // inputs has two arrays of doubles inside
  double* in1 = inputs[0];
  double* in2 = inputs[1];
  // outputs does too
  double* out1 = outputs[0];
  double* out2 = outputs[1];

  // in1, in2, out1 and out2 are now arrays of double
  // we move the pointers with ++in1, ++in2, ++out1, ++out2
  // you could also do out1[s]

  for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++out1, ++out2)
  {
    *out1 = *in1 * mGain;
    *out2 = *in2 * mGain;
  }
}
Hope this helps!
Qrchack 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 04:21 PM.


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