-
Notifications
You must be signed in to change notification settings - Fork 1
Glissando: explanation of implementation
Explanation of the complicated formula/algorithm present in the code for calculating glissando.
What we want to know at the end of this explanation:
Let's start by looking at the desired note index change over time:
Next, we need a formula for relationship between MIDI note index and frequency:
Now we can substitute one into another, to know the frequency over time:
Now, the approach I took to get the waveform value is the following: get the waveform of a given instrument for frequency of 1 Hz, and instead of passing a value of linearly flowing time, modify ("stretch") this time to reflect the smooth change. For this to work, we need to calculate a definite integral from 0 to t
from the above function.
To make it easier, let's first substitute some constant expressions with letters. Ideally we want such form that should be easier to integrate:
and in such case, the letters correspond to:
The indefinite integral would be equal to:
What we actually need is time elapsed from moment 0 to the current moment t
, so it would be the following definite integral:
which concludes the explanation of the convoluted implementation of glissando in fsynth.