Skip to content

Fold the three anti-aliasing functions into one - #328

Open
MAX-WiRED wants to merge 1 commit into
uvcat7:betafrom
MAX-WiRED:feat/waveform-smoothing
Open

MAX-WiRED wants to merge 1 commit into
uvcat7:betafrom
MAX-WiRED:feat/waveform-smoothing

Conversation

@MAX-WiRED

@MAX-WiRED MAX-WiRED commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

The waveform's anti-aliasing is three functions that differ only in how many
samples they average:

    void antiAlias2x(uint8_t* dst, int w, int h) { ... }
    void antiAlias3x(uint8_t* dst, int w, int h) { ... }
    void antiAlias4x(uint8_t* dst, int w, int h) { ... }

picked by a switch that has to grow an arm for every factor.

The change

One loop covers every factor:

    void antiAlias(uint8_t* dst, int w, int h, int factor) {
        const int newW = w / factor, newH = h / factor;
        const int area = factor * factor;
        ...
    }

and the switch becomes

    if (getAntiAliasing() > 0) {
        antiAlias(texBuf, w, h, getAntiAliasing() + 1);
    }

The three named functions and the switch go. Nothing else about how a block is
rendered changes.

The list of settings is untouched: None, 2x, 3x, 4x, as before. The
clamp that used to sit at the call site in loadSettings moved into
setAntiAliasing, so the bound is written once as NUM_AA_MODES rather than
as a bare 3.

Testing

Built on Windows with clang-tidy and clang-format enforced, as the build does.

Walked the setting from None to 4x on a song with real audio: the list reads
as it did, the waveform redraws at each step, and 2x, 3x and 4x look the
way they did before the change.

@Psycast

Psycast commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Personally anything past 4x is already past diminishing returns on quality, and is substantially more compute intensive.

@uvcat7

uvcat7 commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Refactoring the code to remove the three nearly-duplicate functions is worth it. But keep the max antialiasing at 4, please!

@MAX-WiRED
MAX-WiRED force-pushed the feat/waveform-smoothing branch from b559db4 to e3e3067 Compare September 5, 2026 08:25
@MAX-WiRED MAX-WiRED changed the title Let the waveform smooth at any factor up to 16x Fold the three anti-aliasing functions into one Sep 5, 2026

@uvcat7 uvcat7 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks! Just need to fix this one thing.

Comment thread src/Editor/Waveform.cpp Outdated
clearBlocks();
}

int antiAliasingFactor() const { return waveformAntiAliasingMode_ + 1; }

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Remove this function please and replace its calls with getAntiAliasing.

@MAX-WiRED
MAX-WiRED force-pushed the feat/waveform-smoothing branch from e3e3067 to 05f57e7 Compare September 6, 2026 16:15
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.

3 participants