Frequent click & pop sound on the edges of MIDI notes?

Hey, i have this weird problem and since I’m quite new to JUCE and plugin development
im not sure how to fix this.

So I’m building a simple sampler plugin and there are frequent clicks and glitches at the beginning or end of notes
I’ve applied a 4ms fade in and fade out on the output but it seems that if i play more then 1 note at once
the clicking pop sound comes back.

Any ideas on how to fix this issues?

A common cause of this is not using the startSample and numSamples values correctly in your voice rending code. (E.g., assuming startSample is always zero when it certainly isn’t when rending sub-blocks of audio based on MIDI note timestamps.)

Still get all the pops and click, not sure whats wrong in the code
Thats what i have going on

processBlock method

loadSample method

maxMidiChannel is 1

Sounds like an overloaded CPU… did you check the CPU load?

Definitely not CPU overload, i can recreate the problem on any system
and none of them show cpu overload.

Maybe it would help you to compare your code to the synthesizer demo in the JUCE Demo (JUCE/examples/Demo) or the sampler in (JUCE/examples/AUv3Synth). From looking at your code, I think the do something very similar (and don’t pop).