From b399d2d351dbfb54d36fc8022225dfcb061b332d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 03:52:50 +0700 Subject: [PATCH 01/12] feat(harmony): add distinct unison Doubler DSP mode without redefining Duo --- engine/builtin_fx/HarmonyDsp.h | 47 +++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/engine/builtin_fx/HarmonyDsp.h b/engine/builtin_fx/HarmonyDsp.h index 648b7a298..2ba3ae867 100644 --- a/engine/builtin_fx/HarmonyDsp.h +++ b/engine/builtin_fx/HarmonyDsp.h @@ -20,6 +20,7 @@ namespace armix::harmony { struct Settings { int key=0, scale=0, voices=3; // C=0..B=11; 0=major, 1=natural minor; 2..5 voices + int voiceMode=0; // 0=pitched harmony (2-5), 1=true unison doubler (one wet take) bool correction=false; // Manual is always the trusted fallback. Music follows another accepted // ChannelId only after stable chroma confidence (never a PCM route). @@ -29,6 +30,7 @@ struct Settings { }; inline bool valid(const Settings& s) noexcept { return s.key>=0&&s.key<12&&s.scale>=0&&s.scale<=1&& + s.voiceMode>=0&&s.voiceMode<=1&& s.guideMode>=0&&s.guideMode<=1&& (s.guideMode==0?s.guideChannelId==0:s.guideChannelId>0)&& s.voices>=2&&s.voices<=5&&std::isfinite(s.wet)&&s.wet>=0&&s.wet<=1&& @@ -157,6 +159,19 @@ class Engine final { prepared.settings=next; prepared.gain=std::pow(10.f,next.gainDb/20.f); constexpr float pi=3.14159265358979323846f; + if(next.voiceMode==1){ + // Real unison double, NOT 2 pitched harmony voices. One + // independently windowed take follows source F0 at unity ratio. + // A tiny prepared left-back offset plus the existing shared + // room/detune/arrival give a second-take character. + const float pan=-.40f*next.space; + const float angle=(pan+1.f)*pi*.25f; + const float amount=next.wet*(.77f+.38f*next.wet)*.74f; + prepared.mixL[0]=amount*std::cos(angle); + prepared.mixR[0]=amount*std::sin(angle); + out=prepared; + return true; + } float profileEnergy=0.f; for(const auto& singer:singers) if(singerActive(singer.role,next.voices)) @@ -192,6 +207,12 @@ class Engine final { } if(settings_.correction&&!next.settings.correction) leadTune_.release(); + if(next.settings.voiceMode!=settings_.voiceMode){ + // Re-evaluate note targets on the next accepted analysis, + // without stopping the dry singer or reinitializing the room. + tonalTransitionPending_=true; + if(next.settings.voiceMode==1)targetRatio_.fill(1.f); + } settings_=next.settings; targetWet_=next.settings.wet;targetColor_=next.settings.color; targetSpace_=next.settings.space; @@ -563,7 +584,11 @@ class Engine final { } const int activeKey=effectiveKey(),activeScale=effectiveScale(); const int degree=nearestDegree(midi,activeKey,activeScale); - int note=noteAt(degree,activeKey,activeScale); + // In DOUBLE the source's own melody is authoritative, not the key + // wheel's diatonic quantization. Harmony keeps the existing scale. + int note=settings_.voiceMode==1? + static_cast(std::lround(midi)): + noteAt(degree,activeKey,activeScale); if(!tonalTransitionPending_ && !pitchChangeHasMargin(currentNote_,note,midi)){ note=currentNote_; @@ -586,7 +611,9 @@ class Engine final { leadTune_.observe(midi,note,confidence); } if(note!=currentNote_||tonalTransitionPending_){ - voicePlanner_.plan(note,activeKey,activeScale==0?major:minor); + if(settings_.voiceMode==0) + voicePlanner_.plan(note,activeKey,activeScale==0?major:minor); + else voicePlanner_.reset(); ensemble_.beginNote(); } currentNote_=note;voiced_=true;tonalTransitionPending_=false; @@ -606,11 +633,17 @@ class Engine final { }else weakSyncHops_=0; // Integer intervals come from the prepared LUT. The single // fractional ratio tracks the current microphone pitch. - const float baseRatio=std::exp2((note-midi)/12.f); - for(std::size_t v=0;v Date: Wed, 11 Nov 2026 03:53:23 +0700 Subject: [PATCH 02/12] feat(harmony): persist Doubler mode as v3 with v1/v2 Harmony migration --- engine/builtin_fx/ChannelHarmonyProcessor.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/engine/builtin_fx/ChannelHarmonyProcessor.h b/engine/builtin_fx/ChannelHarmonyProcessor.h index b54cea5cc..641d4fcff 100644 --- a/engine/builtin_fx/ChannelHarmonyProcessor.h +++ b/engine/builtin_fx/ChannelHarmonyProcessor.h @@ -165,7 +165,7 @@ class ChannelHarmonyProcessor final : public juce::AudioProcessor, void getStateInformation(juce::MemoryBlock& out) override { juce::MemoryOutputStream stream(out,false); stream.writeInt(0x41484d31); // AHM1 - stream.writeInt(2); + stream.writeInt(3); stream.writeInt(accepted_.key); stream.writeInt(accepted_.scale); stream.writeInt(accepted_.voices); @@ -176,29 +176,32 @@ class ChannelHarmonyProcessor final : public juce::AudioProcessor, stream.writeFloat(accepted_.gainDb); stream.writeInt(accepted_.guideMode); stream.writeInt64(static_cast(accepted_.guideChannelId)); + stream.writeInt(accepted_.voiceMode); } bool restoreUnpublishedState(const void* bytes,int len) { if(published_||!bytes||len<=0||len>128)return false; juce::MemoryInputStream stream(bytes,static_cast(len),false); if(stream.readInt()!=0x41484d31)return false; const int version=stream.readInt(); - if(version!=1&&version!=2)return false; + if(version!=1&&version!=2&&version!=3)return false; armix::harmony::Settings incoming{}; incoming.key=stream.readInt();incoming.scale=stream.readInt(); incoming.voices=stream.readInt();incoming.correction=stream.readBool(); incoming.wet=stream.readFloat();incoming.space=stream.readFloat(); incoming.color=stream.readFloat();incoming.gainDb=stream.readFloat(); - if(version==2){ + if(version>=2){ incoming.guideMode=stream.readInt(); const auto guide=stream.readInt64(); if(guide<0)return false; incoming.guideChannelId=static_cast(guide); } + if(version==3)incoming.voiceMode=stream.readInt(); + // v1/v2 lacked an explicit Doubler; they stay pitched Harmony. if(stream.getPosition()!=stream.getTotalLength()|| !armix::harmony::valid(incoming))return false; if(ready_&&!dsp_.setSettings(incoming))return false; // NativeMixerSessionFxRestore restores AFTER prepareToPlay. An accepted - // v2 ChannelId must become the actual AUDIO guide source, not merely a + // v2/v3 ChannelId must become the actual AUDIO guide source, not merely a // saved GUI value. This is unpublished/control-thread only. if(ready_) { guide_.reset(); From bcf39c63a735e4386c74b12565e6504e580a55fb Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 03:53:47 +0700 Subject: [PATCH 03/12] feat(harmony): validate and project native Doubler mode on ACK/readback --- src/Main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index 02aa30309..35fe94b16 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -2541,7 +2541,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr reply->setProperty("deviceEpoch",epoch); reply->setProperty("graphRevision",revision); reply->setProperty("instanceId",instanceId); - reply->setProperty("schemaVersion",2); + reply->setProperty("schemaVersion",3); reply->setProperty("status",processor?"ACCEPTED":"REJECTED"); if(processor) { const auto s=processor->acceptedSettings(); @@ -2549,6 +2549,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr settings->setProperty("key",s.key); settings->setProperty("scale",s.scale); settings->setProperty("voices",s.voices); + settings->setProperty("voiceMode",s.voiceMode); settings->setProperty("correction",s.correction); settings->setProperty("wet",s.wet); settings->setProperty("space",s.space); @@ -3643,7 +3644,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr } const auto v=args.getProperty("settings",{}); const auto k=v.getProperty("key",{}),sc=v.getProperty("scale",{}); - const auto voices=v.getProperty("voices",{}),tune=v.getProperty("correction",{}); + const auto voices=v.getProperty("voices",{}),mode=v.getProperty("voiceMode",{}); + const auto tune=v.getProperty("correction",{}); auto num=[](const juce::var& value,float& output) { if(!value.isDouble()&&!value.isInt())return false; const auto x=static_cast(value); @@ -3651,13 +3653,15 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr output=static_cast(x);return std::isfinite(output); }; armix::harmony::Settings settings{}; - const bool typed=k.isInt()&&sc.isInt()&&voices.isInt()&&tune.isBool()&& + const bool typed=k.isInt()&&sc.isInt()&&voices.isInt()&&mode.isInt()&&tune.isBool()&& num(v.getProperty("wet",{}),settings.wet)&& num(v.getProperty("space",{}),settings.space)&& num(v.getProperty("color",{}),settings.color)&& num(v.getProperty("gainDb",{}),settings.gainDb); settings.key=static_cast(k);settings.scale=static_cast(sc); - settings.voices=static_cast(voices);settings.correction=static_cast(tune); + settings.voices=static_cast(voices); + settings.voiceMode=static_cast(mode); + settings.correction=static_cast(tune); // Exact ChannelId is never parsed from a JS number. Validate // against the currently admitted native graph, not a UI track // index or a remembered localStorage name. From 1f755eb022aa4442636cf6bbeb886c61c2a5d556 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Wed, 11 Nov 2026 03:55:58 +0700 Subject: [PATCH 04/12] feat(harmonice-ui): introduce Doubler mode and factory preset metadata --- .../preview-v2/assets/mixer-native-harmony.js | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/site/preview-v2/assets/mixer-native-harmony.js b/site/preview-v2/assets/mixer-native-harmony.js index a985603d6..4efb60849 100644 --- a/site/preview-v2/assets/mixer-native-harmony.js +++ b/site/preview-v2/assets/mixer-native-harmony.js @@ -19,6 +19,7 @@ root.innerHTML=` @@ -33,6 +34,10 @@ root.innerHTML=` +