From e74b622da7a759ecda62b42ae11856109628cc1c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:04:53 +0700 Subject: [PATCH 01/61] feat(vocal-throw): implement bounded zero-added-latency phrase capture and rhythmic echo DSP --- engine/builtin_fx/VocalThrow.h | 226 +++++++++++++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 engine/builtin_fx/VocalThrow.h diff --git a/engine/builtin_fx/VocalThrow.h b/engine/builtin_fx/VocalThrow.h new file mode 100644 index 000000000..1ca18fbfa --- /dev/null +++ b/engine/builtin_fx/VocalThrow.h @@ -0,0 +1,226 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include +#include +#include +#include +#include +#include + +// ArSon Vocal Throw. One audio-thread owner; preparation allocates on CONTROL. +// The microphone's dry PCM is never buffered or delayed. A rolling history +// freezes the last word/phrase for tempo-spaced stereo echoes. All samples and +// triggers run on the existing native ChannelId PCM callback, never WebView. +namespace armix::builtin_fx { +struct VocalThrowSettings final { + int mode=2; // 0 manual, 1 automatic, 2 hybrid + float bpm=120.f; // explicit/host or tap BPM (not claimed auto-detected) + int division=0; // 0 quarter, 1 eighth, 2 dotted eighth, 3 half + int repeats=3; + float captureMs=460.f; + float silenceMs=220.f; + float thresholdDb=-35.f; + float wet=.42f; + float decay=.55f; // successive repeat amplitude multiplier + float ducking=.7f; // suppress echo while lead vocalist is active +}; +class VocalThrow final { +public: + static constexpr int addedLatencySamples=0; + static constexpr int maxRepeats=6; + static constexpr float maxCaptureMs=1500.f; + struct PreparedEdit { + VocalThrowSettings settings{}; + double sampleRate=0.; + std::uint32_t intervalSamples=0, captureSamples=0, silenceSamples=0; + float gateLinear=0.f; + bool valid=false; + }; + static bool validSettings(const VocalThrowSettings& s) noexcept { + return s.mode>=0&&s.mode<=2&&s.division>=0&&s.division<=3&& + s.repeats>=1&&s.repeats<=maxRepeats&& + std::isfinite(s.bpm)&&s.bpm>=60.f&&s.bpm<=200.f&& + std::isfinite(s.captureMs)&&s.captureMs>=80.f&&s.captureMs<=maxCaptureMs&& + std::isfinite(s.silenceMs)&&s.silenceMs>=80.f&&s.silenceMs<=900.f&& + std::isfinite(s.thresholdDb)&&s.thresholdDb>=-65.f&&s.thresholdDb<=-15.f&& + std::isfinite(s.wet)&&s.wet>=0.f&&s.wet<=1.f&& + std::isfinite(s.decay)&&s.decay>=.15f&&s.decay<=.9f&& + std::isfinite(s.ducking)&&s.ducking>=0.f&&s.ducking<=1.f; + } + static bool prepareEdit(const VocalThrowSettings& s,double sampleRate,PreparedEdit& out) noexcept { + if(!validSettings(s)||!std::isfinite(sampleRate)|| + sampleRate<8000.||sampleRate>192000.)return false; + constexpr std::array beats{{1.,.5,.75,2.}}; + PreparedEdit next{}; + next.settings=s;next.sampleRate=sampleRate; + next.intervalSamples=std::max(1u,static_cast( + std::llround(60.*sampleRate*beats[static_cast(s.division)]/s.bpm))); + next.captureSamples=std::max(1u,static_cast( + std::llround(sampleRate*s.captureMs/1000.))); + next.silenceSamples=std::max(1u,static_cast( + std::llround(sampleRate*s.silenceMs/1000.))); + next.gateLinear=static_cast(std::pow(10.,s.thresholdDb/20.)); + next.valid=next.gateLinear>0.f; + out=next;return true; + } + // CONTROL thread only, before publishing the insert. Maximum memory is + // bounded by the selected device rate and independent of song duration. + bool prepare(double rate) { + PreparedEdit packet{}; + if(!prepareEdit(VocalThrowSettings{},rate,packet))return false; + const auto historyFrames=static_cast(std::ceil(rate*2.5))+4; + const auto freezeFrames=static_cast(std::ceil(rate*maxCaptureMs/1000.))+4; + if(historyFrames>500000||freezeFrames>300000)return false; + historyL_.assign(historyFrames,0.f); + historyR_.assign(historyFrames,0.f); + freezeL_.assign(freezeFrames,0.f); + freezeR_.assign(freezeFrames,0.f); + rate_=rate;ready_=true;settings_=packet;reset(); + return true; + } + // CONTROL, before publication. No vector resizing during state restore. + bool resetUnpublished(const VocalThrowSettings& settings) noexcept { + PreparedEdit next{}; + if(!ready_||!prepareEdit(settings,rate_,next))return false; + settings_=next;reset();return true; + } + // AUDIO: trivially copied, completely validated, no heap/locks. + bool applyPrepared(const PreparedEdit& edit) noexcept { + if(!ready_||!edit.valid||edit.sampleRate!=rate_|| + !validSettings(edit.settings)||edit.intervalSamples==0|| + edit.captureSamples==0||edit.captureSamples>freezeL_.size()|| + edit.silenceSamples==0)return false; + settings_=edit;return true; + } + // AUDIO: triggers the most recent word/phrase, preferring the latest + // vocal end if the singer stopped within the last 700 ms. + bool throwNow() noexcept { + if(!ready_||recorded_==0)return false; + const auto recent=static_cast(rate_*.7); + const bool ended=lastSoundEnd_>0 && clock_>=lastSoundEnd_ && + clock_-lastSoundEnd_<=recent && quiet_>0; + return freezeAt(ended?lastSoundEnd_:clock_); + } + void processStereo(float* left,float* right,std::size_t frames) noexcept { + if(!ready_||!left||!right)return; + const bool mono=left==right; + for(std::size_t i=0;i(clock_%historyL_.size()); + historyL_[location]=dryL;historyR_[location]=dryR; + ++clock_;recorded_=std::min(recorded_+1,historyL_.size()); + const float peak=std::max(std::abs(dryL),std::abs(dryR)); + // Fast attack, slow release. Singing detector is independent of + // output echo, so feedback cannot self-trigger another phrase. + const float coeff=peak>envelope_?envAttack_:envRelease_; + envelope_=coeff*envelope_+(1.f-coeff)*peak; + if(envelope_<1.0e-20f)envelope_=0.f; + const bool singing=envelope_>=settings_.gateLinear; + if(singing) { + if(quiet_>static_cast(rate_*.06))voiced_=0; + quiet_=0; + voiced_=std::min(voiced_+1,static_cast(rate_)); + lastSoundEnd_=clock_; + if(voiced_>=static_cast(rate_*.08))armed_=true; + } else { + ++quiet_; + if(armed_ && quiet_>=settings_.silenceSamples) { + if(settings_.settings.mode!=0 && clock_>=nextAutoEligible_) { + const bool captured=freezeAt(lastSoundEnd_); + if(captured)nextAutoEligible_=clock_+ + static_cast(rate_*.4); + } + armed_=false; + } + } + float echoL=0.f,echoR=0.f; + if(playing_) { + // A new manual throw replaces the old tail atomically. + // Each voice has a fixed offset in the captured buffer; + // multiple phrases may overlap at short note divisions. + for(int tap=0;tap(tap)]; + if(clock_<=start)continue; + const std::uint64_t offset=clock_-start-1; + if(offset>=freezeCount_)continue; + float ramp=1.f; + const auto edge=static_cast(rate_*.004); + if(edge>0) { + ramp=std::min(ramp,static_cast(offset)/static_cast(edge)); + ramp=std::min(ramp,static_cast(freezeCount_-offset-1)/ + static_cast(edge)); + } + const auto p=static_cast(offset); + const float gain=repeatGains_[static_cast(tap)]*std::max(0.f,ramp); + echoL+=freezeL_[p]*gain;echoR+=freezeR_[p]*gain; + } + const auto end=repeatStarts_[static_cast(settings_.settings.repeats-1)] + +freezeCount_; + if(clock_>end)playing_=false; + } + const float target=singing?1.f-settings_.settings.ducking:1.f; + // Fixed 8-ms one-pole gain smoothing: no clicks on duck transitions. + duck_=duck_*duckCoeff_+target*(1.f-duckCoeff_); + left[i]=dryL+echoL*settings_.settings.wet*duck_; + if(!mono)right[i]=dryR+echoR*settings_.settings.wet*duck_; + } + } + [[nodiscard]] bool ready() const noexcept{return ready_;} + [[nodiscard]] VocalThrowSettings settingsForTests() const noexcept{return settings_.settings;} + [[nodiscard]] bool echoActive() const noexcept{return playing_;} + [[nodiscard]] unsigned throwCount() const noexcept{return throwCount_;} + [[nodiscard]] double sampleRate() const noexcept{return rate_;} +private: + bool freezeAt(std::uint64_t end) noexcept { + if(end==0||end>clock_||historyL_.empty())return false; + const auto available=std::min(end,recorded_); + const auto count=std::min(available,settings_.captureSamples); + if(count(rate_*.025))return false; + const auto from=end-count; + for(std::uint64_t i=0;i((from+i)%historyL_.size()); + freezeL_[static_cast(i)]=historyL_[source]; + freezeR_[static_cast(i)]=historyR_[source]; + } + freezeCount_=count; + // Wait until the next subdivision after the detected phrase end; + // if the silence detector was late, fire immediately (never in past). + const std::uint64_t first=std::max(clock_,end+settings_.intervalSamples); + float amplitude=1.f; + for(int tap=0;tap(tap); + repeatStarts_[slot]=first+static_cast(tap)*settings_.intervalSamples; + repeatGains_[slot]=amplitude;amplitude*=settings_.settings.decay; + } + playing_=true;++throwCount_; + return true; + } + void reset() noexcept { + clock_=lastSoundEnd_=nextAutoEligible_=0; + recorded_=freezeCount_=0; + voiced_=quiet_=0;armed_=playing_=false; + envelope_=0.f;duck_=1.f;throwCount_=0; + if(rate_>0) { + envAttack_=static_cast(std::exp(-1./(rate_*.004))); + envRelease_=static_cast(std::exp(-1./(rate_*.060))); + duckCoeff_=static_cast(std::exp(-1./(rate_*.008))); + } + repeatStarts_.fill(0);repeatGains_.fill(0.f); + std::fill(historyL_.begin(),historyL_.end(),0.f); + std::fill(historyR_.begin(),historyR_.end(),0.f); + } + PreparedEdit settings_{}; + std::vector historyL_,historyR_,freezeL_,freezeR_; + std::array repeatStarts_{}; + std::array repeatGains_{}; + std::uint64_t clock_=0,lastSoundEnd_=0,nextAutoEligible_=0; + std::size_t recorded_=0; + std::uint64_t freezeCount_=0; + std::uint32_t voiced_=0,quiet_=0; + float envelope_=0.f,envAttack_=0.f,envRelease_=0.f,duckCoeff_=0.f,duck_=1.f; + double rate_=0.; + unsigned throwCount_=0; + bool armed_=false,playing_=false,ready_=false; +}; +} // namespace armix::builtin_fx From 070ed0c7c3a36788ec0dd3f9720c3265750176f7 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:05:36 +0700 Subject: [PATCH 02/61] feat(vocal-throw): add native JUCE insert, lock-free DSP commands and schema-versioned state --- engine/builtin_fx/VocalThrowProcessor.h | 151 ++++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 engine/builtin_fx/VocalThrowProcessor.h diff --git a/engine/builtin_fx/VocalThrowProcessor.h b/engine/builtin_fx/VocalThrowProcessor.h new file mode 100644 index 000000000..a6842bed7 --- /dev/null +++ b/engine/builtin_fx/VocalThrowProcessor.h @@ -0,0 +1,151 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "VocalThrow.h" +#include "FxSpsc.h" +#include "../core/RealtimeNativeFxControl.h" +#include +#include +#include + +// JUCE adapter for the existing ChannelId FX rack. All setting/throw requests +// are bound to an exact accepted graph instance by ConsoleWindow before they +// enter the control->audio SPSC. Audio never posts a WebView event. +namespace armix::builtin_fx { +class VocalThrowProcessor final : public juce::AudioProcessor, + public armix::mixer::RealtimeNativeFxControl { +public: + static constexpr const char* catalogIdentity="armix.builtin.vocal-throw.v1"; + enum class CommandKind : std::uint8_t { settings, trigger }; + struct Completion { + std::uint64_t requestId=0; + VocalThrowSettings settings{}; + CommandKind kind=CommandKind::settings; + bool applied=false; + }; + VocalThrowProcessor() + : juce::AudioProcessor(BusesProperties() + .withInput("Input",juce::AudioChannelSet::stereo(),true) + .withOutput("Output",juce::AudioChannelSet::stereo(),true)) { + setLatencySamples(VocalThrow::addedLatencySamples); + } + const juce::String getName() const override {return "ArSon Vocal Throw";} + bool acceptsMidi() const override{return false;} + bool producesMidi() const override{return false;} + bool isMidiEffect() const override{return false;} + double getTailLengthSeconds() const override{return 16.;} + int getNumPrograms() override{return 1;} + int getCurrentProgram() override{return 0;} + void setCurrentProgram(int) override{} + const juce::String getProgramName(int) override{return "Current";} + void changeProgramName(int,const juce::String&) override{} + bool hasEditor() const override{return false;} + juce::AudioProcessorEditor* createEditor() override{return nullptr;} + bool isBusesLayoutSupported(const BusesLayout& layout) const override { + return layout.getMainInputChannelSet()==juce::AudioChannelSet::stereo()&& + layout.getMainOutputChannelSet()==juce::AudioChannelSet::stereo(); + } + void prepareToPlay(double sampleRate,int) override { + ready_=core_.prepare(sampleRate)&&core_.resetUnpublished(accepted_); + if(ready_)rate_=sampleRate; + } + void releaseResources() override{ready_=false;} + void processBlock(juce::AudioBuffer& pcm,juce::MidiBuffer&) override { + juce::ScopedNoDenormals noDenormals; + if(!ready_||pcm.getNumChannels()<2||pcm.getNumSamples()<=0)return; + consumeRealtimeEdits(); + core_.processStereo(pcm.getWritePointer(0),pcm.getWritePointer(1), + static_cast(pcm.getNumSamples())); + observedThrows_.store(core_.throwCount(),std::memory_order_relaxed); + observedTail_.store(core_.echoActive(),std::memory_order_relaxed); + } + void processBlock(juce::AudioBuffer&,juce::MidiBuffer&) override{} + void consumeRealtimeEdits() noexcept override { + Edit e{}; + if(!ready_||!done_.canPush()||!commands_.pop(e))return; + const bool applied=e.kind==CommandKind::settings? + core_.applyPrepared(e.prepared):core_.throwNow(); + (void)done_.push({e.id,e.prepared.settings,e.kind,applied}); + } + bool queueSettings(const VocalThrowSettings& settings,std::uint64_t id) noexcept { + if(!ready_||id==0)return false; + Edit e{};e.id=id;e.kind=CommandKind::settings; + if(!VocalThrow::prepareEdit(settings,rate_,e.prepared))return false; + return commands_.push(e); + } + bool queueTrigger(std::uint64_t id) noexcept { + if(!ready_||id==0)return false; + Edit e{};e.id=id;e.kind=CommandKind::trigger; + return commands_.push(e); + } + bool pollCompletion(Completion& out) noexcept { + if(!done_.pop(out))return false; + if(out.applied&&out.kind==CommandKind::settings)accepted_=out.settings; + return true; + } + VocalThrowSettings acceptedSettings() const noexcept{return accepted_;} + double acceptedSampleRate() const noexcept{return rate_;} + unsigned observedThrowCount() const noexcept { + return observedThrows_.load(std::memory_order_relaxed); + } + bool observedTailActive() const noexcept { + return observedTail_.load(std::memory_order_relaxed); + } + bool isReady() const noexcept{return ready_;} + void sealForRealtime() noexcept override{published_=true;} + bool stateSnapshotQuiescent() const noexcept override{ + return commands_.empty()&&done_.empty(); + } + void getStateInformation(juce::MemoryBlock& out) override { + juce::MemoryOutputStream writer(out,false); + writer.writeInt(0x41565448); // AVTH + writer.writeInt(1); + writer.writeInt(accepted_.mode); + writer.writeFloat(accepted_.bpm); + writer.writeInt(accepted_.division); + writer.writeInt(accepted_.repeats); + writer.writeFloat(accepted_.captureMs); + writer.writeFloat(accepted_.silenceMs); + writer.writeFloat(accepted_.thresholdDb); + writer.writeFloat(accepted_.wet); + writer.writeFloat(accepted_.decay); + writer.writeFloat(accepted_.ducking); + } + bool restoreUnpublishedState(const void* data,int bytes) { + if(published_||!data||bytes!=44||!commands_.empty()||!done_.empty()) + return false; + juce::MemoryInputStream reader(data,static_cast(bytes),false); + if(reader.readInt()!=0x41565448||reader.readInt()!=1)return false; + VocalThrowSettings s{}; + s.mode=reader.readInt(); + s.bpm=reader.readFloat(); + s.division=reader.readInt(); + s.repeats=reader.readInt(); + s.captureMs=reader.readFloat(); + s.silenceMs=reader.readFloat(); + s.thresholdDb=reader.readFloat(); + s.wet=reader.readFloat(); + s.decay=reader.readFloat(); + s.ducking=reader.readFloat(); + if(!reader.isExhausted()||!VocalThrow::validSettings(s))return false; + if(ready_&&!core_.resetUnpublished(s))return false; + accepted_=s;return true; + } + void setStateInformation(const void* data,int bytes) override{ + (void)restoreUnpublishedState(data,bytes); + } +private: + struct Edit { + std::uint64_t id=0; + CommandKind kind=CommandKind::settings; + VocalThrow::PreparedEdit prepared{}; + }; + VocalThrow core_{}; + FxSpsc commands_{}; + FxSpsc done_{}; + VocalThrowSettings accepted_{}; + std::atomic observedThrows_{0}; + std::atomic observedTail_{false}; + double rate_=0.; + bool ready_=false,published_=false; +}; +} // namespace armix::builtin_fx From e13c3fc1424852b3a83254ae30d40b53bbb48a2e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:07:10 +0700 Subject: [PATCH 03/61] feat(vocal-throw): install real native FX node on authoritative ChannelId graph --- src/LiveAudioEngine.h | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index 4bf678b1b..bf3a78b34 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -12,6 +12,7 @@ #include "../engine/dsp/NativeMasterLoudness.h" #include "../engine/builtin_fx/ChannelEqProcessor.h" #include "../engine/builtin_fx/ChannelCompressorProcessor.h" +#include "../engine/builtin_fx/VocalThrowProcessor.h" #include "DiagnosticTone.h" #include "../engine/device/JuceIndependentClockDevice.h" #include "../engine/device/LiveSecondaryOutputDevice.h" @@ -1755,6 +1756,49 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback } } + // ArSon Vocal Throw: single native PCM graph, same insert leases, bypass, + // ChannelId topology and dry monitoring as EQ/Compressor. + LiveDryRoutingLab::NativeBusResult installNativeBuiltInVocalThrow( + std::uint64_t ep,std::uint64_t pcmRevision, + std::uint64_t rosterRevision,armix::mixer::ChannelId id) { + LiveDryRoutingLab::NativeBusResult fail{}; + fail.error="NATIVE_THROW_HOST_UNAVAILABLE"; + auto* device=deviceManager_.getCurrentAudioDevice(); + if(independent_.active()||!attached_||!device|| + !directFence_.permitted()||secondaryOutput_.armed()|| + handoff_.busy()||fxMovePhase_.load(std::memory_order_acquire)!=0|| + routeReconfiguring_.load(std::memory_order_acquire)|| + diagnosticRoute_.load(std::memory_order_acquire)!= + armix::diagnostics::Route::normal)return fail; + if(ep!=dryRoutingLab_.epoch()){ + fail.error="NATIVE_THROW_DEVICE_CHANGED";return fail; + } + const auto rate=device->getCurrentSampleRate(); + const int frames=juce::jmax(32,device->getCurrentBufferSizeSamples()); + if(!(rate>=8000.&&rate<=192000.)|| + frames>LiveDryRoutingLab::Block::hardFrameLimit) { + fail.error="NATIVE_THROW_UNSUPPORTED_AUDIO_FORMAT";return fail; + } + try { + auto processor=std::make_unique(); + processor->prepareToPlay(rate,frames); + if(!processor->isReady()){ + fail.error="NATIVE_THROW_PREPARE_REJECTED";return fail; + } + auto lease=std::make_shared< + armix::mixer::LiveChannelFxGraph::FxInstance>( + std::move(processor), + juce::String(armix::builtin_fx::VocalThrowProcessor::catalogIdentity), + "ArSon Vocal Throw",LiveDryRoutingLab::Block::hardFrameLimit); + return dryRoutingLab_.attachNativeInsert(ep,pcmRevision, + rosterRevision,id, + armix::builtin_fx::VocalThrowProcessor::catalogIdentity, + std::move(lease),true); + } catch(...) { + fail.error="NATIVE_THROW_PREPARE_EXCEPTION";return fail; + } + } + // User-owned VST3 on a true dynamic ChannelId. Instantiation/scan/layout // work is CONTROL only; the callback receives an immutable fx lease. LiveDryRoutingLab::NativeBusResult installNativeVst3( From 29ab4395c2de35c4b9a488d5593b3006068e0e8b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:07:13 +0700 Subject: [PATCH 04/61] feat(vocal-throw): restore schema-validated native FX settings in saved shows --- src/NativeMixerSessionFxRestore.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/NativeMixerSessionFxRestore.h b/src/NativeMixerSessionFxRestore.h index e85e3fbc1..de808929b 100644 --- a/src/NativeMixerSessionFxRestore.h +++ b/src/NativeMixerSessionFxRestore.h @@ -5,6 +5,7 @@ #include "Vst3DescriptionCache.h" #include "../engine/builtin_fx/ChannelEqProcessor.h" #include "../engine/builtin_fx/ChannelCompressorProcessor.h" +#include "../engine/builtin_fx/VocalThrowProcessor.h" #include #include #include @@ -85,6 +86,16 @@ class NativeMixerSessionFxRestore final { static_cast(state.bytes.getSize()))) return "Saved native Compressor state rejected; graph unchanged"; processor=std::move(comp); + } else if(insert.catalogId== + armix::builtin_fx::VocalThrowProcessor::catalogIdentity) { + auto throwFx=std::make_unique(); + throwFx->prepareToPlay(sampleRate,frames); + if(!throwFx->isReady()|| + !throwFx->restoreUnpublishedState( + state.bytes.getData(), + static_cast(state.bytes.getSize()))) + return "Saved native Vocal Throw state rejected; graph unchanged"; + processor=std::move(throwFx); } else { if(!format|| !format->fileMightContainThisPluginType(insert.path)) @@ -104,7 +115,9 @@ class NativeMixerSessionFxRestore final { if(insert.catalogId!= armix::builtin_fx::ChannelEqProcessor::catalogIdentity && insert.catalogId!= - armix::builtin_fx::ChannelCompressorProcessor::catalogIdentity) + armix::builtin_fx::ChannelCompressorProcessor::catalogIdentity && + insert.catalogId!= + armix::builtin_fx::VocalThrowProcessor::catalogIdentity) processor->setStateInformation(state.bytes.getData(), static_cast(state.bytes.getSize())); const int latency=processor->getLatencySamples(); From 56b5cca0e4adeec23326bdd328cc473f24c9122d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:07:16 +0700 Subject: [PATCH 05/61] feat(vocal-throw): catalog stable native effect identity --- engine/builtin_fx/BuiltInFxCatalog.h | 1 + 1 file changed, 1 insertion(+) diff --git a/engine/builtin_fx/BuiltInFxCatalog.h b/engine/builtin_fx/BuiltInFxCatalog.h index bbc6b83d3..67db030e2 100644 --- a/engine/builtin_fx/BuiltInFxCatalog.h +++ b/engine/builtin_fx/BuiltInFxCatalog.h @@ -11,6 +11,7 @@ namespace armix::builtin_fx { inline constexpr std::string_view channelEqId = "armix.builtin.channel-eq.v1"; inline constexpr std::string_view channelCompressorId = "armix.builtin.channel-compressor.v1"; +inline constexpr std::string_view vocalThrowId = "armix.builtin.vocal-throw.v1"; enum class FilterKind : std::uint8_t { highPass, lowShelf, bell, highShelf, lowPass }; enum class Slope : std::uint8_t { db12 = 12, db24 = 24 }; From f8917ec5f5f18a68b90589c787dfc9c9b11f47fd Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:07:19 +0700 Subject: [PATCH 06/61] test(vocal-throw): include deterministic RT-safe DSP tests in existing Windows CI target --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f1af6ea30..2c1702fae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -379,6 +379,12 @@ if(BUILD_TESTING) add_test(NAME NativeCompressorZeroLatencyAndLinkedStereoPCM COMMAND ARMixNativeCompressorTests) add_dependencies(ARMixMixerRoutingTests ARMixNativeCompressorTests) + add_executable(ARMixNativeVocalThrowTests tests/builtin_vocal_throw_test.cpp + engine/builtin_fx/VocalThrow.h) + target_compile_features(ARMixNativeVocalThrowTests PRIVATE cxx_std_20) + add_test(NAME NativeVocalThrowPhraseCaptureManualAutoAndNoHeap COMMAND ARMixNativeVocalThrowTests) + add_dependencies(ARMixMixerRoutingTests ARMixNativeVocalThrowTests) + add_executable(ARMixNativeMasterLoudnessTests tests/native_master_loudness_test.cpp engine/dsp/NativeMasterLoudness.h) target_compile_features(ARMixNativeMasterLoudnessTests PRIVATE cxx_std_20) add_test(NAME P1KMeasuredNativeBS1770StereoAnd4xTruePeak COMMAND ARMixNativeMasterLoudnessTests) From 07ae515306cef065219e7302261f78ada676e3c0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:07:48 +0700 Subject: [PATCH 07/61] fix(vocal-throw): validate exact 48-byte settings state --- engine/builtin_fx/VocalThrowProcessor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/builtin_fx/VocalThrowProcessor.h b/engine/builtin_fx/VocalThrowProcessor.h index a6842bed7..42f2b4af1 100644 --- a/engine/builtin_fx/VocalThrowProcessor.h +++ b/engine/builtin_fx/VocalThrowProcessor.h @@ -111,7 +111,7 @@ class VocalThrowProcessor final : public juce::AudioProcessor, writer.writeFloat(accepted_.ducking); } bool restoreUnpublishedState(const void* data,int bytes) { - if(published_||!data||bytes!=44||!commands_.empty()||!done_.empty()) + if(published_||!data||bytes!=48||!commands_.empty()||!done_.empty()) return false; juce::MemoryInputStream reader(data,static_cast(bytes),false); if(reader.readInt()!=0x41565448||reader.readInt()!=1)return false; From 080bd84a77c17e93811115c523dbb2890d533b96 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:08:13 +0700 Subject: [PATCH 08/61] feat(vocal-throw): route native insert and lifecycle through approved ChannelId engine --- src/Main.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index fb4da2320..2f752d1f9 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -392,6 +392,13 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr } pendingNativeComp_; juce::String lastNativeCompRequest_,lastNativeCompInstance_; juce::String lastNativeCompEpoch_,lastNativeCompRevision_; + struct PendingNativeThrow { + armix::mixer::LiveChannelFxGraph::InstanceLease owner; + juce::String request,channelId,deviceEpoch,revision,instanceId; + juce::uint32 started=0; + } pendingNativeThrow_; + juce::String lastNativeThrowRequest_,lastNativeThrowInstance_; + juce::String lastNativeThrowEpoch_,lastNativeThrowRevision_; std::unique_ptr editorWindow_; std::unique_ptr audioSetupWindow_; juce::String startupError_, lastAudioXml_; @@ -1073,9 +1080,12 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr armix::builtin_fx::ChannelEqProcessor::catalogIdentity; const bool builtInComp=catalogId== armix::builtin_fx::ChannelCompressorProcessor::catalogIdentity; - const auto* plugin=(builtInEq||builtInComp)?nullptr:catalog_.find(catalogId); + const bool builtInThrow=catalogId== + armix::builtin_fx::VocalThrowProcessor::catalogIdentity; + const auto* plugin=(builtInEq||builtInComp||builtInThrow)? + nullptr:catalog_.find(catalogId); std::uint64_t ep=0,rev=0,roster=0,target=0; - if((!builtInEq&&!builtInComp&&!plugin)||catalog_.busy()||nativeShowBusy_|| + if((!builtInEq&&!builtInComp&&!builtInThrow&&!plugin)||catalog_.busy()||nativeShowBusy_|| studioBackupBusy_||engine_.isGraphSwitchPending()) { nativeError="NATIVE_VST3_CATALOG_OR_HOST_BUSY"; } else if(!armix::console::approvedNativeId( @@ -1094,6 +1104,9 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr builtInComp? engine_.installNativeBuiltInCompressor( ep,rev,roster,armix::mixer::ChannelId{target}): + builtInThrow? + engine_.installNativeBuiltInVocalThrow( + ep,rev,roster,armix::mixer::ChannelId{target}): engine_.installNativeVst3( ep,rev,roster,armix::mixer::ChannelId{target}, plugin->path,plugin->uid,plugin->key()); @@ -2023,7 +2036,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr bool captureIdentity) { for(auto& insert:doc.inserts) { if(insert.catalogId==armix::builtin_fx::ChannelEqProcessor::catalogIdentity || - insert.catalogId==armix::builtin_fx::ChannelCompressorProcessor::catalogIdentity) { + insert.catalogId==armix::builtin_fx::ChannelCompressorProcessor::catalogIdentity || + insert.catalogId==armix::builtin_fx::VocalThrowProcessor::catalogIdentity) { if(insert.path.isNotEmpty() || insert.uid!=0) return "Saved built-in FX identity was modified"; continue; @@ -2265,7 +2279,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr action == "routingNativeFxRackBypass" || action == "routingNativeFxInsertBypass" || action == "routingFxRackBypass" || - action == "nativeEqSetBand" || action == "nativeCompSet")) + action == "nativeEqSetBand" || action == "nativeCompSet" || + action == "nativeThrowSet" || action == "nativeThrowTrigger")) { const auto reason=juce::String( "Studio backup in progress. Finish backup before editing saved FX or VST library."); @@ -4390,6 +4405,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr ++timerTicks_; servicePendingNativeEq(); servicePendingNativeComp(); + servicePendingNativeThrow(); // A hidden JUCE/WebView2 peer may defer first navigation. Expose the // compositor behind the opaque startup splash after the first tick; // the user sees the completed mixer only after the ready handshake. From b47fe83b8369abfa29844a4dec1a4ddfd0cd03c6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:08:55 +0700 Subject: [PATCH 09/61] feat(vocal-throw): expose accepted FX settings, capture activity and DSP ACK --- src/Main.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/Main.cpp b/src/Main.cpp index 2f752d1f9..c212e190e 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -2017,6 +2017,90 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr "arMixBuiltinCompAck",juce::var(ack.release())); } + // Native Vocal Throw settings, manual cue and auto-trigger readback. + // Settings and triggers are not accepted until the AUDIO-owned SPSC + // completion is drained on JUCE's message thread. + void emitNativeThrowSnapshot(const juce::String& request, + const juce::String& channelId,const juce::String& epoch, + const juce::String& revision,const juce::String& instanceId, + armix::builtin_fx::VocalThrowProcessor* processor) { + auto reply=std::make_unique(); + reply->setProperty("requestId",request); + reply->setProperty("channelId",channelId); + reply->setProperty("deviceEpoch",epoch); + reply->setProperty("graphRevision",revision); + reply->setProperty("instanceId",instanceId); + reply->setProperty("schemaVersion",1); + reply->setProperty("status",processor?"ACCEPTED":"REJECTED"); + if(processor) { + auto settings=std::make_unique(); + const auto s=processor->acceptedSettings(); + settings->setProperty("mode",s.mode); + settings->setProperty("bpm",s.bpm); + settings->setProperty("division",s.division); + settings->setProperty("repeats",s.repeats); + settings->setProperty("captureMs",s.captureMs); + settings->setProperty("silenceMs",s.silenceMs); + settings->setProperty("thresholdDb",s.thresholdDb); + settings->setProperty("wet",s.wet); + settings->setProperty("decay",s.decay); + settings->setProperty("ducking",s.ducking); + reply->setProperty("settings",juce::var(settings.release())); + reply->setProperty("sampleRate",processor->acceptedSampleRate()); + reply->setProperty("throwCount",static_cast(processor->observedThrowCount())); + reply->setProperty("tailActive",processor->observedTailActive()); + reply->setProperty("addedLatencySamples",processor->getLatencySamples()); + if(instanceId==lastNativeThrowInstance_&& + epoch==lastNativeThrowEpoch_&&revision==lastNativeThrowRevision_) + reply->setProperty("appliedRequestId",lastNativeThrowRequest_); + } else reply->setProperty("error","NATIVE_THROW_INSTANCE_OR_REVISION_UNAVAILABLE"); + if(browser_.loaded)browser_.emitEventIfBrowserIsVisible( + "arMixBuiltinThrowSnapshot",juce::var(reply.release())); + } + + void servicePendingNativeThrow() { + if(!pendingNativeThrow_.owner)return; + auto* processor=dynamic_cast( + pendingNativeThrow_.owner->processor.get()); + if(!processor){pendingNativeThrow_={};return;} + armix::builtin_fx::VocalThrowProcessor::Completion completion{}; + if(!processor->pollCompletion(completion)&& + juce::Time::getMillisecondCounter()-pendingNativeThrow_.started<3000u) + return; + const auto request=pendingNativeThrow_.request; + bool applied=completion.applied&&completion.requestId!=0&& + request=="throw-"+juce::String(std::to_string(completion.requestId)); + const auto snap=approvedNativeSnapshot(); + const auto device=snap.getProperty("device",{}); + const auto graph=snap.getProperty("graph",{}); + applied=applied&&pendingNativeThrow_.deviceEpoch== + device.getProperty("epoch","").toString()&& + pendingNativeThrow_.revision== + graph.getProperty("revision","").toString(); + if(applied) { + lastNativeThrowRequest_=request; + lastNativeThrowInstance_=pendingNativeThrow_.instanceId; + lastNativeThrowEpoch_=pendingNativeThrow_.deviceEpoch; + lastNativeThrowRevision_=pendingNativeThrow_.revision; + } + auto ack=std::make_unique(); + ack->setProperty("requestId",request); + ack->setProperty("channelId",pendingNativeThrow_.channelId); + ack->setProperty("deviceEpoch",pendingNativeThrow_.deviceEpoch); + ack->setProperty("graphRevision",pendingNativeThrow_.revision); + ack->setProperty("instanceId",pendingNativeThrow_.instanceId); + ack->setProperty("status",applied?"APPLIED":"REJECTED"); + ack->setProperty("command",completion.kind== + armix::builtin_fx::VocalThrowProcessor::CommandKind::trigger? + "TRIGGER":"SETTINGS"); + ack->setProperty("errorCode",applied?"NONE": + completion.kind==armix::builtin_fx::VocalThrowProcessor::CommandKind::trigger? + "NO_CAPTURE_OR_STALE_GRAPH":"DSP_EDIT_NOT_APPLIED_OR_STALE"); + pendingNativeThrow_={}; + if(browser_.loaded)browser_.emitEventIfBrowserIsVisible( + "arMixBuiltinThrowAck",juce::var(ack.release())); + } + // Never confuse durable logical ChannelId state with a physical device // authorization. This message-thread report is status only, not PCM. void emitMixerSessionAck(const juce::String& operation, From 8729862b3bd5dedb686a0695198c6deb0469ec73 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:09:29 +0700 Subject: [PATCH 10/61] feat(vocal-throw): validate tempo/settings/trigger commands at native ACK boundary --- src/Main.cpp | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/src/Main.cpp b/src/Main.cpp index c212e190e..6d65d072e 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -2594,6 +2594,92 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr return; } + // ArSon Vocal Throw: all UI commands reference one exact installed + // ChannelId + device epoch + graph revision + insert instance. + if(action=="nativeThrowSnapshot"||action=="nativeThrowSet"|| + action=="nativeThrowTrigger") { + const auto rawChannel=args.getProperty("channelId",{}); + const auto rawEpoch=args.getProperty("deviceEpoch",{}); + const auto rawRevision=args.getProperty("graphRevision",{}); + const auto rawInstance=args.getProperty("instanceId",{}); + const auto request=args.getProperty("requestId",{}).toString(); + const int throwSlot=static_cast(args.getProperty("slot",-1)); + std::uint64_t ch=0,ep=0,rev=0; + const bool valid=armix::console::approvedNativeId(rawChannel,ch)&& + armix::console::approvedNativeId(rawEpoch,ep)&& + armix::console::approvedNativeId(rawRevision,rev)&& + rawInstance.isString()&&rawInstance.toString().isNotEmpty()&& + throwSlot>=0&&throwSlot(throwSlot), + rawInstance.toString()): + armix::mixer::LiveChannelFxGraph::InstanceLease{}; + auto* processor=owner?dynamic_cast( + owner->processor.get()):nullptr; + if(action=="nativeThrowSnapshot") { + emitNativeThrowSnapshot(request,rawChannel.toString(), + rawEpoch.toString(),rawRevision.toString(), + rawInstance.toString(),processor); + return; + } + const auto wire=request.startsWith("throw-")? + request.substring(6).toStdString():std::string(); + std::uint64_t numeric=0; + if(!wire.empty()&&wire.size()<=19&& + wire.find_first_not_of("0123456789")==std::string::npos) { + try{numeric=std::stoull(wire);}catch(...){numeric=0;} + } + const bool isSettings=action=="nativeThrowSet"; + const auto values=args.getProperty("settings",{}); + armix::builtin_fx::VocalThrowSettings settings{}; + auto read=[&values](const char* key,float& out) { + const auto value=values.getProperty(key,{}); + if(!value.isInt()&&!value.isDouble())return false; + const auto v=static_cast(value); + if(!std::isfinite(v))return false; + out=static_cast(v); + return std::isfinite(out); + }; + auto integer=[&read](const char* key,int& out) { + float candidate=0.f; + if(!read(key,candidate)||candidate!=std::floor(candidate)|| + candidate<0.f||candidate>1000.f)return false; + out=static_cast(candidate);return true; + }; + const bool settingsValid=!isSettings || (values.isObject()&& + integer("mode",settings.mode)&&read("bpm",settings.bpm)&& + integer("division",settings.division)&&integer("repeats",settings.repeats)&& + read("captureMs",settings.captureMs)&&read("silenceMs",settings.silenceMs)&& + read("thresholdDb",settings.thresholdDb)&&read("wet",settings.wet)&& + read("decay",settings.decay)&&read("ducking",settings.ducking)&& + armix::builtin_fx::VocalThrow::validSettings(settings)); + bool queued=false; + if(processor&&numeric>0&&settingsValid&&!pendingNativeThrow_.owner&& + !nativeShowBusy_&&!studioBackupBusy_&&!engine_.independentClockActive()) { + queued=isSettings?processor->queueSettings(settings,numeric): + processor->queueTrigger(numeric); + if(queued) { + pendingNativeThrow_.owner=owner; + pendingNativeThrow_.request=request; + pendingNativeThrow_.channelId=rawChannel.toString(); + pendingNativeThrow_.deviceEpoch=rawEpoch.toString(); + pendingNativeThrow_.revision=rawRevision.toString(); + pendingNativeThrow_.instanceId=rawInstance.toString(); + pendingNativeThrow_.started=juce::Time::getMillisecondCounter(); + } + } + auto ack=std::make_unique(); + ack->setProperty("requestId",request); + ack->setProperty("status",queued?"QUEUED":"REJECTED"); + ack->setProperty("errorCode",queued?"NONE": + pendingNativeThrow_.owner?"THROW_CONTROL_BUSY": + "INVALID_OR_STALE_NATIVE_THROW"); + if(browser_.loaded)browser_.emitEventIfBrowserIsVisible( + "arMixBuiltinThrowQueue",juce::var(ack.release())); + return; + } + // Route the approved channel FX picker to the SAME prepared M4 // graph as physical IN/OUT. ID resolves exclusively in the JUCE // catalog; browser paths/names are never trusted as plugin identity. From b9ecd8a4b601d2cbb685d35b0d424e433ee7b4d3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:12:50 +0700 Subject: [PATCH 11/61] feat(vocal-throw): compact approved FX editor with TAP BPM, phrase sensitivity and native THROW ACK --- .../assets/mixer-native-vocal-throw.js | 239 ++++++++++++++++++ 1 file changed, 239 insertions(+) create mode 100644 site/preview-v2/assets/mixer-native-vocal-throw.js diff --git a/site/preview-v2/assets/mixer-native-vocal-throw.js b/site/preview-v2/assets/mixer-native-vocal-throw.js new file mode 100644 index 000000000..a6384307b --- /dev/null +++ b/site/preview-v2/assets/mixer-native-vocal-throw.js @@ -0,0 +1,239 @@ +/* ArSon Vocal Throw: controls ONLY, on the single approved /preview/ mixer. + No browser DSP or optimistic FX ACK: all state comes from JUCE PCM graph. */ +(() => { +"use strict"; +const ID="armix.builtin.vocal-throw.v1"; +const defaults=()=>({mode:2,bpm:120,division:0,repeats:3,captureMs:460, + silenceMs:220,thresholdDb:-35,wet:.42,decay:.55,ducking:.7}); +const presets={ + Concert:defaults(), + Fast:{...defaults(),division:1,repeats:4,captureMs:330,decay:.6}, + Ballad:{...defaults(),bpm:72,captureMs:650,wet:.48}, + Word:{...defaults(),mode:0,captureMs:280,silenceMs:180} +}; +const ranges={bpm:[60,200],repeats:[1,6],captureMs:[80,1500],silenceMs:[80,900], + thresholdDb:[-65,-15],wet:[0,1],decay:[.15,.9],ducking:[0,1]}; +const fields={captureMs:["Capture","ms",5],silenceMs:["End pause","ms",10], + thresholdDb:["Voice gate","dB",1],wet:["Echo mix","%",.01], + decay:["Decay","%",.01],ducking:["Vocal duck","%",.01]}; +const valid=s=>s&&[0,1,2].includes(s.mode)&&[0,1,2,3].includes(s.division)&& + Object.entries(ranges).every(([k,[min,max]])=> + Number.isFinite(s[k])&&s[k]>=min&&s[k]<=max); +const same=(a,b)=>Object.keys(defaults()).every(k=>a[k]===b[k]); +const clamp=(v,min,max)=>Math.max(min,Math.min(max,v)); +const backend=()=>window.__JUCE__?.backend; +const native=()=>typeof backend()?.emitEvent==="function"; +const snapshot=()=>window.__ARMIX_NATIVE_M2__?.state?.()?.current; +const style=document.createElement("style"); +style.textContent=[ + ".mx-vthrow{position:fixed;z-index:15001;left:12vw;top:110px;width:min(410px,calc(100vw - 20px));box-sizing:border-box;background:#16232d;color:#dce8ef;font:12px/1.4 Inter,Arial,sans-serif;border:1px solid #385064;border-radius:10px;box-shadow:0 18px 45px #000b;overflow:hidden}", + ".mx-vthrow[hidden]{display:none}.mx-vthrow *{box-sizing:border-box}", + ".mx-vthrow header{display:flex;gap:7px;align-items:center;padding:8px 10px;background:#20313d;border-bottom:1px solid #354b5b;user-select:none;cursor:move}", + ".mx-vthrow .brand{font-weight:600;font-size:13px;white-space:nowrap}.mx-vthrow .channel{flex:1;color:#99b2c4;font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + ".mx-vthrow select,.mx-vthrow input{background:#101c26;color:#e6f1f9;border:1px solid #41576a;border-radius:5px;font:inherit;min-height:26px;max-width:100%}", + ".mx-vthrow select{padding:3px 5px;cursor:pointer}.mx-vthrow button{background:#2a3c49;color:#dcebf3;border:1px solid #456072;border-radius:5px;font:inherit;cursor:pointer;min-height:27px}", + ".mx-vthrow button:hover{background:#37576a}.mx-vthrow button:disabled{opacity:.5;cursor:default}.mx-vthrow .power{min-width:26px;font-size:15px}", + ".mx-vthrow .power[data-state=on]{color:#99f5bd;background:#23503d}.mx-vthrow .power[data-state=off]{color:#f5a4a4;background:#593238}", + ".mx-vthrow .close{font-size:18px;border:0;border-radius:5px;min-width:26px;background:transparent}.mx-vthrow .close:hover{background:#b8333f;color:#fff}", + ".mx-vthrow .body{padding:11px;display:grid;gap:10px}.mx-vthrow .row{display:flex;align-items:center;justify-content:space-between;gap:9px}", + ".mx-vthrow .topline{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}.mx-vthrow .field{display:grid;gap:4px;min-width:0}", + ".mx-vthrow label,.mx-vthrow .label{color:#9fb6c5;font-size:10px;letter-spacing:.035em}.mx-vthrow .field input{width:100%;padding:4px 7px}", + ".mx-vthrow .manual{display:grid;grid-template-columns:1fr 80px;gap:9px}.mx-vthrow .throw{background:#277d9b;font-size:13px;font-weight:600;min-height:46px;letter-spacing:.07em}.mx-vthrow .throw:hover{background:#2b9ebf}.mx-vthrow .tap{min-height:46px}", + ".mx-vthrow .hint{color:#8fb1c2;min-height:15px;font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mx-vthrow .detail{border-top:1px solid #334b5b;padding-top:8px}", + ".mx-vthrow details>summary{cursor:pointer;color:#bad1df;padding-bottom:7px;font-size:11px}.mx-vthrow .ranges{display:grid;grid-template-columns:1fr 1fr;gap:8px 13px}", + ".mx-vthrow .range{display:grid;grid-template-columns:1fr auto;gap:3px}.mx-vthrow .range input{grid-column:1/-1;width:100%;height:15px;accent-color:#56bada}", + ".mx-vthrow output{font-variant-numeric:tabular-nums;font-size:11px}.mx-vthrow .status{display:flex;justify-content:space-between;font-size:10px;color:#89a6b8}.mx-vthrow .dot{display:inline-block;border-radius:50%;width:6px;height:6px;background:#7892a3;margin-right:5px}.mx-vthrow .dot.active{background:#55ddac}" +].join("\n"); +document.head.append(style); +const panel=document.createElement("section"); +panel.className="mx-vthrow";panel.id="mxNativeVocalThrow";panel.hidden=true; +panel.setAttribute("role","dialog");panel.setAttribute("aria-modal","false"); +panel.setAttribute("aria-label","ArSon Vocal Throw"); +panel.innerHTML=[ + '
Vocal Throw', + '', + '
', + '
TRIGGER MODE
', + '
', + '
', + '
', + '
', + '
Native DSP · waiting for accepted channel
', + '
Phrase & echo shaping
', + '
FX READY0 throws
' +].join(""); +document.body.append(panel); +const $=id=>panel.querySelector("#"+id); +for(const [key,[title,unit,step]] of Object.entries(fields)){ + const label=document.createElement("label");label.className="range";label.dataset.key=key; + label.innerHTML=''+title+''; + const input=label.querySelector("input"),bounds=ranges[key]; + input.min=String(bounds[0]);input.max=String(bounds[1]);input.step=String(step); + input.setAttribute("aria-label",title);label.querySelector("output").dataset.unit=unit; + $("vtRanges").append(label); +} +let current=null,accepted=defaults(),draft=defaults(),pending=null, + readId="",readSent=0,seq=1,taps=[],windowDrag=null; +const context=()=>{ + const state=snapshot(),id=current&&window.__ARMIX_NATIVE_M2__?.nativeIdFor?.(current.track); + const fx=state?.graph?.channels?.find(ch=>ch.id===id)?.inserts?.[current?.slot]; + if(!state?.admitted||!id||fx?.catalogId!==ID||fx?.id!==current?.instanceId)return null; + return {channelId:id,slot:current.slot,instanceId:fx.id, + deviceEpoch:state.device.epoch,graphRevision:state.graph.revision}; +}; +const hint=text=>{$("vtHint").textContent=text;}; +function syncPower(){ + const state=snapshot(),id=current&&window.__ARMIX_NATIVE_M2__?.nativeIdFor?.(current.track); + const lane=state?.graph?.channels?.find(ch=>ch.id===id),fx=lane?.inserts?.[current?.slot]; + const value=!context()?"unknown":lane.fxRackBypassed?"rack-off":fx.bypassed?"off":"on"; + const btn=$("vtPower");btn.dataset.state=value; + btn.disabled=value==="unknown"||value==="rack-off"; + btn.title=value==="on"?"Active · click to bypass":value==="off"?"Bypassed · click to enable": + value==="rack-off"?"FX rack bypassed":"Native FX unavailable"; + btn.setAttribute("aria-pressed",String(value==="on")); + $("vtThrow").disabled=value!=="on"||!!pending; +} +function paint(){ + $("vtMode").value=String(draft.mode);$("vtBpm").value=String(draft.bpm); + $("vtDivision").value=String(draft.division);$("vtRepeats").value=String(draft.repeats); + for(const [key,[,unit]] of Object.entries(fields)){ + const label=$("vtRanges").querySelector('[data-key="'+key+'"]'); + label.querySelector("input").value=String(draft[key]); + label.querySelector("output").textContent= + (unit==="%"?Math.round(draft[key]*100):Math.round(draft[key]))+unit; + } + $("vtPreset").value=Object.entries(presets).find(([,v])=>same(v,draft))?.[0]||"Custom"; + syncPower(); +} +function requestSnapshot(force=false){ + const ctx=context();if(!native()||!ctx||panel.hidden)return; + const now=Date.now();if(!force&&readId&&now-readSent<900)return; + readId="throwsnap-"+now+"-"+(++seq);readSent=now; + backend().emitEvent("arMixAction",{action:"nativeThrowSnapshot",requestId:readId,...ctx}); +} +function send(command){ + const ctx=context(); + if(!native()||!ctx){hint("Native DSP unavailable");return false;} + if(pending){hint("Waiting for DSP ACK");return false;} + if(command==="nativeThrowSet"&&(!valid(draft)||same(draft,accepted)))return false; + const requestId="throw-"+String(Date.now()*1000+(++seq%1000)); + pending={requestId,command,ack:false,created:Date.now()}; + const payload={action:command,requestId,...ctx}; + if(command==="nativeThrowSet")payload.settings={...draft}; + backend().emitEvent("arMixAction",payload); + hint(command==="nativeThrowTrigger"?"Waiting for audio callback":"Applying to DSP"); + syncPower();return true; +} +for(const [key,id] of [["mode","vtMode"],["bpm","vtBpm"], + ["division","vtDivision"],["repeats","vtRepeats"]]){ + $(id).addEventListener("change",()=>{ + draft={...draft,[key]:Number($(id).value)};paint();send("nativeThrowSet"); + }); +} +for(const key of Object.keys(fields)){ + const input=$("vtRanges").querySelector('[data-key="'+key+'"] input'); + input.addEventListener("input",()=>{ + const value=Number(input.value),bounds=ranges[key]; + draft={...draft,[key]:clamp(value,bounds[0],bounds[1])};paint(); + }); + input.addEventListener("change",()=>send("nativeThrowSet")); +} +$("vtPreset").addEventListener("change",()=>{ + const p=presets[$("vtPreset").value];if(!p)return; + draft={...p};paint();send("nativeThrowSet"); +}); +$("vtThrow").addEventListener("click",()=>send("nativeThrowTrigger")); +$("vtTap").addEventListener("click",()=>{ + const now=performance.now(); + if(taps.length&&now-taps[taps.length-1]>2500)taps=[]; + taps.push(now);if(taps.length>6)taps.shift(); + if(taps.length<3){hint("Tap at least three beats");return;} + const deltas=taps.slice(1).map((time,i)=>time-taps[i]).filter(v=>v>=280&&v<=1200); + if(deltas.length<2){hint("Tap a steady beat");return;} + const ordered=[...deltas].sort((a,b)=>a-b); + const median=ordered[Math.floor(ordered.length/2)]; + draft={...draft,bpm:clamp(Math.round(60000/median),60,200)}; + paint();send("nativeThrowSet"); +}); +$("vtPower").addEventListener("click",()=>{ + if(current&&context())window.__ARMIX_NATIVE_M2__?.consumeAction?.( + current.track,"slotPower",{dataset:{slot:String(current.slot)}}); +}); +$("vtClose").addEventListener("click",()=>{panel.hidden=true;pending=null;readId="";}); +window.addEventListener("keydown",e=>{ + if(e.key==="Escape"&&!panel.hidden){panel.hidden=true;pending=null;readId="";} +}); +const head=panel.querySelector("header"); +head.addEventListener("pointerdown",e=>{ + if(e.button||e.target.closest("button,select"))return; + const box=panel.getBoundingClientRect(); + windowDrag={id:e.pointerId,dx:e.clientX-box.left,dy:e.clientY-box.top}; + head.setPointerCapture(e.pointerId);e.preventDefault(); +}); +head.addEventListener("pointermove",e=>{ + if(!windowDrag||e.pointerId!==windowDrag.id)return; + panel.style.left=clamp(e.clientX-windowDrag.dx,0,Math.max(0,innerWidth-panel.offsetWidth))+"px"; + panel.style.top=clamp(e.clientY-windowDrag.dy,0,Math.max(0,innerHeight-panel.offsetHeight))+"px"; +}); +head.addEventListener("pointerup",e=>{windowDrag=null;head.releasePointerCapture?.(e.pointerId);}); +window.ArSonMixNativeVocalThrow=Object.freeze({ + id:ID, + insert(target){return Boolean(window.__ARMIX_NATIVE_M2__?.insertPlugin?.(ID,target));}, + open(track,slot){ + current={track,slot,instanceId:null};pending=null;readId=""; + const state=snapshot(),id=window.__ARMIX_NATIVE_M2__?.nativeIdFor?.(track); + const insert=state?.graph?.channels?.find(ch=>ch.id===id)?.inserts?.[slot]; + if(native()&&state?.admitted&&insert?.catalogId===ID&&insert.id){ + current.instanceId=insert.id;draft=defaults();accepted=defaults(); + hint("Reading accepted DSP settings"); + }else if(!native()){draft=defaults();accepted=defaults(); + hint("Browser preview only · no PCM");} + else hint("Native FX instance unavailable"); + $("vtChannel").textContent=track.name||"CH"; + panel.hidden=false;paint();requestSnapshot(true); + }, + close(){panel.hidden=true;} +}); +backend()?.addEventListener?.("arMixBuiltinThrowQueue",reply=>{ + if(!pending||reply?.requestId!==pending.requestId)return; + if(reply.status==="REJECTED"){hint("DSP rejected · "+(reply.errorCode||"STALE")); + pending=null;requestSnapshot(true);syncPower();} +}); +backend()?.addEventListener?.("arMixBuiltinThrowAck",reply=>{ + if(!pending||reply?.requestId!==pending.requestId)return; + if(reply.status!=="APPLIED"){hint("DSP rejected · "+(reply.errorCode||"UNKNOWN")); + pending=null;requestSnapshot(true);syncPower();return;} + if(pending.command==="nativeThrowTrigger"){hint("THROW executed by audio callback"); + pending=null;requestSnapshot(true);syncPower();} + else{pending.ack=true;requestSnapshot(true);} +}); +backend()?.addEventListener?.("arMixBuiltinThrowSnapshot",reply=>{ + if(panel.hidden||reply?.requestId!==readId)return; + readId="";readSent=0; + const ctx=context(); + if(!ctx||reply.status!=="ACCEPTED"||reply.channelId!==ctx.channelId|| + reply.instanceId!==ctx.instanceId||reply.deviceEpoch!==ctx.deviceEpoch|| + reply.graphRevision!==ctx.graphRevision||!valid(reply.settings)|| + reply.addedLatencySamples!==0){hint("Stale FX graph · reopen editor");return;} + $("vtCount").textContent=String(reply.throwCount||0)+" throws"; + $("vtDot").classList.toggle("active",reply.tailActive===true); + $("vtStatus").textContent=reply.tailActive?"ECHO TAIL":"NATIVE DSP"; + if(pending){ + if(!pending.ack||reply.appliedRequestId!==pending.requestId)return; + accepted={...reply.settings};draft={...accepted};pending=null; + hint("Native DSP settings accepted"); + }else{accepted={...reply.settings};draft={...accepted};} + paint(); +}); +backend()?.addEventListener?.("arMixConsoleSnapshot",()=>{ + if(panel.hidden)return; + if(native()&&!context()){pending=null;hint("FX graph changed · reopen");} + syncPower(); +}); +window.setInterval(()=>{ + if(panel.hidden)return; + if(pending&&Date.now()-pending.created>3500){hint("DSP ACK timeout");pending=null;} + if(native())requestSnapshot(); + syncPower(); +},250); +})(); From 6043d30b6618b54657aef0547cfbab912d01fd82 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:13:21 +0700 Subject: [PATCH 12/61] feat(vocal-throw): expose native effect in same FX picker and compiled approved GUI --- scripts/compose_native_peq.py | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/scripts/compose_native_peq.py b/scripts/compose_native_peq.py index 1a61cf2e5..b697a4349 100644 --- a/scripts/compose_native_peq.py +++ b/scripts/compose_native_peq.py @@ -5,6 +5,7 @@ CATALOG="armix.builtin.channel-eq.v1" SCRIPT='' COMP_SCRIPT='' +THROW_SCRIPT='' PICKER_HEAD="function renderFastPicker(){" PICKER_FN="""function insertChosenNativeEq(){ const t=tracks.concat(master).find(x=>x.id===activeFxTarget?.channelId); @@ -50,22 +51,44 @@ refreshStrip(t);setFastPicker(false); say('Compressor · browser preview ONLY · no audio DSP');return true; } +function insertChosenNativeThrow(){ + const t=tracks.concat(master).find(x=>x.id===activeFxTarget?.channelId); + const slot=Number(activeFxTarget?.slot); + if(!t||!Number.isInteger(slot)||slot<0||slot>=8){ + say('Vocal Throw · choose an empty FX insert');return false; + } + if(window.__JUCE__?.backend?.emitEvent){ + const host=window.ArSonMixNativeVocalThrow; + if(!host?.insert){say('Native Vocal Throw host unavailable');return false;} + host.insert(activeFxTarget);return true; + } + if(t.fx[slot]!=='None'){ + say('FX slot already occupied · choose an empty insert');return false; + } + t.fx[slot]='ArSon Vocal Throw';t.slotBypass[slot]=false; + t.fxInsertIds[slot]={id:'visual-throw-'+t.id+'-'+slot,name:'ArSon Vocal Throw'}; + refreshStrip(t);setFastPicker(false); + say('Vocal Throw · browser preview ONLY · no audio DSP');return true; +} function renderFastPicker(){""" PICKER_RENDER="plugEl('fastResults').innerHTML=list.length?list.map(p=>" PICKER_RENDER_NEW="""const eqBuiltin=!q||['parametric eq','peq','channel eq','built-in fx'].some(n=>n.includes(q))? '':''; const compBuiltin=!q||['compressor','comp','dynamics','built-in fx'].some(n=>n.includes(q))? '':''; - const builtin=(eqBuiltin||compBuiltin?'
BUILT-IN FX
':'')+eqBuiltin+compBuiltin; + const throwBuiltin=!q||['vocal throw','throw','delay','echo','phrase','concert','built-in fx'].some(n=>n.includes(q))? + '':''; + const builtin=(eqBuiltin||compBuiltin||throwBuiltin?'
BUILT-IN FX
':'')+eqBuiltin+compBuiltin+throwBuiltin; plugEl('fastResults').innerHTML=builtin+'
VST3 PLUGINS
'+(list.length?list.map(p=>""" PICKER_END=""").join(''):'
No matching effects
';""" PICKER_END_NEW=""").join(''):'
No matching effects
');""" PICKER_CLICK=" const btn=e.target.closest('[data-fast-id]');if(btn)insertCatalogPlugin(btn.dataset.fastId);" PICKER_CLICK_NEW=""" if(e.target.closest('[data-fast-native-eq]')){insertChosenNativeEq();return;} if(e.target.closest('[data-fast-native-comp]')){insertChosenNativeCompressor();return;} + if(e.target.closest('[data-fast-native-throw]')){insertChosenNativeThrow();return;} const btn=e.target.closest('[data-fast-id]');if(btn)insertCatalogPlugin(btn.dataset.fastId);""" PICKER_ENTER="if(b){e.preventDefault();insertCatalogPlugin(b.dataset.fastId);}" -PICKER_ENTER_NEW="if(b){e.preventDefault();if(b.hasAttribute('data-fast-native-eq'))insertChosenNativeEq();else if(b.hasAttribute('data-fast-native-comp'))insertChosenNativeCompressor();else insertCatalogPlugin(b.dataset.fastId);}" +PICKER_ENTER_NEW="if(b){e.preventDefault();if(b.hasAttribute('data-fast-native-eq'))insertChosenNativeEq();else if(b.hasAttribute('data-fast-native-comp'))insertChosenNativeCompressor();else if(b.hasAttribute('data-fast-native-throw'))insertChosenNativeThrow();else insertCatalogPlugin(b.dataset.fastId);}" OPEN=" if(a==='openPlugin'){openFastPicker(t,Number(btn.dataset.slot),btn);return;}" OPEN_NEW=""" if(a==='openPlugin'){ const index=Number(btn.dataset.slot); @@ -75,6 +98,9 @@ if(t.fx[index]==='Compressor'){ window.ArSonMixNativeCompressor?.open(t,index);return; } + if(t.fx[index]==='ArSon Vocal Throw'){ + window.ArSonMixNativeVocalThrow?.open(t,index);return; + } openFastPicker(t,index,btn);return; }""" def apply_native_peq(html: str)->str: @@ -85,11 +111,11 @@ def apply_native_peq(html: str)->str: (PICKER_ENTER,PICKER_ENTER_NEW), (OPEN,OPEN_NEW)) if html.count('')!=1 or html.count('')!=1 or \ - SCRIPT in html or COMP_SCRIPT in html or 'insertChosenNativeEq' in html: + SCRIPT in html or COMP_SCRIPT in html or THROW_SCRIPT in html or 'insertChosenNativeEq' in html: raise ValueError("Parametric EQ requires one pristine approved compiled GUI") for before,after in anchors: if html.count(before)!=1: raise ValueError('Ambiguous approved picker/editor anchor: '+before[:90]) html=html.replace(before,after,1) - html=html.replace('',SCRIPT+'\n'+COMP_SCRIPT+'\n',1) + html=html.replace('',SCRIPT+'\n'+COMP_SCRIPT+'\n'+THROW_SCRIPT+'\n',1) return html From 49034ce42d9801a7daabfd937c5e44f1ee051c25 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:13:53 +0700 Subject: [PATCH 13/61] feat(vocal-throw): open approved native editor for exact ChannelId FX insert --- web/approved-native-bridge.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index a4a16534e..d58c974e5 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -2737,6 +2737,8 @@ window.ArSonMixNativeEq?.open(t,slot); } else if(insert.catalogId==='armix.builtin.channel-compressor.v1') { window.ArSonMixNativeCompressor?.open(t,slot); + } else if(insert.catalogId==='armix.builtin.vocal-throw.v1') { + window.ArSonMixNativeVocalThrow?.open(t,slot); } else backend.emitEvent("arMixAction",{action:"routingFxEditor",channelId:id,slot, instanceId:insert.id,deviceEpoch:current.device.epoch,revision:current.graph.revision}); } else {discoverFxOnFirstPickerOpen();scope?.openFastPicker?.(t,slot,btn);} @@ -2933,7 +2935,8 @@ if(pendingFxInsert){status("FX INSERT · wait for previous native ACK");return true;} const plugin=nativeCatalog.get(id) || (id==='armix.builtin.channel-eq.v1'?{id,name:'Parametric EQ'}: - id==='armix.builtin.channel-compressor.v1'?{id,name:'Compressor'}:null); + id==='armix.builtin.channel-compressor.v1'?{id,name:'Compressor'}: + id==='armix.builtin.vocal-throw.v1'?{id,name:'ArSon Vocal Throw'}:null); const track=scope?.tracks?.find(x=>x.id===target?.channelId)|| (scope?.master?.id===target?.channelId?scope.master:null); const channel=m4Index(track),slot=Number(target?.slot); From 40621bd9d118c0d482aae2fbb4c320e15e31bd9e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:14:57 +0700 Subject: [PATCH 14/61] test(vocal-throw): verify manual and phrase-aware echo, BPM grid, dry bypass and RT heap safety --- tests/builtin_vocal_throw_test.cpp | 140 +++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 tests/builtin_vocal_throw_test.cpp diff --git a/tests/builtin_vocal_throw_test.cpp b/tests/builtin_vocal_throw_test.cpp new file mode 100644 index 000000000..092b71739 --- /dev/null +++ b/tests/builtin_vocal_throw_test.cpp @@ -0,0 +1,140 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#include "../engine/builtin_fx/VocalThrow.h" +#include +#include +#include +#include +#include +#include +#include +#include +#define check(x) do {if(!(x)){std::fprintf(stderr,"FAIL:%s:%d %s\n",__FILE__,__LINE__,#x);std::abort();}}while(false) +// Catch allocations from inside the audio callback, not from preparation. +static std::atomic noHeap{false}; +void* operator new(std::size_t n) { + if(noHeap.load(std::memory_order_relaxed))std::abort(); + if(void* p=std::malloc(n?n:1))return p; + throw std::bad_alloc(); +} +void* operator new[](std::size_t n) { + if(noHeap.load(std::memory_order_relaxed))std::abort(); + if(void* p=std::malloc(n?n:1))return p; + throw std::bad_alloc(); +} +void operator delete(void* p) noexcept{std::free(p);} +void operator delete[](void* p) noexcept{std::free(p);} +void operator delete(void* p,std::size_t) noexcept{std::free(p);} +void operator delete[](void* p,std::size_t) noexcept{std::free(p);} + +using armix::builtin_fx::VocalThrow; +using armix::builtin_fx::VocalThrowSettings; +static void run(VocalThrow& fx,float l,float r,int frames,float& maxL,float& maxR) { + std::array left{},right{}; + for(int begin=0;begin(n)); + noHeap.store(false,std::memory_order_release); + for(int i=0;i::quiet_NaN(); + check(!VocalThrow::prepareEdit(settings,48000,packet)); + settings=VocalThrowSettings{};settings.mode=3; + check(!VocalThrow::prepareEdit(settings,48000,packet)); + settings=VocalThrowSettings{};settings.repeats=7; + check(!VocalThrow::prepareEdit(settings,48000,packet)); + settings=VocalThrowSettings{};settings.captureMs=1550; + check(!VocalThrow::prepareEdit(settings,48000,packet)); +} +static void manualAndDry(double rate) { + VocalThrow fx;check(fx.prepare(rate)); + auto s=fx.settingsForTests();s.mode=0;s.captureMs=300;s.silenceMs=150; + check(fx.resetUnpublished(s)); + float peakL=0,peakR=0; + // No trigger: the leading vocalist is bit-exact dry, even in an insert. + std::array left{},right{}; + left.fill(.35f);right.fill(-.20f); + noHeap.store(true); + fx.processStereo(left.data(),right.data(),left.size()); + noHeap.store(false); + for(std::size_t n=0;n(rate*.35),peakL,peakR); + run(fx,0,0,static_cast(rate*.06),peakL,peakR); + check(fx.throwCount()==0); + noHeap.store(true); + const bool fired=fx.throwNow(); + noHeap.store(false); + check(fired&&fx.throwCount()==1); + peakL=peakR=0; + run(fx,0,0,static_cast(rate*.10),peakL,peakR); + check(peakL==0&&peakR==0); // beat-scheduled, no immediate echo smear + run(fx,0,0,static_cast(rate*.75),peakL,peakR); + check(peakL>.01f&&peakR>.005f); + // Recorded stereo is preserved (same gain on both channels). + check(peakL>peakR*1.4f); +} +static void automaticAndHybrid(double rate) { + VocalThrow fx;check(fx.prepare(rate)); + auto s=fx.settingsForTests(); + s.mode=1;s.captureMs=220;s.silenceMs=120;s.thresholdDb=-30; + check(fx.resetUnpublished(s)); + float l=0,r=0; + run(fx,.5f,.35f,static_cast(rate*.3),l,r); + run(fx,0,0,static_cast(rate*.23),l,r); + check(fx.throwCount()==1); + run(fx,0,0,static_cast(rate*1.0),l,r); + check(fx.throwCount()==1); // no retrigger on the echoed tail + run(fx,.5f,.35f,static_cast(rate*.28),l,r); + run(fx,0,0,static_cast(rate*.23),l,r); + check(fx.throwCount()==2); + +} +static void hybridEditAndNoHeap() { + VocalThrow fx;check(fx.prepare(48000)); + VocalThrowSettings s{};s.mode=2;s.bpm=95;s.division=1;s.repeats=6; + VocalThrow::PreparedEdit edit{};check(VocalThrow::prepareEdit(s,48000,edit)); + check(!fx.applyPrepared(VocalThrow::PreparedEdit{})); + auto stale=edit;stale.sampleRate=44100;check(!fx.applyPrepared(stale)); + noHeap.store(true);const bool ok=fx.applyPrepared(edit);noHeap.store(false); + check(ok); + float l=0,r=0; + run(fx,.4f,.2f,10000,l,r); + noHeap.store(true);const bool fired=fx.throwNow();noHeap.store(false); + check(fired); + run(fx,0,0,200000,l,r); + check(std::isfinite(l)&&std::isfinite(r)); +} +int main() { + validation(); + manualAndDry(8000); + manualAndDry(44100); + manualAndDry(48000); + automaticAndHybrid(8000); + automaticAndHybrid(48000); + hybridEditAndNoHeap(); + std::puts("PASS: vocal-throw native dry/rolling capture/phrase/echo/tempo/no-heap"); +} From 4fc0de858313e69ea4ecb09f2ef303dbbea70d64 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:15:22 +0700 Subject: [PATCH 15/61] fix(vocal-throw): use faster vocal-end envelope for responsive phrase triggering --- engine/builtin_fx/VocalThrow.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/builtin_fx/VocalThrow.h b/engine/builtin_fx/VocalThrow.h index 1ca18fbfa..a46c7512d 100644 --- a/engine/builtin_fx/VocalThrow.h +++ b/engine/builtin_fx/VocalThrow.h @@ -203,7 +203,7 @@ class VocalThrow final { envelope_=0.f;duck_=1.f;throwCount_=0; if(rate_>0) { envAttack_=static_cast(std::exp(-1./(rate_*.004))); - envRelease_=static_cast(std::exp(-1./(rate_*.060))); + envRelease_=static_cast(std::exp(-1./(rate_*.018))); duckCoeff_=static_cast(std::exp(-1./(rate_*.008))); } repeatStarts_.fill(0);repeatGains_.fill(0.f); From d37aa3a0bf1d1dc983cfe1aa2896a7e0c5009419 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:17:12 +0700 Subject: [PATCH 16/61] perf(vocal-throw): amortize frozen phrase copy with fixed RT work budget --- engine/builtin_fx/VocalThrow.h | 53 ++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/engine/builtin_fx/VocalThrow.h b/engine/builtin_fx/VocalThrow.h index a46c7512d..f85ea3af8 100644 --- a/engine/builtin_fx/VocalThrow.h +++ b/engine/builtin_fx/VocalThrow.h @@ -134,12 +134,13 @@ class VocalThrow final { armed_=false; } } + if(copyPending_)copyFrozenChunk(); // fixed real-time budget float echoL=0.f,echoR=0.f; if(playing_) { // A new manual throw replaces the old tail atomically. // Each voice has a fixed offset in the captured buffer; // multiple phrases may overlap at short note divisions. - for(int tap=0;tap(tap)]; if(clock_<=start)continue; const std::uint64_t offset=clock_-start-1; @@ -155,7 +156,7 @@ class VocalThrow final { const float gain=repeatGains_[static_cast(tap)]*std::max(0.f,ramp); echoL+=freezeL_[p]*gain;echoR+=freezeR_[p]*gain; } - const auto end=repeatStarts_[static_cast(settings_.settings.repeats-1)] + const auto end=repeatStarts_[static_cast(active_.settings.repeats-1)] +freezeCount_; if(clock_>end)playing_=false; } @@ -177,29 +178,39 @@ class VocalThrow final { const auto available=std::min(end,recorded_); const auto count=std::min(available,settings_.captureSamples); if(count(rate_*.025))return false; - const auto from=end-count; - for(std::uint64_t i=0;i((from+i)%historyL_.size()); - freezeL_[static_cast(i)]=historyL_[source]; - freezeR_[static_cast(i)]=historyR_[source]; + // No large memcpy in a 64/128-sample ASIO callback. Copy only a + // fixed number of stereo frames per processed sample before playback. + copyFrom_=end-count;copyEnd_=end;copyIndex_=0; + freezeCount_=count;active_=settings_; + playing_=false;copyPending_=true;++throwCount_; + return true; + } + void copyFrozenChunk() noexcept { + if(!copyPending_)return; + for(int n=0;n<24 && copyIndex_( + (copyFrom_+copyIndex_)%historyL_.size()); + const auto dest=static_cast(copyIndex_++); + freezeL_[dest]=historyL_[source];freezeR_[dest]=historyR_[source]; } - freezeCount_=count; - // Wait until the next subdivision after the detected phrase end; - // if the silence detector was late, fire immediately (never in past). - const std::uint64_t first=std::max(clock_,end+settings_.intervalSamples); + if(copyIndex_!=freezeCount_)return; + copyPending_=false; + // The phrase-end interval is authoritative. If capture completion + // is later than the first repeat, begin on the next safe sample. + const auto first=std::max(clock_,copyEnd_+active_.intervalSamples); float amplitude=1.f; - for(int tap=0;tap(tap); - repeatStarts_[slot]=first+static_cast(tap)*settings_.intervalSamples; - repeatGains_[slot]=amplitude;amplitude*=settings_.settings.decay; + repeatStarts_[slot]=first+ + static_cast(tap)*active_.intervalSamples; + repeatGains_[slot]=amplitude;amplitude*=active_.settings.decay; } - playing_=true;++throwCount_; - return true; + playing_=true; } void reset() noexcept { clock_=lastSoundEnd_=nextAutoEligible_=0; - recorded_=freezeCount_=0; - voiced_=quiet_=0;armed_=playing_=false; + recorded_=freezeCount_=0;copyFrom_=copyEnd_=copyIndex_=0; + voiced_=quiet_=0;armed_=playing_=copyPending_=false; envelope_=0.f;duck_=1.f;throwCount_=0; if(rate_>0) { envAttack_=static_cast(std::exp(-1./(rate_*.004))); @@ -210,17 +221,17 @@ class VocalThrow final { std::fill(historyL_.begin(),historyL_.end(),0.f); std::fill(historyR_.begin(),historyR_.end(),0.f); } - PreparedEdit settings_{}; + PreparedEdit settings_{},active_{}; std::vector historyL_,historyR_,freezeL_,freezeR_; std::array repeatStarts_{}; std::array repeatGains_{}; std::uint64_t clock_=0,lastSoundEnd_=0,nextAutoEligible_=0; std::size_t recorded_=0; - std::uint64_t freezeCount_=0; + std::uint64_t freezeCount_=0,copyFrom_=0,copyEnd_=0,copyIndex_=0; std::uint32_t voiced_=0,quiet_=0; float envelope_=0.f,envAttack_=0.f,envRelease_=0.f,duckCoeff_=0.f,duck_=1.f; double rate_=0.; unsigned throwCount_=0; - bool armed_=false,playing_=false,ready_=false; + bool armed_=false,playing_=false,copyPending_=false,ready_=false; }; } // namespace armix::builtin_fx From 04d8dc7924cfb77aea3768c888db71918c39d6e8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:18:38 +0700 Subject: [PATCH 17/61] fix(vocal-throw): share approved 24px close-button chrome and red pressed feedback --- site/preview-v2/assets/mixer-native-vocal-throw.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/preview-v2/assets/mixer-native-vocal-throw.js b/site/preview-v2/assets/mixer-native-vocal-throw.js index a6384307b..bfa870516 100644 --- a/site/preview-v2/assets/mixer-native-vocal-throw.js +++ b/site/preview-v2/assets/mixer-native-vocal-throw.js @@ -52,7 +52,7 @@ panel.setAttribute("aria-label","ArSon Vocal Throw"); panel.innerHTML=[ '
Vocal Throw', '', - '
', + '', '
TRIGGER MODE
', '
', '
', From 7475cf63532aff8a46db7d627577b226de5666f3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:21:28 +0700 Subject: [PATCH 18/61] test(vocal-throw): guard single approved picker, editor, DSP ACK and bundled asset --- tests/native_peq_assembly_test.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/native_peq_assembly_test.py b/tests/native_peq_assembly_test.py index 890d798f1..647eb4851 100644 --- a/tests/native_peq_assembly_test.py +++ b/tests/native_peq_assembly_test.py @@ -24,6 +24,9 @@ def test_one_authoritative_mixer(self): self.assertEqual(self.assembled.count('src="assets/mixer-native-peq.js?v=eq-graph1"'),1) self.assertEqual(self.assembled.count('src="assets/mixer-native-compressor.js?v=comp-1"'),1) self.assertEqual(self.assembled.count("function insertChosenNativeCompressor(){"),1) + self.assertEqual(self.assembled.count("function insertChosenNativeThrow(){"),1) + self.assertEqual(self.assembled.count('src="assets/mixer-native-vocal-throw.js?v=throw-1"'),1) + self.assertEqual(self.assembled.count('data-fast-native-throw="1"'),1) def test_native_rack_uses_regular_insert_slot(self): self.assertIn("host.insert(activeFxTarget)",self.assembled) @@ -35,6 +38,7 @@ def test_native_rack_uses_regular_insert_slot(self): self.assertEqual(self.assembled.count('data-fast-native-eq="1"'),1) self.assertEqual(self.assembled.count('data-fast-native-comp="1"'),1) self.assertIn("if(t.fx[index]==='Compressor')",self.assembled) + self.assertIn("if(t.fx[index]==='ArSon Vocal Throw')",self.assembled) def test_single_style_owner(self): # The approved CSS compiler requires exactly 18 component-owner links. @@ -54,6 +58,13 @@ def test_single_style_owner(self): self.assertIn('addedLatencySamples!==0',compressor) self.assertNotIn("new AudioContext",compressor) self.assertIn(".mx-comp[hidden]{display:none}",css) + throw=(ROOT/"site/preview-v2/assets/mixer-native-vocal-throw.js").read_text("utf-8") + self.assertIn("arMixBuiltinThrowAck",throw) + self.assertIn("arMixBuiltinThrowSnapshot",throw) + self.assertIn("nativeThrowTrigger",throw) + self.assertIn('id="vtPreset"',throw) + self.assertIn("armix-floating-close",throw) + self.assertNotIn("new AudioContext",throw) def test_fail_closed_on_repeat(self): with self.assertRaises(ValueError): From 4d6e677bc48ec506dfbc250524d02df963891402 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:22:11 +0700 Subject: [PATCH 19/61] style(vocal-throw): integrate compact editor in existing FX CSS owner --- site/preview-v2/assets/mixer-fx-rack.css | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/site/preview-v2/assets/mixer-fx-rack.css b/site/preview-v2/assets/mixer-fx-rack.css index 54a22709d..43bfac31a 100644 --- a/site/preview-v2/assets/mixer-fx-rack.css +++ b/site/preview-v2/assets/mixer-fx-rack.css @@ -397,3 +397,22 @@ @media(max-height:350px){ .mx-comp{top:4px;max-height:calc(100dvh - 8px)} } + +/* ArSon Vocal Throw shares the single approved FX CSS owner. */ +.mx-vthrow{position:fixed;z-index:15001;left:12vw;top:110px;width:min(410px,calc(100vw - 20px));box-sizing:border-box;background:#16232d;color:#dce8ef;font:12px/1.4 Inter,Arial,sans-serif;border:1px solid #385064;border-radius:10px;box-shadow:0 18px 45px #000b;overflow:hidden} +.mx-vthrow[hidden]{display:none}.mx-vthrow *{box-sizing:border-box} +.mx-vthrow header{display:flex;gap:7px;align-items:center;padding:8px 10px;background:#20313d;border-bottom:1px solid #354b5b;user-select:none;cursor:move} +.mx-vthrow .brand{font-weight:600;font-size:13px;white-space:nowrap}.mx-vthrow .channel{flex:1;color:#99b2c4;font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} +.mx-vthrow select,.mx-vthrow input{background:#101c26;color:#e6f1f9;border:1px solid #41576a;border-radius:5px;font:inherit;min-height:26px;max-width:100%} +.mx-vthrow select{padding:3px 5px;cursor:pointer}.mx-vthrow button{background:#2a3c49;color:#dcebf3;border:1px solid #456072;border-radius:5px;font:inherit;cursor:pointer;min-height:27px} +.mx-vthrow button:hover{background:#37576a}.mx-vthrow button:disabled{opacity:.5;cursor:default}.mx-vthrow .power{min-width:26px;font-size:15px} +.mx-vthrow .power[data-state=on]{color:#99f5bd;background:#23503d}.mx-vthrow .power[data-state=off]{color:#f5a4a4;background:#593238} +.mx-vthrow .close{font-size:18px;border:0;border-radius:5px;min-width:26px;background:transparent}.mx-vthrow .close:hover{background:#b8333f;color:#fff} +.mx-vthrow .body{padding:11px;display:grid;gap:10px}.mx-vthrow .row{display:flex;align-items:center;justify-content:space-between;gap:9px} +.mx-vthrow .topline{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}.mx-vthrow .field{display:grid;gap:4px;min-width:0} +.mx-vthrow label,.mx-vthrow .label{color:#9fb6c5;font-size:10px;letter-spacing:.035em}.mx-vthrow .field input{width:100%;padding:4px 7px} +.mx-vthrow .manual{display:grid;grid-template-columns:1fr 80px;gap:9px}.mx-vthrow .throw{background:#277d9b;font-size:13px;font-weight:600;min-height:46px;letter-spacing:.07em}.mx-vthrow .throw:hover{background:#2b9ebf}.mx-vthrow .tap{min-height:46px} +.mx-vthrow .hint{color:#8fb1c2;min-height:15px;font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mx-vthrow .detail{border-top:1px solid #334b5b;padding-top:8px} +.mx-vthrow details>summary{cursor:pointer;color:#bad1df;padding-bottom:7px;font-size:11px}.mx-vthrow .ranges{display:grid;grid-template-columns:1fr 1fr;gap:8px 13px} +.mx-vthrow .range{display:grid;grid-template-columns:1fr auto;gap:3px}.mx-vthrow .range input{grid-column:1/-1;width:100%;height:15px;accent-color:#56bada} +.mx-vthrow output{font-variant-numeric:tabular-nums;font-size:11px}.mx-vthrow .status{display:flex;justify-content:space-between;font-size:10px;color:#89a6b8}.mx-vthrow .dot{display:inline-block;border-radius:50%;width:6px;height:6px;background:#7892a3;margin-right:5px}.mx-vthrow .dot.active{background:#55ddac} From 1fdb7c281fe6d99d6b08afbe8353a085affb4dd6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:22:13 +0700 Subject: [PATCH 20/61] refactor(vocal-throw): remove runtime CSS injection, reuse canonical FX stylesheet --- .../assets/mixer-native-vocal-throw.js | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/site/preview-v2/assets/mixer-native-vocal-throw.js b/site/preview-v2/assets/mixer-native-vocal-throw.js index bfa870516..f24859635 100644 --- a/site/preview-v2/assets/mixer-native-vocal-throw.js +++ b/site/preview-v2/assets/mixer-native-vocal-throw.js @@ -24,27 +24,7 @@ const clamp=(v,min,max)=>Math.max(min,Math.min(max,v)); const backend=()=>window.__JUCE__?.backend; const native=()=>typeof backend()?.emitEvent==="function"; const snapshot=()=>window.__ARMIX_NATIVE_M2__?.state?.()?.current; -const style=document.createElement("style"); -style.textContent=[ - ".mx-vthrow{position:fixed;z-index:15001;left:12vw;top:110px;width:min(410px,calc(100vw - 20px));box-sizing:border-box;background:#16232d;color:#dce8ef;font:12px/1.4 Inter,Arial,sans-serif;border:1px solid #385064;border-radius:10px;box-shadow:0 18px 45px #000b;overflow:hidden}", - ".mx-vthrow[hidden]{display:none}.mx-vthrow *{box-sizing:border-box}", - ".mx-vthrow header{display:flex;gap:7px;align-items:center;padding:8px 10px;background:#20313d;border-bottom:1px solid #354b5b;user-select:none;cursor:move}", - ".mx-vthrow .brand{font-weight:600;font-size:13px;white-space:nowrap}.mx-vthrow .channel{flex:1;color:#99b2c4;font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", - ".mx-vthrow select,.mx-vthrow input{background:#101c26;color:#e6f1f9;border:1px solid #41576a;border-radius:5px;font:inherit;min-height:26px;max-width:100%}", - ".mx-vthrow select{padding:3px 5px;cursor:pointer}.mx-vthrow button{background:#2a3c49;color:#dcebf3;border:1px solid #456072;border-radius:5px;font:inherit;cursor:pointer;min-height:27px}", - ".mx-vthrow button:hover{background:#37576a}.mx-vthrow button:disabled{opacity:.5;cursor:default}.mx-vthrow .power{min-width:26px;font-size:15px}", - ".mx-vthrow .power[data-state=on]{color:#99f5bd;background:#23503d}.mx-vthrow .power[data-state=off]{color:#f5a4a4;background:#593238}", - ".mx-vthrow .close{font-size:18px;border:0;border-radius:5px;min-width:26px;background:transparent}.mx-vthrow .close:hover{background:#b8333f;color:#fff}", - ".mx-vthrow .body{padding:11px;display:grid;gap:10px}.mx-vthrow .row{display:flex;align-items:center;justify-content:space-between;gap:9px}", - ".mx-vthrow .topline{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}.mx-vthrow .field{display:grid;gap:4px;min-width:0}", - ".mx-vthrow label,.mx-vthrow .label{color:#9fb6c5;font-size:10px;letter-spacing:.035em}.mx-vthrow .field input{width:100%;padding:4px 7px}", - ".mx-vthrow .manual{display:grid;grid-template-columns:1fr 80px;gap:9px}.mx-vthrow .throw{background:#277d9b;font-size:13px;font-weight:600;min-height:46px;letter-spacing:.07em}.mx-vthrow .throw:hover{background:#2b9ebf}.mx-vthrow .tap{min-height:46px}", - ".mx-vthrow .hint{color:#8fb1c2;min-height:15px;font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mx-vthrow .detail{border-top:1px solid #334b5b;padding-top:8px}", - ".mx-vthrow details>summary{cursor:pointer;color:#bad1df;padding-bottom:7px;font-size:11px}.mx-vthrow .ranges{display:grid;grid-template-columns:1fr 1fr;gap:8px 13px}", - ".mx-vthrow .range{display:grid;grid-template-columns:1fr auto;gap:3px}.mx-vthrow .range input{grid-column:1/-1;width:100%;height:15px;accent-color:#56bada}", - ".mx-vthrow output{font-variant-numeric:tabular-nums;font-size:11px}.mx-vthrow .status{display:flex;justify-content:space-between;font-size:10px;color:#89a6b8}.mx-vthrow .dot{display:inline-block;border-radius:50%;width:6px;height:6px;background:#7892a3;margin-right:5px}.mx-vthrow .dot.active{background:#55ddac}" -].join("\n"); -document.head.append(style); + const panel=document.createElement("section"); panel.className="mx-vthrow";panel.id="mxNativeVocalThrow";panel.hidden=true; panel.setAttribute("role","dialog");panel.setAttribute("aria-modal","false"); From a493896cdb4a78d48b65c6e3e904c2bbc4820f1b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:23:22 +0700 Subject: [PATCH 21/61] docs(vocal-throw): live DSP architecture, acceptance test and auto-BPM scope boundary --- docs/ARSON_VOCAL_THROW_NATIVE_20261108.md | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 docs/ARSON_VOCAL_THROW_NATIVE_20261108.md diff --git a/docs/ARSON_VOCAL_THROW_NATIVE_20261108.md b/docs/ARSON_VOCAL_THROW_NATIVE_20261108.md new file mode 100644 index 000000000..d205881af --- /dev/null +++ b/docs/ARSON_VOCAL_THROW_NATIVE_20261108.md @@ -0,0 +1,40 @@ +# ArSon Vocal Throw — native phrase-aware live delay + +**Status: functional prototype on a separate feature branch; not a certified live-performance release.** + +This is a first-class native ChannelId insert in ArSonMix's single JUCE PCM render graph, not a second audio callback, browser-generated sound or independent DAW. + +## Implemented + +- **Manual:** rolling ring buffer holds up to 1.5 seconds of the most recent vocal. THROW captures a word or phrase and schedules up to six decaying repeats. +- **Auto:** energy envelope, minimum voice duration, silence threshold and cooldown detect the end of a sung phrase without letting the wet echo re-trigger itself. +- **Hybrid (default):** phrase-end automation and manual cue together. +- **Tempo:** BPM entry (60-200), TAP BPM, quarter/eighth/dotted-eighth/half note subdivisions. Interval timing is in native samples at the actual device rate. +- **Mix:** direct dry input with zero added samples, stereo echo, decay, short fades, and ducking while the singer is active. +- **Real-time:** all rolling/frozen buffers are allocated off-callback; a fixed 24-stereo-frame-per-sample capture copy budget avoids a single large callback memcpy. A lock-free SPSC transfers host settings and manual cue to the audio callback. Callback never allocates/logs/locks. +- **Identity & persistence:** stable native catalog ID; ChannelId, device epoch, graph revision, and insert instance fencing. DSP completed ACK and later readback precede accepted display. Schema-versioned 48-byte AVTH settings blob validated during Show restore; audio capture and tails are not persisted. +- **UX:** a compact FX editor inside the exact approved /preview/ mixer; presets in header, uniform power/close, BPM/note/repeat, THROW, TAP and collapsible advanced controls. One shared FX stylesheet. + +## Architecture + +Hardware input → ChannelId mixer strip → upstream EQ/Compressor/VST3 → VocalThrowProcessor → downstream inserts → fader/pan → WIRE/BUS/MAIN → hardware output. + +Core files: engine/builtin_fx/VocalThrow.h (DSP), VocalThrowProcessor.h (JUCE), src/LiveAudioEngine.h (graph install), src/Main.cpp (validated command/readback), src/NativeMixerSessionFxRestore.h (versioned state), scripts/compose_native_peq.py (one picker), web/approved-native-bridge.js (real insert), site/preview-v2/assets/mixer-native-vocal-throw.js (controls only). + +## Tests / qualification + +The ARMixNativeVocalThrowTests CTest covers zero-added-sample dry, tempo divisions, captured stereo echoes after manual cue, auto-end detection and no self-trigger, bad parameter rejection, 8/44.1/48 kHz sample rates and a global allocator guard around realtime processing. Python native picker/compiled-gui tests enforce no extra mixer screen and real-ACK event names. + +Before shipping: exact-SHA Windows MSVC + CTest, actual approved /preview/ Chromium screenshots, ASIO 64/128-frame stress at 44.1/48/96 kHz, live singer audition, device restart, bypass/tail behavior, and Show restore. + +## Explicit limitations + +1. **Automatic BPM analysis from the music/backing bus is not yet implemented.** Auto currently means automatic vocal phrase-end trigger, not auto-estimated music tempo. BPM is entered or TAP-derived. Full beat tracking requires an independent music-bus feed, beat confidence and phase tracking. +2. Voice end detector uses an adjustable energy-envelope heuristic, not linguistic speech recognition or a trained singing model. Breaths, falsetto and microphone bleed can cause false cues. +3. No MIDI footswitch binding, simultaneous phrase layers, stretchable echo phrases, global music BPM transport integration, or direct song-snapshot binding in this milestone. +4. Green quick CI is not equivalent to real Windows native compilation or ASIO device certification. +5. Existing channel routing and independent secondary audio clock remain authoritative; the FX insert makes no new claims about unresolved WIRE/SOURCE ONLY issues. + +## Field test + +Insert ID armix.builtin.vocal-throw.v1 into real ChannelId vocal strip; confirm graph ACK; sing “atau tidak” then press THROW at 72/95/120/160 BPM; try Auto with varying held notes and short breaths; toggle bypass while dry vocal remains direct; change device/quantum and reject stale instance requests. Compare physical ASIO callback xruns, stereo/feedback, click-free fades and singer subjective quality. From d24014835164cb4f4fc54dbbfa533213b74a4b97 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:23:43 +0700 Subject: [PATCH 22/61] ci(vocal-throw): verify native FX editor syntax in existing cheap UI lane --- .github/workflows/ui-smoke.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ui-smoke.yml b/.github/workflows/ui-smoke.yml index 257a1396c..093c32350 100644 --- a/.github/workflows/ui-smoke.yml +++ b/.github/workflows/ui-smoke.yml @@ -107,6 +107,7 @@ jobs: node --check site/preview-v2/assets/gui-perf-probe.js node --check site/preview-v2/assets/mixer-native-peq.js node --check site/preview-v2/assets/mixer-native-compressor.js + node --check site/preview-v2/assets/mixer-native-vocal-throw.js python tests/native_peq_assembly_test.py python tests/approved_operator_ux_smoke.py python scripts/build_ui_css.py --check From c035f406bf2009230bfef8d753ab0bb2c95661d9 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:25:45 +0700 Subject: [PATCH 23/61] fix(vocal-throw): bound compact editor to mobile viewport and allow vertical overflow --- site/preview-v2/assets/mixer-fx-rack.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/site/preview-v2/assets/mixer-fx-rack.css b/site/preview-v2/assets/mixer-fx-rack.css index 43bfac31a..998e29db4 100644 --- a/site/preview-v2/assets/mixer-fx-rack.css +++ b/site/preview-v2/assets/mixer-fx-rack.css @@ -399,7 +399,7 @@ } /* ArSon Vocal Throw shares the single approved FX CSS owner. */ -.mx-vthrow{position:fixed;z-index:15001;left:12vw;top:110px;width:min(410px,calc(100vw - 20px));box-sizing:border-box;background:#16232d;color:#dce8ef;font:12px/1.4 Inter,Arial,sans-serif;border:1px solid #385064;border-radius:10px;box-shadow:0 18px 45px #000b;overflow:hidden} +.mx-vthrow{position:fixed;z-index:15001;left:clamp(10px,12vw,170px);top:clamp(10px,12vh,100px);width:min(410px,calc(100vw - 20px));max-height:calc(100dvh - 20px);overflow:auto;box-sizing:border-box;background:#16232d;color:#dce8ef;font:12px/1.4 Inter,Arial,sans-serif;border:1px solid #385064;border-radius:10px;box-shadow:0 18px 45px #000b;overflow:hidden} .mx-vthrow[hidden]{display:none}.mx-vthrow *{box-sizing:border-box} .mx-vthrow header{display:flex;gap:7px;align-items:center;padding:8px 10px;background:#20313d;border-bottom:1px solid #354b5b;user-select:none;cursor:move} .mx-vthrow .brand{font-weight:600;font-size:13px;white-space:nowrap}.mx-vthrow .channel{flex:1;color:#99b2c4;font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap} @@ -416,3 +416,4 @@ .mx-vthrow details>summary{cursor:pointer;color:#bad1df;padding-bottom:7px;font-size:11px}.mx-vthrow .ranges{display:grid;grid-template-columns:1fr 1fr;gap:8px 13px} .mx-vthrow .range{display:grid;grid-template-columns:1fr auto;gap:3px}.mx-vthrow .range input{grid-column:1/-1;width:100%;height:15px;accent-color:#56bada} .mx-vthrow output{font-variant-numeric:tabular-nums;font-size:11px}.mx-vthrow .status{display:flex;justify-content:space-between;font-size:10px;color:#89a6b8}.mx-vthrow .dot{display:inline-block;border-radius:50%;width:6px;height:6px;background:#7892a3;margin-right:5px}.mx-vthrow .dot.active{background:#55ddac} +@media(max-width:480px){.mx-vthrow{left:10px;top:10px}} From 62edf741124c4a11f707cbbe3e23b1506dd222fe Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:26:34 +0700 Subject: [PATCH 24/61] test(vocal-throw): Chromium native FX insertion, manual cue ACK and compact desktop/mobile UI --- tests/approved_native_vocal_throw_smoke.py | 134 +++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 tests/approved_native_vocal_throw_smoke.py diff --git a/tests/approved_native_vocal_throw_smoke.py b/tests/approved_native_vocal_throw_smoke.py new file mode 100644 index 000000000..ea8421625 --- /dev/null +++ b/tests/approved_native_vocal_throw_smoke.py @@ -0,0 +1,134 @@ +"""Real approved /preview/ bundle: ArSon Vocal Throw picker, insert, native ACK. +The JUCE event transport is emulated, NOT the native DSP nor singing quality. +DSP is independently tested in standalone CTest on Windows.""" +import copy +import importlib.util +from pathlib import Path +import tempfile +from playwright.sync_api import sync_playwright +from approved_native_wire_gain_smoke import snapshot, emit, ack, SOURCE + +ROOT=Path(__file__).resolve().parents[1] +ID="armix.builtin.vocal-throw.v1" +INSTANCE="vocal-throw-test-instance" +DEFAULTS={"mode":2,"bpm":120,"division":0,"repeats":3, + "captureMs":460,"silenceMs":220,"thresholdDb":-35, + "wet":.42,"decay":.55,"ducking":.7} + +def last(page,action): + records=page.evaluate("name=>window.__actions.filter(x=>x.action===name)",action) + assert records, "No "+action+" event" + return records[-1] + +def reply_snapshot(page,state,settings,applied=None,count=0,tail=False): + act=last(page,"nativeThrowSnapshot") + data={"requestId":act["requestId"],"channelId":SOURCE,"slot":0, + "instanceId":INSTANCE,"status":"ACCEPTED","schemaVersion":1, + "deviceEpoch":state["device"]["epoch"], + "graphRevision":state["graph"]["revision"],"sampleRate":48000, + "addedLatencySamples":0,"throwCount":count,"tailActive":tail, + "settings":copy.deepcopy(settings)} + if applied:data["appliedRequestId"]=applied + emit(page,"arMixBuiltinThrowSnapshot",data) + +def main(): + spec=importlib.util.spec_from_file_location( + "bundle",ROOT/"scripts/build_approved_native_gui.py") + bundle=importlib.util.module_from_spec(spec);spec.loader.exec_module(bundle) + with tempfile.TemporaryDirectory(prefix="armix-throw-") as directory,sync_playwright() as pw: + out=Path(directory);bundle.stage(out) + browser=pw.chromium.launch(headless=True) + for width,height in [(1366,768),(390,844)]: + page=browser.new_page(viewport={"width":width,"height":height}) + errors=[] + page.on("pageerror",lambda e:errors.append(str(e))) + page.add_init_script("""window.__nativeListeners=new Map(); + window.__nativeIntents=[];window.__actions=[]; + window.__JUCE__={backend:{ + emitEvent(name,payload){ + if(name==='arMixConsoleIntent')window.__nativeIntents.push(payload); + if(name==='arMixAction')window.__actions.push(payload);}, + addEventListener(name,callback){ + const old=window.__nativeListeners.get(name); + window.__nativeListeners.set(name,old? + payload=>{old(payload);callback(payload);}:callback);}}};""") + page.goto((out/"index.html").as_uri()) + page.wait_for_function("()=>window.__ARMIX_NATIVE_M2__?.enabled && window.ArSonMixNativeVocalThrow") + state=snapshot() + state["graph"]["capabilities"]["supportedOps"]+=["LOAD_INSERT","REMOVE_INSERT","MOVE_INSERT"] + emit(page,"arMixConsoleSnapshot",state) + if width<=500:page.locator("#bankSelect").select_option("0") + strip=page.locator('#tracks .strip[data-id="1"]') + strip.locator('.fx-pick.empty').first.click() + picker=page.locator("#fastResults [data-fast-native-throw]") + picker.wait_for(state="visible") + assert picker.count()==1,"exactly one Vocal Throw built-in picker option" + picker.click() + intents=page.evaluate("""()=>window.__nativeIntents.filter( + x=>x.operation==='LOAD_INSERT')""") + assert len(intents)==1,intents + assert intents[0]["payload"]["catalogId"]==ID + assert page.locator("#mxNativeVocalThrow").is_hidden(),"no editor before accepted insert" + state["graph"].update(revision="3",rosterRevision="3") + state["graph"]["channels"][0]["fxRackBypassed"]=False + state["graph"]["channels"][0]["inserts"].append({ + "id":INSTANCE,"catalogId":ID,"name":"ArSon Vocal Throw","bypassed":False}) + state["mixerSession"].update(routeRevision="3",rosterRevision="3", + channels=copy.deepcopy(state["graph"]["channels"])) + ack(page,state,intents[0]);emit(page,"arMixConsoleSnapshot",state) + row=strip.locator('.fxslot-row[data-insert-id="'+INSTANCE+'"]') + row.wait_for(state="visible") + page.keyboard.press("Escape") + row.locator('[data-action="openPlugin"]').click() + editor=page.locator("#mxNativeVocalThrow") + editor.wait_for(state="visible") + assert editor.locator("#vtPreset").count()==1 + assert editor.locator("#vtClose.armix-floating-close").count()==1 + assert editor.locator("#vtPower").get_attribute("data-state")=="on" + assert editor.locator("#vtMode").input_value()=="2" + initial=last(page,"nativeThrowSnapshot") + page.wait_for_timeout(300) + assert last(page,"nativeThrowSnapshot")["requestId"]==initial["requestId"],\ + "snapshot polling overwrote outstanding request too early" + reply_snapshot(page,state,DEFAULTS) + assert editor.locator("#vtStatus").inner_text()=="NATIVE DSP" + assert editor.locator("#vtCount").inner_text()=="0 throws" + box=editor.bounding_box() + assert box and box["width"]<=410 and box["width"]<=width and \ + box["x"]>=0 and box["x"]+box["width"]<=width+1,(width,box) + assert editor.evaluate("(el)=>el.scrollWidth<=el.clientWidth+1"),\ + "compact FX window overflows horizontal viewport" + page.screenshot(path="arsonmix-vocal-throw-"+str(width)+".png") + editor.screenshot(path="arsonmix-vocal-throw-editor-"+str(width)+".png") + if width==1366: + editor.locator("#vtMode").select_option("0") + edit=last(page,"nativeThrowSet") + assert edit["settings"]["mode"]==0 and edit["instanceId"]==INSTANCE + assert edit["channelId"]==SOURCE + emit(page,"arMixBuiltinThrowQueue",{"requestId":edit["requestId"],"status":"QUEUED"}) + emit(page,"arMixBuiltinThrowAck",{"requestId":edit["requestId"],"status":"APPLIED"}) + reply_snapshot(page,state,{**DEFAULTS,"mode":0},applied=edit["requestId"]) + assert editor.locator("#vtMode").input_value()=="0" + editor.locator("#vtThrow").click() + cue=last(page,"nativeThrowTrigger") + assert cue["instanceId"]==INSTANCE and cue["channelId"]==SOURCE + assert cue["slot"]==0 + emit(page,"arMixBuiltinThrowQueue",{"requestId":cue["requestId"],"status":"QUEUED"}) + emit(page,"arMixBuiltinThrowAck",{"requestId":cue["requestId"],"status":"APPLIED"}) + reply_snapshot(page,state,{**DEFAULTS,"mode":0},count=1,tail=True) + assert editor.locator("#vtCount").inner_text()=="1 throws" + assert editor.locator("#vtStatus").inner_text()=="ECHO TAIL" + # The next changed graph invalidates the old editor instance. + state["graph"]["channels"][0]["inserts"][0]["id"]="replaced-instance" + state["mixerSession"]["channels"]=copy.deepcopy(state["graph"]["channels"]) + emit(page,"arMixConsoleSnapshot",state) + assert editor.locator("#vtThrow").is_disabled() + editor.locator("#vtClose").click() + assert editor.is_hidden(),"standard close must dismiss editor" + assert not errors,(width,errors) + page.close() + browser.close() + print("PASS: ArSon Vocal Throw native picker/ACK/manual cue/compact editor in 2 viewports") + +if __name__=="__main__": + main() From 32e1cc4b5513fb6acbc8e539ec1714904a13365b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:27:08 +0700 Subject: [PATCH 25/61] ci(vocal-throw): one scoped Chromium FAT for actual approved editor and callback ACK --- .github/workflows/ui-smoke.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/ui-smoke.yml b/.github/workflows/ui-smoke.yml index 093c32350..822b894fe 100644 --- a/.github/workflows/ui-smoke.yml +++ b/.github/workflows/ui-smoke.yml @@ -127,6 +127,32 @@ jobs: - name: Block incomplete product release only when preparing product review if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.draft && startsWith(github.head_ref, 'integration/product-') }} run: node scripts/check_console_puzzle.mjs --release + vocal-throw-preview: + name: Vocal Throw native editor desktop/mobile Chromium FAT + needs: quick + if: ${{ github.event_name == 'pull_request' && github.head_ref == 'feature/arson-vocal-throw-native-20261108' }} + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Install Chromium for targeted Vocal Throw UI + run: | + python -m pip install playwright + python -m playwright install --with-deps chromium + - name: Check exact mixer picker, native ACK and editor in desktop/mobile + run: python tests/approved_native_vocal_throw_smoke.py + - name: Keep compact editor screenshot evidence + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: ArSonMix-Vocal-Throw-Desktop-Mobile-${{ github.run_id }} + path: arsonmix-vocal-throw-*.png + if-no-files-found: ignore + retention-days: 7 + operator-ux-fat: name: Operator UX real Chromium / native-assembled GUI (5 viewports) needs: quick From 3a00451f89bf5d87c7db527b131e1e05249f67ee Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:28:55 +0700 Subject: [PATCH 26/61] test(vocal-throw): increment graph revision when simulating FX-instance replacement --- tests/approved_native_vocal_throw_smoke.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/approved_native_vocal_throw_smoke.py b/tests/approved_native_vocal_throw_smoke.py index ea8421625..2e9006266 100644 --- a/tests/approved_native_vocal_throw_smoke.py +++ b/tests/approved_native_vocal_throw_smoke.py @@ -120,9 +120,11 @@ def main(): assert editor.locator("#vtStatus").inner_text()=="ECHO TAIL" # The next changed graph invalidates the old editor instance. state["graph"]["channels"][0]["inserts"][0]["id"]="replaced-instance" - state["mixerSession"]["channels"]=copy.deepcopy(state["graph"]["channels"]) + state["graph"].update(revision="4",rosterRevision="4") + state["mixerSession"].update(routeRevision="4",rosterRevision="4", + channels=copy.deepcopy(state["graph"]["channels"])) emit(page,"arMixConsoleSnapshot",state) - assert editor.locator("#vtThrow").is_disabled() + page.wait_for_function("""()=>document.querySelector('#vtThrow')?.disabled""",timeout=2000) editor.locator("#vtClose").click() assert editor.is_hidden(),"standard close must dismiss editor" assert not errors,(width,errors) From 1bf4290676ef534bd7c4b09476f64b4220da6b6e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:29:41 +0700 Subject: [PATCH 27/61] fix(vocal-throw): manual throw rejects stale silence instead of reporting empty echo --- engine/builtin_fx/VocalThrow.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/builtin_fx/VocalThrow.h b/engine/builtin_fx/VocalThrow.h index f85ea3af8..4f218c286 100644 --- a/engine/builtin_fx/VocalThrow.h +++ b/engine/builtin_fx/VocalThrow.h @@ -95,10 +95,10 @@ class VocalThrow final { // AUDIO: triggers the most recent word/phrase, preferring the latest // vocal end if the singer stopped within the last 700 ms. bool throwNow() noexcept { - if(!ready_||recorded_==0)return false; + if(!ready_||recorded_==0||lastSoundEnd_==0||clock_(rate_*.7); - const bool ended=lastSoundEnd_>0 && clock_>=lastSoundEnd_ && - clock_-lastSoundEnd_<=recent && quiet_>0; + if(clock_-lastSoundEnd_>recent)return false; // reject stale/silent cues + const bool ended=quiet_>0; return freezeAt(ended?lastSoundEnd_:clock_); } void processStereo(float* left,float* right,std::size_t frames) noexcept { From a5e2565e5dab3b209bda9968a5e7615466fda7cb Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:29:55 +0700 Subject: [PATCH 28/61] test(vocal-throw): reject long-after-singing manual cue --- tests/builtin_vocal_throw_test.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/builtin_vocal_throw_test.cpp b/tests/builtin_vocal_throw_test.cpp index 092b71739..e8261848b 100644 --- a/tests/builtin_vocal_throw_test.cpp +++ b/tests/builtin_vocal_throw_test.cpp @@ -96,6 +96,10 @@ static void manualAndDry(double rate) { check(peakL>.01f&&peakR>.005f); // Recorded stereo is preserved (same gain on both channels). check(peakL>peakR*1.4f); + noHeap.store(true); + const bool staleCue=fx.throwNow(); + noHeap.store(false); + check(!staleCue); // 700ms after last vocal: never report an empty throw } static void automaticAndHybrid(double rate) { VocalThrow fx;check(fx.prepare(rate)); From bb9ed6bc2fc07faf31e609aacadaab54a5763bbf Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:53:46 +0700 Subject: [PATCH 29/61] perf(vocal-throw): keep overlapping tails and optimize RT capture copy --- engine/builtin_fx/VocalThrow.h | 199 +++++++++++++++++++++------------ 1 file changed, 125 insertions(+), 74 deletions(-) diff --git a/engine/builtin_fx/VocalThrow.h b/engine/builtin_fx/VocalThrow.h index 4f218c286..ec1d3af9e 100644 --- a/engine/builtin_fx/VocalThrow.h +++ b/engine/builtin_fx/VocalThrow.h @@ -73,8 +73,11 @@ class VocalThrow final { if(historyFrames>500000||freezeFrames>300000)return false; historyL_.assign(historyFrames,0.f); historyR_.assign(historyFrames,0.f); - freezeL_.assign(freezeFrames,0.f); - freezeR_.assign(freezeFrames,0.f); + // Two independent tails: new phrases never overwrite an active echo. + for(auto& voice:voices_) { + voice.freezeL.assign(freezeFrames,0.f); + voice.freezeR.assign(freezeFrames,0.f); + } rate_=rate;ready_=true;settings_=packet;reset(); return true; } @@ -88,7 +91,7 @@ class VocalThrow final { bool applyPrepared(const PreparedEdit& edit) noexcept { if(!ready_||!edit.valid||edit.sampleRate!=rate_|| !validSettings(edit.settings)||edit.intervalSamples==0|| - edit.captureSamples==0||edit.captureSamples>freezeL_.size()|| + edit.captureSamples==0||edit.captureSamples>voices_[0].freezeL.size()|| edit.silenceSamples==0)return false; settings_=edit;return true; } @@ -99,139 +102,187 @@ class VocalThrow final { const auto recent=static_cast(rate_*.7); if(clock_-lastSoundEnd_>recent)return false; // reject stale/silent cues const bool ended=quiet_>0; - return freezeAt(ended?lastSoundEnd_:clock_); + const bool accepted=freezeAt(ended?lastSoundEnd_:clock_); + if(accepted)manualInCurrentPhrase_=true; + return accepted; } void processStereo(float* left,float* right,std::size_t frames) noexcept { if(!ready_||!left||!right)return; const bool mono=left==right; + const std::uint32_t maxQuiet=static_cast(rate_); + const std::uint32_t phraseGap=static_cast(rate_*.06); + const std::uint32_t minVoice=static_cast(rate_*.08); for(std::size_t i=0;i(clock_%historyL_.size()); - historyL_[location]=dryL;historyR_[location]=dryR; + historyL_[writeIndex_]=dryL;historyR_[writeIndex_]=dryR; + if(++writeIndex_==historyL_.size())writeIndex_=0; ++clock_;recorded_=std::min(recorded_+1,historyL_.size()); const float peak=std::max(std::abs(dryL),std::abs(dryR)); - // Fast attack, slow release. Singing detector is independent of - // output echo, so feedback cannot self-trigger another phrase. const float coeff=peak>envelope_?envAttack_:envRelease_; envelope_=coeff*envelope_+(1.f-coeff)*peak; if(envelope_<1.0e-20f)envelope_=0.f; const bool singing=envelope_>=settings_.gateLinear; if(singing) { - if(quiet_>static_cast(rate_*.06))voiced_=0; + if(quiet_>phraseGap) { + voiced_=0; + manualInCurrentPhrase_=false; // genuinely new sung phrase + } quiet_=0; - voiced_=std::min(voiced_+1,static_cast(rate_)); + voiced_=std::min(voiced_+1,maxQuiet); lastSoundEnd_=clock_; - if(voiced_>=static_cast(rate_*.08))armed_=true; + if(voiced_>=minVoice)armed_=true; } else { - ++quiet_; + if(quiet_=settings_.silenceSamples) { - if(settings_.settings.mode!=0 && clock_>=nextAutoEligible_) { - const bool captured=freezeAt(lastSoundEnd_); - if(captured)nextAutoEligible_=clock_+ - static_cast(rate_*.4); + if(settings_.settings.mode!=0 && !manualInCurrentPhrase_ + && clock_>=nextAutoEligible_) { + if(freezeAt(lastSoundEnd_)) { + nextAutoEligible_=clock_+ + static_cast(rate_*.4); + } } armed_=false; } } - if(copyPending_)copyFrozenChunk(); // fixed real-time budget float echoL=0.f,echoR=0.f; - if(playing_) { - // A new manual throw replaces the old tail atomically. - // Each voice has a fixed offset in the captured buffer; - // multiple phrases may overlap at short note divisions. - for(int tap=0;tap(tap)]; + for(auto& voice:voices_) { + if(voice.copying)copyFrozenChunk(voice); + if(!voice.playing)continue; + // Fixed six-tap limit, constant time; voice owns its capture + // and scheduling packet even when BPM changes mid-tail. + for(int tap=0;tap(tap); + const std::uint64_t start=voice.repeatStarts[slot]; if(clock_<=start)continue; const std::uint64_t offset=clock_-start-1; - if(offset>=freezeCount_)continue; + if(offset>=voice.freezeCount)continue; float ramp=1.f; - const auto edge=static_cast(rate_*.004); - if(edge>0) { - ramp=std::min(ramp,static_cast(offset)/static_cast(edge)); - ramp=std::min(ramp,static_cast(freezeCount_-offset-1)/ - static_cast(edge)); + if(voice.edgeSamples>0) { + ramp=std::min(ramp,static_cast(offset)/ + static_cast(voice.edgeSamples)); + ramp=std::min(ramp,static_cast(voice.freezeCount-offset-1)/ + static_cast(voice.edgeSamples)); } const auto p=static_cast(offset); - const float gain=repeatGains_[static_cast(tap)]*std::max(0.f,ramp); - echoL+=freezeL_[p]*gain;echoR+=freezeR_[p]*gain; + const float gain=voice.repeatGains[slot]*std::max(0.f,ramp); + echoL+=voice.freezeL[p]*gain;echoR+=voice.freezeR[p]*gain; } - const auto end=repeatStarts_[static_cast(active_.settings.repeats-1)] - +freezeCount_; - if(clock_>end)playing_=false; + const auto end=voice.repeatStarts[ + static_cast(voice.active.settings.repeats-1)] + +voice.freezeCount; + if(clock_>end)voice.playing=false; } - const float target=singing?1.f-settings_.settings.ducking:1.f; - // Fixed 8-ms one-pole gain smoothing: no clicks on duck transitions. - duck_=duck_*duckCoeff_+target*(1.f-duckCoeff_); - left[i]=dryL+echoL*settings_.settings.wet*duck_; - if(!mono)right[i]=dryR+echoR*settings_.settings.wet*duck_; + // Slew wet level and ducking independently to avoid zipper + // noise on rapid GUI edits and the next vocal entrance. + const float duckTarget=singing?1.f-settings_.settings.ducking:1.f; + duck_=duck_*duckCoeff_+duckTarget*(1.f-duckCoeff_); + wetSmoothed_=wetSmoothed_*duckCoeff_+ + settings_.settings.wet*(1.f-duckCoeff_); + const float echoGain=wetSmoothed_*duck_; + left[i]=dryL+echoL*echoGain; + if(!mono)right[i]=dryR+echoR*echoGain; } } [[nodiscard]] bool ready() const noexcept{return ready_;} [[nodiscard]] VocalThrowSettings settingsForTests() const noexcept{return settings_.settings;} - [[nodiscard]] bool echoActive() const noexcept{return playing_;} + [[nodiscard]] bool echoActive() const noexcept{ + for(const auto& voice:voices_)if(voice.playing)return true; + return false; + } [[nodiscard]] unsigned throwCount() const noexcept{return throwCount_;} [[nodiscard]] double sampleRate() const noexcept{return rate_;} private: + struct TailVoice final { + std::vector freezeL,freezeR; + std::array repeatStarts{}; + std::array repeatGains{}; + PreparedEdit active{}; + std::uint64_t copyEnd=0,freezeCount=0; + std::size_t copyIndex=0,sourceIndex=0; + std::uint32_t edgeSamples=0; + bool copying=false,playing=false; + }; bool freezeAt(std::uint64_t end) noexcept { if(end==0||end>clock_||historyL_.empty())return false; + // Bounded polyphony: do not cut or overwrite an existing phrase. + // A full pool rejects a cue (and reports this via native ACK). + TailVoice* slot=nullptr; + for(auto& voice:voices_) { + if(!voice.playing&&!voice.copying){slot=&voice;break;} + } + if(!slot)return false; const auto available=std::min(end,recorded_); const auto count=std::min(available,settings_.captureSamples); if(count(rate_*.025))return false; - // No large memcpy in a 64/128-sample ASIO callback. Copy only a - // fixed number of stereo frames per processed sample before playback. - copyFrom_=end-count;copyEnd_=end;copyIndex_=0; - freezeCount_=count;active_=settings_; - playing_=false;copyPending_=true;++throwCount_; + slot->copyEnd=end; + slot->freezeCount=count; + slot->copyIndex=0; + slot->sourceIndex=static_cast((end-count)%historyL_.size()); + slot->edgeSamples=static_cast(rate_*.004); + slot->active=settings_; + slot->copying=true; + ++throwCount_; return true; } - void copyFrozenChunk() noexcept { - if(!copyPending_)return; - for(int n=0;n<24 && copyIndex_( - (copyFrom_+copyIndex_)%historyL_.size()); - const auto dest=static_cast(copyIndex_++); - freezeL_[dest]=historyL_[source];freezeR_[dest]=historyR_[source]; - } - if(copyIndex_!=freezeCount_)return; - copyPending_=false; - // The phrase-end interval is authoritative. If capture completion - // is later than the first repeat, begin on the next safe sample. - const auto first=std::max(clock_,copyEnd_+active_.intervalSamples); + void copyFrozenChunk(TailVoice& voice) noexcept { + // A fixed 24-frame budget each sample. Contiguous bulk copying + // replaces per-frame division/modulo in the former implementation. + const std::size_t left=static_cast(voice.freezeCount)-voice.copyIndex; + const std::size_t n=std::min({24,left, + historyL_.size()-voice.sourceIndex}); + std::copy_n(historyL_.data()+voice.sourceIndex,n, + voice.freezeL.data()+voice.copyIndex); + std::copy_n(historyR_.data()+voice.sourceIndex,n, + voice.freezeR.data()+voice.copyIndex); + voice.copyIndex+=n; + voice.sourceIndex+=n; + if(voice.sourceIndex==historyL_.size())voice.sourceIndex=0; + if(voice.copyIndex!=voice.freezeCount)return; + voice.copying=false; + const auto first=std::max(clock_,voice.copyEnd+voice.active.intervalSamples); float amplitude=1.f; - for(int tap=0;tap(tap); - repeatStarts_[slot]=first+ - static_cast(tap)*active_.intervalSamples; - repeatGains_[slot]=amplitude;amplitude*=active_.settings.decay; + voice.repeatStarts[slot]=first+ + static_cast(tap)*voice.active.intervalSamples; + voice.repeatGains[slot]=amplitude; + amplitude*=voice.active.settings.decay; } - playing_=true; + voice.playing=true; } void reset() noexcept { clock_=lastSoundEnd_=nextAutoEligible_=0; - recorded_=freezeCount_=0;copyFrom_=copyEnd_=copyIndex_=0; - voiced_=quiet_=0;armed_=playing_=copyPending_=false; + recorded_=writeIndex_=0; + voiced_=quiet_=0; + armed_=manualInCurrentPhrase_=false; envelope_=0.f;duck_=1.f;throwCount_=0; + wetSmoothed_=settings_.settings.wet; if(rate_>0) { envAttack_=static_cast(std::exp(-1./(rate_*.004))); envRelease_=static_cast(std::exp(-1./(rate_*.018))); duckCoeff_=static_cast(std::exp(-1./(rate_*.008))); } - repeatStarts_.fill(0);repeatGains_.fill(0.f); + for(auto& voice:voices_) { + voice.copyEnd=voice.freezeCount=0; + voice.copyIndex=voice.sourceIndex=0; + voice.edgeSamples=0; + voice.copying=voice.playing=false; + voice.repeatStarts.fill(0);voice.repeatGains.fill(0.f); + } std::fill(historyL_.begin(),historyL_.end(),0.f); std::fill(historyR_.begin(),historyR_.end(),0.f); } - PreparedEdit settings_{},active_{}; - std::vector historyL_,historyR_,freezeL_,freezeR_; - std::array repeatStarts_{}; - std::array repeatGains_{}; + PreparedEdit settings_{}; + std::vector historyL_,historyR_; + std::array voices_{}; std::uint64_t clock_=0,lastSoundEnd_=0,nextAutoEligible_=0; - std::size_t recorded_=0; - std::uint64_t freezeCount_=0,copyFrom_=0,copyEnd_=0,copyIndex_=0; + std::size_t recorded_=0,writeIndex_=0; std::uint32_t voiced_=0,quiet_=0; - float envelope_=0.f,envAttack_=0.f,envRelease_=0.f,duckCoeff_=0.f,duck_=1.f; + float envelope_=0.f,envAttack_=0.f,envRelease_=0.f,duckCoeff_=0.f; + float duck_=1.f,wetSmoothed_=.42f; double rate_=0.; unsigned throwCount_=0; - bool armed_=false,playing_=false,copyPending_=false,ready_=false; + bool armed_=false,manualInCurrentPhrase_=false,ready_=false; }; } // namespace armix::builtin_fx From bbe0e868c81f68f00e23fc54b5c03260e20d1221 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:54:49 +0700 Subject: [PATCH 30/61] test(vocal-throw): assert overlapping tails, bounded cues and manual-auto dedup --- tests/builtin_vocal_throw_test.cpp | 73 ++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/tests/builtin_vocal_throw_test.cpp b/tests/builtin_vocal_throw_test.cpp index e8261848b..ed5b98205 100644 --- a/tests/builtin_vocal_throw_test.cpp +++ b/tests/builtin_vocal_throw_test.cpp @@ -132,6 +132,75 @@ static void hybridEditAndNoHeap() { run(fx,0,0,200000,l,r); check(std::isfinite(l)&&std::isfinite(r)); } +// Two separate frozen phrases must coexist. A new cue must not chop the +// already sounding repeat. All fixtures run as 64/128-ish PCM chunks without +// any callback allocations, including at the highest allowed device rate. +static void twoTailsStayLive(double rate) { + VocalThrow reference,overlap; + check(reference.prepare(rate)&&overlap.prepare(rate)); + auto s=reference.settingsForTests(); + s.mode=0;s.bpm=200;s.division=1;s.repeats=3; + s.captureMs=300;s.silenceMs=120; + check(reference.resetUnpublished(s)&&overlap.resetUnpublished(s)); + float l=0.f,r=0.f; + auto both=[&](float input,int frames) { + run(reference,input,input*.5f,frames,l,r); + run(overlap,input,input*.5f,frames,l,r); + }; + both(.5f,static_cast(rate*.20)); + both(0.f,static_cast(rate*.10)); + noHeap.store(true); + const bool firstA=reference.throwNow(),firstB=overlap.throwNow(); + noHeap.store(false); + check(firstA&&firstB); + both(.4f,static_cast(rate*.12)); + both(0.f,static_cast(rate*.03)); + noHeap.store(true); + const bool second=overlap.throwNow(); + const bool saturated=overlap.throwNow(); + noHeap.store(false); + check(second&&!saturated); + check(overlap.throwCount()==2); + // From 0.45 to 0.485 s the second voice is preparing, and its first + // scheduled echo is still in the future. Output must be IDENTICAL to + // the reference's first tail, not abruptly muted by the second cue. + std::array refL{},refR{},mixL{},mixR{}; + float maxReference=0.f,maxOverlap=0.f; + const int compareFrames=static_cast(rate*.035); + for(int done=0;done(std::min(128,compareFrames-done)); + noHeap.store(true); + reference.processStereo(refL.data(),refR.data(),count); + overlap.processStereo(mixL.data(),mixR.data(),count); + noHeap.store(false); + for(std::size_t i=0;i.001f&&maxOverlap>.001f); + run(overlap,0.f,0.f,static_cast(rate*.8),l,r); + check(overlap.throwCount()==2); +} +static void manualOverrideSuppressesAuto() { + VocalThrow fx;check(fx.prepare(48000)); + auto s=fx.settingsForTests(); + s.mode=2;s.silenceMs=160;s.captureMs=250; + check(fx.resetUnpublished(s)); + float l=0.f,r=0.f; + run(fx,.5f,.25f,12000,l,r); // phrase 1 + run(fx,0.f,0.f,2400,l,r); // manual cue before auto silence timeout + noHeap.store(true); + const bool fired=fx.throwNow(); + noHeap.store(false); + check(fired&&fx.throwCount()==1); + run(fx,0.f,0.f,12000,l,r); + check(fx.throwCount()==1); // same phrase must not double-fire + run(fx,.5f,.25f,12000,l,r); // genuinely new phrase + run(fx,0.f,0.f,10000,l,r); + check(fx.throwCount()==2); +} int main() { validation(); manualAndDry(8000); @@ -140,5 +209,9 @@ int main() { automaticAndHybrid(8000); automaticAndHybrid(48000); hybridEditAndNoHeap(); + twoTailsStayLive(8000); + twoTailsStayLive(48000); + twoTailsStayLive(96000); + manualOverrideSuppressesAuto(); std::puts("PASS: vocal-throw native dry/rolling capture/phrase/echo/tempo/no-heap"); } From 5cc440009907279535b16ecf0f4eeaf654a82d66 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:56:28 +0700 Subject: [PATCH 31/61] audio(vocal-throw): contain dense multi-tap wet peak without touching dry monitoring --- engine/builtin_fx/VocalThrow.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/engine/builtin_fx/VocalThrow.h b/engine/builtin_fx/VocalThrow.h index ec1d3af9e..95f1d5b75 100644 --- a/engine/builtin_fx/VocalThrow.h +++ b/engine/builtin_fx/VocalThrow.h @@ -145,7 +145,7 @@ class VocalThrow final { armed_=false; } } - float echoL=0.f,echoR=0.f; + float echoL=0.f,echoR=0.f,activeTapGain=0.f; for(auto& voice:voices_) { if(voice.copying)copyFrozenChunk(voice); if(!voice.playing)continue; @@ -167,6 +167,7 @@ class VocalThrow final { const auto p=static_cast(offset); const float gain=voice.repeatGains[slot]*std::max(0.f,ramp); echoL+=voice.freezeL[p]*gain;echoR+=voice.freezeR[p]*gain; + activeTapGain+=gain; } const auto end=voice.repeatStarts[ static_cast(voice.active.settings.repeats-1)] @@ -179,7 +180,11 @@ class VocalThrow final { duck_=duck_*duckCoeff_+duckTarget*(1.f-duckCoeff_); wetSmoothed_=wetSmoothed_*duckCoeff_+ settings_.settings.wet*(1.f-duckCoeff_); - const float echoGain=wetSmoothed_*duck_; + // Concert-safe overlap headroom: many closely spaced taps, + // including two phrases, must not multiply the wet peak by 6x. + // No attenuation for ordinary nonoverlapping delays. + const float echoGain=(wetSmoothed_*duck_)/ + std::max(1.f,activeTapGain*wetSmoothed_); left[i]=dryL+echoL*echoGain; if(!mono)right[i]=dryR+echoR*echoGain; } From 29b92b79097a2bb060f0e2b47061f8ce4572f980 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:56:54 +0700 Subject: [PATCH 32/61] test(vocal-throw): bound dense overlap level at full wet --- tests/builtin_vocal_throw_test.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/builtin_vocal_throw_test.cpp b/tests/builtin_vocal_throw_test.cpp index ed5b98205..b734fc5a6 100644 --- a/tests/builtin_vocal_throw_test.cpp +++ b/tests/builtin_vocal_throw_test.cpp @@ -183,6 +183,26 @@ static void twoTailsStayLive(double rate) { run(overlap,0.f,0.f,static_cast(rate*.8),l,r); check(overlap.throwCount()==2); } +static void denseRepeatsStayBounded() { + VocalThrow fx;check(fx.prepare(48000)); + auto settings=fx.settingsForTests(); + settings.mode=0;settings.bpm=200;settings.division=1; + settings.repeats=6;settings.decay=.9f; + settings.captureMs=1200.f;settings.wet=1.f;settings.ducking=0.f; + check(fx.resetUnpublished(settings)); + float maxL=0.f,maxR=0.f; + run(fx,.75f,.6f,48000,maxL,maxR); + noHeap.store(true); + const bool fired=fx.throwNow(); + noHeap.store(false); + check(fired); + maxL=maxR=0.f; + run(fx,0.f,0.f,static_cast(48000*2.5),maxL,maxR); + check(maxL>.20f&&maxR>.10f); + // An exposed six-tap feedback-like burst must not produce >0dBFS + // solely because echo taps overlap (dry path is unchanged). + check(maxL<=.751f&&maxR<=.601f); +} static void manualOverrideSuppressesAuto() { VocalThrow fx;check(fx.prepare(48000)); auto s=fx.settingsForTests(); @@ -213,5 +233,6 @@ int main() { twoTailsStayLive(48000); twoTailsStayLive(96000); manualOverrideSuppressesAuto(); + denseRepeatsStayBounded(); std::puts("PASS: vocal-throw native dry/rolling capture/phrase/echo/tempo/no-heap"); } From 63d86189102a04425c3f5d3282f004651e72c191 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:57:51 +0700 Subject: [PATCH 33/61] docs(vocal-throw): qualification evidence and RT/musical hardening contract --- docs/ARSON_VOCAL_THROW_NATIVE_20261108.md | 28 +++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/docs/ARSON_VOCAL_THROW_NATIVE_20261108.md b/docs/ARSON_VOCAL_THROW_NATIVE_20261108.md index d205881af..e39acc139 100644 --- a/docs/ARSON_VOCAL_THROW_NATIVE_20261108.md +++ b/docs/ARSON_VOCAL_THROW_NATIVE_20261108.md @@ -6,12 +6,12 @@ This is a first-class native ChannelId insert in ArSonMix's single JUCE PCM rend ## Implemented -- **Manual:** rolling ring buffer holds up to 1.5 seconds of the most recent vocal. THROW captures a word or phrase and schedules up to six decaying repeats. +- **Manual:** rolling ring buffer holds up to 1.5 seconds of the most recent vocal. THROW captures a word or phrase and schedules up to six decaying repeats. Two independent tail voices allow a subsequent phrase to overlap an existing echo instead of cutting it. - **Auto:** energy envelope, minimum voice duration, silence threshold and cooldown detect the end of a sung phrase without letting the wet echo re-trigger itself. -- **Hybrid (default):** phrase-end automation and manual cue together. +- **Hybrid (default):** phrase-end automation and manual cue together, with manual-cue suppression of a subsequent auto event for the same phrase. - **Tempo:** BPM entry (60-200), TAP BPM, quarter/eighth/dotted-eighth/half note subdivisions. Interval timing is in native samples at the actual device rate. -- **Mix:** direct dry input with zero added samples, stereo echo, decay, short fades, and ducking while the singer is active. -- **Real-time:** all rolling/frozen buffers are allocated off-callback; a fixed 24-stereo-frame-per-sample capture copy budget avoids a single large callback memcpy. A lock-free SPSC transfers host settings and manual cue to the audio callback. Callback never allocates/logs/locks. +- **Mix:** direct dry input with zero added samples, stereo echo, decay, short fades, smoothed wet edits, and ducking while the singer is active. A bounded active-tap gain normalizer prevents dense repeats/overlapping phrases from amplifying the wet bus simply because taps stack; dry is never attenuated. +- **Real-time:** all rolling/frozen buffers are allocated off-callback; a fixed maximum 24-stereo-frame-per-sample capture copy budget per active tail avoids a single large callback memcpy. Contiguous copy chunks eliminate per-frame modulo, and the ring write cursor rolls over without division. A lock-free SPSC transfers host settings and manual cue to the audio callback. Callback never allocates/logs/locks. - **Identity & persistence:** stable native catalog ID; ChannelId, device epoch, graph revision, and insert instance fencing. DSP completed ACK and later readback precede accepted display. Schema-versioned 48-byte AVTH settings blob validated during Show restore; audio capture and tails are not persisted. - **UX:** a compact FX editor inside the exact approved /preview/ mixer; presets in header, uniform power/close, BPM/note/repeat, THROW, TAP and collapsible advanced controls. One shared FX stylesheet. @@ -23,7 +23,7 @@ Core files: engine/builtin_fx/VocalThrow.h (DSP), VocalThrowProcessor.h (JUCE), ## Tests / qualification -The ARMixNativeVocalThrowTests CTest covers zero-added-sample dry, tempo divisions, captured stereo echoes after manual cue, auto-end detection and no self-trigger, bad parameter rejection, 8/44.1/48 kHz sample rates and a global allocator guard around realtime processing. Python native picker/compiled-gui tests enforce no extra mixer screen and real-ACK event names. +The ARMixNativeVocalThrowTests CTest covers zero-added-sample dry, tempo divisions, captured stereo echoes after manual cue, auto-end detection and no self-trigger, bad parameter rejection, 8/44.1/48 kHz sample rates and a global allocator guard around realtime processing. Additional deterministic tests cover 8/48/96 kHz two-tail preservation during a second cue, a full two-tail pool reporting cue refusal rather than overwriting a running phrase, suppression of manual/auto double-cues, and peak containment of dense six-tap echoes. Python native picker/compiled-gui tests enforce no extra mixer screen and real-ACK event names. Before shipping: exact-SHA Windows MSVC + CTest, actual approved /preview/ Chromium screenshots, ASIO 64/128-frame stress at 44.1/48/96 kHz, live singer audition, device restart, bypass/tail behavior, and Show restore. @@ -31,10 +31,24 @@ Before shipping: exact-SHA Windows MSVC + CTest, actual approved /preview/ Chrom 1. **Automatic BPM analysis from the music/backing bus is not yet implemented.** Auto currently means automatic vocal phrase-end trigger, not auto-estimated music tempo. BPM is entered or TAP-derived. Full beat tracking requires an independent music-bus feed, beat confidence and phase tracking. 2. Voice end detector uses an adjustable energy-envelope heuristic, not linguistic speech recognition or a trained singing model. Breaths, falsetto and microphone bleed can cause false cues. -3. No MIDI footswitch binding, simultaneous phrase layers, stretchable echo phrases, global music BPM transport integration, or direct song-snapshot binding in this milestone. -4. Green quick CI is not equivalent to real Windows native compilation or ASIO device certification. +3. No MIDI footswitch binding, more than two simultaneous phrase layers, stretchable echo phrases, global music BPM transport integration, or direct song-snapshot binding in this milestone. When both frozen-tail slots are busy, further THROW requests are rejected (native ACK reports not applied) rather than cutting an existing musical phrase. +4. Green quick CI is not equivalent to real Windows native compilation or ASIO device certification. Zero reported PDC applies only to the FX DSP's dry path; end-to-end hardware/driver latency and callback CPU load still require ASIO measurements. 5. Existing channel routing and independent secondary audio clock remain authoritative; the FX insert makes no new claims about unresolved WIRE/SOURCE ONLY issues. ## Field test Insert ID armix.builtin.vocal-throw.v1 into real ChannelId vocal strip; confirm graph ACK; sing “atau tidak” then press THROW at 72/95/120/160 BPM; try Auto with varying held notes and short breaths; toggle bypass while dry vocal remains direct; change device/quantum and reject stale instance requests. Compare physical ASIO callback xruns, stereo/feedback, click-free fades and singer subjective quality. + +## 2026-11-08 — performance and musicality hardening audit + +Audit of the first native revision identified these concrete risks: +- Triggering a second phrase reset `playing_` and overwrote the frozen buffer of the first tail; audible repeat discontinuity was possible. +- The original capture copied 24 frames via two per-frame ring modulo operations; this was an avoidable callback hot-path cost. +- Hybrid manual cues could be followed by auto-trigger of the same sung phrase, producing unintended double repeats. +- Wet level changed immediately on edits; close-spaced six-tap feedback-like echoes could produce unnecessarily high wet peaks. + +Hardening: two independent frozen voices, bounded cue admission (explicit rejection if full), bulk contiguous ring capture, write cursor without modulo, continuous smoothing of wet/duck gain, current-phrase manual suppression of auto replay, and peak-aware wet overlap normalization. Silence counters are now saturating for multi-hour sessions. + +**Realtime caveats:** No heap, locks, logging or file operations in `processStereo`, `throwNow`, or parameter application. Worst-case processing still includes two simultaneous 24-frame copy budgets, and an up-to-twelve-tap mix; on low-buffer ASIO that requires measured xrun and callback-duration evidence, not just source inspection. Extra frozen buffer memory is allocated only on channels with this effect. A full two-voice pool intentionally rejects a new cue, so polyphony and cue policies should be evaluated with vocalist/operator tests. + +**Next release gates:** exact-SHA MSVC CTest and native JUCE compile, 64/128-frame ASIO at 44.1/48/96 kHz, overnight stability and lifecycle/device-rate restart, phrase-ending listening sessions including breath/bleed/falsetto, bypass/re-enable and FX graph routing, and latency/xrun baseline comparisons versus bypass. Beat tracking from an isolated backing/music bus (confidence, phase and half/double-time hysteresis) remains a separate architecture milestone, not an already delivered feature. From b2657cd0e6c56a69599162c56e6d81fd60ba23d5 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:58:57 +0700 Subject: [PATCH 34/61] test(vocal-throw): clear dry fixture between PCM comparison blocks --- tests/builtin_vocal_throw_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/builtin_vocal_throw_test.cpp b/tests/builtin_vocal_throw_test.cpp index b734fc5a6..7ceb38934 100644 --- a/tests/builtin_vocal_throw_test.cpp +++ b/tests/builtin_vocal_throw_test.cpp @@ -133,7 +133,7 @@ static void hybridEditAndNoHeap() { check(std::isfinite(l)&&std::isfinite(r)); } // Two separate frozen phrases must coexist. A new cue must not chop the -// already sounding repeat. All fixtures run as 64/128-ish PCM chunks without +// already sounding repeat. All fixtures run as bounded PCM chunks without // any callback allocations, including at the highest allowed device rate. static void twoTailsStayLive(double rate) { VocalThrow reference,overlap; @@ -169,6 +169,7 @@ static void twoTailsStayLive(double rate) { const int compareFrames=static_cast(rate*.035); for(int done=0;done(std::min(128,compareFrames-done)); + refL.fill(0.f);refR.fill(0.f);mixL.fill(0.f);mixR.fill(0.f); noHeap.store(true); reference.processStereo(refL.data(),refR.data(),count); overlap.processStereo(mixL.data(),mixR.data(),count); From 2a7c6a6fc496529edbd065097cdd22fac9b4a574 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:20:58 +0700 Subject: [PATCH 35/61] test(vocal-throw): account for envelope release in hybrid rearm gate --- tests/builtin_vocal_throw_test.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/builtin_vocal_throw_test.cpp b/tests/builtin_vocal_throw_test.cpp index 7ceb38934..5909505e9 100644 --- a/tests/builtin_vocal_throw_test.cpp +++ b/tests/builtin_vocal_throw_test.cpp @@ -219,8 +219,13 @@ static void manualOverrideSuppressesAuto() { run(fx,0.f,0.f,12000,l,r); check(fx.throwCount()==1); // same phrase must not double-fire run(fx,.5f,.25f,12000,l,r); // genuinely new phrase - run(fx,0.f,0.f,10000,l,r); - check(fx.throwCount()==2); + // The 18ms release envelope must fall below the voice gate BEFORE + // the 160ms silence threshold begins. 208ms total is insufficient + // with a sustained 0.5 peak and threshold -35dB. + run(fx,0.f,0.f,9000,l,r); + check(fx.throwCount()==1); // no premature false-positive throw + run(fx,0.f,0.f,5000,l,r); + check(fx.throwCount()==2); // new phrase, after full release + gate } int main() { validation(); From f6ad2d6be41def2451603fca09bba1d1cbc8447c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:24:51 +0700 Subject: [PATCH 36/61] fix(vocal-throw): reject late manual duplicate of auto-triggered vocal phrase --- engine/builtin_fx/VocalThrow.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/engine/builtin_fx/VocalThrow.h b/engine/builtin_fx/VocalThrow.h index 95f1d5b75..308bda56c 100644 --- a/engine/builtin_fx/VocalThrow.h +++ b/engine/builtin_fx/VocalThrow.h @@ -102,6 +102,9 @@ class VocalThrow final { const auto recent=static_cast(rate_*.7); if(clock_-lastSoundEnd_>recent)return false; // reject stale/silent cues const bool ended=quiet_>0; + // Auto already threw this finished phrase. A late manual click must + // not produce a second identical echo in Hybrid mode. + if(ended && lastSoundEnd_==autoTriggeredPhraseEnd_)return false; const bool accepted=freezeAt(ended?lastSoundEnd_:clock_); if(accepted)manualInCurrentPhrase_=true; return accepted; @@ -127,6 +130,7 @@ class VocalThrow final { if(quiet_>phraseGap) { voiced_=0; manualInCurrentPhrase_=false; // genuinely new sung phrase + autoTriggeredPhraseEnd_=0; } quiet_=0; voiced_=std::min(voiced_+1,maxQuiet); @@ -138,6 +142,7 @@ class VocalThrow final { if(settings_.settings.mode!=0 && !manualInCurrentPhrase_ && clock_>=nextAutoEligible_) { if(freezeAt(lastSoundEnd_)) { + autoTriggeredPhraseEnd_=lastSoundEnd_; nextAutoEligible_=clock_+ static_cast(rate_*.4); } @@ -257,7 +262,7 @@ class VocalThrow final { voice.playing=true; } void reset() noexcept { - clock_=lastSoundEnd_=nextAutoEligible_=0; + clock_=lastSoundEnd_=nextAutoEligible_=autoTriggeredPhraseEnd_=0; recorded_=writeIndex_=0; voiced_=quiet_=0; armed_=manualInCurrentPhrase_=false; @@ -281,7 +286,7 @@ class VocalThrow final { PreparedEdit settings_{}; std::vector historyL_,historyR_; std::array voices_{}; - std::uint64_t clock_=0,lastSoundEnd_=0,nextAutoEligible_=0; + std::uint64_t clock_=0,lastSoundEnd_=0,nextAutoEligible_=0,autoTriggeredPhraseEnd_=0; std::size_t recorded_=0,writeIndex_=0; std::uint32_t voiced_=0,quiet_=0; float envelope_=0.f,envAttack_=0.f,envRelease_=0.f,duckCoeff_=0.f; From 4db384851e6f6378cca4fd037b744c98bd1f0ba3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:25:12 +0700 Subject: [PATCH 37/61] test(vocal-throw): manual-after-auto idempotence and next-phrase rearm --- tests/builtin_vocal_throw_test.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/builtin_vocal_throw_test.cpp b/tests/builtin_vocal_throw_test.cpp index 5909505e9..28d6ea9b2 100644 --- a/tests/builtin_vocal_throw_test.cpp +++ b/tests/builtin_vocal_throw_test.cpp @@ -184,6 +184,27 @@ static void twoTailsStayLive(double rate) { run(overlap,0.f,0.f,static_cast(rate*.8),l,r); check(overlap.throwCount()==2); } +static void autoThenManualMustNotDoubleEcho() { + VocalThrow fx;check(fx.prepare(48000)); + auto s=fx.settingsForTests(); + s.mode=2;s.silenceMs=120;s.captureMs=250; + check(fx.resetUnpublished(s)); + float l=0.f,r=0.f; + run(fx,.5f,.25f,14400,l,r); + run(fx,0.f,0.f,12000,l,r); + check(fx.throwCount()==1); + noHeap.store(true); + const bool duplicated=fx.throwNow(); + noHeap.store(false); + check(!duplicated&&fx.throwCount()==1); + // A fresh phrase re-arms the manual path: previous auto trigger must + // not poison legitimate new cues when the singer starts again. + run(fx,.5f,.25f,12000,l,r); + noHeap.store(true); + const bool newPhrase=fx.throwNow(); + noHeap.store(false); + check(newPhrase&&fx.throwCount()==2); +} static void denseRepeatsStayBounded() { VocalThrow fx;check(fx.prepare(48000)); auto settings=fx.settingsForTests(); @@ -239,6 +260,7 @@ int main() { twoTailsStayLive(48000); twoTailsStayLive(96000); manualOverrideSuppressesAuto(); + autoThenManualMustNotDoubleEcho(); denseRepeatsStayBounded(); std::puts("PASS: vocal-throw native dry/rolling capture/phrase/echo/tempo/no-heap"); } From f95b748928ad479e74b62347a4a2b5df7daf97be Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:53:46 +0700 Subject: [PATCH 38/61] feat(vocal-throw): bounded native music-channel onset monitor and control-only BPM estimator --- engine/core/NativeMusicTempoMonitor.h | 209 ++++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 engine/core/NativeMusicTempoMonitor.h diff --git a/engine/core/NativeMusicTempoMonitor.h b/engine/core/NativeMusicTempoMonitor.h new file mode 100644 index 000000000..e84e9d270 --- /dev/null +++ b/engine/core/NativeMusicTempoMonitor.h @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "../builtin_fx/FxSpsc.h" +#include "DynamicChannelRoster.h" +#include +#include +#include +#include +#include +#include + +// ArSon M2: source-specific music tempo observation inside the ONE installed +// ChannelId renderer. AUDIO only summarizes its explicitly selected music +// channel into 10ms energy frames and pushes a bounded SPSC. CONTROL owns all +// onset, pulse-correlation and tempo work. This is NOT a second audio engine. +namespace armix::mixer { +class MusicTempoEstimator final { +public: + struct Result final { + float bpm=0.f,confidence=0.f; + std::uint64_t beatAnchorTick=0,observationTick=0; + bool locked=false; + }; + void reset() noexcept { + previous_=floor_=0.f;count_=write_=0; + lastHit_=lastScan_=lastTick_=0; + stableCount_=0;candidateBpm_=0;result_={}; + } + void ingest(float energy,std::uint64_t tick) noexcept { + if(!std::isfinite(energy)||energy<0.f)energy=0.f; + if(lastTick_ && (tick<=lastTick_ || tick-lastTick_>4))reset(); + lastTick_=tick; + floor_+=.005f*(energy-floor_); + const float rise=energy-previous_; + // Attack transient only; sustained pads/bleed cannot retrigger + // every 10ms. 80ms refractory rejects the same drum's ringing. + if(tick>=lastHit_+8 && energy>.003f && + rise>std::max(.005f,floor_*.45f)) { + hits_[write_]={tick,std::min(1.f,rise)}; + write_=(write_+1)%hits_.size(); + count_=std::min(count_+1,hits_.size()); + lastHit_=tick; + } + previous_=energy; + if(result_.locked && tick>lastHit_+320) { + result_.locked=false;result_.confidence=0.f; + candidateBpm_=stableCount_=0; + } + if(tick>=lastScan_+50) { + lastScan_=tick; + evaluate(); + } + } + Result result() const noexcept {return result_;} +private: + struct Hit {std::uint64_t tick=0;float strength=0.f;}; + std::array hits_{}; + std::size_t count_=0,write_=0; + std::uint64_t lastHit_=0,lastScan_=0,lastTick_=0; + float previous_=0.f,floor_=0.f; + int stableCount_=0,candidateBpm_=0; + Result result_{}; + + void evaluate() noexcept { + if(count_<7 || lastTick_<300 || lastTick_>lastHit_+320)return; + const auto at=[&](std::size_t i) noexcept ->const Hit& { + return hits_[(write_+hits_.size()-count_+i)%hits_.size()]; + }; + if(at(count_-1).tick-at(0).tick<300)return; + int bestBpm=0; + float bestScore=0.f; + // CONTROL ONLY: bounded 121 candidates x 128 onsets. Emphasize + // one-beat matches; harmonics, half- and double-time are penalized. + for(int bpm=60;bpm<=180;++bpm) { + const float period=6000.f/static_cast(bpm); + float score=0.f; + for(std::size_t j=1;j1100)continue; + for(std::size_t i=j;i-->0;) { + const auto& earlier=at(i); + const float dt=static_cast(later.tick-earlier.tick); + if(dt>period*3.08f)break; + const int cycles=static_cast(std::lround(dt/period)); + if(cycles<1||cycles>3)continue; + const float tolerance=std::max(1.4f,.022f*period*cycles); + const float error=std::abs(dt-period*cycles); + if(error>=tolerance)continue; + const float strength=std::sqrt(earlier.strength*later.strength); + score+=strength*(1.f-error/tolerance)/ + (cycles==1?1.f:cycles==2?1.6f:2.25f); + } + } + if(score>bestScore) {bestScore=score;bestBpm=bpm;} + } + if(bestBpm==0 || bestScore<2.0f)return; + if(std::abs(bestBpm-candidateBpm_)<=2)++stableCount_; + else {candidateBpm_=bestBpm;stableCount_=1;} + // A proven lock resists transient alternate half/double-time peaks. + if(result_.locked && std::abs(bestBpm-result_.bpm)>5.f && + stableCount_<6)return; + if(stableCount_<3)return; + result_.bpm=static_cast(candidateBpm_); + result_.confidence=std::clamp(bestScore/ + static_cast(std::max(7,count_))*.9f,0.f,1.f); + if(result_.confidence<.28f)return; + // The strongest recent transient is a practical pulse anchor; + // explicit "beat-phase certified" remains a separate field FAT. + float strength=0.f; + std::uint64_t anchor=0; + const auto period=6000.f/result_.bpm; + for(std::size_t i=0;iperiod*1.8f)continue; + if(h.strength>=strength) {strength=h.strength;anchor=h.tick;} + } + result_.beatAnchorTick=anchor; + result_.observationTick=lastTick_; + result_.locked=true; + } +}; + +class NativeMusicTempoMonitor final { +public: + struct State final { + ChannelId source{}; + std::uint64_t epoch=0,revision=0; + MusicTempoEstimator::Result tempo{}; + std::uint32_t dropped=0; + bool active=false; + }; + // CONTROL, only after checking this exact ChannelId exists in the + // accepted PCM graph and does not point at vocals, MAIN or MONITOR. + bool select(ChannelId id,std::uint64_t epoch,std::uint64_t revision, + double sampleRate) noexcept { + if(id.value && (!epoch||!revision||!std::isfinite(sampleRate)|| + sampleRate<8000.||sampleRate>192000.))return false; + source_.store(id.value,std::memory_order_relaxed); + epoch_.store(epoch,std::memory_order_relaxed); + revision_.store(revision,std::memory_order_relaxed); + window_.store(id.value? + static_cast(std::lround(sampleRate*.01)):0, + std::memory_order_relaxed); + config_.fetch_add(1,std::memory_order_release); + return true; + } + // AUDIO: invoked once for every scheduled source channel by the existing + // renderer's pre-FX dispatch. Only the selected ID costs per-sample work. + void capture(ChannelId id,const float* left,const float* right,int frames, + std::uint64_t epoch,std::uint64_t revision) noexcept { + const auto generation=config_.load(std::memory_order_acquire); + if(audioGeneration_!=generation) { + audioGeneration_=generation; + bucketSamples_=0;energySum_=0.f;audioTick_=0; + } + if(!id.value||id.value!=source_.load(std::memory_order_relaxed)|| + epoch!=epoch_.load(std::memory_order_relaxed)|| + revision!=revision_.load(std::memory_order_relaxed)|| + !left||!right||frames<=0)return; + const auto window=window_.load(std::memory_order_relaxed); + if(window==0)return; + for(int i=0;i frames_{}; + MusicTempoEstimator estimator_{}; // CONTROL owner only + std::atomic source_{0},epoch_{0},revision_{0}; + std::atomic config_{0},window_{0},dropped_{0}; + // The following fields are AUDIO-thread exclusive. + std::uint32_t audioGeneration_=0,bucketSamples_=0; + float energySum_=0.f; + std::uint64_t audioTick_=0; + std::uint32_t controlGeneration_=0; // CONTROL only +}; +} // namespace armix::mixer From 3c5265938fc00d9d0db51549ac737f013055eda3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:54:21 +0700 Subject: [PATCH 39/61] feat(music-tempo): tap exactly one accepted ChannelId pre-FX inside native PCM renderer --- engine/core/DynamicNativeSessionPublisher.h | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/engine/core/DynamicNativeSessionPublisher.h b/engine/core/DynamicNativeSessionPublisher.h index a4f3d6ac8..24c519140 100644 --- a/engine/core/DynamicNativeSessionPublisher.h +++ b/engine/core/DynamicNativeSessionPublisher.h @@ -2,6 +2,7 @@ #pragma once #include "DynamicPreparedMixerBlock.h" #include "DynamicConsoleRoutingView.h" +#include "NativeMusicTempoMonitor.h" #include "RealtimeRoutePublisher.h" #include "RealtimeRenderPermit.h" #include @@ -191,6 +192,10 @@ class DynamicNativeSessionPublisher final { // Snapshot ownership pins the M4 instance throughout this callback; // only control-thread retirement releases the shared owner. const auto dispatch=[&](ChannelId id,float* l,float* r,int n) noexcept { + // Analysis source is the installed ChannelId MUSIC PCM, before + // its VST rack; never microphone/echo/main unless explicitly + // selected and role-checked on CONTROL. No analysis on AUDIO. + musicTempo_.capture(id,l,r,n,snap->deviceEpoch,snap->graphRevision); const auto& acceptedFx=snap->prepared->fx; if(acceptedFx.render) acceptedFx.render(acceptedFx.context,id,l,r,n); @@ -203,6 +208,25 @@ class DynamicNativeSessionPublisher final { return ok; } + // CONTROL ONLY: choose an actual active backing input/GROUP/FX return. + // Preserve the one authoritative PCM graph and reject stale selectors. + bool setMusicTempoSource(std::uint64_t epoch,std::uint64_t revision, + ChannelId source,double sampleRate) noexcept { + const auto* p=publisher_.controlPrepared(epoch,revision); + if(!p)return false; + if(source.value) { + const auto* ch=p->routing.find(source); + if(!ch || (ch->role!=ChannelRole::input && + ch->role!=ChannelRole::group && + ch->role!=ChannelRole::fxReturn) || + !p->graph.channelScheduled(source))return false; + } + return musicTempo_.select(source,epoch,revision,sampleRate); + } + NativeMusicTempoMonitor::State pollMusicTempo(std::uint64_t epoch, + std::uint64_t revision) noexcept { + return musicTempo_.poll(epoch,revision); + } // CONTROL ONLY; pointer is valid until the next structural commit. // The caller must COPY needed fields before yielding the writer thread. // Future WebView event serializes this only after native ACK, never draft. @@ -289,6 +313,7 @@ class DynamicNativeSessionPublisher final { } private: Publisher publisher_; + NativeMusicTempoMonitor musicTempo_{}; std::atomic_flag rendering_=ATOMIC_FLAG_INIT; }; } // namespace armix::mixer From c7c62bb0495954ae1a8c3cd21de5ce26281c014a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:54:46 +0700 Subject: [PATCH 40/61] feat(music-tempo): source/epoch admission and control-only insert traversal --- src/LiveDryRoutingLab.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index 5a0a6ac62..28ec60e42 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -5,6 +5,7 @@ #include "../engine/core/MasterOutputMonoPolicy.h" #include "../engine/core/LiveChannelFxGraph.h" #include "../engine/core/DynamicChannelFxLeaseBank.h" +#include "../engine/core/NativeMusicTempoMonitor.h" #include "../engine/device/DeviceSessionTransitionPolicy.h" #include "../engine/core/NativeFxRackTransaction.h" #include "../engine/core/UnifiedLegacyProductionAdmission.h" @@ -1389,6 +1390,32 @@ class LiveDryRoutingLab final { return nativeAccepted_.setFxBypass(nativePublisher_,epochAtEdit, pcmRevision,target,slot,token,bypass); } + // Native music onset analysis has no secondary audio callback. A source + // selector is admitted only against the ACTIVE epoch/revision graph. + bool selectMusicTempoSource(std::uint64_t ep,std::uint64_t rev, + armix::mixer::ChannelId source,double sampleRate) noexcept { + if(!channelIdPhysicalPcmActive()||ep!=epoch()|| + rev!=nativeAccepted_.pcmRevision)return false; + return nativePublisher_.setMusicTempoSource(ep,rev,source,sampleRate); + } + armix::mixer::NativeMusicTempoMonitor::State pollMusicTempo() noexcept { + const auto ep=channelIdPhysicalPcmActive()?epoch():0; + return nativePublisher_.pollMusicTempo(ep,nativeAccepted_.pcmRevision); + } + // CONTROL traversal of the *published* insert owners. No audio-thread + // graph search or raw unmanaged pointers survive this synchronous call. + template + void forEachNativeProcessor(Callback&& visit) const { + if(!channelIdPhysicalPcmActive()||!nativeAccepted_.fxOwners)return; + for(const auto& ch:nativeAccepted_.graph.roster.channels()) { + const auto count=nativeAccepted_.fxOwners->insertCount(ch.id); + for(std::size_t slot=0;slotownerForControl(ch.id,slot); + if(owner && *owner && (*owner)->processor) + visit(ch.id,(*owner)->processor.get()); + } + } + } bool nativeChannelIsOriginalCh1(armix::mixer::ChannelId target) const noexcept { return nativeAccepted_.fxOwners && nativeAccepted_.fxOwners->externalChannel()==target && From 853785f427449df74362ed19a15c3829ee9cb0eb Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:55:01 +0700 Subject: [PATCH 41/61] feat(music-tempo): expose verified native tempo tap to existing JUCE control thread --- src/LiveAudioEngine.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index bf3a78b34..987494379 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -1799,6 +1799,22 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback } } + bool selectNativeMusicTempoSource(std::uint64_t epoch,std::uint64_t revision, + armix::mixer::ChannelId musicChannel) noexcept { + auto* device=deviceManager_.getCurrentAudioDevice(); + if(!device||independent_.active()||!attached_||!directFence_.permitted()) + return false; + return dryRoutingLab_.selectMusicTempoSource(epoch,revision, + musicChannel,device->getCurrentSampleRate()); + } + armix::mixer::NativeMusicTempoMonitor::State pollNativeMusicTempo() noexcept { + return dryRoutingLab_.pollMusicTempo(); + } + template + void forEachNativeProcessor(Callback&& visit) const { + dryRoutingLab_.forEachNativeProcessor(std::forward(visit)); + } + // User-owned VST3 on a true dynamic ChannelId. Instantiation/scan/layout // work is CONTROL only; the callback receives an immutable fx lease. LiveDryRoutingLab::NativeBusResult installNativeVst3( From d8ce4dbd920ab4e6f2a94059720161cc59072b12 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:55:32 +0700 Subject: [PATCH 42/61] feat(vocal-throw): consume precomputed native music BPM interval with manual fallback --- engine/builtin_fx/VocalThrow.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/engine/builtin_fx/VocalThrow.h b/engine/builtin_fx/VocalThrow.h index 308bda56c..0b0aaaee8 100644 --- a/engine/builtin_fx/VocalThrow.h +++ b/engine/builtin_fx/VocalThrow.h @@ -95,6 +95,12 @@ class VocalThrow final { edit.silenceSamples==0)return false; settings_=edit;return true; } + // AUDIO: incoming transport interval is already computed on CONTROL. + // A zero interval explicitly falls back to accepted song/TAP BPM. Each + // frozen tail keeps its interval when a backing track changes tempo. + void setMusicIntervalSamples(std::uint32_t samples) noexcept { + musicIntervalSamples_=samples; + } // AUDIO: triggers the most recent word/phrase, preferring the latest // vocal end if the singer stopped within the last 700 ms. bool throwNow() noexcept { @@ -231,6 +237,8 @@ class VocalThrow final { slot->sourceIndex=static_cast((end-count)%historyL_.size()); slot->edgeSamples=static_cast(rate_*.004); slot->active=settings_; + if(musicIntervalSamples_) + slot->active.intervalSamples=musicIntervalSamples_; slot->copying=true; ++throwCount_; return true; @@ -292,6 +300,7 @@ class VocalThrow final { float envelope_=0.f,envAttack_=0.f,envRelease_=0.f,duckCoeff_=0.f; float duck_=1.f,wetSmoothed_=.42f; double rate_=0.; + std::uint32_t musicIntervalSamples_=0; unsigned throwCount_=0; bool armed_=false,manualInCurrentPhrase_=false,ready_=false; }; From 014c83ab851819c7206209bd7f124811ba1805bd Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:55:35 +0700 Subject: [PATCH 43/61] feat(vocal-throw): consume precomputed native music BPM interval with manual fallback --- engine/builtin_fx/VocalThrowProcessor.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/engine/builtin_fx/VocalThrowProcessor.h b/engine/builtin_fx/VocalThrowProcessor.h index 42f2b4af1..c1a7ee1a6 100644 --- a/engine/builtin_fx/VocalThrowProcessor.h +++ b/engine/builtin_fx/VocalThrowProcessor.h @@ -48,11 +48,17 @@ class VocalThrowProcessor final : public juce::AudioProcessor, ready_=core_.prepare(sampleRate)&&core_.resetUnpublished(accepted_); if(ready_)rate_=sampleRate; } - void releaseResources() override{ready_=false;} + void releaseResources() override{ + ready_=false;musicInterval_.store(0,std::memory_order_release); + } void processBlock(juce::AudioBuffer& pcm,juce::MidiBuffer&) override { juce::ScopedNoDenormals noDenormals; if(!ready_||pcm.getNumChannels()<2||pcm.getNumSamples()<=0)return; consumeRealtimeEdits(); + // Transport is published by CONTROL as an already prepared sample + // interval; AUDIO performs only one atomic read at the block edge. + core_.setMusicIntervalSamples( + musicInterval_.load(std::memory_order_acquire)); core_.processStereo(pcm.getWritePointer(0),pcm.getWritePointer(1), static_cast(pcm.getNumSamples())); observedThrows_.store(core_.throwCount(),std::memory_order_relaxed); @@ -66,6 +72,18 @@ class VocalThrowProcessor final : public juce::AudioProcessor, core_.applyPrepared(e.prepared):core_.throwNow(); (void)done_.push({e.id,e.prepared.settings,e.kind,applied}); } + // CONTROL-thread song/auto BPM, deliberately independent of accepted + // serialized preset BPM. No queue ACK storm or GUI state overwrite. + void publishMusicBpm(float bpm) noexcept { + if(!ready_||!std::isfinite(bpm)||bpm<60.f||bpm>200.f) { + musicInterval_.store(0,std::memory_order_release);return; + } + auto settings=accepted_;settings.bpm=bpm; + VocalThrow::PreparedEdit packet{}; + const auto valid=VocalThrow::prepareEdit(settings,rate_,packet); + musicInterval_.store(valid?packet.intervalSamples:0, + std::memory_order_release); + } bool queueSettings(const VocalThrowSettings& settings,std::uint64_t id) noexcept { if(!ready_||id==0)return false; Edit e{};e.id=id;e.kind=CommandKind::settings; @@ -144,6 +162,7 @@ class VocalThrowProcessor final : public juce::AudioProcessor, FxSpsc done_{}; VocalThrowSettings accepted_{}; std::atomic observedThrows_{0}; + std::atomic musicInterval_{0}; std::atomic observedTail_{false}; double rate_=0.; bool ready_=false,published_=false; From 91bfdca7d1c03364361b5b4f226443a672ec5f4a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:56:33 +0700 Subject: [PATCH 44/61] feat(vocal-throw): native music-source selector, tempo polling and DSP fanout --- src/Main.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index 6d65d072e..9033e4752 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -399,6 +399,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr } pendingNativeThrow_; juce::String lastNativeThrowRequest_,lastNativeThrowInstance_; juce::String lastNativeThrowEpoch_,lastNativeThrowRevision_; + armix::mixer::NativeMusicTempoMonitor::State lastMusicTempo_{}; std::unique_ptr editorWindow_; std::unique_ptr audioSetupWindow_; juce::String startupError_, lastAudioXml_; @@ -1882,6 +1883,17 @@ 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("musicDroppedFrames", + static_cast(lastMusicTempo_.dropped)); juce::Array bands; for(const auto& band:processor->acceptedBands()){ auto item=std::make_unique(); @@ -2017,6 +2029,21 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr "arMixBuiltinCompAck",juce::var(ack.release())); } + // CONTROL ONLY: drain at most 512 ten-ms music summary frames per 12Hz + // host tick. The actual music audio was tapped inside the existing PCM + // graph; BPM/onset analysis never touches the ASIO callback. All live + // vocal inserts consume a precomputed atomic interval, not a WebView BPM. + void serviceNativeMusicTempo() { + lastMusicTempo_=engine_.pollNativeMusicTempo(); + const auto bpm=lastMusicTempo_.active&&lastMusicTempo_.tempo.locked? + lastMusicTempo_.tempo.bpm:0.f; + engine_.forEachNativeProcessor([bpm]( + armix::mixer::ChannelId,juce::AudioProcessor* p) { + if(auto* vocal=dynamic_cast(p)) + vocal->publishMusicBpm(bpm); + }); + } + // Native Vocal Throw settings, manual cue and auto-trigger readback. // Settings and triggers are not accepted until the AUDIO-owned SPSC // completion is drained on JUCE's message thread. @@ -2364,7 +2391,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr action == "routingNativeFxInsertBypass" || action == "routingFxRackBypass" || action == "nativeEqSetBand" || action == "nativeCompSet" || - action == "nativeThrowSet" || action == "nativeThrowTrigger")) + action == "nativeThrowSet" || action == "nativeThrowTrigger" || + action == "nativeThrowTempoSource")) { const auto reason=juce::String( "Studio backup in progress. Finish backup before editing saved FX or VST library."); @@ -2597,7 +2625,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr // ArSon Vocal Throw: all UI commands reference one exact installed // ChannelId + device epoch + graph revision + insert instance. if(action=="nativeThrowSnapshot"||action=="nativeThrowSet"|| - action=="nativeThrowTrigger") { + action=="nativeThrowTrigger"||action=="nativeThrowTempoSource") { const auto rawChannel=args.getProperty("channelId",{}); const auto rawEpoch=args.getProperty("deviceEpoch",{}); const auto rawRevision=args.getProperty("graphRevision",{}); @@ -2623,6 +2651,29 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr rawInstance.toString(),processor); return; } + if(action=="nativeThrowTempoSource") { + // A single shared song clock is selected by stable ChannelId; + // the source cannot be this vocal channel, MAIN or MONITOR. + const auto rawSource=args.getProperty("sourceChannelId",{}); + const auto sourceText=rawSource.toString(); + std::uint64_t source=0; + const bool parsed=sourceText=="0" || + armix::console::approvedNativeId(rawSource,source); + const bool chosen=processor && parsed && (!source||source!=ch) && + !nativeShowBusy_&&!studioBackupBusy_ && + engine_.selectNativeMusicTempoSource( + ep,rev,armix::mixer::ChannelId{source}); + if(chosen)serviceNativeMusicTempo(); + auto reply=std::make_unique(); + reply->setProperty("requestId",request); + reply->setProperty("status",chosen?"APPLIED":"REJECTED"); + reply->setProperty("sourceChannelId",sourceText); + reply->setProperty("errorCode",chosen?"NONE": + "INVALID_OR_STALE_MUSIC_CHANNEL"); + if(browser_.loaded)browser_.emitEventIfBrowserIsVisible( + "arMixBuiltinThrowTempoAck",juce::var(reply.release())); + return; + } const auto wire=request.startsWith("throw-")? request.substring(6).toStdString():std::string(); std::uint64_t numeric=0; @@ -4573,6 +4624,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr guiPerf_.prevTickMs = tickStart; } ++timerTicks_; + serviceNativeMusicTempo(); servicePendingNativeEq(); servicePendingNativeComp(); servicePendingNativeThrow(); From f11b0b59ef3933c9c836de7aedaac31fc5351053 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:58:12 +0700 Subject: [PATCH 45/61] ui(vocal-throw): compact native music source and lock status controls --- .../assets/mixer-native-vocal-throw.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/site/preview-v2/assets/mixer-native-vocal-throw.js b/site/preview-v2/assets/mixer-native-vocal-throw.js index f24859635..3551cb9e8 100644 --- a/site/preview-v2/assets/mixer-native-vocal-throw.js +++ b/site/preview-v2/assets/mixer-native-vocal-throw.js @@ -37,6 +37,7 @@ panel.innerHTML=[ '
', '
', '
', + '
Manual BPM fallback
', '
', '
Native DSP · waiting for accepted channel
', '
Phrase & echo shaping
', @@ -54,6 +55,7 @@ for(const [key,[title,unit,step]] of Object.entries(fields)){ } let current=null,accepted=defaults(),draft=defaults(),pending=null, readId="",readSent=0,seq=1,taps=[],windowDrag=null; +let tempoPending=null,musicSource="0"; const context=()=>{ const state=snapshot(),id=current&&window.__ARMIX_NATIVE_M2__?.nativeIdFor?.(current.track); const fx=state?.graph?.channels?.find(ch=>ch.id===id)?.inserts?.[current?.slot]; @@ -62,6 +64,31 @@ const context=()=>{ deviceEpoch:state.device.epoch,graphRevision:state.graph.revision}; }; const hint=text=>{$("vtHint").textContent=text;}; +function refreshMusicChannels(){ + const state=snapshot(),ctx=context(),selector=$("vtMusicSource"); + const selected=tempoPending?.source||musicSource; + const candidates=(state?.graph?.channels||[]).filter(ch=> + ch&&ch.id&&String(ch.id)!==String(ctx?.channelId)&& + ["INPUT","GROUP","FX_RETURN","FXRETURN"].includes( + String(ch.role||"").toUpperCase().replaceAll("-","_"))); + selector.replaceChildren(new Option("Manual / TAP","0")); + for(const ch of candidates)selector.add(new Option( + String(ch.name||ch.id).slice(0,45),String(ch.id))); + if([...selector.options].some(x=>x.value===String(selected))) + selector.value=String(selected); + else selector.value="0"; + selector.disabled=!ctx||!native()||Boolean(tempoPending); +} +function renderMusicStatus(tempo){ + const label=$("vtMusicStatus"); + if(tempoPending){label.textContent="Validating music channel…";return;} + if(musicSource==="0"){label.textContent="Manual BPM / TAP";return;} + if(!tempo?.musicSourceActive){label.textContent="Source stale · manual fallback";return;} + if(!tempo.musicLocked){label.textContent="Listening for beat · manual fallback";return;} + const confidence=Math.round(Math.max(0,Math.min(1,Number(tempo.musicConfidence)||0))*100); + label.textContent="AUTO "+Math.round(Number(tempo.musicBpm))+ + " BPM · "+confidence+"% confidence"; +} function syncPower(){ const state=snapshot(),id=current&&window.__ARMIX_NATIVE_M2__?.nativeIdFor?.(current.track); const lane=state?.graph?.channels?.find(ch=>ch.id===id),fx=lane?.inserts?.[current?.slot]; From 1339cb66092a1f984c92d94e6c51cb06b61e60f6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:58:31 +0700 Subject: [PATCH 46/61] ui(vocal-throw): verified backing-source selection, ACK and real BPM status --- .../assets/mixer-native-vocal-throw.js | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/site/preview-v2/assets/mixer-native-vocal-throw.js b/site/preview-v2/assets/mixer-native-vocal-throw.js index 3551cb9e8..46bb46cfe 100644 --- a/site/preview-v2/assets/mixer-native-vocal-throw.js +++ b/site/preview-v2/assets/mixer-native-vocal-throw.js @@ -145,6 +145,15 @@ for(const key of Object.keys(fields)){ }); input.addEventListener("change",()=>send("nativeThrowSet")); } +$("vtMusicSource").addEventListener("change",()=>{ + const ctx=context(),source=String($("vtMusicSource").value); + if(!ctx||!native()||tempoPending){refreshMusicChannels();return;} + const requestId="tempo-"+Date.now()+"-"+(++seq); + tempoPending={requestId,source,created:Date.now()}; + backend().emitEvent("arMixAction",{ + action:"nativeThrowTempoSource",requestId,sourceChannelId:source,...ctx}); + renderMusicStatus();refreshMusicChannels(); +}); $("vtPreset").addEventListener("change",()=>{ const p=presets[$("vtPreset").value];if(!p)return; draft={...p};paint();send("nativeThrowSet"); @@ -166,7 +175,7 @@ $("vtPower").addEventListener("click",()=>{ if(current&&context())window.__ARMIX_NATIVE_M2__?.consumeAction?.( current.track,"slotPower",{dataset:{slot:String(current.slot)}}); }); -$("vtClose").addEventListener("click",()=>{panel.hidden=true;pending=null;readId="";}); +$("vtClose").addEventListener("click",()=>{panel.hidden=true;pending=null;tempoPending=null;readId="";}); window.addEventListener("keydown",e=>{ if(e.key==="Escape"&&!panel.hidden){panel.hidden=true;pending=null;readId="";} }); @@ -187,7 +196,7 @@ window.ArSonMixNativeVocalThrow=Object.freeze({ id:ID, insert(target){return Boolean(window.__ARMIX_NATIVE_M2__?.insertPlugin?.(ID,target));}, open(track,slot){ - current={track,slot,instanceId:null};pending=null;readId=""; + current={track,slot,instanceId:null};pending=null;tempoPending=null;musicSource="0";readId=""; const state=snapshot(),id=window.__ARMIX_NATIVE_M2__?.nativeIdFor?.(track); const insert=state?.graph?.channels?.find(ch=>ch.id===id)?.inserts?.[slot]; if(native()&&state?.admitted&&insert?.catalogId===ID&&insert.id){ @@ -197,10 +206,19 @@ window.ArSonMixNativeVocalThrow=Object.freeze({ hint("Browser preview only · no PCM");} else hint("Native FX instance unavailable"); $("vtChannel").textContent=track.name||"CH"; - panel.hidden=false;paint();requestSnapshot(true); + panel.hidden=false;paint();refreshMusicChannels();requestSnapshot(true); }, close(){panel.hidden=true;} }); +backend()?.addEventListener?.("arMixBuiltinThrowTempoAck",reply=>{ + if(!tempoPending||reply?.requestId!==tempoPending.requestId)return; + if(reply.status==="APPLIED"){ + musicSource=tempoPending.source; + hint("Music tempo source accepted by native PCM graph"); + }else hint("Tempo source rejected · "+(reply.errorCode||"STALE")); + tempoPending=null;refreshMusicChannels();renderMusicStatus(); + requestSnapshot(true); +}); backend()?.addEventListener?.("arMixBuiltinThrowQueue",reply=>{ if(!pending||reply?.requestId!==pending.requestId)return; if(reply.status==="REJECTED"){hint("DSP rejected · "+(reply.errorCode||"STALE")); @@ -222,6 +240,10 @@ backend()?.addEventListener?.("arMixBuiltinThrowSnapshot",reply=>{ reply.instanceId!==ctx.instanceId||reply.deviceEpoch!==ctx.deviceEpoch|| reply.graphRevision!==ctx.graphRevision||!valid(reply.settings)|| reply.addedLatencySamples!==0){hint("Stale FX graph · reopen editor");return;} + if(reply.musicSourceChannelId!==undefined) { + musicSource=String(reply.musicSourceChannelId||"0"); + refreshMusicChannels();renderMusicStatus(reply); + } $("vtCount").textContent=String(reply.throwCount||0)+" throws"; $("vtDot").classList.toggle("active",reply.tailActive===true); $("vtStatus").textContent=reply.tailActive?"ECHO TAIL":"NATIVE DSP"; @@ -234,12 +256,18 @@ backend()?.addEventListener?.("arMixBuiltinThrowSnapshot",reply=>{ }); backend()?.addEventListener?.("arMixConsoleSnapshot",()=>{ if(panel.hidden)return; - if(native()&&!context()){pending=null;hint("FX graph changed · reopen");} - syncPower(); + if(native()&&!context()){ + pending=null;tempoPending=null; + hint("FX graph changed · reopen"); + } + refreshMusicChannels();syncPower(); }); window.setInterval(()=>{ if(panel.hidden)return; if(pending&&Date.now()-pending.created>3500){hint("DSP ACK timeout");pending=null;} + if(tempoPending&&Date.now()-tempoPending.created>3500){ + hint("Tempo source ACK timeout");tempoPending=null;refreshMusicChannels(); + } if(native())requestSnapshot(); syncPower(); },250); From 00a16e2ea655236101c21e5aa604d17aa00f428b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:58:41 +0700 Subject: [PATCH 47/61] style(vocal-throw): compact source and auto BPM state in approved FX editor --- site/preview-v2/assets/mixer-fx-rack.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/site/preview-v2/assets/mixer-fx-rack.css b/site/preview-v2/assets/mixer-fx-rack.css index 998e29db4..a8b968fe9 100644 --- a/site/preview-v2/assets/mixer-fx-rack.css +++ b/site/preview-v2/assets/mixer-fx-rack.css @@ -411,6 +411,10 @@ .mx-vthrow .body{padding:11px;display:grid;gap:10px}.mx-vthrow .row{display:flex;align-items:center;justify-content:space-between;gap:9px} .mx-vthrow .topline{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px}.mx-vthrow .field{display:grid;gap:4px;min-width:0} .mx-vthrow label,.mx-vthrow .label{color:#9fb6c5;font-size:10px;letter-spacing:.035em}.mx-vthrow .field input{width:100%;padding:4px 7px} +.mx-vthrow .music-source{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:3px 9px;align-items:center;border-top:1px solid #344957;padding-top:7px} +.mx-vthrow .music-source label{grid-column:1/-1} +.mx-vthrow .music-source select{min-width:0;width:100%;font-size:11px} +.mx-vthrow .music-status{font-size:10px;color:#91b6c4;overflow:hidden;white-space:nowrap;text-overflow:ellipsis} .mx-vthrow .manual{display:grid;grid-template-columns:1fr 80px;gap:9px}.mx-vthrow .throw{background:#277d9b;font-size:13px;font-weight:600;min-height:46px;letter-spacing:.07em}.mx-vthrow .throw:hover{background:#2b9ebf}.mx-vthrow .tap{min-height:46px} .mx-vthrow .hint{color:#8fb1c2;min-height:15px;font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mx-vthrow .detail{border-top:1px solid #334b5b;padding-top:8px} .mx-vthrow details>summary{cursor:pointer;color:#bad1df;padding-bottom:7px;font-size:11px}.mx-vthrow .ranges{display:grid;grid-template-columns:1fr 1fr;gap:8px 13px} From 920d9498958008b2f0daca55868f36c709230273 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:59:46 +0700 Subject: [PATCH 48/61] test(music-tempo): real PCM tap, BPM rhythm, holdover and stale-graph no-heap --- tests/native_music_tempo_test.cpp | 92 +++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 tests/native_music_tempo_test.cpp diff --git a/tests/native_music_tempo_test.cpp b/tests/native_music_tempo_test.cpp new file mode 100644 index 000000000..8253673ed --- /dev/null +++ b/tests/native_music_tempo_test.cpp @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#include "../engine/core/NativeMusicTempoMonitor.h" +#include +#include +#include +#include +#include +#include +#include +#define check(x) do {if(!(x)){std::fprintf(stderr,"FAIL:%s:%d %s\n",__FILE__,__LINE__,#x);std::abort();}}while(false) +static std::atomic noHeap{false}; +void* operator new(std::size_t n) { + if(noHeap.load(std::memory_order_relaxed))std::abort(); + if(void* p=std::malloc(n?n:1))return p; + throw std::bad_alloc(); +} +void* operator new[](std::size_t n) { + if(noHeap.load(std::memory_order_relaxed))std::abort(); + if(void* p=std::malloc(n?n:1))return p; + throw std::bad_alloc(); +} +void operator delete(void* p) noexcept {std::free(p);} +void operator delete[](void* p) noexcept {std::free(p);} +void operator delete(void* p,std::size_t) noexcept {std::free(p);} +void operator delete[](void* p,std::size_t) noexcept {std::free(p);} +using armix::mixer::ChannelId; +using armix::mixer::NativeMusicTempoMonitor; +static void renderWindow(NativeMusicTempoMonitor& tap,int index,int period, + float beat=.7f,bool weakOffbeats=false, + std::uint64_t epoch=7,std::uint64_t revision=13) { + std::array l{},r{}; + const int pos=index%period; + const float level=pos==0?beat: + weakOffbeats&&pos==period/2?.07f:0.f; + l.fill(level);r.fill(level); + // A 10ms bucket is split across 64+36 ASIO callback frames at 10kHz. + noHeap.store(true,std::memory_order_release); + tap.capture(ChannelId{301},l.data(),r.data(),64,epoch,revision); + tap.capture(ChannelId{301},l.data()+64,r.data()+64,36,epoch,revision); + noHeap.store(false,std::memory_order_release); + if(index%8==0)(void)tap.poll(epoch,revision); // host timer, not RT +} +static void lockTempo(int bpm,bool hats=false) { + NativeMusicTempoMonitor tap; + check(!tap.select(ChannelId{301},7,13,0)); + check(tap.select(ChannelId{301},7,13,10000)); + auto state=tap.poll(7,13); + check(state.active&&state.source.value==301&&!state.tempo.locked); + const int period=static_cast(std::lround(6000.0/bpm)); + for(int n=0;n<1100;++n)renderWindow(tap,n,period,.75f,hats); + state=tap.poll(7,13); + check(state.tempo.locked); + check(std::abs(state.tempo.bpm-bpm)<=3.1f); + check(state.tempo.confidence>=.28f); + check(state.tempo.beatAnchorTick>0); + check(state.dropped==0); + // One second of no music must NOT produce spurious half/double BPM. + for(int n=1100;n<1200;++n)renderWindow(tap,n,6000); + state=tap.poll(7,13); + check(state.tempo.locked); + // The user must see manual/TAP fallback after >3.2s of silence. + for(int n=1200;n<1580;++n)renderWindow(tap,n,6000); + state=tap.poll(7,13); + check(!state.tempo.locked); +} +static void failClosed() { + NativeMusicTempoMonitor tap; + check(tap.select(ChannelId{301},7,13,48000)); + std::array pcm{};pcm.fill(.8f); + noHeap.store(true); + for(int i=0;i<240;++i) { + // Wrong channel and wrong graph revision must not populate the FIFO. + tap.capture(ChannelId{302},pcm.data(),pcm.data(),128,7,13); + tap.capture(ChannelId{301},pcm.data(),pcm.data(),128,7,14); + } + noHeap.store(false); + auto stale=tap.poll(7,14); + check(!stale.active&&!stale.tempo.locked); + auto active=tap.poll(7,13); + check(active.active&&!active.tempo.locked); + check(tap.select(ChannelId{},7,13,0)); + check(!tap.poll(7,13).active); +} +int main() { + lockTempo(72); + lockTempo(95); + lockTempo(120); + lockTempo(160); + lockTempo(120,true); + failClosed(); + std::puts("PASS: native music-channel BPM 72/95/120/160, silence holdover, stale graph, no RT heap"); +} From 2254afc0e71f89788aa3aed31aaab3060fbadcf8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 22:59:56 +0700 Subject: [PATCH 49/61] build(music-tempo): register deterministic native CTest in existing Windows lane --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c1702fae..af792fd07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -384,6 +384,12 @@ if(BUILD_TESTING) target_compile_features(ARMixNativeVocalThrowTests PRIVATE cxx_std_20) add_test(NAME NativeVocalThrowPhraseCaptureManualAutoAndNoHeap COMMAND ARMixNativeVocalThrowTests) add_dependencies(ARMixMixerRoutingTests ARMixNativeVocalThrowTests) + add_executable(ARMixNativeMusicTempoTests tests/native_music_tempo_test.cpp + engine/core/NativeMusicTempoMonitor.h) + target_compile_features(ARMixNativeMusicTempoTests PRIVATE cxx_std_20) + add_test(NAME NativeMusicTempoSourceOnsetsAndFallback COMMAND ARMixNativeMusicTempoTests) + add_dependencies(ARMixMixerRoutingTests ARMixNativeMusicTempoTests) + add_executable(ARMixNativeMasterLoudnessTests tests/native_master_loudness_test.cpp engine/dsp/NativeMasterLoudness.h) target_compile_features(ARMixNativeMasterLoudnessTests PRIVATE cxx_std_20) From 699a0e03971b35ba33040b1013ab446c9d49225a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 23:00:25 +0700 Subject: [PATCH 50/61] fix(music-tempo): rebind valid source safely across native graph revisions --- engine/core/NativeMusicTempoMonitor.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/engine/core/NativeMusicTempoMonitor.h b/engine/core/NativeMusicTempoMonitor.h index e84e9d270..81560fa3d 100644 --- a/engine/core/NativeMusicTempoMonitor.h +++ b/engine/core/NativeMusicTempoMonitor.h @@ -144,6 +144,23 @@ class NativeMusicTempoMonitor final { config_.fetch_add(1,std::memory_order_release); return true; } + // CONTROL: harmless structural WIRE/FX commits should preserve a valid + // music source. If the selected channel disappears, fall back to manual + // immediately rather than capturing stale processor/graph PCM. + ChannelId selectedSource() const noexcept { + return ChannelId{source_.load(std::memory_order_relaxed)}; + } + void onGraphCommitted(std::uint64_t epoch,std::uint64_t previousRevision, + std::uint64_t revision,bool retained) noexcept { + if(!selectedSource().value)return; + if(!retained || epoch_.load(std::memory_order_relaxed)!=epoch || + revision_.load(std::memory_order_relaxed)!=previousRevision) { + (void)select(ChannelId{},epoch,revision,0); + return; + } + revision_.store(revision,std::memory_order_relaxed); + config_.fetch_add(1,std::memory_order_release); + } // AUDIO: invoked once for every scheduled source channel by the existing // renderer's pre-FX dispatch. Only the selected ID costs per-sample work. void capture(ChannelId id,const float* left,const float* right,int frames, From ad599a8a27f36dece0ed736a5b47a972d4026bab Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 23:00:37 +0700 Subject: [PATCH 51/61] fix(music-tempo): preserve validated music ChannelId across WIRE/FX commits --- engine/core/DynamicNativeSessionPublisher.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/engine/core/DynamicNativeSessionPublisher.h b/engine/core/DynamicNativeSessionPublisher.h index 24c519140..a2246c308 100644 --- a/engine/core/DynamicNativeSessionPublisher.h +++ b/engine/core/DynamicNativeSessionPublisher.h @@ -125,8 +125,23 @@ class DynamicNativeSessionPublisher final { const auto status=publisher_.publish(std::move(next), expectedRevision,activeDeviceEpoch); switch(status) { - case Publisher::Result::applied: + case Publisher::Result::applied: { + const auto source=musicTempo_.selectedSource(); + if(source.value) { + const auto* published=publisher_.controlPrepared( + proposedDeviceEpoch,expectedRevision+1); + const auto* channel=published? + published->routing.find(source):nullptr; + const bool retained=published&&channel&& + (channel->role==ChannelRole::input|| + channel->role==ChannelRole::group|| + channel->role==ChannelRole::fxReturn)&& + published->graph.channelScheduled(source); + musicTempo_.onGraphCommitted(proposedDeviceEpoch, + expectedRevision,expectedRevision+1,retained); + } report.revision=expectedRevision+1;return report; + } case Publisher::Result::staleDevice: report.fault=Fault::staleDevice;break; case Publisher::Result::staleRevision: From 7e80f00d71e80bd992c8b3c455c1dcd7eeaeb249 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 23:01:24 +0700 Subject: [PATCH 52/61] test(vocal-throw-ui): native music-source ACK and live BPM readback desktop/mobile --- tests/approved_native_vocal_throw_smoke.py | 24 ++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tests/approved_native_vocal_throw_smoke.py b/tests/approved_native_vocal_throw_smoke.py index 2e9006266..8ac628731 100644 --- a/tests/approved_native_vocal_throw_smoke.py +++ b/tests/approved_native_vocal_throw_smoke.py @@ -6,7 +6,7 @@ from pathlib import Path import tempfile from playwright.sync_api import sync_playwright -from approved_native_wire_gain_smoke import snapshot, emit, ack, SOURCE +from approved_native_wire_gain_smoke import snapshot, emit, ack, SOURCE, RECEIVER ROOT=Path(__file__).resolve().parents[1] ID="armix.builtin.vocal-throw.v1" @@ -20,13 +20,18 @@ def last(page,action): assert records, "No "+action+" event" return records[-1] -def reply_snapshot(page,state,settings,applied=None,count=0,tail=False): +def reply_snapshot(page,state,settings,applied=None,count=0,tail=False,music=None): act=last(page,"nativeThrowSnapshot") data={"requestId":act["requestId"],"channelId":SOURCE,"slot":0, "instanceId":INSTANCE,"status":"ACCEPTED","schemaVersion":1, "deviceEpoch":state["device"]["epoch"], "graphRevision":state["graph"]["revision"],"sampleRate":48000, "addedLatencySamples":0,"throwCount":count,"tailActive":tail, + "musicSourceChannelId":music["source"] if music else "0", + "musicSourceActive":bool(music), + "musicLocked":bool(music), + "musicBpm":music["bpm"] if music else 0, + "musicConfidence":music["confidence"] if music else 0, "settings":copy.deepcopy(settings)} if applied:data["appliedRequestId"]=applied emit(page,"arMixBuiltinThrowSnapshot",data) @@ -125,6 +130,21 @@ def main(): channels=copy.deepcopy(state["graph"]["channels"])) emit(page,"arMixConsoleSnapshot",state) page.wait_for_function("""()=>document.querySelector('#vtThrow')?.disabled""",timeout=2000) + # Real native tempo-source command (not a browser-only BPM guess). + source_menu=editor.locator("#vtMusicSource") + assert source_menu.locator('option[value="'+RECEIVER+'"]').count()==1 + source_menu.select_option(RECEIVER) + request=last(page,"nativeThrowTempoSource") + assert request["sourceChannelId"]==RECEIVER and request["channelId"]==SOURCE + assert editor.locator("#vtMusicStatus").inner_text().startswith("Validating") + emit(page,"arMixBuiltinThrowTempoAck",{ + "requestId":request["requestId"],"status":"APPLIED", + "sourceChannelId":RECEIVER}) + reply_snapshot(page,state, + {**DEFAULTS,"mode":0} if width==1366 else DEFAULTS, + count=1 if width==1366 else 0,tail=width==1366, + music={"source":RECEIVER,"bpm":120,"confidence":.85}) + assert "AUTO 120 BPM" in editor.locator("#vtMusicStatus").inner_text() editor.locator("#vtClose").click() assert editor.is_hidden(),"standard close must dismiss editor" assert not errors,(width,errors) From d6daf5df4ef1b29fe7c43eb6da09edcdae1eb341 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 23:01:42 +0700 Subject: [PATCH 53/61] test(vocal-throw): verify tempo ACK before exercising stale FX instance --- tests/approved_native_vocal_throw_smoke.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/approved_native_vocal_throw_smoke.py b/tests/approved_native_vocal_throw_smoke.py index 8ac628731..19783aa9a 100644 --- a/tests/approved_native_vocal_throw_smoke.py +++ b/tests/approved_native_vocal_throw_smoke.py @@ -123,13 +123,6 @@ def main(): reply_snapshot(page,state,{**DEFAULTS,"mode":0},count=1,tail=True) assert editor.locator("#vtCount").inner_text()=="1 throws" assert editor.locator("#vtStatus").inner_text()=="ECHO TAIL" - # The next changed graph invalidates the old editor instance. - state["graph"]["channels"][0]["inserts"][0]["id"]="replaced-instance" - state["graph"].update(revision="4",rosterRevision="4") - state["mixerSession"].update(routeRevision="4",rosterRevision="4", - channels=copy.deepcopy(state["graph"]["channels"])) - emit(page,"arMixConsoleSnapshot",state) - page.wait_for_function("""()=>document.querySelector('#vtThrow')?.disabled""",timeout=2000) # Real native tempo-source command (not a browser-only BPM guess). source_menu=editor.locator("#vtMusicSource") assert source_menu.locator('option[value="'+RECEIVER+'"]').count()==1 @@ -145,6 +138,14 @@ def main(): count=1 if width==1366 else 0,tail=width==1366, music={"source":RECEIVER,"bpm":120,"confidence":.85}) assert "AUTO 120 BPM" in editor.locator("#vtMusicStatus").inner_text() + if width==1366: + # The next changed graph invalidates the old editor instance. + state["graph"]["channels"][0]["inserts"][0]["id"]="replaced-instance" + state["graph"].update(revision="4",rosterRevision="4") + state["mixerSession"].update(routeRevision="4",rosterRevision="4", + channels=copy.deepcopy(state["graph"]["channels"])) + emit(page,"arMixConsoleSnapshot",state) + page.wait_for_function("""()=>document.querySelector('#vtThrow')?.disabled""",timeout=2000) editor.locator("#vtClose").click() assert editor.is_hidden(),"standard close must dismiss editor" assert not errors,(width,errors) From 9906d9a6781c4ec26477a1466f755ce254f405ee Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 23:02:02 +0700 Subject: [PATCH 54/61] style(test): normalize native music tempo smoke fixture indent --- tests/approved_native_vocal_throw_smoke.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/approved_native_vocal_throw_smoke.py b/tests/approved_native_vocal_throw_smoke.py index 19783aa9a..b4a799984 100644 --- a/tests/approved_native_vocal_throw_smoke.py +++ b/tests/approved_native_vocal_throw_smoke.py @@ -139,13 +139,13 @@ def main(): music={"source":RECEIVER,"bpm":120,"confidence":.85}) assert "AUTO 120 BPM" in editor.locator("#vtMusicStatus").inner_text() if width==1366: - # The next changed graph invalidates the old editor instance. - state["graph"]["channels"][0]["inserts"][0]["id"]="replaced-instance" - state["graph"].update(revision="4",rosterRevision="4") - state["mixerSession"].update(routeRevision="4",rosterRevision="4", - channels=copy.deepcopy(state["graph"]["channels"])) - emit(page,"arMixConsoleSnapshot",state) - page.wait_for_function("""()=>document.querySelector('#vtThrow')?.disabled""",timeout=2000) + # The next changed graph invalidates the old editor instance. + state["graph"]["channels"][0]["inserts"][0]["id"]="replaced-instance" + state["graph"].update(revision="4",rosterRevision="4") + state["mixerSession"].update(routeRevision="4",rosterRevision="4", + channels=copy.deepcopy(state["graph"]["channels"])) + emit(page,"arMixConsoleSnapshot",state) + page.wait_for_function("""()=>document.querySelector('#vtThrow')?.disabled""",timeout=2000) editor.locator("#vtClose").click() assert editor.is_hidden(),"standard close must dismiss editor" assert not errors,(width,errors) From 1576c2327bbcc27b7267b3ac6898a6756341c9c7 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 23:02:19 +0700 Subject: [PATCH 55/61] perf(music-tempo): deduplicate control BPM packets and avoid repeated parameter math --- engine/builtin_fx/VocalThrowProcessor.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/engine/builtin_fx/VocalThrowProcessor.h b/engine/builtin_fx/VocalThrowProcessor.h index c1a7ee1a6..fb041709b 100644 --- a/engine/builtin_fx/VocalThrowProcessor.h +++ b/engine/builtin_fx/VocalThrowProcessor.h @@ -76,11 +76,21 @@ class VocalThrowProcessor final : public juce::AudioProcessor, // serialized preset BPM. No queue ACK storm or GUI state overwrite. void publishMusicBpm(float bpm) noexcept { if(!ready_||!std::isfinite(bpm)||bpm<60.f||bpm>200.f) { - musicInterval_.store(0,std::memory_order_release);return; + if(lastTempoBpm_!=0.f) { + lastTempoBpm_=0.f;lastTempoDivision_=-1; + musicInterval_.store(0,std::memory_order_release); + } + return; } + // The 12Hz message timer may deliver the same accepted tempo many + // times. Never recompute power/division or publish redundant atomics. + if(lastTempoBpm_==bpm && lastTempoDivision_==accepted_.division) + return; auto settings=accepted_;settings.bpm=bpm; VocalThrow::PreparedEdit packet{}; const auto valid=VocalThrow::prepareEdit(settings,rate_,packet); + lastTempoBpm_=valid?bpm:0.f; + lastTempoDivision_=valid?accepted_.division:-1; musicInterval_.store(valid?packet.intervalSamples:0, std::memory_order_release); } @@ -165,6 +175,8 @@ class VocalThrowProcessor final : public juce::AudioProcessor, std::atomic musicInterval_{0}; std::atomic observedTail_{false}; double rate_=0.; + float lastTempoBpm_=0.f; // CONTROL only + int lastTempoDivision_=-1; // CONTROL only bool ready_=false,published_=false; }; } // namespace armix::builtin_fx From 9662de5bf6001624a04e121ccb2536dbda6ab1d1 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 23:03:53 +0700 Subject: [PATCH 56/61] ci(vocal-throw): run focused Chromium FAT for native and music tempo milestones --- .github/workflows/ui-smoke.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ui-smoke.yml b/.github/workflows/ui-smoke.yml index 822b894fe..2d30113e8 100644 --- a/.github/workflows/ui-smoke.yml +++ b/.github/workflows/ui-smoke.yml @@ -130,7 +130,7 @@ jobs: vocal-throw-preview: name: Vocal Throw native editor desktop/mobile Chromium FAT needs: quick - if: ${{ github.event_name == 'pull_request' && github.head_ref == 'feature/arson-vocal-throw-native-20261108' }} + if: ${{ github.event_name == 'pull_request' && startsWith(github.head_ref, 'feature/arson-vocal-throw-') }} runs-on: ubuntu-latest timeout-minutes: 15 steps: From cce63231da52f69e6789873ecc406adba69aa1cb Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 23:05:19 +0700 Subject: [PATCH 57/61] test(music-tempo): prove actual accepted graph PCM tap and revision fencing --- tests/native_music_tempo_test.cpp | 55 +++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/native_music_tempo_test.cpp b/tests/native_music_tempo_test.cpp index 8253673ed..558d61c72 100644 --- a/tests/native_music_tempo_test.cpp +++ b/tests/native_music_tempo_test.cpp @@ -1,5 +1,6 @@ // SPDX-License-Identifier: AGPL-3.0-only #include "../engine/core/NativeMusicTempoMonitor.h" +#include "../engine/core/DynamicNativeSessionPublisher.h" #include #include #include @@ -81,6 +82,59 @@ static void failClosed() { check(tap.select(ChannelId{},7,13,0)); check(!tap.poll(7,13).active); } +static void actualGraphSourcePcm() { + using namespace armix::mixer; + DynamicChannelRoster roster; + ChannelEdit source,main; + source.kind=ChannelEdit::Kind::add;source.position=0; + source.role=ChannelRole::input;source.text="BACKING"; + main.kind=ChannelEdit::Kind::add;main.position=1; + main.role=ChannelRole::main;main.text="MAIN"; + main.format=ProcessingFormat::stereo; + const std::array adds{source,main}; + const auto created=roster.edit(0,adds); + check(created.ok()&&created.createdIds.size()==2); + const auto music=created.createdIds[0],master=created.createdIds[1]; + ChannelEdit output; + output.kind=ChannelEdit::Kind::setPrimaryOutput; + output.id=music;output.target=master; + const std::array links{output}; + check(roster.edit(1,links).ok()); + DynamicGraphRequest request; + request.physicalInputs=1;request.maxFrames=128; + request.sources={{music,0,-1,false}}; + DynamicNativeSessionPublisher graph; + constexpr std::uint64_t epoch=7; + const auto applied=graph.commit(roster,request,0,epoch,epoch,true); + check(applied.ok()&&applied.revision==1); + check(!graph.setMusicTempoSource(epoch,1,master,10000)); // MAIN forbidden + check(!graph.setMusicTempoSource(epoch-1,1,music,10000)); + check(graph.setMusicTempoSource(epoch,1,music,10000)); + std::array input{},outL{},outR{}; + const float* physical[]{input.data()}; + const auto dryFx=[](ChannelId,float*,float*,int) noexcept {}; + for(int tick=0;tick<1000;++tick) { + input.fill((tick%50)==0?.65f:0.f); // 120 BPM from real graph + noHeap.store(true,std::memory_order_release); + const bool rendered=graph.render(epoch,physical,1, + outL.data(),outR.data(),100,false,dryFx); + noHeap.store(false,std::memory_order_release); + check(rendered); + if(tick%8==0)(void)graph.pollMusicTempo(epoch,1); + } + auto state=graph.pollMusicTempo(epoch,1); + check(state.active&&state.source==music); + check(state.tempo.locked&&std::abs(state.tempo.bpm-120.f)<=3.f); + // The *same* music ChannelId survives a graph revision with no second + // callback or preserved stale PCM pointers. + const auto newer=graph.commit(roster,request,1,epoch,epoch,true); + check(newer.ok()&&newer.revision==2); + state=graph.pollMusicTempo(epoch,2); + check(state.active&&state.source==music); + check(!graph.pollMusicTempo(epoch,1).active); + graph.unpublish(); + graph.pollRetirement(); +} int main() { lockTempo(72); lockTempo(95); @@ -88,5 +142,6 @@ int main() { lockTempo(160); lockTempo(120,true); failClosed(); + actualGraphSourcePcm(); std::puts("PASS: native music-channel BPM 72/95/120/160, silence holdover, stale graph, no RT heap"); } From 237634557b9c7583c3951e43bfc34877291d632b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 23:22:07 +0700 Subject: [PATCH 58/61] fix(vocal-throw): read music tempo before same-block throw and reset on device reprepare --- engine/builtin_fx/VocalThrowProcessor.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/engine/builtin_fx/VocalThrowProcessor.h b/engine/builtin_fx/VocalThrowProcessor.h index fb041709b..a7573b0a1 100644 --- a/engine/builtin_fx/VocalThrowProcessor.h +++ b/engine/builtin_fx/VocalThrowProcessor.h @@ -45,6 +45,10 @@ class VocalThrowProcessor final : public juce::AudioProcessor, layout.getMainOutputChannelSet()==juce::AudioChannelSet::stereo(); } void prepareToPlay(double sampleRate,int) override { + // Each device epoch gets a new frame clock. A previously accepted + // auto BPM interval is invalid if the hardware sample rate changed. + lastTempoBpm_=0.f;lastTempoDivision_=-1; + musicInterval_.store(0,std::memory_order_release); ready_=core_.prepare(sampleRate)&&core_.resetUnpublished(accepted_); if(ready_)rate_=sampleRate; } @@ -54,11 +58,9 @@ class VocalThrowProcessor final : public juce::AudioProcessor, void processBlock(juce::AudioBuffer& pcm,juce::MidiBuffer&) override { juce::ScopedNoDenormals noDenormals; if(!ready_||pcm.getNumChannels()<2||pcm.getNumSamples()<=0)return; + // consumeRealtimeEdits() snapshots the accepted tempo BEFORE any + // manual cue in the same block; bypassed inserts use the same path. consumeRealtimeEdits(); - // Transport is published by CONTROL as an already prepared sample - // interval; AUDIO performs only one atomic read at the block edge. - core_.setMusicIntervalSamples( - musicInterval_.load(std::memory_order_acquire)); core_.processStereo(pcm.getWritePointer(0),pcm.getWritePointer(1), static_cast(pcm.getNumSamples())); observedThrows_.store(core_.throwCount(),std::memory_order_relaxed); @@ -66,8 +68,13 @@ class VocalThrowProcessor final : public juce::AudioProcessor, } void processBlock(juce::AudioBuffer&,juce::MidiBuffer&) override{} void consumeRealtimeEdits() noexcept override { + if(!ready_)return; + // One atomic acquire per callback, before queueing the newest throw. + // A source change and button click cannot freeze the previous BPM. + core_.setMusicIntervalSamples( + musicInterval_.load(std::memory_order_acquire)); Edit e{}; - if(!ready_||!done_.canPush()||!commands_.pop(e))return; + if(!done_.canPush()||!commands_.pop(e))return; const bool applied=e.kind==CommandKind::settings? core_.applyPrepared(e.prepared):core_.throwNow(); (void)done_.push({e.id,e.prepared.settings,e.kind,applied}); From 88af4f4344afc62f2368952f403756b1db6945fe Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 23:22:48 +0700 Subject: [PATCH 59/61] test(vocal-throw): auto music BPM freeze, no tail retime, Manual/TAP fallback --- tests/builtin_vocal_throw_test.cpp | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/builtin_vocal_throw_test.cpp b/tests/builtin_vocal_throw_test.cpp index 28d6ea9b2..35d1b5d30 100644 --- a/tests/builtin_vocal_throw_test.cpp +++ b/tests/builtin_vocal_throw_test.cpp @@ -248,6 +248,42 @@ static void manualOverrideSuppressesAuto() { run(fx,0.f,0.f,5000,l,r); check(fx.throwCount()==2); // new phrase, after full release + gate } +// Accepted music BPM affects only new frozen tails, never retimes a tail +// already singing. An unlocked source must use persisted Manual/TAP BPM. +static void musicTempoChangesOnlyFutureTail() { + VocalThrow music,manual; + check(music.prepare(48000)&&manual.prepare(48000)); + auto s=music.settingsForTests(); + s.mode=0;s.bpm=120.f;s.division=0;s.repeats=1; + s.captureMs=120.f;s.wet=1.f;s.ducking=0.f; + check(music.resetUnpublished(s)&&manual.resetUnpublished(s)); + float a=0.f,b=0.f; + run(music,.6f,.4f,12000,a,b); + run(manual,.6f,.4f,12000,a,b); + run(music,0.f,0.f,2880,a,b); + run(manual,0.f,0.f,2880,a,b); + noHeap.store(true); + music.setMusicIntervalSamples(12000); // 1/4 at 240 BPM equivalent + const bool firedMusic=music.throwNow(); + const bool firedManual=manual.throwNow(); + // The selected backing bus can disappear immediately after the cue. + // Its already frozen tail must retain the accepted .25s repeat interval. + music.setMusicIntervalSamples(0); + noHeap.store(false); + check(firedMusic&&firedManual); + a=b=0.f; + run(music,0.f,0.f,8640,a,b); // 180 ms after cue + check(a==0.f&&b==0.f); + a=b=0.f; + run(music,0.f,0.f,6720,a,b); // repeat around 190-310 ms + check(a>.01f&&b>.01f); + a=b=0.f; + run(manual,0.f,0.f,15360,a,b); // manual .5s must still be silent + check(a==0.f&&b==0.f); + a=b=0.f; + run(manual,0.f,0.f,11520,a,b); + check(a>.01f&&b>.01f); +} int main() { validation(); manualAndDry(8000); @@ -262,5 +298,6 @@ int main() { manualOverrideSuppressesAuto(); autoThenManualMustNotDoubleEcho(); denseRepeatsStayBounded(); + musicTempoChangesOnlyFutureTail(); std::puts("PASS: vocal-throw native dry/rolling capture/phrase/echo/tempo/no-heap"); } From 632cb473debc0ff0f892d6b563468a63ed1e64ed Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 23:23:19 +0700 Subject: [PATCH 60/61] test(music-tempo): use valid 180 BPM interval vs 120 BPM fallback --- tests/builtin_vocal_throw_test.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/builtin_vocal_throw_test.cpp b/tests/builtin_vocal_throw_test.cpp index 35d1b5d30..11ed08ab3 100644 --- a/tests/builtin_vocal_throw_test.cpp +++ b/tests/builtin_vocal_throw_test.cpp @@ -263,7 +263,7 @@ static void musicTempoChangesOnlyFutureTail() { run(music,0.f,0.f,2880,a,b); run(manual,0.f,0.f,2880,a,b); noHeap.store(true); - music.setMusicIntervalSamples(12000); // 1/4 at 240 BPM equivalent + music.setMusicIntervalSamples(16000); // quarter-note at 180 BPM const bool firedMusic=music.throwNow(); const bool firedManual=manual.throwNow(); // The selected backing bus can disappear immediately after the cue. @@ -272,16 +272,16 @@ static void musicTempoChangesOnlyFutureTail() { noHeap.store(false); check(firedMusic&&firedManual); a=b=0.f; - run(music,0.f,0.f,8640,a,b); // 180 ms after cue + run(music,0.f,0.f,12960,a,b); // 270 ms after cue check(a==0.f&&b==0.f); a=b=0.f; - run(music,0.f,0.f,6720,a,b); // repeat around 190-310 ms + run(music,0.f,0.f,8160,a,b); // repeat around 290-410 ms check(a>.01f&&b>.01f); a=b=0.f; - run(manual,0.f,0.f,15360,a,b); // manual .5s must still be silent + run(manual,0.f,0.f,17760,a,b); // manual .5s must still be silent check(a==0.f&&b==0.f); a=b=0.f; - run(manual,0.f,0.f,11520,a,b); + run(manual,0.f,0.f,7680,a,b); check(a>.01f&&b>.01f); } int main() { From 39ba9a48de8fe87270f9ed0cf9cac49fb004dfed Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 23:23:56 +0700 Subject: [PATCH 61/61] docs(music-tempo): architecture, evidence and explicit live-qualification boundary --- ...SON_VOCAL_THROW_MUSIC_TEMPO_M2_20261108.md | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 docs/ARSON_VOCAL_THROW_MUSIC_TEMPO_M2_20261108.md diff --git a/docs/ARSON_VOCAL_THROW_MUSIC_TEMPO_M2_20261108.md b/docs/ARSON_VOCAL_THROW_MUSIC_TEMPO_M2_20261108.md new file mode 100644 index 000000000..088665a93 --- /dev/null +++ b/docs/ARSON_VOCAL_THROW_MUSIC_TEMPO_M2_20261108.md @@ -0,0 +1,45 @@ +# ArSon Vocal Throw M2 — Native Music Channel Tempo Detection + +**Status:** implementation and qualification draft, stacked on Vocal Throw M1 PR #469. M1 green head `4db384851e6f6378cca4fd037b744c98bd1f0ba3`; M2 is PR #474 and tracks issue #473. + +## Signal authority + +``` +Authoritative ChannelId native PCM graph, single JUCE / ASIO callback + MUSIC ChannelId selected explicitly by singer/operator + -> PRE-FX non-mutating read-only music tap + -> 10ms stereo absolute-energy summary, bounded SPSC + -> existing 12Hz JUCE control timer: onset search + BPM confidence + -> accepted tempo precomputed into sample intervals, CONTROL only + -> per-VocalThrow atomic pending interval + -> next dry/vocal PCM callback copies interval BEFORE any THROW + -> new frozen vocal echo gets music interval, old tails keep prior schedule + VOICE ChannelId -> VocalThrow (no added dry PCM delay) -> WIRE/BUS/MAIN +``` + +**AUDIO callback contract:** no memory allocations, FFT, file I/O, logging, locks, networking, JS DSP, or new audio threads. Only the explicitly selected source channel's input stereo samples are summarized; every other channel skips the per-sample music tap. Existing JUCE callback remains the only audio authority. Core audio buffers and retained FX leases remain with the native graph. + +**CONTROL contract:** only an accepted `ChannelId` with input / GROUP / FX_RETURN role and an actually scheduled PCM lane is a permissible tempo source. The native FX editor validates both its own vocal insert instance and source identity, device epoch and graph revision. Monitor/MAIN and the vocal channel itself are not accepted. On a valid structural graph recompile, an existing source ID is rebound with a new analysis generation; if absent or stale, the music clock is disabled, and Vocal Throw falls back to its saved BPM or TAP tempo. + +## Detector + +- A 10ms energy onset, 80ms transient refractory and adaptive floor reject a simple repeated rise from a sustained note. +- Bounded pairwise onset-period candidate scoring (60–180 BPM), with penalty for octave half/double candidates, three consistent estimates and confidence threshold. +- Native readback distinguishes **AUTO BPM locked**, **Listening**, and **Manual/TAP fallback**. A silence period exceeding 3.2s resets lock. +- UI conveys confidence as measured by estimator; this number is not field-certified reliability. + +**Explicit limitations:** Music/onset BPM estimation does not provide sample-perfect beat-phase grid alignment. A recent transient anchor is retained for diagnostics only; it is not used as a globally compensated sample clock. Syncopated and heavily compressed music, live mic bleed, time-signature changes, half/double-time ambiguity and device-specific ASIO timing remain hardware field gates. Tempo selection is ephemeral song-wide, not yet persisted per Show. The fallback path always remains audible on the singer's dry stream. + +## Qualification evidence + +- Prior M1 Windows MSVC/JUCE: 63/63 CTest on exact SHA `4db384851e6f6378cca4fd037b744c98bd1f0ba3`. +- M2 Windows MSVC/JUCE: 64/64 CTest, including `NativeMusicTempoSourceOnsetsAndFallback`, on exact SHA `cce63231da52f69e6789873ecc406adba69aa1cb`. See [Actions run 42498186748](https://github.com/masarray/arsonmix/actions/runs/42498186748). +- Chromium FAT M2 native Vocal Throw picker, music source ACK, BPM readback and stale instance handling passed on same SHA. +- Later hardening: inbound tempo sampled before same-callback THROW and reset on plugin audio reprepare; corresponding regression checks for manual fallback and active tail interval stability. Qualification on the later SHA must be checked independently. +- Deterministic PCM: 72, 95, 120, 160 BPM; non-vocal source, stale revision, source change, dropout, default fallback. The CTest calls the *actual* native publisher to verify a music signal traverses the accepted graph, not only the isolated estimator. + +**Not qualified:** physical ASIO 64/128 frame load at 44.1/48/96 kHz; prolonged simultaneous singer/backing test; live beat-grid sync / stereo echo hearing test; WASAPI secondary stream callback load; long-run xrun/restart and voice-music bleed reliability. Green CI is necessary but not sufficient for release. + +## Next DSP/UX milestone + +Prove stable beat phase with a source-specific latency-compensated anchor; handle half/double-time ambiguity with confidence floor and long-window hysteresis; permit song/Show fallback preference; add footswitch mapping and live capture metrics without callback work. Until then label UI as estimated **AUTO BPM** rather than **sample-accurate beat quantization**.