Cabbage Logo
Back to Cabbage Site

Filter ADSR envelopes

My new home project is an implementation of Welsh’s cookbook subtractive synth in csound/cabbage.
And yes, I am stuck with the envelope filter.
There are a lot of suggestions. In another post Rory suggests:
kFilterCutOff*kAdsr
which means that the lowest point of the envelope graph is 0 (or 0.0001 if expsegr is used) and the peak point is the cut off frequency.
Floss csound manual suggests
kFiltEnv expsegr 0.0001, iFAtt, iCPS*iCF, iFDec, iCPS*iCF*iFSus, iFRel, 0.0001
suggesting that the peak frequency of the (moogladder) filter is the product of the note pitch and the cut off frequency.
Finally a supercollider implementation suggests that the envelope modulates the frequency between cut off frequency and an octave higher.

What am I supposed to do here… :thinking:

Finally there is a percentage in Welsch’s book:
Envelope: Sets the amount by which the filter envelope controls the amount of
filtering. On some synths this is called the Initial Level setting. Again 0% is the
minimum value and 100% is the maximum .

Any idea, please? On a graph where the adsr line is drawn vs time what are the values of the y-axis?

I’m not sure what the most typical implementation is, but I guess you could use multiple implementations and let the user decides which works best for them?

I’ll try to reverse engineer synths in my computer. Cookbook proposes a method for figuring absolute cut off frequency values from knob position. I suppose I can use similar method to determine how adsr works.
I still cannot understand why nobody addresses this problem in a satisfactory manner.
I’ll keep you posted.
Yet… if anyone… anyone… knows, please, share.

I found the answer. Actually, it is a matter of choice.
An absolute cut off frequency as in
kFilterCutOff*kAdsr
affects the sound of the patch along the keyboard. On the other hand,
kFiltEnv expsegr 0.0001, iFAtt, iCPS*iCF, iFDec, iCPS*iCF*iFSus, iFRel, 0.0001
secures the relative peak of each harmonic. In this case, the knob that controls the iCF variable operates as a multiplier; its value shows the number of harmonics that remain unaffected from the filter.

1 Like

I finally found a formula that works properly.
The ADSR envelope modulates the frequency from the filter cut off frequency (equivalent to the 0 point of the ADSR envelope) to a max frequency which is determined by the amount of filter involved. This max frequency corresponds to the 1 point of the ADSR envelope. But, what is this frequency? I understand it as a percentage of the maximum cut off frequency, that is when you turn the cut off knob to its maximum value. Whether this percentage should be implemented in a linear or exponential fashion, I don’t know. Maybe a reader of this post has a better answer.
I implemented it as a point on a line between points (0,a) and (1,b). That is y = ( b - a ) * x + a.

kfenv     madsr       ifatt, ifdec, ifsus, ifrel
khifreq   =           20000 * kamount   ;(*) see note below
kmlfreq   =           ((khifreq - kcutoff) * kfenv) + kcutoff
aout      moogladder2 afilterinput, kmlfreq, kresonance

where ‘kfenv’ plays the role of x in the formula.

Example: cutoff frequency = 100 Hz and the knob goes up to 20000 Hz. Then 80% = 16000 Hz.
The envelope modulates the filter’s frequency from 100 to 16000 Hz.

Note that the 2nd line of the code above needs improvement, since it is possible that we calculate a khifreq which is lower that the kcutoff. But you get the spirit!

I think it make sense for all frequency parameters to be exponential. But I really have no idea how this is typically done. I always assumed it would be exponential?