Canonical implementation of frequency modulation

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

Post Reply
f00bar
Established Member
Posts: 83
Joined: Sun May 12, 2013 7:40 pm

Canonical implementation of frequency modulation

Post by f00bar »

I asked something similar in the "Effects and plug-ins" board but perhaps this is a better place. I also found more problems how to implement filter modulation.

I am getting somewhere with an LV2 clone of "Transcender SE". So far I have 11 out-of-tune sawtooth oscillators with option for turning 5 of then one octave down. These oscillators are modulated by a common ADSR envelope.

What I need to know is how to organize the filter modulation. The filter has a Q value and f_c. The least restrictive way would be to modulate Q and f_c independently with two independent LFO:s and two additional ADSR:s but I think that will result in to many parameters, since the final gate adds an additional ADSR+depth (5 parameters). I would like to have only one LFO and one ADSR for the filter. That is what I find in the original as well as for example JX16.
ssj71
Established Member
Posts: 1294
Joined: Tue Sep 25, 2012 6:36 pm
Has thanked: 1 time

Re: Canonical implementation of frequency modulation

Post by ssj71 »

ok. I was playing around in gnu octave to get it the way I think it should be. Here's the script (if you aren't familiar with matlab/octave I can explain it more):

Code: Select all

fc0 = 440*8; %users frequency setting
sus = .5; %sustain level, range [0,1]
adsr = [0:1/9:1 (1-sus/5):-sus/5:sus sus*ones(1,30) sus:-sus/4:0]; %adsr linear in range [0,1]
amt = 4; %adsr amount, 4 = 4 octaves
lfo = [zeros(1,14) sin(4*(0:1/35:1)*2*pi)]; %sine wave lfo 4 cycles, doesn't start until the sustain of envelope
amp = .5; %lfo amplitude, .5 = 6 semitones = 1/2 octave

%each octave is a doubling of frequency, so the 2 modulators are exponents to a factor of 2 multiplied to the unmodulated cutoff freq (fc0)
fc = fc0*2.^(amt*(adsr-sus) + amp*lfo); %I offset the adsr such that cutoff = the user setting at the sustain
semilogy(fc)
Anywho that was fun. Thats how I would do it. I always use octave for some quick prototyping and working out ideas. It's great for me (but I've been using it for years).
I've never seen a basic modulation scheme that adjusts the resonance. Typically only advanced synths modulate that afaik.
_ssj71

music: https://soundcloud.com/ssj71
My plugins are Infamous! http://ssj71.github.io/infamousPlugins
I just want to get back to making music!
f00bar
Established Member
Posts: 83
Joined: Sun May 12, 2013 7:40 pm

Re: Canonical implementation of frequency modulation

Post by f00bar »

ssj71 wrote:ok. I was playing around in gnu octave to get it the way I think it should be. Here's the script (if you aren't familiar with matlab/octave I can explain it more):

Code: Select all

fc0 = 440*8; %users frequency setting
sus = .5; %sustain level, range [0,1]
adsr = [0:1/9:1 (1-sus/5):-sus/5:sus sus*ones(1,30) sus:-sus/4:0]; %adsr linear in range [0,1]
amt = 4; %adsr amount, 4 = 4 octaves
lfo = [zeros(1,14) sin(4*(0:1/35:1)*2*pi)]; %sine wave lfo 4 cycles, doesn't start until the sustain of envelope
amp = .5; %lfo amplitude, .5 = 6 semitones = 1/2 octave

%each octave is a doubling of frequency, so the 2 modulators are exponents to a factor of 2 multiplied to the unmodulated cutoff freq (fc0)
fc = fc0*2.^(amt*(adsr-sus) + amp*lfo); %I offset the adsr such that cutoff = the user setting at the sustain
semilogy(fc)
Anywho that was fun. Thats how I would do it. I always use octave for some quick prototyping and working out ideas. It's great for me (but I've been using it for years).
I've never seen a basic modulation scheme that adjusts the resonance. Typically only advanced synths modulate that afaik.
Octave is really good at testing things. So I can skip modulating the resonance (good). But the LFO should continue running since all voices share the same phase for this synth.

If the filter shall follow MIDI key, where does this frequency go?
ssj71
Established Member
Posts: 1294
Joined: Tue Sep 25, 2012 6:36 pm
Has thanked: 1 time

Re: Canonical implementation of frequency modulation

Post by ssj71 »

f00bar wrote:octave
If the filter shall follow MIDI key, where does this frequency go?
using the feedback in that other thread that keyfollowing should be a gradient, not just on or off, something like:

Code: Select all

fc0 = 440*8; %users frequency setting
sus = .5; %sustain level, range [0,1]
adsr = [0:1/9:1 (1-sus/5):-sus/5:sus sus*ones(1,30) sus:-sus/4:0]; %adsr linear in range [0,1]
amt = 4; %adsr amount, 4 = 4 octaves
lfo = [zeros(1,14) sin(4*(0:1/35:1)*2*pi)]; %sine wave lfo 4 cycles, doesn't start until the sustain of envelope
amp = .5; %lfo amplitude, .5 = 6 semitones = 1/2 octave
kbdf_amt = 1; %keyboard follow amount range [0,1]
note = 75; %midi note

%each octave is a doubling of frequency, so the 2 modulators are exponents to a factor of 2 multiplied to the unmodulated cutoff freq (fc0)
%I offset the adsr such that cutoff = the user setting at the sustain
%I also center the keyboard following around a4. No idea what the standard implementation would do
fc = fc0*2.^(amt*(adsr-sus) + amp*lfo + kbdf_amt*(note-69)/12); 
semilogy(fc)

does that make sense? a4 (440 hz) just seemed like a logical place to center the keyboard following.
_ssj71

music: https://soundcloud.com/ssj71
My plugins are Infamous! http://ssj71.github.io/infamousPlugins
I just want to get back to making music!
f00bar
Established Member
Posts: 83
Joined: Sun May 12, 2013 7:40 pm

Re: Canonical implementation of frequency modulation

Post by f00bar »

Do I understand it right that $f_{c0}$ is either a hardcoded value or modulated by keyboard input:

$f_{c0}=440(1-\text{keytrack}) + f_{\text{key}}\text{keytrack} $
ssj71
Established Member
Posts: 1294
Joined: Tue Sep 25, 2012 6:36 pm
Has thanked: 1 time

Re: Canonical implementation of frequency modulation

Post by ssj71 »

f00bar wrote:Do I understand it right that $f_{c0}$ is either a hardcoded value or modulated by keyboard input:

$f_{c0}=440(1-\text{keytrack}) + f_{\text{key}}\text{keytrack} $

fc0 would be where the user sets the knob for cutoff frequency, so if all modulation (and key following) is turned off the filter cutoff stays static at that freq. Everything else is a change from there. I'm guessing early hardware synths did not follow keys originally and it became a feature added in later hardware synths, and so its common to be able to toggle which method is used.
_ssj71

music: https://soundcloud.com/ssj71
My plugins are Infamous! http://ssj71.github.io/infamousPlugins
I just want to get back to making music!
Post Reply