Synthesizer VSTi cuts sound

Hi everyone, I'm back with a (possibly stupid) question...

I'm building an additive synthesizer, and it's working pretty well... generally

The problem is: when I test it in REAPER, for example, I can play a few notes, then the sound crackles and glitches and then stops, and I can't play any more notes. The strange thing is that the VU meter shows actual signal, with the correct envelope and everything.

Can anyone help me sorting this out?

This is the source for the SynthesizerVoice:

What going on is I have a wavetable and 64 harmonics with separate linear ADSR. I know, it's ugly code, it probably creates a lot of aliasing and lots of other nasty things, but I'd like to solve this issue before polishing the engine.


mmm just out of curiosity... what are you returning in line 82?

Then, I'll check the whole loop since looks like you are only writing 1 sample to the buffer at startSample.


My 2 cents,


In line 82 I'm returning because the synth is not playing, so no point filling the buffer with zeroes, I guess...

I'm afraid I didn't understand what you mean by "you are only writing 1 sample to the buffer at startSample": I'm iterating down from numSamples to 0, so that should put numSamples floats into the buffer, right?

I have just noticed that using VSTHost instead of REAPER causes stutter instead of silence: I've come to the conclusion that the cause is CPU overload, basically I'm doing too much in a cycle. I still don't understand why it only happens after a while...

By profiling and adjusting the code I managed to reduce CPU usage and get some usable sounds. Thanks anyway!

BTW, are you the Luca from Progsounds? I remember reading your article on Johannson's lead sound some years ago... That was a good read!