3 ms·
That's almost the beauty of a lot of audio DSP filters. They can be 1-10 lines of code, but to understand why they work and how to create similar ones with prop
by orlp 5y ago
That's almost the beauty of a lot of audio DSP filters. They can be 1-10 lines of code, but to understand why they work and how to create similar ones with properties you want you need a heavy math background and a 500+ page book (e.g. https://www.native-instruments.com/fileadmin/ni_media/downloads/pdf/VAFilterDesign_2.1.0.pdf https://www.native-instruments.com/fileadmin/ni_media/downlo...).
Other complicated DSP algorithms I've read about (but haven't come close to fully grokking) are:
- Band-limited oscillators. Ask yourself, how do you generate a square wave signal? It's "just" 1 for t seconds and -1 for t seconds, repeating, right? But what if t isn't a multiple of our sampling frequency? Also, a square wave can be interpreted as an infinite sum of ever increasing frequency sine waves. But Nyquist tells us we can't have those higher frequencies. So even if t was a multiple of our sampling frequency, it still wouldn't be right to have t/f samples of 1 followed by t/f samples of -1. But just taking the first N terms of the infinite sum (those below Nyquist) is slow, so you get things like polyblep: https://www.kvraudio.com/forum/viewtopic.php?t=375517 https://www.kvraudio.com/forum/viewtopic.php?t=375517.
- Resampling. So a sampled bandlimited signal is perfectly represented by the samples through the Whittaker–Shannon interpolation formula. To resample we simply have to pick equidistant samples using the interpolation formula. However this is slow (and global, so not real-time), so there's a bunch of techniques to speed this up with minimal distortion: http://ldesoras.free.fr/doc/articles/resampler-en.pdf http://ldesoras.free.fr/doc/articles/resampler-en.pdf
- Pitch shift. This seems innocuous enough, right? But suppose it were easy to shift pitch. Then we could resample our audio to 2x the frequency, shift the pitch up by an octave and play back at the original speed. Now we've made our audio twice as long without changing the pitch! Pitch shifting and timescaling are two sides of the same coin. And I don't understand either side. Fundamentally I don't really understand what it means to make an audio signal "longer", without changing the pitch, at the waveform level. But people do it anyway: https://en.wikipedia.org/wiki/Audio_time_stretching_and_pitch_scaling https://en.wikipedia.org/wiki/Audio_time_stretching_and_pitc...
- The rabbit hole goes on...