Glitch problem in ADSR [synth - Plug-In]


#1

Hi everyone,

I’am doing a synth plug-in in which I implemented 2 oscillators with different waveshapes, LFO, filters and ADSR.
Everything works great but not the ADSR: while I am playing and I change note, when the new note is starting I have an initial glitch. If I wait until the sound of the first note is finished I don’t have this issue…I neither have it when I am playing without the ADSR so I really don’t know how to solve this issue.
The ADSR is done by multiplying the samples with a linear envelope (practically using the basic formula y=mx+q of a line and calculating the angular coefficient “m” depending on the values of the ADSR parameters). I also tried to use all the values as “LinearSmoothedValue” but unluckily it didn’t solve the problem.
Anyone else had this problem or have any idea on how to solve this?


#2

It could be any number of things… Just to check, is your synth polyphonic? If not, it will cut off each note as it starts a new.

You can output your ADSR values into the audio buffer alone, and inspect the samples afterwards to see any discontinuities (spectrum analysers can be a great help here).


#3

Thanks for the reply!
Yes, the synt is polyphonic but even in monophonic case I have the same issue (if I play a note, even the same one, before it finishes it’s ADSR, I can hear a glitch when I start a new note). As I said, if I wait until the note is over (so the ADSR has finished) the glitch doesn’t show.
Your seems an interesting solution but I don’t think is a matter of the values of the ADSR: I tried to make it start from zero at every call and to clear the buffer before using the ADSR but I’m still having the problem.
Tomorrow I will try your suggestion (the spectrum analyser thing). Thanks for your time!


#4

Record the waveform and look at the glitch … sometimes reveals a lot about the problem.

PS. I got a weird glitch once by neglecting to realise that the synth’s process function doesn’t always start at sample 1 when it gets a note…