Only SOME instances of plugin glitch sound in DAW

Need some advice on how to start tracking down this intermittent issue. Sometimes, when i load another instance of my synth plugin into a DAW, it causes fluttery glitch noises on playback. If i load up a few instances, and one starts making the noises, i can delete that track, create a new track, and add another instance, and it’s often fine for a few more instances, until the another starts with the glitch. This happens in both Ableton and Reaper. It happens in both VST3 and AU, although more often in AU. And i haven’t been able to get the Standalone App version of it to glitch at all.

You can see in my video below, the first two instances work fine. The third i loaded has glitch issues. They’re just playing the Main Oscillator as a sine wave. The ADSR affects the amplitude. The Portamento is a SmoothedValue. Foldback Distortion is at 0. The ring mod, freq shift, and s&h are 100% Dry. The filter cutoff affects the tone of the glitching, which leads me to believe it’s happening at the filter processSingleSampleRaw() method, but i haven’t the slightest idea what to check for.

The code is on my GitHub

The fact that there’s some frequency pulsing of the glitch against the pitch, i’m looking for somewhere the sampleRate or buffer sizes might not be getting the right data, but i’m not seeing anything yet. But i’d love any thoughts as to what would cause this to only happen sometimes would help.

Grazie in advance

I think you’ll need do a bit more due diligence before asking. It’s quite a big repository to look for an issue.

  1. Make sure it’s not a CPU issue. If it happens with multiple instances of the plugin running you might just be taking too long to process

  2. Make sure if it is or it isn’t the filter. Remove and re-add processing steps till you’re sure which processor is causing the issue.

Report back and I’ll be happy to take a look

float NotchFilter::processNotch()
    filterEnvControl            ( envelopeVal, cutoffSend, resSend );
    notchFilter.setCoefficients ( IIRCoefficients::makeNotchFilter(sampleRate, cutoffLFO, resonanceScale) );
    return notchFilter.processSingleSampleRaw(inputSample);

Setting coefficients for the filter every sample would definitely cause CPU issues.

Also in your readme:

I'm using 56 harmonic sines for the square, spike, and sawtooth because i love how aggressively dirty they sound.

1 Like


I wasn’t asking anyone to dig through my code to find the issue for me. More asking for where to start looking, because i’ve been looking at this for about three days trying to figure out where the issue could be. Even took me 3 tries to make the screen recording because the first two the glitch didn’t happen. Supplied the code link just so it’s there if need be.

As for the CPU load issue:

  • It’s not running the 56 harmonics the whole time. It’s just using them to create the wavetable at startup, and then it’s reading from the wavetables.

  • My CPU usage is only down around 6% in Live, even with about 10 instances open. Reaper shows CPU load at 0.4% for an instance.

  • If it was CPU load, why would it show up on say, the 3rd instance of the plugin, but the first two would still work properly? And then would would i be able to add more instances and have those work fine?

Will definitely try lowering the sine count while creating the wavetables, see if setting the Filter Coeffs differently helps, and then will start Removing/Re-adding processing steps.

I do thank you for your suggestions. It gives me a clearer idea of what to check for and how to attack it. :+1:

Ahh yeah fair enough, I actually somehow didn’t see that was a video when I first clicked the post it looked like a screenshot.

From your description it doesn’t sound like a CPU issue. If it happens after a long time running then I’d check for rounding errors in places like phases indexes etc can run off course after a while processing a float, but yeah it’s a tough thing to isolate for sure.

1 Like

if the glitch only happens with multiple instances, take a look for any static variables that might be using.


No worries. I think you might have been onto something with the filter coefficients, but i had to stop last night because it was too late. Will be digging in again today.

Oddly enough, it’s not a length of time thing. It’s immediate upon loading an instance onto a track. And the next instance will immediately work completely fine, even without deleting the previous track or instance.

What would static variables do to cause issues in different instances of a plugin in the DAW?

Off the top of my head, I think i only used them if they were absolutely necessary for something else to work (if at all), but i’ll definitely look into static variables and see if they’re causing trouble.

Does the glitching happen also in debug mode? If yes, have you tried attaching the debugger to the offending plugin instance?

1 Like

Static and global variables are shared by plugin instances running in the same process.

1 Like

I was interested so took a quick look. I can’t see any statics. And the santizers in Xcode don’t show up any uninitialzed members (for example, as that could be an issue). Only issues showing up in the vorbis code I think!

1 Like

