Repository navigation
fix(audio): heard clocks for song and guitar, measured not tuned - #22
Merged
Merged
Conversation
…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>
Song (stems, ASIO/exclusive): a second renderer bus carries the song alone, each push anchored to its AudioContext frame; the output callback stamps its start, so getSongBusClock() names the context frame reaching the DAC (output latency included). Measured on ASIO4ALL: the heard delay is 26-58 ms depending on buffer size and bus fill (steady to +-1.5 ms over 3 min), where the old loopback path ran 130-180 ms and jumped 43 ms mid-run. Song (native backing): getBackingPosition() returns the heard position (the rendered block start reaches the DAC one output latency after its callback), not the end of the last rendered block. Guitar: every input block is stamped with its callback's start time; the verifier places each sample from that stamp minus the device's capture latency (reported input latency - one buffer, ASIO and JUCE WASAPI alike), on a playhead model that measures the playback rate (practice speeds were extrapolated at 1.0x) and filters IPC delay (fastest push wins). Rebuilt as the JUCE-free engine/PlayheadModel.h. Onset backdate: 525 samples (the detector's own lag, measured on synthetic picks with a known attack: tests/onset_lag), replacing a 50 ms value tuned from live medians that silently absorbed capture and display latency and was wrong at any other sample rate. Tests: engine_units renderer_bus (heard clock) + playhead_model (every buffer/latency/rate config lands < 1 ms), onset_lag, heard-clock-wiring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SLOPSMITH_TEST_LOOPBACK=1 (duplex devices only, read once at start) feeds the engine's own output back as its input, delayed by the device's reported output + input latency: an ideal cable from output jack to input. With the song's guitar stem soloed it measures the whole chain end to end. Measured: median hit timing +27/+28/+27/+28 ms at ASIO 128/256/512/1024 (the constant is the chart vs the stem) and +28..+33 ms at 0.5-0.8x. Off in normal runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Hit timing now uses the real delay until you hear the song and your guitar. It measures that delay instead of using hand-tuned offsets.
getBackingPosition()returns the position you hear, not the end of the last rendered block.engine/PlayheadModel.hmeasures the playback rate, so practice speeds are handled.SLOPSMITH_TEST_LOOPBACK=1feeds the output back as the input for end-to-end timing runs. It's off in normal use.Results
The end-to-end loopback median is +27/+28/+27/+28 ms at ASIO 128/256/512/1024, and that constant is the chart vs the stem. It's +28 to +33 ms at 0.5–0.8× speed.
Tests
engine_units: renderer_bus and playhead_modelonset_lagheard-clock-wiringPlay-tested on the local packaged build.
Stacked after #21; once #21 merges this diff is only the two latency commits.
🤖 Generated with Claude Code