LMMS / lmms

Cross-platform music production software
https://lmms.io
GNU General Public License v2.0
7.82k stars 988 forks source link

Implementing oversampling in plug-ins. #3605

Open Sawuare opened 7 years ago

Sawuare commented 7 years ago

• Synthesizers: When playing high notes on a synthesizer using a harmonically rich wave like a saw wave, there are probably some frequencies that will go above the nyquist frequency, so aliasing occurs.

Just play the note C8 on TripleOscillator using a saw wave to hear the aliasing noise.

My idea of the UI implementation is radio buttons in the plugin tab of each synthesizer offering oversampling factors in powers of 2.

• Effect plug-ins: There are 2 types of plug-ins that would benefit from using oversampling (as far as I know).

(1) Waveshapers, distorters, overdrivers, bitcrushers and Lo-fi effects (or anything that generates a lot of overtones). When using any of the effects above on a sound, extra overtones are being added to it, and if these overtones go above the nyquist frequency, aliasing occurs.

Spectrum of a heavily waveshaped sine wave. distorted sine wave Spectrum of the same sound but with 16x oversampling. distorted sine wave with 16x oversampling

My idea of the UI implementation is a slider in each of these plug-ins mentioned earlier offering oversampling factors in powers of 2.

(2) Equalizers. When a band (of any type) in the equalizer gets close to the nyquist frequency, its shape distorts.

A normal low-pass filter at 1000 Hz looks like this: lpf 1000 hz The same filter but at 16000 Hz looks like this: lpf 16000 hz

Using oversampling will prevent this distortion and improve audio quality, particularly at high frequencies. My idea of the UI implementation is an off/on "Oversampling" button on each equalizer plug-in effect that uses a specific oversampling factor that is just enough to prevent the distortion without introducing excess CPU load.

PaulBatchelor commented 7 years ago

Have you looked at the oversampling options in the export menu?

Sawuare commented 7 years ago

Have you looked at the oversampling options in the export menu?

Yes, but they don't even work at the moment, and even if they do work, they're on export only.

grejppi commented 7 years ago

IIRC the Oscillator class has band-limited waveforms available, which are available in LB302 and Monstro, but they are not enabled for TripleOscillator.

Sawuare commented 7 years ago

IIRC the Oscillator class has band-limited waveforms available, which are available in LB302 and Monstro, but they are not enabled for TripleOscillator.

Band-limited waveforms are a good idea, but modulation of said waveforms could still cause aliasing.

PaulBatchelor commented 7 years ago

This feature would require a lot of internal refactoring of the plugin and classes, as well as introduce new UI. It's a very tall order, but the code is there if you'd like to take a stab at it and make a PR. I'm not also entirely convinced that this would be an effective new feature. Oversampling is very much a brute-force approach to alias reduction. I'd be more keen on approaching more specific solutions to alias reduction for particular plugins and effects, rather than try cram a "one shoe fits all" feature. Or better yet, just build new instruments and effects that sound better.

Rossmaxx commented 2 months ago

Oversampling is gone entirely since #7228

Rossmaxx commented 2 months ago

@sakertooth close?

zonkmachine commented 2 months ago

Oversampling is gone entirely since #7228

The description of that PR says should really be an option on a per-plugin basis, which this issue is all about. If someone want's to implement oversampling in a plugin or two, why not?

Rossmaxx commented 2 months ago

Oops, another misread.