After hours of listening to pure sine waves :crazy_face:Just an update:

  • I removed everything except the main oscillator and it will still do the problem occasionally. No envelopes, no velocity, no SmoothedValues, no portamento, no modifiers, no foldback, no filters, no out gain. Wavetable sample into outputBuffer.
  • I compared the sine wavetable values of a glitching instance against a working instance, and i didn’t find any differences, so it’s not in the wavetable itself.
  • No static variables in use.
  • Reducing the number of sine harmonics used to create the wavetables down to 10 harmonics didn’t make a difference.
  • Annoyingly, sometimes it’ll seem like it’s working with about 8 plugins loaded. So i quit and reopen Live and try again with another 8 or so and it seems to work. Then i quit and load Live again and one of the instances will glitch. So it’s tricky even figuring if the issue stopped because of the last element i removed, or just because i got lucky for a while.

I have a hunch it might have something to do with either the ADSR values, SmoothedValues, my tailoff/noteOff handling, or there’s something i’m not doing .reset() for properly. Or, maybe i did something in my GUI that’s sneaking into the audio thread. But, i need to give my ears a rest for a bit.

@oxxyyd I does it in both Debug and Release modes. And i’ve been sticking DBG in various places trying to find an issue. But, i’m not even sure what values to test. Everything i’ve tested seems to be behaving properly. If i was smarter i’d probably be better at finding this. heheheh.

@xenakios Good to know! Thanks. I didn’t use any static variables, but i’ll double check.

@martinrobinson Thanks for checking! Yeah, it would be easier to fix if there was something throwing up a flag or if it was ALWAYS not working.

But, yeah, like i said, i need a break. There’s only so many hours of sine waves i can listen to. I’ll come back to this later tonight.

Still haven’t figured it out but i’m digging deeper.

On the instances of the plugin that glitch, there’s a pattern of several wave cycles that are clean, followed by several wave cycles that have a deformation, always in the positive side of each cycle, usually right at the beginning of the wave (but not exclusively), then the clean waves, etc. etc.

For example: 11 Good Cycles; 5 Bad Cycles; 11 Good; 5 Bad; 9 Good; 6 Bad…

When i look at the sample values in the wavetables of the different plugins (Working vs Glitching) they’re the same. And I’ve run the synth with everything removed between the wavetable and the output buffer and it still happened. (This includes the envelope, velocity, portamento, generic gui, etc.)

So, it seems like i have to figure out why there’s weird values being added to the out buffer that aren’t in the wavetables. Possibly my lagrange interpolation, or some other part of my code that is reading the values from the table and mangling them on the way to the output buffer. Maybe something to do with denormals being too small? I dunno. Still digging. Still confused. :rofl: :sob: :rofl:

I just took a quick look at your wave table class on my phone and it looks like like when you populate the wave table it’s 0-1023 for indexed but your phase wrapping values greater than 1024? Could it be an indexing issues maybe? Perhaps try just replacing even your wave table with just a pure sine function and then ensure it’s definitely due to something funky in the wave table?

1 Like

Shoot! I was playing around with that yesterday and i think i erroneously switched that and forgot to change it back. Good eye. Will definitely double check everything i did/undid/forgot to fix in my wavetables.

Good call. Didn’t even think to do this. I already have my oscillator classes there for the wavetable. Should be an easy test. Much thanks!

I think Jake got it. But I want to point out, that your doing mod on negative values here:

and the result isn’t what you expect:

The fix is easy in this case. Just add wavetableSize to make sure index isn’t negative before taking the mod.

So I think your Lagrange code reads values from before the start of the array - which may explain the glitches.


Omg @TurboCyber , I’m pretty sure that’s the problem right there. The modulo with negative numbers was done deliberately and was giving the correct output.

I failed to then wrap that negative number back around to the end of the wavetable.

So i added a condition to wrap it:

for (int i = -2; i < 2; i++)
    int index = floor(readHeadPos + (i + 1));   // index after readHeadPos in time
    index %= waveTableSize;                     // wrap index

    if (index < 0.0f)
        index += waveTableSize;

So far i’ve been testing for about 30 minutes in VST3 and AU, in Live and Reaper, 10+ instances per DAW session, and I haven’t gotten it to glitch once. Pretty confident that’s it.

Thank you so much, and thanks everyone else who took the time too!

1 Like

w00t w00t

1 Like

Is there a way i can mark this thread as solved? Not seeing it anywhere.