Skip to content

Fix Mixer clip() overflow bug; add per-channel hot-swap loading - #19

Open
djdefi wants to merge 1 commit into
CircuitMess:masterfrom
djdefi:fix/mixer-clip-and-hotswap-load
Open

djdefi wants to merge 1 commit into
CircuitMess:masterfrom
djdefi:fix/mixer-clip-and-hotswap-load

Conversation

@djdefi

@djdefi djdefi commented Aug 20, 2026

Copy link
Copy Markdown

Mixer::clip() overflow bug (audio pop/click)

clip() used 0x7FFFF (5 hex digits) as the positive clamp value. That
doesn't fit in the int16_t return type — it silently truncates to -1
on the implicit conversion. So whenever the mixed signal exceeds
+32767 (loud passages, or effects like Reverb/BitCrusher boosting
level), the mixer emits a raw -1 sample instead of clamping to full
volume, producing an audible pop/click.

Fixed to 0x7FFF with an explicit (int16_t) cast on the pass-through
path. Verified with an isolated reproduction of the old vs. new logic:
clip_old(40000) == -1, clip_new(40000) == 32767.

MixSystem::openChannel() — load a deck without touching the other

Added openChannel()/_openChannel() so a channel's source file can be
loaded or replaced while the mixer is already running, without
disturbing the other deck. Follows the existing request-queue pattern
(addSpeed/setEffect/etc.): routes through the audio thread via a new
MixRequest::OPEN when running, pausing only the target channel for
the swap.

This is needed by a companion JayD-Firmware change that lets
MixScreen start playing as soon as one deck is loaded, instead of
blocking until both decks are chosen.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 1b2cfc57-c6c7-44ce-95c9-72368d409ca8
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.

1 participant