Unexpected Discontinuities

Wait, what is a discontinuity?

Generally speaking, when you hear a click in your audio, that's a "discontinuity". We inherited the word from mathmaticians which is why it's such a mouthful. In audio we usually just call them clicks, but it's helpful to know the word discontinuity because it also sort of explains what it is.

This ties back into envelopes I swear

A discontinuity is a place where the audio wave isn't continuous (basically when it's not smooth). Here is an example (discontinuities are notated with the little blue arrows)

Click the image to see a new discontinuity

Why does this happen?

A discontinuity (an audible click) happens whenever the amplitude of the wave changes abruptly. The bigger the change in amplitude, the louder the click. You can also see now why it's called a discontinuity, it's a visible cut in the smooth shape of the wave which makes the wave not continuous

What does this have to do with envelopes?

Envelopes can create discontinuities in your sound (as you've probably heard before if you've ever tried to use Operator in Ableton to make your sub bass). Sine waves with a sharp amp env are the easiest place to catch this happening, but it is also happening in other wave shapes (but the sound can be masked by the other frequencies that wave is making/contains)

Here you can see, depending on how you set the envelope settings, that your envelope can make discontinuities in the wave. Discontinuities are highlighted with the blue (teal?) arrows, like above.

Also please note that the code I wrote for detecting the discontinuities is a bit over sensitive and you aren't likely to hear discontinuities at most places in the envelope other than where the slope of the envelope is straight up and down (usually at the beginning and end), but if you're hearing some unexpected ones you can come back here to remember where they can happen.

PHEWF

Alright, that's enough of that. Was that too much detail too soon? Maybe, but that's ok, let's keep truckin'. Envelopes can control a lot more than volume, they can control anything! The next chapter will explore some other stuff we can control.



Want the gory details of why the algo is so sensitive?

I'm using a threshold on the third derivative to check how abruptly the waveform changes,unfortunately this is sort of an adhoc solution. If you increase the frequency of the wave the regular oscillations will also register as "discontinuities". I tried to scale the threshold with the frequency but it's... well, as you can see I'm not a math wiz so this was a bit above my paygrade. It was a pretty fun exercise for me though so I decided to keep it. I kind of got the feeling that if I kept taking the derivative, eventually I'd get a really nice solution but I got a bit tired of doing it haha. If you've got a better solution please submit a pull request!


Onwards

(this will be a link to the next page eventually)