PDA

View Full Version : Multiple instance malfunction?


metalhobo
05-06-2010, 06:27 PM
So with this plugin I'm working on, whenever I try and playback two different tracks (each with an instance of the plugin) I get some severe malfunctioning. Sometimes I just get this really weird digital chirping noise and other times I just get like a ridiculously loud output (scared the jesus outta me). Single instances of the plugin work exactly as they should; I'm at a loss here. Anybody got any ideas? Thanks.

Xenakios
05-06-2010, 07:23 PM
So with this plugin I'm working on, whenever I try and playback two different tracks (each with an instance of the plugin) I get some severe malfunctioning. Sometimes I just get this really weird digital chirping noise and other times I just get like a ridiculously loud output (scared the jesus outta me). Single instances of the plugin work exactly as they should; I'm at a loss here. Anybody got any ideas? Thanks.

Check if you are using globally scoped variables or static variables. Those are the usual reasons for this "SynthEdit" kind of bug. (SynthEdit used to make every plugin made on it exhibit this bug.)

By the way, are you running the plugin on a multicore computer? If not, then the appearance of this kind of bug may be a bit more difficult to explain. The problem with the global and static variable is most likely to happen when running the code in a multithreaded host app on a multicore equipped computer.

If you confirm it is indeed global and/or static variables causing this, the fix is to not use those kinds of variables in the code. The usual solution is to put counters and similar things that need to persist their values between function/method runs as data members of a class.

edit : I by the way saw this in a code you posted in the other thread :

WDL_fft_init();
WDL_fft(fftbuffer, fftbuffersize, false);
//---------------------------------------


//--
for(int p = 0; p < fftbuffersize; p++) //make quieter
{
fftbuffer[p].re /= (fftbuffersize);
fftbuffer[p].im /= (fftbuffersize);
}
//--


You should not be initing the WDL FFT library at each buffer cycle. That won't be thread-safe and would probably be causing the problems you are experiencing. (Also it probably will be making your processing code run slower than necessary.)

junioreq
05-07-2010, 07:46 AM
Yep, always global vars doing this in my past experience.

metalhobo
05-08-2010, 09:12 PM
No global variables, but I use quite a few static variables. I can't use static variables at all then?


Thanks for the info guys!

junioreq
05-08-2010, 10:07 PM
Post some code example, and it will be very apparent to us within seconds. You have a global in there somewhere, one plug is trying to change it, while the other is using it,then changing it lol..

~Rob.

junioreq
05-08-2010, 10:09 PM
I do all my variable stuff in onparmchange:


void SimpleDelay::OnParamChange(int paramIdx) {

SR = this->GetSampleRate();
double lowpass = GetParam(flowpass)->Value();

bandFilter[1].calc_filter_coeffs(0,lowpass,SR,1,1,0);
}

bvesco
05-09-2010, 12:16 AM
No global variables, but I use quite a few static variables. I can't use static variables at all then?


Only use statics that are intended to be shared by all instances.