Add SlewDistortion effect and oversampling support #7641
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
LMMS didn't have any particularly impressive distortion plugins, so I decided to make one for everybody.
The GUI was designed by thismoon.
Slew Distortion is a 2-band slew rate limiter and distortion plugin. Almost the entirety of its audio processing code is written in pure SSE2 instructions, meaning it can process all four channels (two stereo channels x two bands) simultaneously in a single thread, resulting in extremely low CPU usage for what it provides.
Unlike most distortion plugins, this one has an optional dynamics-restoring feature which can restore all of the dynamic range that distortion usually removes from your signal, meaning you can push it as hard as you want to change your sound's timbre without worrying about things sounding too squashed.
The slew rate limit can be set for both upward and downward movement independently, and can be modulated internally using an envelope follower so it morphs in time with the volume.
Most distortion plugins, especially the ones in LMMS currently, majorly struggle with aliasing, which introduces ugly and harsh high frequencies that are inharmonic and can even completely destroy the cleanliness of your song. This plugin supports up to 32x oversampling, meaning up to an extra ten whole octaves of overhead before aliased frequencies become audible, far more than you'd ever realistically need.
Ten waveshaping types are featured. Let me know if there's another one you'd like for me to add and I'd be happy to add it in!
(And yes, as mentioned, every single one of these distortion types are fully implemented as pure SSE2 instructions. I have not been getting eight hours of sleep.)
My personal favorites are Tanh and Sinusoidal, since they are mathematically smooth and infinitely differentiable. In less stupid terms, they can generally be pushed far more aggressively before they start to create any harsh upper frequencies.
But only having a few waveshaping presets to choose from is no fun, so I've added a couple handy knobs to help you sculpt your own with almost no performance detriment. Warp and Crush are algorithms of my own invention which allow you to pass lower-amplitude sample values through without distortion, and concentrate the waveshaping up at the higher peaks.
(They can also be used to create waveshapes essentially identical to those used in the relatively famous Camelcrusher plugin, which is fun.)
Slew Distortion comes with a handy visualizer on the right side to show you exactly what you're doing to the waveshaping curve, no guesswork needed.
I recommend trying the plugin out for yourself, but here are some old videos I recorded during the development process.
Singleband demo: https://youtu.be/nqabNFl46Vo
Multiband demo: https://youtu.be/jqdMEhJw_8I
These demos kinda suck, but it should hopefully give a general idea of a few things it can do. Obviously its more creative features would be far more useful on individual songs than full mixes.
KNOWN BUGS (do not merge until these are resolved):
The graph axes are off-center, I somehow didn't notice until just now. It's an easy fix.FIXEDDonations for developing free audio software is literally my only source of income, and I can't quite afford enough food to keep myself fully healthy, so if you're willing and able, any contributions would be deeply appreciated: https://www.patreon.com/c/lostrobot