Skip to content

Conversation

@LostRobotMusic
Copy link
Contributor

@LostRobotMusic LostRobotMusic commented Oct 30, 2022

A crucial library for high-performance oversampling within LMMS, licensed under WTFPL.

There are many situations within LMMS that require oversampling. The quality of oversampling is heavily determined by the filters used in the process... the ideal is to have as steep of a filter slope as possible (to remove all aliasing without the filtering being audible at all) while also introducing minimal phase shifting (or else the filtering will audibly smear the audio).

Generic Butterworth lowpass filters are not adequate for this goal. In order for the desired steep slope to be achieved, it would be necessary to stack a very large number of these filters on top of each other, which results in tons of audible phase shifting and quite a hefty CPU demand.

An idealized FIR filter also won't work in many situations... the number of taps required to make the filter usable will result in large amounts of latency and quite a massive CPU demand once again.

HIIR solves this by using a different type of IIR filter called an elliptic filter, which is characterized by having an extremely steep slope with minimal filter taps.
image

Butterworth filters have such a gentle slope because they are designed to have minimal passband and stopband rippling. Elliptic filters allow a small amount of rippling and are able to have a far steeper slope as a result. Conveniently, this ripple is mostly only audible near the cutoff frequency, which is not an issue when you're filtering near Nyquist at frequencies too high for a human to hear.

The filters within HIIR are designed specifically with oversampling in mind, and will be the best things to use in almost all cases where oversampling is required. It also comes with some other useful filters which work in similar ways, like an IIR Hilbert Transform which shifts the audio by 90 degrees (an essential ingredient for frequency shifting).

I'll be modifying #6540 to make use of this library once it is added.

@sakertooth
Copy link
Contributor

Why not add this library as a Git Submodule?

@JohannesLorenz JohannesLorenz self-requested a review January 23, 2023 18:49
Copy link
Contributor

@JohannesLorenz JohannesLorenz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit weird to add code that is not used, but I can't see errors in the code.

@Veratil
Copy link
Contributor

Veratil commented Jan 23, 2023

A crucial library for high-performance oversampling within LMMS, licensed under WTFPL.

Just so we can see what the license is here without having to look it up. 👍 http://www.wtfpl.net/

        DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
                    Version 2, December 2004 

 Copyright (C) 2004 Sam Hocevar <[email protected]> 

 Everyone is permitted to copy and distribute verbatim or modified 
 copies of this license document, and changing it is allowed as long 
 as the name is changed. 

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 

  0. You just DO WHAT THE FUCK YOU WANT TO.

@LostRobotMusic LostRobotMusic merged commit 4d1d887 into LMMS:master Jan 26, 2023
LostRobotMusic added a commit that referenced this pull request Jan 26, 2023
sakertooth pushed a commit to sakertooth/lmms that referenced this pull request May 30, 2023
sakertooth pushed a commit to sakertooth/lmms that referenced this pull request May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants