From e74b622da7a759ecda62b42ae11856109628cc1c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 8 Nov 2026 21:04:53 +0700 Subject: [PATCH 01/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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/37] 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"); }