From a0eaa4c04f18a5fae100db95c6a6e64a6c3c2ce6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Tue, 10 Nov 2026 06:49:40 +0700 Subject: [PATCH 1/3] fix(harmony): invalidate Music detector history once on ChannelId guide dropout --- engine/builtin_fx/ChannelHarmonyProcessor.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/engine/builtin_fx/ChannelHarmonyProcessor.h b/engine/builtin_fx/ChannelHarmonyProcessor.h index ebbf0610b..565cfc4a8 100644 --- a/engine/builtin_fx/ChannelHarmonyProcessor.h +++ b/engine/builtin_fx/ChannelHarmonyProcessor.h @@ -62,9 +62,16 @@ class ChannelHarmonyProcessor final : public juce::AudioProcessor, consumeRealtimeEdits(); // Missing/deleted/disconnected source must not leave a stale accepted // tonal estimate running indefinitely. Manual Key is the fallback. + const int guideTimeout=static_cast(sampleRate_*2.); + const bool guideWasFresh=guideAge_<=guideTimeout; guideAge_=std::min(guideAge_+samples.getNumSamples(), static_cast(sampleRate_*3.)); - if(guideAge_>static_cast(sampleRate_*2.)){ + if(guideWasFresh && guideAge_>guideTimeout){ + // Disconnected ChannelId must reacquire from fresh music, rather + // than instantly reinstating the pre-dropout detector estimate + // when source PCM resumes. Reset exactly once at the timeout; + // repeated missing-source callbacks do no detector housekeeping. + guide_.reset(); dsp_.setGuideKey(-1,-1); guideObservedKey_.store(-1,std::memory_order_relaxed); guideObservedScale_.store(-1,std::memory_order_relaxed); From 8ac12f471ba18226e9fb9cef96ff2bae6bd8ea72 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Tue, 10 Nov 2026 06:49:57 +0700 Subject: [PATCH 2/3] test(harmony): prevent stale key reactivation after missing music ChannelId PCM --- tests/harmony_music_bank_test.cpp | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/harmony_music_bank_test.cpp b/tests/harmony_music_bank_test.cpp index ba4adbc72..2c0aa8948 100644 --- a/tests/harmony_music_bank_test.cpp +++ b/tests/harmony_music_bank_test.cpp @@ -71,6 +71,39 @@ int main(){ } assert(live->observedMusicKey()==-1); assert(live->effectiveKeyCode()==14); // music absent: manual D minor + // Regression: resuming a missing music ChannelId must NOT reuse its + // previously acquired key after two seconds of missing PCM. The old + // detector retained a valid C-major estimate and immediately published + // it on the first resumed source block, before any new tonal evidence. + { + float resumedL[128]{},resumedR[128]{}; + for(int j=0;j<128;++j){ + const double t=static_cast(j)/48000.; + resumedL[j]=resumedR[j]=static_cast(.09*( + std::sin(6.28318530718*220.*t)+ + std::sin(6.28318530718*261.625565*t)+ + std::sin(6.28318530718*329.627557*t))); + } + const float originalL=resumedL[17],originalR=resumedR[17]; + bank(music,resumedL,resumedR,128); + assert(resumedL[17]==originalL&&resumedR[17]==originalR); + assert(live->observedMusicKey()==-1); + assert(live->effectiveKeyCode()==14); // no stale C major flash + } + // Fresh A-minor guide must eventually retune after reacquisition. + for(int block=0;block<1450;++block){ + float l[128]{},r[128]{}; + for(int j=0;j<128;++j){ + const double t=static_cast(block*128+j)/48000.; + l[j]=r[j]=static_cast(.09*( + std::sin(6.28318530718*220.*t)+ + std::sin(6.28318530718*261.625565*t)+ + std::sin(6.28318530718*329.627557*t))); + } + bank(music,l,r,128); + } + assert(live->observedMusicKey()==9&&live->observedMusicScale()==1); + assert(live->effectiveKeyCode()==21); juce::MemoryBlock saved; live->getStateInformation(saved); // Realtime processor owns fixed DSP and reflection rings; production From db2bcf8c2f2091db061309de1775fe3aee838537 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Tue, 10 Nov 2026 06:51:50 +0700 Subject: [PATCH 3/3] test(harmony): keep singer live through music guide dropout and fresh key reacquisition --- tests/harmony_music_bank_test.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/harmony_music_bank_test.cpp b/tests/harmony_music_bank_test.cpp index 2c0aa8948..e01d848e2 100644 --- a/tests/harmony_music_bank_test.cpp +++ b/tests/harmony_music_bank_test.cpp @@ -67,8 +67,16 @@ int main(){ // ages out safely without touching physical routing/output authority. for(int i=0;i<950;++i) { float l[128]{},r[128]{}; - bank(vocal,l,r,128); + for(int j=0;j<128;++j) { + const double t=static_cast(i*128+j)/48000.; + l[j]=r[j]=static_cast(.20*std::sin( + 6.28318530718*220.*t)); + } + bank(vocal,l,r,128); // singer remains live during guide loss + for(int j=0;j<128;++j) + assert(std::isfinite(l[j])&&std::isfinite(r[j])); } + assert(live->observedNote()>=0); // no lead/pitch-analysis interruption assert(live->observedMusicKey()==-1); assert(live->effectiveKeyCode()==14); // music absent: manual D minor // Regression: resuming a missing music ChannelId must NOT reuse its