Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion engine/core/NativeMusicTempoMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,17 @@ class MusicTempoEstimator final {
// double/half-time peak that we explicitly rejected.
const float acceptedScore=
candidates[static_cast<std::size_t>(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<count_;++i)
if(lastTick_-at(i).tick<=1100)++recentCount;
const float confidence=std::clamp(acceptedScore/
static_cast<float>(std::max<std::size_t>(7,count_))*.9f,0.f,1.f);
static_cast<float>(std::max<std::size_t>(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
Expand Down
48 changes: 30 additions & 18 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(lastMusicTempo_.dropped));
juce::Array<juce::var> bands;
for(const auto& band:processor->acceptedBands()){
auto item=std::make_unique<juce::DynamicObject>();
Expand Down Expand Up @@ -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<int>(lastMusicTempo_.dropped):0);

reply->setProperty("throwCount",static_cast<int>(processor->observedThrowCount()));
reply->setProperty("tailActive",processor->observedTailActive());
reply->setProperty("addedLatencySamples",processor->getLatencySamples());
Expand Down
37 changes: 37 additions & 0 deletions tests/native_peq_assembly_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading