From af27a523eb609cdf28c062c0ea42f26f45e673af Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 9 Nov 2026 19:17:39 +0700 Subject: [PATCH 1/3] fix(vocal-throw): route native MUSIC BPM/beat-grid readback to Throw snapshot, not EQ; fence stale device revisions --- src/Main.cpp | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index 5da65ef57..dac32203e 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1894,24 +1894,6 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr reply->setProperty("status",processor?"ACCEPTED":"REJECTED"); if(processor) { reply->setProperty("sampleRate",processor->acceptedSampleRate()); - // Accepted native source and analyzer readback; never invent an - // AUTO lock from the manual BPM text field. - reply->setProperty("musicSourceChannelId", - juce::String(std::to_string(lastMusicTempo_.source.value))); - reply->setProperty("musicSourceActive",lastMusicTempo_.active); - reply->setProperty("musicLocked",lastMusicTempo_.active&& - lastMusicTempo_.tempo.locked); - reply->setProperty("musicBpm",lastMusicTempo_.tempo.bpm); - reply->setProperty("musicConfidence",lastMusicTempo_.tempo.confidence); - reply->setProperty("musicGridAvailable",lastMusicTempo_.active&& - lastMusicTempo_.tempo.locked&& - lastMusicTempo_.tempo.phaseLocked); - reply->setProperty("musicPhaseConfidence", - lastMusicTempo_.tempo.phaseConfidence); - reply->setProperty("musicBeatAnchorFrame",juce::String( - std::to_string(lastMusicTempo_.tempo.beatAnchorFrame))); - reply->setProperty("musicDroppedFrames", - static_cast(lastMusicTempo_.dropped)); juce::Array bands; for(const auto& band:processor->acceptedBands()){ auto item=std::make_unique(); @@ -2194,6 +2176,36 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr settings->setProperty("ducking",s.ducking); reply->setProperty("settings",juce::var(settings.release())); reply->setProperty("sampleRate",processor->acceptedSampleRate()); + // MUSIC tempo belongs to Vocal Throw, not to the unrelated EQ. + // Fence every displayed source/beat to THIS accepted graph. + // A retired device may leave a last control-timer snapshot; it + // must never appear as a locked beat on a newly opened device. + const bool currentMusicGraph=lastMusicTempo_.active&& + epoch==juce::String(std::to_string(lastMusicTempo_.epoch))&& + revision==juce::String(std::to_string(lastMusicTempo_.revision)); + reply->setProperty("musicSourceChannelId", + currentMusicGraph? + juce::String(std::to_string(lastMusicTempo_.source.value)): + juce::String("0")); + reply->setProperty("musicSourceActive",currentMusicGraph); + reply->setProperty("musicLocked",currentMusicGraph&& + lastMusicTempo_.tempo.locked); + reply->setProperty("musicBpm", + currentMusicGraph&&lastMusicTempo_.tempo.locked? + lastMusicTempo_.tempo.bpm:0.f); + reply->setProperty("musicConfidence", + currentMusicGraph?lastMusicTempo_.tempo.confidence:0.f); + reply->setProperty("musicGridAvailable",currentMusicGraph&& + lastMusicTempo_.tempo.locked&& + lastMusicTempo_.tempo.phaseLocked); + reply->setProperty("musicPhaseConfidence", + currentMusicGraph?lastMusicTempo_.tempo.phaseConfidence:0.f); + reply->setProperty("musicBeatAnchorFrame",juce::String( + std::to_string(currentMusicGraph? + lastMusicTempo_.tempo.beatAnchorFrame:0))); + reply->setProperty("musicDroppedFrames",currentMusicGraph? + static_cast(lastMusicTempo_.dropped):0); + reply->setProperty("throwCount",static_cast(processor->observedThrowCount())); reply->setProperty("tailActive",processor->observedTailActive()); reply->setProperty("addedLatencySamples",processor->getLatencySamples()); From ea3bf90b335d281e497fa6256ce195215fc3448b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 9 Nov 2026 19:18:31 +0700 Subject: [PATCH 2/3] test(m6): enforce native tempo data appears only in graph-fenced Vocal Throw ACK snapshot --- tests/native_peq_assembly_test.py | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/native_peq_assembly_test.py b/tests/native_peq_assembly_test.py index 647eb4851..069bd4889 100644 --- a/tests/native_peq_assembly_test.py +++ b/tests/native_peq_assembly_test.py @@ -66,6 +66,43 @@ def test_single_style_owner(self): self.assertIn("armix-floating-close",throw) self.assertNotIn("new AudioContext",throw) + def test_native_tempo_readback_belongs_to_vocal_throw_not_eq(self): + # The real C++ dispatcher must populate the exact VocalThrow + # snapshot, not an unrelated EQ response. Browser-only mocks cannot + # catch a payload sent on the wrong native event. + main=(ROOT/"src/Main.cpp").read_text("utf-8") + def body(start,finish): + self.assertEqual(main.count(start),1) + return main.split(start,1)[1].split(finish,1)[0] + eq=body("void emitNativeEqSnapshot(", + "void servicePendingNativeEq()") + vocal=body("void emitNativeThrowSnapshot(", + "void servicePendingNativeThrow()") + fields=("musicSourceChannelId","musicSourceActive", + "musicLocked","musicBpm","musicConfidence", + "musicGridAvailable","musicPhaseConfidence", + "musicBeatAnchorFrame","musicDroppedFrames") + for field in fields: + self.assertIn('reply->setProperty("'+field+'"',vocal, + "missing accepted Vocal Throw BPM field: "+field) + self.assertNotIn('reply->setProperty("'+field+'"',eq, + "cross-FX snapshot pollution: "+field) + # After device restart or graph change the last control snapshot + # is stale. No stale source/phase can be advertised as locked. + self.assertIn("const bool currentMusicGraph=lastMusicTempo_.active",vocal) + self.assertIn("lastMusicTempo_.epoch",vocal) + self.assertIn("lastMusicTempo_.revision",vocal) + self.assertIn("currentMusicGraph&&",vocal) + self.assertIn("musicBpm",vocal) + self.assertIn('juce::String("0")',vocal) + self.assertIn('"arMixBuiltinThrowSnapshot"',vocal) + self.assertNotIn('"arMixBuiltinThrowSnapshot"',eq) + throw_js=(ROOT/"site/preview-v2/assets/mixer-native-vocal-throw.js").read_text("utf-8") + for field in ("musicLocked","musicBpm","musicGridAvailable", + "musicSourceChannelId"): + self.assertIn(field,throw_js) + self.assertNotIn("new AudioContext",throw_js) + def test_fail_closed_on_repeat(self): with self.assertRaises(ValueError): apply_native_peq(self.assembled) From fea39dd95a3099865b20641f63d57c91d11d4820 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 9 Nov 2026 19:21:23 +0700 Subject: [PATCH 3/3] fix(tempo): normalize beat confidence over live onset window so stale weak percussion cannot prevent reacquisition --- engine/core/NativeMusicTempoMonitor.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/engine/core/NativeMusicTempoMonitor.h b/engine/core/NativeMusicTempoMonitor.h index 71e2e91aa..7023de8ed 100644 --- a/engine/core/NativeMusicTempoMonitor.h +++ b/engine/core/NativeMusicTempoMonitor.h @@ -163,8 +163,17 @@ class MusicTempoEstimator final { // double/half-time peak that we explicitly rejected. const float acceptedScore= candidates[static_cast(bestBpm-60)]; + // Only the same LIVE 11-second onset window contributes to the + // candidate score. The ring may still contain many old weak hat + // attacks from a previous passage. Dividing by all 128 archival + // hits permanently depresses confidence even after a convincing + // quarter-note pulse returns (observed Windows CTest regression). + // Keep numerator and denominator on the identical time horizon. + std::size_t recentCount=0; + for(std::size_t i=0;i(std::max(7,count_))*.9f,0.f,1.f); + static_cast(std::max(7,recentCount))*.9f,0.f,1.f); if(confidence<.28f) { // A busy but low-confidence groove is NOT a stable beat. The // previous code kept locked=true (and old beat-phase) while