From 1ac1a255034def51d6b9fae07930ae9e36635c03 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Tue, 10 Nov 2026 05:12:57 +0700 Subject: [PATCH 1/3] fix(harmony): keep native DSP PCM-warm on bypass and preserve vocal continuity on tonal changes --- CMakeLists.txt | 10 +- engine/builtin_fx/ChannelHarmonyProcessor.h | 1 + engine/builtin_fx/HarmonyDsp.h | 20 ++-- engine/core/LiveChannelFxGraph.h | 19 +++- engine/core/RealtimeNativeFxControl.h | 5 + tests/harmony_bypass_reliability_test.cpp | 115 ++++++++++++++++++++ tests/harmony_dsp_test.cpp | 40 ++++++- 7 files changed, 197 insertions(+), 13 deletions(-) create mode 100644 tests/harmony_bypass_reliability_test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index dd0abb54d..4a5491aaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,10 +148,18 @@ if(BUILD_TESTING) target_link_libraries(ARMixHarmonyChannelPcmTests PRIVATE juce::juce_audio_processors juce::juce_recommended_config_flags) target_compile_features(ARMixHarmonyChannelPcmTests PRIVATE cxx_std_20) add_test(NAME NativeHarmonyMusicFromOtherChannelIdAndStateMigration COMMAND ARMixHarmonyChannelPcmTests) + # Explicit FX lease + ChannelId PCM regression: continuous Harmony DSP on + # disabled insert/rack, exact dry PDC and state-identical wet reactivation. + juce_add_console_app(ARMixHarmonyBypassPcmTests PRODUCT_NAME "ArSonMix Harmony Clickless Bypass PCM") + target_sources(ARMixHarmonyBypassPcmTests PRIVATE tests/harmony_bypass_reliability_test.cpp) + target_link_libraries(ARMixHarmonyBypassPcmTests PRIVATE + juce::juce_audio_processors juce::juce_recommended_config_flags) + target_compile_features(ARMixHarmonyBypassPcmTests PRIVATE cxx_std_20) + add_test(NAME NativeHarmonyWarmBypassRackSlotAndLatencyParity COMMAND ARMixHarmonyBypassPcmTests) add_test(NAME ApprovedNativeHarmonyEditorAckAndSingleGui COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/tests/native_harmony_assembly_test.py") add_executable(ARMixMixerRoutingTests tests/mixer_routing_plan_test.cpp) target_compile_features(ARMixMixerRoutingTests PRIVATE cxx_std_20) - add_dependencies(ARMixMixerRoutingTests ARMixHarmonyDspTests ARMixHarmonyMusicGuideTests ARMixHarmonyChannelPcmTests ARMixHarmonyCpuProfileTests) + add_dependencies(ARMixMixerRoutingTests ARMixHarmonyDspTests ARMixHarmonyMusicGuideTests ARMixHarmonyChannelPcmTests ARMixHarmonyBypassPcmTests ARMixHarmonyCpuProfileTests) add_test(NAME TenStripStaticRoutingAndMaster COMMAND ARMixMixerRoutingTests) # M3D atomic native Session: the accepted Console roster cannot advance # without a successful epoch/revision-gated PCM publication. diff --git a/engine/builtin_fx/ChannelHarmonyProcessor.h b/engine/builtin_fx/ChannelHarmonyProcessor.h index 5573c3c25..7d2e15a7d 100644 --- a/engine/builtin_fx/ChannelHarmonyProcessor.h +++ b/engine/builtin_fx/ChannelHarmonyProcessor.h @@ -141,6 +141,7 @@ class ChannelHarmonyProcessor final : public juce::AudioProcessor, } double acceptedSampleRate() const noexcept {return sampleRate_;} bool isReady() const noexcept{return ready_;} + bool requiresContinuousBypassProcessing() const noexcept override {return true;} void sealForRealtime() noexcept override {published_=true;} bool stateSnapshotQuiescent() const noexcept override { return queued_.empty()&&completion_.empty()&&!pendingId_; diff --git a/engine/builtin_fx/HarmonyDsp.h b/engine/builtin_fx/HarmonyDsp.h index e8f76587d..e1d60272c 100644 --- a/engine/builtin_fx/HarmonyDsp.h +++ b/engine/builtin_fx/HarmonyDsp.h @@ -117,7 +117,7 @@ class Engine final { pitchActive_=false;pitchBest_=-1.f;pitchBestLag_=0; peakPitchLagWork_=0;completedPitchAnalyses_=0;abandonedPitchAnalyses_=0; noteHold_=0;currentNote_=-1;candidateNote_=-1; - guideKey_=-1;guideScale_=-1; + guideKey_=-1;guideScale_=-1;tonalTransitionPending_=false; voiced_=false;voicedGain_=0.f;settings_=Settings{}; smoothingAlpha_=static_cast(1.-std::exp(-1./(rate*0.005))); // 5 ms control ramp // Preserve the established 48k envelope while keeping durations @@ -164,12 +164,14 @@ class Engine final { } bool applyPreparedSettings(const PreparedSettings& next) noexcept { // Caller publishes only prepareSettings()-validated packets. - // A scale/key change must not inherit the previous tonal quantizer - // candidate or remain held on a now-out-of-scale note. + // Discard only the TONAL candidate on a key/source edit. The singer's + // current voiced envelope, source period and active grains continue. + // Next completed pitch windows retune to the new scale, bypassing + // old-key note hysteresis exactly until a new note is confirmed. if(next.settings.key!=settings_.key||next.settings.scale!=settings_.scale|| next.settings.guideMode!=settings_.guideMode|| next.settings.guideChannelId!=settings_.guideChannelId){ - candidateNote_=-1;currentNote_=-1;noteHold_=0;voiced_=false; + candidateNote_=-1;noteHold_=0;tonalTransitionPending_=true; } if(next.settings.guideMode!=settings_.guideMode|| next.settings.guideChannelId!=settings_.guideChannelId){ @@ -207,7 +209,9 @@ class Engine final { const int previousKey=effectiveKey(),previousScale=effectiveScale(); guideKey_=key;guideScale_=scale; if(previousKey!=effectiveKey()||previousScale!=effectiveScale()){ - currentNote_=-1;candidateNote_=-1;noteHold_=0;voiced_=false; + // A guide-key revision is not vocal silence. Preserve the + // continuous sound and retune at the next stable pitch evidence. + candidateNote_=-1;noteHold_=0;tonalTransitionPending_=true; } } int effectiveKey() const noexcept { @@ -504,7 +508,8 @@ class Engine final { const int activeKey=effectiveKey(),activeScale=effectiveScale(); int degree=nearestDegree(midi,activeKey,activeScale); int note=noteAt(degree,activeKey,activeScale); - if(!pitchChangeHasMargin(currentNote_,note,midi)){ + if(!tonalTransitionPending_ && + !pitchChangeHasMargin(currentNote_,note,midi)){ note=currentNote_; degree=nearestDegree(static_cast(note),activeKey,activeScale); } @@ -515,7 +520,7 @@ class Engine final { // Two consistent windows for both phrase onset and melodic transitions; // do not generate provisional harmony on a single noisy transient. if(noteHold_<2)return; - currentNote_=note;voiced_=true; + currentNote_=note;voiced_=true;tonalTransitionPending_=false; const float newPeriod=static_cast(rate_/hz); if(sourcePeriodSamples_>0.f&& std::abs(newPeriod-sourcePeriodSamples_)>.25f*sourcePeriodSamples_){ @@ -553,6 +558,7 @@ class Engine final { std::array pitchCorrelations_{}; int currentNote_=-1,candidateNote_=-1,noteHold_=0; int guideKey_=-1,guideScale_=-1; + bool tonalTransitionPending_=false; // retune note, never mute voiced singer bool voiced_=false;float voicedGain_=0.f; bool processed_=false; float smoothingAlpha_=1.f,voicedGateAlpha_=0.002f,ratioAlpha_=0.00045f; diff --git a/engine/core/LiveChannelFxGraph.h b/engine/core/LiveChannelFxGraph.h index 769bc927a..03f8d9cf6 100644 --- a/engine/core/LiveChannelFxGraph.h +++ b/engine/core/LiveChannelFxGraph.h @@ -33,6 +33,7 @@ class LiveChannelFxGraph final { struct FxInstance final : juce::AudioProcessorListener { std::unique_ptr processor; RealtimeNativeFxControl* nativeControl=nullptr; // bound once OFF realtime + bool continuousBypassProcessing=false; // prepared once; no dynamic cast in RT juce::MidiBuffer midi; const juce::String catalogId; const juce::String name; @@ -61,7 +62,11 @@ class LiveChannelFxGraph final { bypassFade.prepare(false,processor?processor->getSampleRate():48000.0,0); if(processor){ nativeControl=dynamic_cast(processor.get()); - if(nativeControl)nativeControl->sealForRealtime(); + if(nativeControl){ + continuousBypassProcessing= + nativeControl->requiresContinuousBypassProcessing(); + nativeControl->sealForRealtime(); + } processor->addListener(this); } } @@ -135,11 +140,16 @@ class LiveChannelFxGraph final { dryLeft[static_cast(i)]=l; dryRight[static_cast(i)]=r; } - if(bypassFade.fullyBypassed()||latencyChanged.load(std::memory_order_acquire)) { + const bool fullyBypassed=bypassFade.fullyBypassed(); + if((fullyBypassed&&!continuousBypassProcessing)|| + latencyChanged.load(std::memory_order_acquire)) { juce::FloatVectorOperations::copy(left,dryLeft.data(),samples); juce::FloatVectorOperations::copy(right,dryRight.data(),samples); processing.clear(std::memory_order_release);return; } + // Harmony alone remains timeline-warm while fully bypassed. + // The host consumes real PCM, but publishes the exact PDC dry path: + // no stale pitch history or room tail can leak on reactivation. const bool fading=bypassFade.transitioning(); try { float* planar[]{left,right}; @@ -152,7 +162,10 @@ class LiveChannelFxGraph final { juce::FloatVectorOperations::clear(left,samples); juce::FloatVectorOperations::clear(right,samples); } - if(fading)for(int i=0;i(i)]*mix.dry; right[i]=right[i]*mix.wet+dryRight[static_cast(i)]*mix.dry; diff --git a/engine/core/RealtimeNativeFxControl.h b/engine/core/RealtimeNativeFxControl.h index b15eab95d..f0bd648b5 100644 --- a/engine/core/RealtimeNativeFxControl.h +++ b/engine/core/RealtimeNativeFxControl.h @@ -9,6 +9,11 @@ namespace armix::mixer { struct RealtimeNativeFxControl { virtual ~RealtimeNativeFxControl() = default; virtual void consumeRealtimeEdits() noexcept = 0; + // CONTROL-queried once when the native FX lease is prepared. Temporal DSP + // that cannot resume from stale input (Harmony pitch/history/room) must + // continue processing the actual PCM while its output is bypassed. + // Ordinary EQ/compressor/vendor FX retain the CPU-saving bypass fast path. + virtual bool requiresContinuousBypassProcessing() const noexcept {return false;} // CONTROL-only lifecycle: after FxInstance accepts this processor, a // vendor-state restore must not mutate published audio-owned filters. virtual void sealForRealtime() noexcept {} diff --git a/tests/harmony_bypass_reliability_test.cpp b/tests/harmony_bypass_reliability_test.cpp new file mode 100644 index 000000000..dac48dff9 --- /dev/null +++ b/tests/harmony_bypass_reliability_test.cpp @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Real JUCE FX instance and native ChannelId PCM lease, not just envelope math. +// The enabled reference must equal the twice-bypassed Harmony AFTER re-entry. +// Old code failed because a fully bypassed Harmony stopped reading live PCM. +#include "../engine/core/DynamicChannelFxLeaseBank.h" +#include "../engine/builtin_fx/ChannelHarmonyProcessor.h" +#if defined(NDEBUG) +#undef NDEBUG +#endif +#include +#include +#include +#include +#include +#include + +using namespace armix::mixer; +using armix::builtin_fx::ChannelHarmonyProcessor; + +static float singer(int n) noexcept { + const double t=static_cast(n)/48000.; + return static_cast(.16*std::sin(6.283185307179586*220.*t)+ + .045*std::sin(6.283185307179586*440.*t)); +} +static LiveChannelFxGraph::InstanceLease makeHarmony() { + auto p=std::make_unique(); + p->prepareToPlay(48000.,64); + assert(p->isReady() && p->getLatencySamples()==1536); + armix::harmony::Settings rich; + rich.voices=5;rich.wet=1.f;rich.space=1.f; + assert(p->queueAccepted(rich,9001)); + return std::make_shared( + std::move(p),ChannelHarmonyProcessor::catalogIdentity, + "ArSon Harmony",64); +} +int main() { + constexpr ChannelId vocal{7301}; + auto uninterrupted=makeHarmony(), switching=makeHarmony(); + assert(switching->continuousBypassProcessing); + assert(uninterrupted->latencySamples==1536); + assert(switching->latencySamples==uninterrupted->latencySamples); + DynamicChannelFxLeaseBank::Assignment referenceRow,switchingRow; + referenceRow.id=vocal;referenceRow.format=ProcessingFormat::stereo; + referenceRow.inserts.push_back(uninterrupted); + switchingRow.id=vocal;switchingRow.format=ProcessingFormat::stereo; + switchingRow.inserts.push_back(switching); + DynamicChannelFxLeaseBank alwaysOn,switched; + const std::array referenceRows{referenceRow}; + const std::array switchingRows{switchingRow}; + assert(DynamicChannelFxLeaseBank::prepare(1,1,referenceRows,alwaysOn)== + DynamicChannelFxLeaseBank::Fault::none); + assert(DynamicChannelFxLeaseBank::prepare(1,1,switchingRows,switched)== + DynamicChannelFxLeaseBank::Fault::none); + bool priorSlot=false,priorRack=false; + float maxWetDifference=0.f,maxDryDifference=0.f; + int samplesCheckedWet=0,samplesCheckedDry=0; + // Fixed 64-frame hardware-shaped partitions, with slot and rack OFF. + // The last pair is a quick reverse-toggle (no graph or callback restart). + for(int block=0;block<1300;++block) { + const bool slotOff=(block>=320&&block<580)|| + (block>=700&&block<780)|| + (block==1110||block==1112); + const bool rackOff=(block>=850&&block<1000)|| + (block==1111||block==1113); + if(slotOff!=priorSlot) { + assert(switched.setInsertBypass(1,1,vocal,0,switching->instanceId,slotOff)); + priorSlot=slotOff; + } + if(rackOff!=priorRack) { + assert(switched.setRackBypass(1,1,vocal,rackOff)); + priorRack=rackOff; + } + std::array baseL{},baseR{},probeL{},probeR{}; + for(int i=0;i<64;++i) { + const int n=block*64+i; + baseL[i]=probeL[i]=singer(n); + baseR[i]=probeR[i]=singer(n); + } + alwaysOn(vocal,baseL.data(),baseR.data(),64); + switched(vocal,probeL.data(),probeR.data(),64); + const bool quietBypass=slotOff||rackOff; + const bool steadyWet=!quietBypass && + (block>=590&&block<700 || block>=790&&block<850 || + block>=1010&&block<1110 || block>=1125); + const bool steadyDry=quietBypass&& + (block>=330&&block<580 || block>=710&&block<780 || + block>=860&&block<1000); + for(int i=0;i<64;++i) { + assert(std::isfinite(probeL[i])&&std::isfinite(probeR[i])); + assert(std::abs(probeL[i])<=4.f&&std::abs(probeR[i])<=4.f); + if(steadyWet) { + const float d=std::max(std::abs(probeL[i]-baseL[i]), + std::abs(probeR[i]-baseR[i])); + maxWetDifference=std::max(maxWetDifference,d); + assert(d<.00002f); // same exact history as never-bypassed DSP + ++samplesCheckedWet; + } + if(steadyDry) { + const int n=block*64+i-1536; + const float expect=n>=0?singer(n):0.f; + const float d=std::max(std::abs(probeL[i]-expect), + std::abs(probeR[i]-expect)); + maxDryDifference=std::max(maxDryDifference,d); + assert(d<.00002f); // never switch PDC when OFF + ++samplesCheckedDry; + } + } + } + assert(samplesCheckedWet>10000&&samplesCheckedDry>10000); + assert(!switched.rackBypassed(vocal)); + std::cout<<"Harmony native ChannelId warm bypass, dry PDC and state parity PASS; " + <<"wet_samples="<applyPreparedSettings(keyPacket),"key edit was rejected"); - need(!rekey->voiced()&&rekey->observedMidiNote()==-1, - "key edit reused a stale note from previous scale"); + need(rekey->voiced()&&rekey->observedMidiNote()==69, + "key edit interrupted a sustained voiced singer"); for(int i=0;i<48000;++i) rkL[i]=rkR[i]=.2f*std::sin(6.28318530718*440*i/48000); for(int i=0;i<48000;i+=128)rekey->process(rkL.data()+i,rkR.data()+i,128); need(rekey->voiced()&&rekey->observedMidiNote()==69, "fresh key did not reacquire stable A4"); + + // A change of guide key and fallback MUST NOT suppress active vocal + // analysis/room/grains. The former setGuideKey() immediately unvoiced a + // singer, making Music mode audibly sputter on uncertain key boundaries. + auto guided=std::make_unique(); + need(guided->prepare(48000),"guided vocal prepare failed"); + Settings guideSettings;guideSettings.key=0;guideSettings.scale=0; + guideSettings.guideMode=1;guideSettings.guideChannelId=6001; + guideSettings.voices=5;guideSettings.wet=1.f; + need(guided->setSettings(guideSettings),"guided settings failed"); + std::vector gL(48000),gR(48000); + const auto feedGuided=[&](int count){ + for(int i=0;i(.20*std::sin( + 6.283185307179586*440.*i/48000.)); + for(int i=0;iprocess(gL.data()+i,gR.data()+i,std::min(64,count-i)); + }; + feedGuided(48000); + need(guided->voiced()&&guided->observedMidiNote()==69, + "guide singer baseline lost stable voice"); + for(int cycle=0;cycle<8;++cycle){ + if(cycle%2==0)guided->setGuideKey(0,1); // C minor excludes sung A + else guided->setGuideKey(-1,-1); // explicit Manual fallback + need(guided->voiced()&&guided->observedMidiNote()>=0, + "guide key event hard-gated sustained vocal"); + feedGuided(4096); + need(guided->voiced()&&guided->observedMidiNote()>=0, + "singer failed to continue across guide key transition"); + if(cycle%2==0) + need(guided->observedMidiNote()!=69, + "old C-major pitch was stuck after C-minor transition"); + else + need(guided->observedMidiNote()==69, + "manual fallback failed to retune singing A"); + } // Fixed-size reduced audio history must survive repeated wraparound at // the highest supported device rate without changing declared PDC. auto wrap=std::make_unique(); From 53c40884d4fa0605ed2032c1e93916f363567b28 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Tue, 10 Nov 2026 05:27:10 +0700 Subject: [PATCH 2/3] test(harmony): quantify old stale-DSP bypass divergence and bound audible switch slope against aligned PCM --- tests/harmony_bypass_reliability_test.cpp | 53 ++++++++++++++++++++--- 1 file changed, 46 insertions(+), 7 deletions(-) diff --git a/tests/harmony_bypass_reliability_test.cpp b/tests/harmony_bypass_reliability_test.cpp index dac48dff9..2004e6359 100644 --- a/tests/harmony_bypass_reliability_test.cpp +++ b/tests/harmony_bypass_reliability_test.cpp @@ -35,25 +35,36 @@ static LiveChannelFxGraph::InstanceLease makeHarmony() { } int main() { constexpr ChannelId vocal{7301}; - auto uninterrupted=makeHarmony(), switching=makeHarmony(); + auto uninterrupted=makeHarmony(), switching=makeHarmony(),legacy=makeHarmony(); assert(switching->continuousBypassProcessing); + // Isolated offline reference of PRE-FIX host behavior; production never + // disables the warm-processing contract. This must diverge on reentry. + legacy->continuousBypassProcessing=false; assert(uninterrupted->latencySamples==1536); assert(switching->latencySamples==uninterrupted->latencySamples); - DynamicChannelFxLeaseBank::Assignment referenceRow,switchingRow; + DynamicChannelFxLeaseBank::Assignment referenceRow,switchingRow,legacyRow; referenceRow.id=vocal;referenceRow.format=ProcessingFormat::stereo; referenceRow.inserts.push_back(uninterrupted); switchingRow.id=vocal;switchingRow.format=ProcessingFormat::stereo; switchingRow.inserts.push_back(switching); - DynamicChannelFxLeaseBank alwaysOn,switched; + legacyRow.id=vocal;legacyRow.format=ProcessingFormat::stereo; + legacyRow.inserts.push_back(legacy); + DynamicChannelFxLeaseBank alwaysOn,switched,oldBehavior; const std::array referenceRows{referenceRow}; const std::array switchingRows{switchingRow}; + const std::array legacyRows{legacyRow}; + assert(DynamicChannelFxLeaseBank::prepare(1,1,legacyRows,oldBehavior)== + DynamicChannelFxLeaseBank::Fault::none); assert(DynamicChannelFxLeaseBank::prepare(1,1,referenceRows,alwaysOn)== DynamicChannelFxLeaseBank::Fault::none); assert(DynamicChannelFxLeaseBank::prepare(1,1,switchingRows,switched)== DynamicChannelFxLeaseBank::Fault::none); bool priorSlot=false,priorRack=false; float maxWetDifference=0.f,maxDryDifference=0.f; + float maxOldBypassDifference=0.f,maxClickSlopeExcess=0.f; int samplesCheckedWet=0,samplesCheckedDry=0; + float previousWetL=0.f,previousWetR=0.f; + float previousProbeL=0.f,previousProbeR=0.f,previousDry=0.f; // Fixed 64-frame hardware-shaped partitions, with slot and rack OFF. // The last pair is a quick reverse-toggle (no graph or callback restart). for(int block=0;block<1300;++block) { @@ -64,20 +75,23 @@ int main() { (block==1111||block==1113); if(slotOff!=priorSlot) { assert(switched.setInsertBypass(1,1,vocal,0,switching->instanceId,slotOff)); + assert(oldBehavior.setInsertBypass(1,1,vocal,0,legacy->instanceId,slotOff)); priorSlot=slotOff; } if(rackOff!=priorRack) { assert(switched.setRackBypass(1,1,vocal,rackOff)); + assert(oldBehavior.setRackBypass(1,1,vocal,rackOff)); priorRack=rackOff; } - std::array baseL{},baseR{},probeL{},probeR{}; + std::array baseL{},baseR{},probeL{},probeR{},oldL{},oldR{}; for(int i=0;i<64;++i) { const int n=block*64+i; - baseL[i]=probeL[i]=singer(n); - baseR[i]=probeR[i]=singer(n); + baseL[i]=probeL[i]=oldL[i]=singer(n); + baseR[i]=probeR[i]=oldR[i]=singer(n); } alwaysOn(vocal,baseL.data(),baseR.data(),64); switched(vocal,probeL.data(),probeR.data(),64); + oldBehavior(vocal,oldL.data(),oldR.data(),64); const bool quietBypass=slotOff||rackOff; const bool steadyWet=!quietBypass && (block>=590&&block<700 || block>=790&&block<850 || @@ -86,6 +100,24 @@ int main() { (block>=330&&block<580 || block>=710&&block<780 || block>=860&&block<1000); for(int i=0;i<64;++i) { + const int n=block*64+i; + const float delayed=n>=1536?singer(n-1536):0.f; + if(n>=1537){ + // Actual post-bypass sample slope may only exceed either + // continuous wet or exact aligned dry slope by the 8ms ramp + // contribution. No block-edge impulse is allowed. + const float wetSlope=std::max(std::abs(baseL[i]-previousWetL), + std::abs(baseR[i]-previousWetR)); + const float drySlope=std::abs(delayed-previousDry); + const float actualSlope=std::max(std::abs(probeL[i]-previousProbeL), + std::abs(probeR[i]-previousProbeR)); + const float excess=actualSlope-std::max(wetSlope,drySlope); + maxClickSlopeExcess=std::max(maxClickSlopeExcess,excess); + assert(excess<.035f); + } + previousWetL=baseL[i];previousWetR=baseR[i]; + previousProbeL=probeL[i];previousProbeR=probeR[i]; + previousDry=delayed; assert(std::isfinite(probeL[i])&&std::isfinite(probeR[i])); assert(std::abs(probeL[i])<=4.f&&std::abs(probeR[i])<=4.f); if(steadyWet) { @@ -94,6 +126,10 @@ int main() { maxWetDifference=std::max(maxWetDifference,d); assert(d<.00002f); // same exact history as never-bypassed DSP ++samplesCheckedWet; + if(block>=590&&block<615 || block>=790&&block<815) + maxOldBypassDifference=std::max(maxOldBypassDifference, + std::max(std::abs(oldL[i]-baseL[i]), + std::abs(oldR[i]-baseR[i]))); } if(steadyDry) { const int n=block*64+i-1536; @@ -107,9 +143,12 @@ int main() { } } assert(samplesCheckedWet>10000&&samplesCheckedDry>10000); + assert(maxOldBypassDifference>.003f); // old skipped DSP history visibly diverges assert(!switched.rackBypassed(vocal)); std::cout<<"Harmony native ChannelId warm bypass, dry PDC and state parity PASS; " <<"wet_samples="< Date: Tue, 10 Nov 2026 05:29:25 +0700 Subject: [PATCH 3/3] =?UTF-8?q?test(harmony):=20profile=203=E2=80=935=20vo?= =?UTF-8?q?ices,=2048/96/192=20kHz=20and=20timed=20Music=20ChannelId=20gui?= =?UTF-8?q?de=20across=20ASIO=20buffers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/harmony_cpu_profile_test.cpp | 42 +++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/tests/harmony_cpu_profile_test.cpp b/tests/harmony_cpu_profile_test.cpp index deadc8bcd..5c5f0168a 100644 --- a/tests/harmony_cpu_profile_test.cpp +++ b/tests/harmony_cpu_profile_test.cpp @@ -2,6 +2,7 @@ // Non-gating, reproducible synthetic ENGINE-only callback CPU profile. // Does not measure JUCE graph scheduling, ASIO driver or singer ear latency. #include "../engine/builtin_fx/HarmonyDsp.h" +#include "../engine/builtin_fx/HarmonyMusicKey.h" #include #include #include @@ -15,13 +16,19 @@ namespace { using Clock=std::chrono::steady_clock; constexpr int warmup=256; constexpr int measured=512; -void profile(double rate,int block,int voices){ +void profile(double rate,int block,int voices,bool musicGuide=false){ auto engine=std::make_unique(); if(!engine->prepare(rate)){std::cerr<<"Harmony prepare failed\n";std::exit(2);} armix::harmony::Settings settings; settings.voices=voices;settings.wet=0.55f;settings.correction=true; + settings.guideMode=musicGuide?1:0; + settings.guideChannelId=musicGuide?770:0; + armix::harmony::MusicKeyDetector guide; + if(musicGuide&&!guide.prepare(rate)){ + std::cerr<<"Music guide prepare failed\\n";std::exit(2); + } if(!engine->setSettings(settings)){std::cerr<<"Harmony settings rejected\n";std::exit(2);} - std::array l{},r{}; + std::array l{},r{},musicL{},musicR{}; std::array elapsed{}; double phase=0.; const double step=6.283185307179586*220./rate; @@ -32,10 +39,25 @@ void profile(double rate,int block,int voices){ 0.04*std::sin(2.*phase)); l[static_cast(i)]=x; r[static_cast(i)]=x; + if(musicGuide){ + // Different ChannelId source; no music PCM mixed into vocal. + // Exclude guide-tone fixture synthesis from timed callback. + const double t=static_cast(blockIndex*block+i)/rate; + musicL[static_cast(i)]= + musicR[static_cast(i)]=static_cast( + .06*(std::sin(6.283185307179586*261.625565*t)+ + std::sin(6.283185307179586*329.627557*t)+ + std::sin(6.283185307179586*391.995436*t))); + } phase+=step; if(phase>=6.283185307179586)phase-=6.283185307179586; } const auto started=Clock::now(); + if(musicGuide){ + guide.process(musicL.data(),musicR.data(),block); + const auto key=guide.estimate(); + engine->setGuideKey(key.valid()?key.key:-1,key.valid()?key.scale:-1); + } engine->process(l.data(),r.data(),block); const auto finished=Clock::now(); if(blockIndex>=warmup) @@ -54,6 +76,7 @@ void profile(double rate,int block,int voices){ std::cout<