Skip to content

Glissando: explanation of implementation

Peter edited this page Dec 24, 2018 · 2 revisions

Explanation of the complicated formula/algorithm present in the code for calculating glissando.

What we want to know at the end of this explanation:

latex

Let's start by looking at the desired note index change over time:

latex

Next, we need a formula for relationship between MIDI note index and frequency:

latex

Now we can substitute one into another, to know the frequency over time:

latex

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:

latex and in such case, the letters correspond to:

latex

The indefinite integral would be equal to:

latex

What we actually need is time elapsed from moment 0 to the current moment t, so it would be the following definite integral:

latex

which concludes the explanation of the convoluted implementation of glissando in fsynth.

Clone this wiki locally