Skip to content

fix(audio): tone switches no longer freeze the engine; verdicts say if timed - #21

Merged
mattromano merged 1 commit into
customfrom
fix/tone-stall-and-untimed-verdicts
Nov 9, 2026
Merged

mattromano merged 1 commit into
customfrom
fix/tone-stall-and-untimed-verdicts

Conversation

@mattromano

Copy link
Copy Markdown
Owner

Tone switch freeze

Every tone switch froze the whole audio callback for about 0.75 s. I reproduced it live on ASIO4ALL: the renderer bus, which trims itself to about 85 ms whenever the engine reads it, backed up to about 37k frames (about 770 ms) and then dropped. You heard a hard glitch, and the song delay jumped afterwards.

I narrowed it down by changing one thing at a time:

Trial Freeze
clearChain() only 0 ms
loadPreset with no slot state 0 ms
clearChain() + full loadPreset 768 ms

The cause is in LoadPreset. It loads each NAM or IR slot by path, then applies the slot's saved state, and that state's modelPath / irPath names the same file. So the same model was loaded a second time while the slot was already live.

Fix:

  • NAMProcessor::setStateInformation and IRLoader::setStateInformation only reload when the state names a different file.
  • NAMProcessor::processBlock now uses ScopedTryLock on modelLock, so the audio thread never waits on a model swap. If the lock is busy, that block is silent.

Verdict timing

When NoteVerifier can't match a hit to a pick attack, it stamps the hit at the chart time, and nothing marked it as such. Consumers read that as a measured 0 ms, which skewed timing stats and Sync Lab. Verdicts now carry timed: true only when an onset was claimed. Both getNoteVerdicts and getSourceNoteVerdicts expose it.

The consumer side is mattromano/feedBack-plugin-notedetect#6.

Tests

  • New tests/tone-load-no-stall.test.js (source-level).
  • The native code is compiled by addon CI.

🤖 Generated with Claude Code

…f timed

Tone switch stall: LoadPreset loads each NAM/IR slot by path and then
applies its saved state, which loaded the SAME model a second time while
the slot was live. The audio callback froze ~0.75 s on every switch
(reproduced on ASIO: the renderer bus backed up to ~37k frames and then
dropped), heard as a hard glitch plus a song-delay jump. State restore now
skips a same-file reload (NAM and IR), and NAMProcessor::processBlock
try-locks the model so the audio thread never waits on a swap.

Verdict timing: a hit with no matched pick attack was stamped at the chart
time with no flag, so consumers read a measured 0 ms. Verdicts now carry
`timed` (true only when an onset was claimed), exposed by getNoteVerdicts
and getSourceNoteVerdicts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattromano
mattromano merged commit efdbf61 into custom Nov 9, 2026
2 of 3 checks passed
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