diff --git a/.github/workflows/ui-smoke.yml b/.github/workflows/ui-smoke.yml index ffc92c72b..d2d777d94 100644 --- a/.github/workflows/ui-smoke.yml +++ b/.github/workflows/ui-smoke.yml @@ -168,6 +168,8 @@ jobs: run: python tests/approved_stage_c_css_visual_parity_smoke.py - name: Check real mobile /preview/ touch toolbar, popup and stray chevrons run: python tests/approved_preview_mobile_navigation_smoke.py + - name: FX rack master bypass preserves each insert state (real Chromium) + run: python tests/approved_fx_rack_master_power_smoke.py - name: Stage D one runtime CSSOM and actual stylesheet network count run: python tests/approved_css_stage_d_single_bundle_smoke.py - name: Stage C rendered CSS parity (original vs compiled, three viewports + hover) diff --git a/engine/core/DynamicChannelFxLeaseBank.h b/engine/core/DynamicChannelFxLeaseBank.h index 46c29f4f8..36499a531 100644 --- a/engine/core/DynamicChannelFxLeaseBank.h +++ b/engine/core/DynamicChannelFxLeaseBank.h @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include #include @@ -33,6 +35,9 @@ class DynamicChannelFxLeaseBank final { ChannelId id{}; ProcessingFormat format=ProcessingFormat::stereo; std::vector inserts; // CONTROL only; no creation on callback + // Reused over revision changes. This flag overrides the effective + // output without changing the individual FxInstance bypass flags. + std::shared_ptr> rackBypassed; }; // Occupied CH1 vendor/Orbit owner remains alive with accepted PCM. @@ -101,6 +106,8 @@ class DynamicChannelFxLeaseBank final { if(b.format!=ProcessingFormat::mono && b.format!=ProcessingFormat::stereo)return Fault::invalidBusLayout; Row row;row.id=b.id;row.format=b.format; + row.rackBypassed=b.rackBypassed?b.rackBypassed: + std::make_shared>(false); // CONTROL allocation row.count=static_cast(b.inserts.size()); for(std::size_t i=0;ibypassRequested.store(bypass,std::memory_order_release); return true; } + bool setRackBypass(std::uint64_t expectedEpoch, + std::uint64_t expectedRevision,ChannelId id, + bool bypass) const noexcept { + if(expectedEpoch!=epoch_||expectedRevision!=revision_||!id.value) + return false; + const auto* row=find(id); + if(!row||!row->rackBypassed)return false; + row->rackBypassed->store(bypass,std::memory_order_release); + return true; + } + bool rackBypassed(ChannelId id) const noexcept { + const auto* row=find(id); + return row&&row->rackBypassed && + row->rackBypassed->load(std::memory_order_acquire); + } // The actual prepared vendor instance is also the native editor owner; // never synthesize a WebView editor or use a catalog name as identity. Lease leaseEditor(std::uint64_t expectedEpoch, @@ -199,7 +221,7 @@ class DynamicChannelFxLeaseBank final { retained.reserve(prior.rows_.size()); for(const auto& row:prior.rows_) { Assignment item; - item.id=row.id;item.format=row.format; + item.id=row.id;item.format=row.format;item.rackBypassed=row.rackBypassed; item.inserts.reserve(row.count); for(std::size_t slot=0;slotrackBypassed && + row->rackBypassed->load(std::memory_order_acquire); for(std::size_t i=0;icount;++i) - row->raw[i]->render(left,right,frames); + row->raw[i]->render(left,right,frames,rackOff); } private: @@ -262,6 +287,7 @@ class DynamicChannelFxLeaseBank final { ChannelId id{}; ProcessingFormat format=ProcessingFormat::stereo; std::uint8_t count=0; + std::shared_ptr> rackBypassed; // persists across revisions std::array owners{}; std::array raw{}; }; diff --git a/engine/core/LiveChannelFxGraph.h b/engine/core/LiveChannelFxGraph.h index 281b172f9..7bd2ba0e4 100644 --- a/engine/core/LiveChannelFxGraph.h +++ b/engine/core/LiveChannelFxGraph.h @@ -79,7 +79,7 @@ class LiveChannelFxGraph final { processing.clear(std::memory_order_release); return ok; } - void render(float* left,float* right,int samples) noexcept { + void render(float* left,float* right,int samples,bool rackBypassed=false) noexcept { if(processing.test_and_set(std::memory_order_acquire)) { contention.fetch_add(1,std::memory_order_relaxed); juce::FloatVectorOperations::clear(left,samples); @@ -87,7 +87,8 @@ class LiveChannelFxGraph final { return; } // G5C: atomic request from control; fade and scratch RT-owned. - bypassFade.request(bypassRequested.load(std::memory_order_relaxed)); + // Master rack bypass affects the WET/DRY envelope, never the remembered insert preference. + bypassFade.request(rackBypassed || bypassRequested.load(std::memory_order_relaxed)); if(bypassFade.fullyBypassed()) { processing.clear(std::memory_order_release); return; @@ -227,6 +228,17 @@ class LiveChannelFxGraph final { fx->bypassRequested.store(bypass,std::memory_order_release); return true; } + // One atomic rack override per channel. Individual slot bypass flags stay + // unchanged; ON restores the previous enabled/disabled combination. + bool setRackBypass(int strip,bool bypass) noexcept { + if(strip<0||strip>=fxSlots)return false; + rackBypassed_[strip].store(bypass,std::memory_order_release); + return true; + } + bool rackBypassed(int strip) const noexcept { + return strip>=0&&stripcatalogId!=catalogId)return false; for(int i=0;i=fxSlots)return; const int count=counts_[strip]; // immutable, prepared OFF RT + const bool rackOff=rackBypassed_[strip].load(std::memory_order_acquire); if(count>0) { for(int slot=0;slotrender(l,r,samples); // no shared_ptr copies or RT heap use + instance->render(l,r,samples,rackOff); // existing 8ms fade; no RT allocation } } else if(strip==0 && externalFx) + // The legacy CH1 callback owns its own per-slot smooth rack + // bypass. Never skip it abruptly or strip out its FX tail. externalFx(externalContext,strip,l,r,samples); }; if(monitorEnabled_ && (!monitorL||!monitorR))return false; @@ -315,6 +334,7 @@ class LiveChannelFxGraph final { RealtimeStripControls controls_ {}; FxBank processors_ {}; std::array counts_ {}; + std::array,fxSlots> rackBypassed_{}; // CONTROL write; one RT read per lane int activeInserts_=0; int pluginQuantum_=512; int mainOutputLeft_=0,mainOutputRight_=1; diff --git a/engine/core/UnifiedLegacyProductionAdmission.h b/engine/core/UnifiedLegacyProductionAdmission.h index 37d431806..e82a86b55 100644 --- a/engine/core/UnifiedLegacyProductionAdmission.h +++ b/engine/core/UnifiedLegacyProductionAdmission.h @@ -59,6 +59,12 @@ struct UnifiedLegacyAccepted final { fxOwners->setInsertBypass(epoch,revision,id,slot, instanceId,bypass); } + bool setFxRackBypass(const DynamicNativeSessionPublisher& publisher, + std::uint64_t epoch,std::uint64_t revision, + ChannelId id,bool bypass) const noexcept { + return matches(publisher,epoch,revision) && + fxOwners->setRackBypass(epoch,revision,id,bypass); + } DynamicChannelFxLeaseBank::Lease leaseFxEditor( const DynamicNativeSessionPublisher& publisher, std::uint64_t epoch,std::uint64_t revision,ChannelId id, diff --git a/scripts/approved_fx_rack_power.py b/scripts/approved_fx_rack_power.py new file mode 100644 index 000000000..5bbad92d3 --- /dev/null +++ b/scripts/approved_fx_rack_power.py @@ -0,0 +1,32 @@ +"""Approved single-GUI FX rack power semantics, injected at the ONE Pages build. + +The historical V28 source HTML is immutable. Apply exactly TWO audited +semantic substitutions to its JavaScript when assembling both public /preview/ +and native JUCE WebView2. No additional stylesheet, second state store, or +private fork of the mixer. t.fxOn is rack authority, slotBypass[] is the +preserved per-insert preference. Effective = fxOn && !slotBypass[i]. +""" +def apply_authoritative_fx_power(html: str) -> str: + substitutions = [ + ( + "name==='None'?'is-empty':t.slotBypass[i]?'is-bypassed':'is-active'", + "name==='None'?'is-empty':(!t.fxOn||t.slotBypass[i])?'is-bypassed':'is-active'", + ), + ( + 'aria-pressed="\'+Boolean(!t.slotBypass[i])+\'">', + 'aria-pressed="\'+Boolean(t.fxOn&&!t.slotBypass[i])+\'">', + ), + ( + "title=\"'+(t.slotBypass[i]?'Enable':'Bypass')+' only insert", + "title=\"'+(!t.fxOn?'Rack bypassed, saved '+(t.slotBypass[i]?'OFF':'ON'):t.slotBypass[i]?'Enable':'Bypass')+' only insert", + ), + ( + "aria-label=\"'+(t.slotBypass[i]?'Enable':'Bypass')+' only FX insert", + "aria-label=\"'+(!t.fxOn?'Rack bypassed, saved '+(t.slotBypass[i]?'OFF':'ON'):t.slotBypass[i]?'Enable':'Bypass')+' only FX insert", + ), + ] + for before, after in substitutions: + if html.count(before) != 1: + raise ValueError("FX master semantics anchor missing or ambiguous: " + before[:90]) + html=html.replace(before,after,1) + return html diff --git a/scripts/build_pages.py b/scripts/build_pages.py index e0e92b0c3..df0937e67 100644 --- a/scripts/build_pages.py +++ b/scripts/build_pages.py @@ -2,6 +2,7 @@ from pathlib import Path import argparse,os,json,shutil,subprocess,sys from compile_approved_css import optimize_assets +from approved_fx_rack_power import apply_authoritative_fx_power ROOT=Path(__file__).resolve().parents[1] p=argparse.ArgumentParser() p.add_argument('--out',default='dist-pages') @@ -59,6 +60,7 @@ if canonical_html.count('')!=1 or probe_tag in canonical_html: raise SystemExit('Approved Pages profiler injection must have exactly one body') canonical_html=canonical_html.replace('',probe_tag+'\n',1) +canonical_html=apply_authoritative_fx_power(canonical_html) # Stage C: compile only DEPLOYED copies, never modify locked V28 source # owners or approved PNG artwork. No new CSS/override or second renderer. canonical_html,css_compilation=optimize_assets(canonical_html,buttons_dest/'assets',runtime_bundle=True) diff --git a/src/ApprovedNativeV8Projection.h b/src/ApprovedNativeV8Projection.h index ab95387fd..b5f4b4cc5 100644 --- a/src/ApprovedNativeV8Projection.h +++ b/src/ApprovedNativeV8Projection.h @@ -82,6 +82,11 @@ inline bool projectApprovedNativeV8(juce::var& snapshot,const juce::var& bus) { fx.add(juce::var(insert.release())); } ch->setProperty("inserts",juce::var(fx)); + const auto rackBypassed=row.getProperty("fxRackBypassed",{}); + if(!rackBypassed.isVoid()) { + if(!rackBypassed.isBool())return false; + ch->setProperty("fxRackBypassed",rackBypassed); + } ch->setProperty("sends",juce::var(juce::Array{})); if(role!="INPUT"){ auto dst=std::make_unique(); diff --git a/src/ConsoleLiveBridgeV6.h b/src/ConsoleLiveBridgeV6.h index a30991611..8db86ac42 100644 --- a/src/ConsoleLiveBridgeV6.h +++ b/src/ConsoleLiveBridgeV6.h @@ -150,6 +150,8 @@ class LiveConsoleBridgeV6 final { if(peaksL.isArray())object->setProperty("channelPeaksL",peaksL); if(peaksR.isArray())object->setProperty("channelPeaksR",peaksR); if(inserts.isArray())object->setProperty("fxInstances",inserts); + const auto rackPower=route.getProperty("fxRackBypassed",juce::var()); + if(rackPower.isArray())object->setProperty("fxRackBypassed",rackPower); // The prepared/unpatched native M4 graph is a real silent route. // It allows direct IN gesture to activate the FIRST source. // This does not set productionCallbackLive or fake PCM. diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index 20bc4039e..23d617480 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -91,6 +91,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback } std::array slots {}; std::array, maxFx> bypassFlags {}; + std::atomic rackBypassed{false}; // does not overwrite per-slot flags // Owned and advanced exclusively by the realtime render callback. // Physical-slot identity survives an atomic logical reorder (PR #102). std::array bypassEnvelope {}; @@ -1229,6 +1230,16 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback !=armix::diagnostics::Route::normal)return false; return dryRoutingLab_.setFxBypass(lane,slot,epoch,revision,instanceId,bypass); } + bool setDryRoutingLabFxRackBypass(int lane,std::uint64_t epoch, + std::uint64_t revision,bool bypass) noexcept { + if(routeReconfiguring_.load(std::memory_order_acquire)|| + diagnosticRoute_.load(std::memory_order_acquire)!= + armix::diagnostics::Route::normal)return false; + if(!dryRoutingLab_.setFxRackBypass(lane,epoch,revision,bypass))return false; + if(lane==0 && graphOwned_) + graphOwned_->rackBypassed.store(bypass,std::memory_order_release); + return true; + } armix::mixer::LiveChannelFxGraph::InstanceLease leaseRoutedFxForEditor( int lane,int slot,std::uint64_t epoch,std::uint64_t revision, const juce::String& instanceId) const noexcept { @@ -1333,6 +1344,18 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback return dryRoutingLab_.bypassNativeInsert(epoch,revision,id,slot, token,bypass); } + bool bypassNativeFxRack(std::uint64_t epoch,std::uint64_t revision, + armix::mixer::ChannelId id,bool bypass) noexcept { + if(routeReconfiguring_.load(std::memory_order_acquire)|| + diagnosticRoute_.load(std::memory_order_acquire)!= + armix::diagnostics::Route::normal)return false; + if(!dryRoutingLab_.bypassNativeRack(epoch,revision,id,bypass))return false; + // The original CH1 VST3 instance can be external-leased into the + // native ChannelId publisher. Its own crossfade gate must agree. + if(graphOwned_ && dryRoutingLab_.nativeChannelIsOriginalCh1(id)) + graphOwned_->rackBypassed.store(bypass,std::memory_order_release); + return true; + } armix::mixer::LiveChannelFxGraph::InstanceLease leaseNativeVst3Editor( std::uint64_t epoch,std::uint64_t revision, armix::mixer::ChannelId id,std::size_t slot, @@ -1935,7 +1958,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback auto& slot=graph.slots[physical]; if(!slot.processor)continue; auto& bypass=graph.bypassEnvelope[physical]; - bypass.request(graph.bypassFlags[physical].load(std::memory_order_acquire)); + bypass.request(graph.rackBypassed.load(std::memory_order_acquire) || + graph.bypassFlags[physical].load(std::memory_order_acquire)); const bool blend=bypass.transitioning(); if(blend) { diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index 82f5ea88b..d1fe16ebb 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -946,6 +946,16 @@ class LiveDryRoutingLab final { }); } + // Master rack gate is a single RT-visible atomic per lane; never overwrite + // stored individual insert bypass flags. Safe under current epoch/revision. + bool setFxRackBypass(int lane,std::uint64_t expectedEpoch, + std::uint64_t expectedRevision,bool bypass) noexcept { + if(lane<0||lane>=fxSlots||!hasExplicitRoute()|| + expectedEpoch!=epoch()||expectedRevision!=revision())return false; + return publisher_.updateActiveControl(expectedEpoch,expectedRevision, + [&](FxGraph& fx) noexcept {return fx.setRackBypass(lane,bypass);}); + } + // Quiescent message-thread identity lease for the vendor's native GUI. // Shared lifetime is independent of route reorder, but not authority: // an editor request MUST match the current accepted route. @@ -1197,6 +1207,16 @@ class LiveDryRoutingLab final { return nativeAccepted_.setFxBypass(nativePublisher_,epochAtEdit, pcmRevision,target,slot,token,bypass); } + bool nativeChannelIsOriginalCh1(armix::mixer::ChannelId target) const noexcept { + return nativeAccepted_.fxOwners && + nativeAccepted_.fxOwners->externalChannel()==target && + target==nativeAccepted_.graph.ids.inputs[0]; + } + bool bypassNativeRack(std::uint64_t epochAtEdit,std::uint64_t pcmRevision, + armix::mixer::ChannelId target,bool bypass) noexcept { + return nativeAccepted_.setFxRackBypass(nativePublisher_,epochAtEdit, + pcmRevision,target,bypass); + } armix::mixer::DynamicChannelFxLeaseBank::Lease leaseNativeInsertEditor( std::uint64_t epochAtEdit,std::uint64_t pcmRevision, armix::mixer::ChannelId target,std::size_t slot, @@ -1720,6 +1740,8 @@ class LiveDryRoutingLab final { liveInserts.add(juce::var(item.release())); } row->setProperty("inserts",juce::var(liveInserts)); + row->setProperty("fxRackBypassed", + nativeAccepted_.fxOwners->rackBypassed(ch.id)); if(pcmMeterValid && meterIndexsetProperty("peakL",static_cast( nativeMeterPeaksL_[meterIndex].load(std::memory_order_relaxed))); @@ -2169,6 +2191,10 @@ class LiveDryRoutingLab final { liveFxInstances.add(juce::var(slots)); } out->setProperty("fxInstances",juce::var(liveFxInstances)); + juce::Array rackFlags; + for(int lane=0;lanerackBypassed(lane):false); + out->setProperty("fxRackBypassed",juce::var(rackFlags)); juce::Array controls,fxNames; for(int i=0;i(); + ack->setProperty("requestId",args.getProperty("requestId",{})); + ack->setProperty("ok",false); + ack->setProperty("error",reason); + browser_.emitEventIfBrowserIsVisible( + "arMixNativeFxPowerAck",juce::var(ack.release())); + } return emitNotice(reason,true); } @@ -1614,6 +1625,65 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr if(!ok)emitNotice("Live AUX send rejected; refresh accepted routing.",true); return; } + // Accepted ChannelId FX power. A rack master is an additive gate, + // not a rewrite of the eight saved individual bypass preferences. + // Both gestures are fenced to the actual device epoch + PCM revision + // and reply with an ACK; the WebView re-reads the producer snapshot. + if(action=="routingNativeFxRackBypass" || + action=="routingNativeFxInsertBypass") { + const auto request=args.getProperty("requestId",{}).toString(); + const auto rawId=args.getProperty("channelId",{}); + const auto rawEpoch=args.getProperty("deviceEpoch",{}); + const auto rawRevision=args.getProperty("revision",{}); + const auto parse=[](const juce::var& wire,std::uint64_t& out) -> bool { + if(!wire.isString())return false; + const auto text=wire.toString().toStdString(); + if(text.empty()||text.size()>20|| + text[0]=='0'||text.find_first_not_of("0123456789")!=std::string::npos) + return false; + try { + const auto decoded=std::stoull(text); + if(!decoded||std::to_string(decoded)!=text)return false; + out=decoded;return true; + } catch(...) {return false;} + }; + std::uint64_t channel=0,ep=0,rev=0; + const bool valid=request.isNotEmpty()&&request.length()<=128 && + parse(rawId,channel)&&parse(rawEpoch,ep)&& + parse(rawRevision,rev)&&value.isBool() && + !studioBackupBusy_&&!nativeShowBusy_&& + !engine_.independentClockActive(); + bool applied=false; + if(valid && !acceptedControlRequests_.contains(request)) { + acceptedControlRequests_.add(request); + if(acceptedControlRequests_.size()>512) + acceptedControlRequests_.remove(0); + const armix::mixer::ChannelId id{channel}; + if(action=="routingNativeFxRackBypass") + applied=engine_.bypassNativeFxRack(ep,rev,id,static_cast(value)); + else { + const auto token=args.getProperty("insertId",{}).toString(); + applied=slot>=0&&slot(slot),token,static_cast(value)); + } + } + auto ack=std::make_unique(); + ack->setProperty("requestId",request); + ack->setProperty("ok",applied); + ack->setProperty("channelId",rawId); + ack->setProperty("bypassed",value); + ack->setProperty("error",applied?juce::String(): + "Native FX power rejected: stale device/revision, Show busy or instance mismatch"); + if(browser_.loaded)browser_.emitEventIfBrowserIsVisible( + "arMixNativeFxPowerAck",juce::var(ack.release())); + if(applied)diagnostics_.record("NATIVE_FX_POWER", + rawId.toString()+(action=="routingNativeFxRackBypass"?" rack":" insert")+ + (static_cast(value)?" BYPASS":" ENABLE")); + return; + } + // G5C native per-instance BYPASS never recompiles the graph and // does not require muting the output. All identity gates must agree. if (action == "routingFxBypass") { diff --git a/tests/approved_fx_rack_master_power_smoke.py b/tests/approved_fx_rack_master_power_smoke.py new file mode 100644 index 000000000..25eb5dd9e --- /dev/null +++ b/tests/approved_fx_rack_master_power_smoke.py @@ -0,0 +1,89 @@ +"""P0 FX rack: header bypass overrides effective power, never saved slots. + +Chromium exercises ONE actual built /preview/ GUI (also used by native JUCE). +Public Pages only demonstrates the control state; real DSP is checked in +native engine contracts/Windows CTest and physical hardware FAT separately. +""" +from pathlib import Path +from playwright.sync_api import sync_playwright + +PAGE=Path(__file__).resolve().parents[1]/"dist-pages/preview/index.html" + + +def snapshot(page, channel=1): + root=page.locator(f'#tracks .strip[data-id="{channel}"] .fx-section') + return root.evaluate("""el=>({ + rack:el.dataset.fxChainEnabled, + header:el.querySelector('[data-action="fxOn"]').getAttribute('aria-pressed'), + slots:[...el.querySelectorAll('.fxslot-row:not(.is-empty)')].map(row=>({ + id:row.dataset.insertId, + individual:row.dataset.fxSlotEnabled, + effective:row.dataset.fxEffective, + power:row.querySelector('[data-action="slotPower"]') + ?.getAttribute('aria-pressed'), + bypassed:row.classList.contains('is-bypassed') + })) + })""") + + +def main(): + assert PAGE.is_file(), "build official /preview/ first" + with sync_playwright() as pw: + browser=pw.chromium.launch(headless=True) + try: + for width,height in [(390,844),(1366,768),(1680,900)]: + page=browser.new_page(viewport={"width":width,"height":height}) + errors=[] + page.on("pageerror",lambda e:errors.append(str(e))) + page.goto(PAGE.as_uri()) + page.locator("#tracks .strip[data-id='1']").wait_for() + root=page.locator('#tracks .strip[data-id="1"]') + initial=snapshot(page) + assert len(initial["slots"])==1 and initial["slots"][0]["power"]=="true",initial + # Load the second effect using the actual UI picker. + root.locator('.fx-pick.empty').click() + page.locator('#fastResults [data-fast-id]').first.click() + both=snapshot(page) + assert len(both["slots"])==2 and all( + x["power"]=="true" for x in both["slots"]),both + # Individual OFF is a stored preference, never overwritten. + root.locator('[data-action="slotPower"][data-slot="0"]').click() + individual=snapshot(page) + assert individual["slots"][0]["individual"]=="false",individual + assert individual["slots"][1]["individual"]=="true",individual + # On phones the official console banks one channel at a + # time; inspect CH2 via its real bank selector, not a hidden DOM. + if width < 500: + page.locator("#bankSelect").select_option("1") + other=snapshot(page,2) + if width < 500: + page.locator("#bankSelect").select_option("0") + root.locator('[data-action="fxOn"]').click() + off=snapshot(page) + assert off["header"]==off["rack"]=="false",off + assert all(row["power"]=="false" and + row["effective"]=="false" and row["bypassed"] + for row in off["slots"]),off + assert [r["individual"] for r in off["slots"]]==["false","true"],off + assert [r["id"] for r in off["slots"]]==[r["id"] for r in individual["slots"]],off + if width < 500: + page.locator("#bankSelect").select_option("1") + assert snapshot(page,2)==other,"Rack power leaked into other channel" + if width < 500: + page.locator("#bankSelect").select_option("0") + root.locator('[data-action="fxOn"]').click() + restored=snapshot(page) + assert restored["header"]==restored["rack"]=="true",restored + assert [r["power"] for r in restored["slots"]]==["false","true"],restored + assert [r["effective"] for r in restored["slots"]]==["false","true"],restored + assert [r["individual"] for r in restored["slots"]]==["false","true"],restored + assert [r["id"] for r in restored["slots"]]==[r["id"] for r in individual["slots"]],restored + assert not errors,errors + print("PASS FX rack master power + saved individual state",width,height) + page.close() + finally: + browser.close() + + +if __name__=="__main__": + main() diff --git a/tests/live_channel_fx_graph_test.cpp b/tests/live_channel_fx_graph_test.cpp index 515c7481c..475d820a1 100644 --- a/tests/live_channel_fx_graph_test.cpp +++ b/tests/live_channel_fx_graph_test.cpp @@ -178,7 +178,18 @@ static void verifyUniversalChannelIdFxLeaseAndLivePcm() { auto second=newFx(1.25f,"ch11-second-vst3"); assert(Bank::appendOwned(epoch,3,bank,ch11,ProcessingFormat::mono, second,expanded)==Bank::Fault::none); + // Rack OFF applies to the new plugin too; old per-plugin OFF remains + // untouched and native append carries the same authoritative override. + assert(bank.setRackBypass(epoch,2,ch11,true)); + assert(bank.rackBypassed(ch11)); assert(expanded.insertCount(ch11)==2); + // expanded was already created before the OFF gesture. Its revision + // holds the same shared rack gate, so it observes the control live. + assert(expanded.rackBypassed(ch11)); + assert(!expanded.setRackBypass(epoch,2,ch11,false)); // stale version + assert(expanded.setRackBypass(epoch,3,ch11,false)); + assert(!bank.rackBypassed(ch11)); + assert(!expanded.rackBypassed(ch11)); assert(expanded.insertCount(ch1)==bank.insertCount(ch1)); assert((*expanded.ownerForControl(ch11,0))->instanceId== (*bank.ownerForControl(ch11,0))->instanceId); @@ -2246,6 +2257,33 @@ int main(int argc,char** argv) { assert(heapCalls.load(std::memory_order_relaxed)==beforeNextProcess); assert(left[0]>.3f); } + // FX RACK POWER: one atomic master overrides effective processing, + // without destroying the ON/OFF preferences of individual inserts. + { + auto graph=makeGraph(2.f,3.f); + const auto token=graph->insertInstanceId(0); + assert(!graph->rackBypassed(0)); + assert(graph->setInsertBypass(0,0,token,true)); // individual OFF + assert(graph->insertBypassed(0,0)); + assert(graph->setRackBypass(0,true)); // master OFF + assert(graph->rackBypassed(0)&&graph->insertBypassed(0,0)); + assert(graph->setRackBypass(0,false)); // master ON + assert(!graph->rackBypassed(0)); + assert(graph->insertBypassed(0,0)); // stays OFF + assert(graph->setInsertBypass(0,0,token,false)); + assert(graph->setRackBypass(0,true)); + assert(graph->setRackBypass(0,false)); + assert(!graph->insertBypassed(0,0)); // returns to ON + assert(!graph->setRackBypass(-1,true)); + assert(!graph->setRackBypass(LiveChannelFxGraph::fxSlots,true)); + auto moved=makeGraph(1.f,1.f,false); + assert(graph->setRackBypass(0,true)); + assert(moved->reuse(0,*graph,"vst3-ch1-id")); + assert(moved->rackBypassed(0)); // graph retirement retains gate + assert(moved->insertBypassed(0,0)==graph->insertBypassed(0,0)); + assert(moved->setRackBypass(0,false)); + assert(!moved->insertBypassed(0,0)); // saved ON restored + } // Run M5 AFTER the legacy suite: older M4 tests use absolute global // GainFx::living/released counters as their own lifetime oracle. Running // M5 before them changes those historical baseline counts, not DSP. diff --git a/tests/live_graph_contract_test.mjs b/tests/live_graph_contract_test.mjs index 6edcd12f1..b33a201fd 100644 --- a/tests/live_graph_contract_test.mjs +++ b/tests/live_graph_contract_test.mjs @@ -62,7 +62,10 @@ test('bypass is sample-smoothed by one original CH1 DSP owner for M4 and native 'native and M4 must share the original CH1 sample-accurate DSP owner'); const originalDSP=e.slice(start,legacy); const adapters=e.slice(legacy,end); - assert.match(originalDSP,/bypass\.request\(graph\.bypassFlags/); + assert.match(originalDSP,/bypass\.request\(graph\.rackBypassed\.load/); + assert.match(originalDSP,/graph\.bypassFlags\[physical\]\.load/); + assert.match(originalDSP,/\|\|/, "rack override must OR with individual insert bypass"); + assert.match(originalDSP,/slot\.processor->processBlock\(buffer,midi\)/); assert.match(originalDSP,/bypass\.transitioning\(\)/); assert.match(originalDSP,/graph\.dryScratch\.getWritePointer\(0\)/); diff --git a/tests/single_preview_publication_contract_test.py b/tests/single_preview_publication_contract_test.py index ea2397a95..93d23b9b7 100644 --- a/tests/single_preview_publication_contract_test.py +++ b/tests/single_preview_publication_contract_test.py @@ -3,6 +3,7 @@ import json, re, sys, hashlib sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'scripts')) from compile_approved_css import LINK, optimize_css, compile_runtime_bundle, link_runtime_bundle, RUNTIME_CSS +from approved_fx_rack_power import apply_authoritative_fx_power ROOT=Path(__file__).resolve().parents[1] DST=Path(sys.argv[1]).resolve() if len(sys.argv)>1 else ROOT/'dist-pages' gui=DST/'preview' @@ -36,6 +37,7 @@ def require(ok,why): require((gui/'assets/gui-perf-probe.js').read_bytes()== (ROOT/'site/preview-v2/assets/gui-perf-probe.js').read_bytes(), 'opt-in performance probe was not copied byte-for-byte') +expected=apply_authoritative_fx_power(expected) # Stage C: the source HTML remains byte-exact, but the 18 deployed CSS files # contain only proven cascade winners. Verify every *generated* byte and query # hash; never approve an extra stylesheet, different owner or PNG mutation. diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 212cd2d9f..bb9877ebe 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -20,6 +20,7 @@ // B-stage: attached-node-only meter caches; a structural render invalidates // them atomically. Never retain detached WebView2 strips or stale channel IDs. const meterElements = new Map(); + let nativeFxPowerSerial=0, pendingNativeFxPower=null; let controller = null; const status = message => { lastNativeError = message; @@ -82,6 +83,8 @@ t.mute=ch.controls.mute; t.solo=ch.controls.solo; t.selected=previous.get(t.id)?.selected || false; + if(typeof ch.fxRackBypassed==="boolean") + t.fxOn=!ch.fxRackBypassed; // ONLY actual native rack readback if (Array.isArray(ch.inserts)) { t.fx=Array.from({length:8},(_,i)=>ch.inserts[i]?.name||"None"); t.slotBypass=Array.from({length:8},(_,i)=>Boolean(ch.inserts[i]?.bypassed)); @@ -304,7 +307,7 @@ // Control readback may change at the SAME structural graph revision. // Compare the actual accepted controls/edges, never skip native fader updates. const signature=next.identity+"|"+JSON.stringify(next.graph.channels.map(ch=>[ - ch.id,ch.controls,ch.inserts,ch.primaryOutId]))+"|"+JSON.stringify(next.graph.edges); + ch.id,ch.controls,ch.inserts,ch.fxRackBypassed,ch.primaryOutId]))+"|"+JSON.stringify(next.graph.edges); if (signature===lastPaintedSignature) { // Telemetry often advances without a structural graph revision. paintNativeMeters(next); @@ -317,6 +320,16 @@ } flags.productionCallbackLive=next.productLive;flags.acceptedGraphConnected=true; lastPaintedSignature=signature;stopDemo();paintNativeMeters(next); + if(pendingNativeFxPower?.acked) { + const pending=pendingNativeFxPower; + const nativeCh=next.graph.channels.find(ch=>ch.id===pending.channelId); + const actual=pending.kind==="rack"?nativeCh?.fxRackBypassed: + nativeCh?.inserts?.find(i=>i.id===pending.insertId)?.bypassed; + if(actual===pending.bypassed) { + pendingNativeFxPower=null; + status("NATIVE FX "+pending.kind+" power verified from actual PCM readback"); + } + } status((next.productLive?"NATIVE PRODUCT LIVE":"NATIVE PCM GRAPH ACCEPTED · FAT PENDING")+ " · device "+next.device.epoch+ " · graph "+next.graph.revision+" · roster "+next.graph.rosterRevision); @@ -349,6 +362,17 @@ finally{profiler.sample("nativeSnapshotJsMs",performance.now()-started);} }); backend.addEventListener("arMixConsoleAck", ack=>controller.onAck(ack)); + backend.addEventListener("arMixNativeFxPowerAck", ack=>{ + if(!pendingNativeFxPower||ack?.requestId!==pendingNativeFxPower.requestId)return; + if(ack.ok!==true){ + pendingNativeFxPower=null; + status("NATIVE FX REJECTED: "+(ack?.error||"stale engine authority")); + controller.subscribe(); // restore authoritative state + return; + } + pendingNativeFxPower.acked=true; + controller.subscribe(); // ACK is not state; await independent PCM readback + }); backend.addEventListener("arMixSourceSwitchAck", ack=>{ if(!pendingSourceId||ack?.requestId!==pendingSourceId)return; pendingSourceId=0; @@ -420,6 +444,43 @@ const key=action==="mute"?"SET_MUTE":"SET_SOLO"; intent(key,t,{value:!t[action],enabled:!t[action]});return true; } + if(action==="fxOn" || action==="slotPower") { + const current=controller?.state()?.current; + const id=nativeIdFor(t); + const ch=current?.graph?.channels?.find(x=>x.id===id); + if(!current?.admitted||!id||!ch||pendingNativeFxPower){ + status("NATIVE FX: wait for accepted graph/readback or pending ACK"); + return true; + } + const rack=action==="fxOn"; + const slot=Number(btn?.dataset?.slot); + const insert=!rack&&Number.isInteger(slot)&&slot>=0&&slot<8? + ch.inserts?.[slot]:null; + if((rack&&typeof ch.fxRackBypassed!=="boolean")|| + (!rack&&(!insert||typeof insert.bypassed!=="boolean"|| + typeof insert.id!=="string"||!insert.id))){ + status("NATIVE FX: rack/insert is not admitted on this ChannelId"); + return true; + } + const requestId="fx-"+(++nativeFxPowerSerial)+"-"+Date.now().toString(36); + const bypassed=rack?!ch.fxRackBypassed:!insert.bypassed; + pendingNativeFxPower={requestId,channelId:id,kind:rack?"rack":"insert", + insertId:insert?.id,bypassed,acked:false}; + backend.emitEvent("arMixAction",{ + action:rack?"routingNativeFxRackBypass":"routingNativeFxInsertBypass", + requestId,channelId:id,deviceEpoch:current.device.epoch, + revision:current.graph.revision,value:bypassed, + ...(rack?{}:{slot,insertId:insert.id}) + }); + status("NATIVE FX "+(rack?"RACK":"INSERT")+" pending ACK + PCM readback"); + window.setTimeout(()=>{ + if(pendingNativeFxPower?.requestId===requestId){ + pendingNativeFxPower=null;controller?.subscribe(); + status("NATIVE FX ACK/readback timeout; control unchanged until producer confirms"); + } + },8000); + return true; + } status("NATIVE: "+action+" is not an accepted ChannelId operation");return true; }, consumeWire(ops) {