lmms icon indicating copy to clipboard operation
lmms copied to clipboard

Implementing oversampling in plug-ins.

Open husamalhomsi opened this issue 8 years ago • 9 comments

• 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.

husamalhomsi avatar Jun 03 '17 15:06 husamalhomsi

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

PaulBatchelor avatar Jun 15 '17 18:06 PaulBatchelor

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.

husamalhomsi avatar Jun 16 '17 17:06 husamalhomsi

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

grejppi avatar Jun 16 '17 19:06 grejppi

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.

husamalhomsi avatar Jun 16 '17 20:06 husamalhomsi

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.

PaulBatchelor avatar Jun 25 '17 01:06 PaulBatchelor

Oversampling is gone entirely since #7228

Rossmaxx avatar May 12 '24 17:05 Rossmaxx

@sakertooth close?

Rossmaxx avatar May 13 '24 15:05 Rossmaxx

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?

zonkmachine avatar May 13 '24 16:05 zonkmachine

Oops, another misread.

Rossmaxx avatar May 13 '24 16:05 Rossmaxx