From 30224fb9bfc93046da7e9272d0eeb5173af50ceb Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 03:51:38 +0700 Subject: [PATCH 01/43] research(sonku): add allocation-free music-first directional difference filter --- .../builtin_fx/sonku/SonKuP84ClarityAnchor.h | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h diff --git a/engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h b/engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h new file mode 100644 index 000000000..507273afb --- /dev/null +++ b/engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include +#include + +// P8.4 OFFLINE research only. NOT Sennheiser's patented CLARITY. +// This does not prove virtual loudspeaker externalization. +// Two existing native P82 and P83 PCM outputs are *offline* references. +// Never run two full DSP cores in the live JUCE callback. +// The production milestone must fuse into one native graph if approved. +namespace armix::sonku::p84 { +class ClarityAnchor final { +public: + bool prepare(double rate,float influence=.18f,float crossover=750.f) noexcept { + if(!std::isfinite(rate)||rate<44000.||rate>48100.|| + !std::isfinite(influence)||influence<0.f||influence>.30f|| + !std::isfinite(crossover)||crossover<400.f||crossover>2400.f)return false; + strength_=influence; + alpha_=static_cast(1.-std::exp(-2.*3.14159265358979323846*crossover/rate)); + reset();return true; + } + void reset() noexcept {low_.fill(0.f);} + void process(float refL,float refR,float physicalL,float physicalR, + float& outL,float& outR) noexcept { + if(strength_==0.f){outL=refL;outR=refR;return;} + const float deltaL=physicalL-refL,deltaR=physicalR-refR; + low_[0]+=alpha_*(deltaL-low_[0]); + low_[1]+=alpha_*(deltaR-low_[1]); + outL=refL+strength_*(deltaL-low_[0]); + outR=refR+strength_*(deltaR-low_[1]); + } +private: + std::array low_{}; + float strength_=0.f,alpha_=0.f; +}; +} // namespace armix::sonku::p84 From 15b58ca297417955f3f970e4503ae817039c1423 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 03:52:23 +0700 Subject: [PATCH 02/43] test(sonku): actual native P82 and physical P83 PCM six-program musical quality gate --- tests/sonku_p84_clarity_candidate_test.cpp | 167 +++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 tests/sonku_p84_clarity_candidate_test.cpp diff --git a/tests/sonku_p84_clarity_candidate_test.cpp b/tests/sonku_p84_clarity_candidate_test.cpp new file mode 100644 index 000000000..0eb981846 --- /dev/null +++ b/tests/sonku_p84_clarity_candidate_test.cpp @@ -0,0 +1,167 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// P8.4 fidelity-first independent OFFLINE SonKu PCM tests; no JUCE graph change. +#include "../engine/builtin_fx/sonku/SonKuSpatialCore.h" +#include "../engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h" +#include +#include +#include +#include +#include +#include +#include +#include +using armix::sonku::SonKuSpatialCore; +using armix::sonku::SonKuReflectionProfile; +using armix::sonku::Settings; +using armix::sonku::p83::Mode; +using armix::sonku::p84::ClarityAnchor; +struct Sound {std::vector l,r;}; +enum class Program {Mono,AntiPhase,Left,Right,Partial,Transient}; +static constexpr double pi=3.14159265358979323846; +static void require(bool yes,const char* msg){ + if(!yes){std::fprintf(stderr,"FAIL P84: %s\n",msg);std::abort();} +} +static const char* label(Program p) { + switch(p){case Program::Mono:return "mono"; + case Program::AntiPhase:return "antiphase"; + case Program::Left:return "left"; + case Program::Right:return "right"; + case Program::Partial:return "partial"; + case Program::Transient:return "transient";} + return "unknown"; +} +static Sound music(double rate,Program kind,int frames){ + Sound a{{std::vector(frames)},{std::vector(frames)}}; + const double hz[]={83,157,311,461,719,1139,1703,2891,5387,9301}; + const double amp[]={.056,.026,.021,.038,.022,.015,.032,.012,.019,.008}; + for(int i=0;i(amp[k]*std::sin(2*pi*hz[k]*t+.15*k)); + y+=static_cast(amp[k]*std::sin(2*pi*hz[k]*t+.11*k+.30)); + } + if(kind==Program::Transient){ + const int age=i%2304; + const float strike=age<128? + static_cast(.18*std::exp(-age*.055)*std::sin(2*pi*3000*t)):0.f; + x+=strike;y-=.7f*strike; + } + switch(kind) { + case Program::Mono:a.l[i]=a.r[i]=x;break; + case Program::AntiPhase:a.l[i]=x;a.r[i]=-x;break; + case Program::Left:a.l[i]=x;break; + case Program::Right:a.r[i]=x;break; + case Program::Partial:a.l[i]=x;a.r[i]=.7f*x+.3f*y;break; + case Program::Transient:a.l[i]=x;a.r[i]=y;break; + } + } + return a; +} +static Sound native(double rate,bool room,Program kind,int block, + Mode mode,float yaw=0.f) { + auto dsp=std::make_unique(); + require(dsp->prepare(rate,SonKuReflectionProfile::SixSurfaceKemarResearch),"prepare"); + Settings s{}; + s.moving=false;s.startAzimuthDegrees=0.f;s.stereoSpreadDegrees=60.f; + s.directElevationDegrees=0.f;s.spatialMix=1.f;s.outputTrim=.75f; + s.spacePreset=room?1:0;s.sourceDistanceMeters=1.6f; + s.roomAmount=room?.55f:0.f;s.ambience=room?.30f:0.f; + require(dsp->setSettings(s),"settings"); + require(dsp->setResearchRenderMode(mode),"mode"); + require(dsp->setResearchHeadYaw(yaw),"yaw"); + Sound out=music(rate,kind,room?16384:8192); + const int frames=static_cast(out.l.size()); + for(int i=0;iprocess(out.l.data()+i,out.r.data()+i,std::min(block,frames-i)); + return out; +} +static Sound blend(double rate,const Sound& anchor,const Sound& physical, + float amount,int block){ + require(anchor.l.size()==physical.l.size(),"same PCM timeline"); + const int n=static_cast(anchor.l.size()); + ClarityAnchor clarity{}; + require(clarity.prepare(rate,amount),"clarity prepare"); + Sound o{{std::vector(n)},{std::vector(n)}}; + for(int i=0;i(a.l[i])*a.l[i]+ + static_cast(a.r[i])*a.r[i]; + return e; +} +static double difference(const Sound& a,const Sound& b){ + require(a.l.size()==b.l.size(),"matched"); + double e=0; + for(std::size_t i=0;i rot(std::cos(2*pi*hz/rate), + -std::sin(2*pi*hz/rate)); + std::complex phase{1,0},L{},R{}; + for(std::size_t i=0;i=1024){L+=static_cast(a.l[i])*phase; + R+=static_cast(a.r[i])*phase;} + phase*=rot; + } + return std::norm(L)+std::norm(R); +} +int main(){ + double broadMax=0,bandMax=0; + for(double rate:{44100.,48000.}) + for(bool room:{false,true}) + for(Program input:{Program::Mono,Program::AntiPhase,Program::Left, + Program::Right,Program::Partial,Program::Transient}){ + const auto anchor=native(rate,room,input,128,Mode::MusicBedP82); + const auto physical=native(rate,room,input,128,Mode::SpeakerMonitor); + const auto disabled=blend(rate,anchor,physical,0.f,128); + require(difference(anchor,disabled)==0,"zero influence MUST preserve P82 PCM exactly"); + const auto candidate=blend(rate,anchor,physical,.18f,128); + const auto smaller=blend(rate,anchor,physical,.18f,64); + require(difference(candidate,smaller)==0,"buffer64/128 parity"); + const double gain=relativeDb(energy(candidate),energy(anchor)); + broadMax=std::max(broadMax,std::abs(gain)); + std::printf("P84_PROGRAM,%.0f,room=%d,%s,physical_dB=%.3f,clarity_dB=%.3f\n", + rate,room,label(input),relativeDb(energy(physical),energy(anchor)),gain); + require(std::isfinite(gain)&&std::abs(gain)<=1.5, + "whole-program level loss or boost beyond 1.5 dB"); + for(double hz:{83.,157.,311.,461.,719.,1139.,1703.,2891.,5387.,9301.}){ + const double before=probe(anchor,rate,hz); + if(before<1.e-9)continue; + const double db=relativeDb(probe(candidate,rate,hz),before); + bandMax=std::max(bandMax,std::abs(db)); + std::printf("P84_PROBE,%.0f,room=%d,%s,%.0fHz,delta_dB=%.3f\n", + rate,room,label(input),hz,db); + require(std::isfinite(db)&&std::abs(db)<=2.5, + "specific music frequency deviation >2.5 dB"); + } + for(std::size_t i=0;i.005&&cue<.5,"world yaw positional variation bounded and nonzero"); + } + } + std::printf("PASS P84 RESEARCH: 44.1/48 kHz P82 byte bypass, six stereo programs, " + "room ON/OFF, 10 frequencies, chunk and yaw; worst_broad=%.3fdB " + "worst_frequency=%.3fdB; listening and ASIO NOT PROVEN\n", + broadMax,bandMax); +} From a0053f895a8a6c3bc22db7bf72e64ca6bff2de9f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 03:52:58 +0700 Subject: [PATCH 03/43] docs(sonku): formalize dearVR-informed musical clarity strategy, evidence, vetoes and fused-DSP gate --- ...P84_CLARITY_FIRST_ARCHITECTURE_20261115.md | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md diff --git a/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md b/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md new file mode 100644 index 000000000..eda9523f2 --- /dev/null +++ b/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md @@ -0,0 +1,43 @@ +# SonKu P8.4 — Musical-fidelity-first externalization research + +Date: 15 November 2026 WIB. **Research only, NOT an accepted headphone candidate.** The owner rejected the actual P8.3 native mixer as quiet, boxed-in and hollow; P8.2 is the golden audible baseline. PR #701 remains rejected and unmerged. + +## Evidence and independent external research + +- Sennheiser says the Clarity parameter in dearVR PRO 2 trades HRTF spectral coloration against localization/externalization, and the best compromise varies between voices and instruments: https://help.sennheiser.com/hc/en-us/articles/27424692616594-How-to-produce-natural-immersive-music-with-the-CLARITY-modul-of-dearVR-PRO2 +- AES paper on Perceptually-Optimized Headphone Virtualizer: maximize sound-source externalization under a natural-timbre constraint, with subjective A/B validation: https://aes.org/publications/elibrary/elibrary-page/?id=18286 +- Sound Externalization review: non-individual HRTFs, inaccurate headphone equalization, head motion and room acoustics can impair externalization: https://pmc.ncbi.nlm.nih.gov/articles/PMC7488874/ +- SOFA/AES69 is a measurement interchange format for HRTFs and room IRs, not an unconditional license to reuse data: https://www.sofacoustics.org/ +- The SADIE virtual loudspeaker dataset includes measured diffuse-field compensated HRTFs, ITD data and specific loudspeaker array measurements: https://pure.york.ac.uk/portal/en/datasets/sadie-virtual-loudspeaker-database/ + +**No proprietary algorithm is copied.** The P8.4 code does not implement Sennheiser's patented Clarity. + +## Actual P8.3 causes + +The rejected 'positionedMode' explicitly bypassed P8.2's transparent stereo bass, music-safe centered HRTF and SIDE preservation. It also excluded the P8.2 room-presence compensation. Independent +/-30° HRIR stereo transfer and an invented 480Hz bass matrix sounded weak. Four isolated frequency probes were NOT an adequate music-quality test. The initial field listening result must override previous numeric PASS claims. + +## Stage 1 completed as source code: offline musical anchor experiment + +New isolated experimental class: engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h + +Formula: output = P8.2 + 0.18 * highpass_750Hz(P8.3Physical - P8.2) + +- P8.2 is the primary music signal; influence zero is **bit exact**. +- Direct P8.3 world-fixed HRTF directional contrast is a small HF research term, with no fabricated LF matrix, makeup gain, correlation detector or extra room tail. +- A 1-pole differentiator crossover is bounded, allocation-free, lock-free, and has no lookahead. +- 0.18 is a **research candidate**, not perceptually optimized. +- Important physical limitation: the P8.2 anchor remains head-locked while the difference follows head-relative orientation. This is NOT a fully consistent measured BRIR or a demonstrated externalized room. Its purpose is rejecting or supporting the feasibility of a music-preserving localizer. +- Two native SonKuSpatialCore instances are used ONLY in an OFFLINE analytical test. The full dual-core processing overhead is forbidden in production. If validated, fuse to a single native DSP graph before JUCE integration. + +Test: tests/sonku_p84_clarity_candidate_test.cpp — actual C++ SonKu DSP, not WebAudio or mocked responses. Tested 44.1/48k, six program types (mono, anti-phase, hard L/R, partially correlated, transient), ROOM ON and OFF, ten frequencies (83–9301Hz), PCM 64/128 parity, full-band output RMS <=1.5dB difference to P8.2, each applicable tone <=2.5dB, finite/no clipping, byte-exact zero-influence P8.2 bypass and head-yaw differential. + +This is only a necessary *source qualification*. Passing tone and RMS checks does not demonstrate natural timbre on real music, front/back separation, externalization, IACC, headphone-specific frequency response, or good CPU p99. + +## Next architectural gates (NOT completed) + +1. Run wideband multi-content FFT/erb spectral distance, ITD, ILD, transient and phase checks, room DRR and measured direct/early/late impulse responses, with P8.2 and the rejected P8.3 as controls. Avoid tuning only to hand-picked tones. +2. Use a properly licensed SOFA/AES69 measured near-field BRIR dataset and, later, personalized headphone compensation and live head tracking. Ensure all scene signals respond consistently to world-fixed yaw; distinguish stereo speaker monitoring from 3D audio object spatialization. +3. Replace double offline renderer with **ONE** JUCE native PCM callback and coherent fused measured transfer if acoustic fidelity gate holds. Keep SPSC/ACK, state rollback, .smix, native GUI, no M4 alternate routing; verify CPU at 44.1/48 kHz, buffer 64/128/256, 1/2/4 inserts. +4. **Before** Windows portable/merge/public release, physical level-matched headphone tests against P8.2 and dearVR with multiple songs, blind directions including front/back, externalization and overhead false-positive ratings, ASIO XRUN evidence. + +Do not merge/release PR #701 or this experimental stack without owner-approved headphone FAT. The approved P8.2 listening baseline is preserved. From db4ee5dc25ef845892be8d8d62dc52a0452004a3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 03:53:15 +0700 Subject: [PATCH 04/43] ci(sonku): gate P8.4 music-first directional contrast without costly Windows build --- .../workflows/sonku-p84-clarity-research.yml | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/sonku-p84-clarity-research.yml diff --git a/.github/workflows/sonku-p84-clarity-research.yml b/.github/workflows/sonku-p84-clarity-research.yml new file mode 100644 index 000000000..eed3b68e8 --- /dev/null +++ b/.github/workflows/sonku-p84-clarity-research.yml @@ -0,0 +1,35 @@ +name: SonKu P8.4 musical fidelity constrained research + +on: + pull_request: + paths: + - 'engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h' + - 'tests/sonku_p84_clarity_candidate_test.cpp' + - 'docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md' + - '.github/workflows/sonku-p84-clarity-research.yml' + workflow_dispatch: + +permissions: + contents: read + +jobs: + clarity-source: + runs-on: ubuntu-latest + timeout-minutes: 8 + steps: + - uses: actions/checkout@v4 + - name: Native source P82 reference versus physical P83, PCM music integrity and yaw + shell: bash + run: | + set -euo pipefail + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 \ + -DSONKU_P72_NATIVE_XYZ_RT=1 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 \ + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 \ + -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 \ + tests/sonku_p84_clarity_candidate_test.cpp -o /tmp/sonku-p84 + /tmp/sonku-p84 | tee /tmp/sonku-p84.log + grep -q '^PASS P84 RESEARCH:' /tmp/sonku-p84.log From 49c8a44be4c95da346ec9d199ee5097ca2e98b4b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 03:54:18 +0700 Subject: [PATCH 05/43] test(sonku): retain full per-frequency evidence when P8.4 acoustic guard aborts --- tests/sonku_p84_clarity_candidate_test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/sonku_p84_clarity_candidate_test.cpp b/tests/sonku_p84_clarity_candidate_test.cpp index 0eb981846..c40dcac6a 100644 --- a/tests/sonku_p84_clarity_candidate_test.cpp +++ b/tests/sonku_p84_clarity_candidate_test.cpp @@ -120,6 +120,7 @@ static double probe(const Sound& a,double rate,double hz){ return std::norm(L)+std::norm(R); } int main(){ + std::setvbuf(stdout,nullptr,_IONBF,0); // retain diagnostic evidence on gate abort double broadMax=0,bandMax=0; for(double rate:{44100.,48000.}) for(bool room:{false,true}) From ba8b33cadb88e2bca05e6d09db0f65022e718c42 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 03:55:00 +0700 Subject: [PATCH 06/43] test(sonku): aggregate all program, room and spectral evidence before source-fidelity veto --- tests/sonku_p84_clarity_candidate_test.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/sonku_p84_clarity_candidate_test.cpp b/tests/sonku_p84_clarity_candidate_test.cpp index c40dcac6a..a8a55ab36 100644 --- a/tests/sonku_p84_clarity_candidate_test.cpp +++ b/tests/sonku_p84_clarity_candidate_test.cpp @@ -122,6 +122,7 @@ static double probe(const Sound& a,double rate,double hz){ int main(){ std::setvbuf(stdout,nullptr,_IONBF,0); // retain diagnostic evidence on gate abort double broadMax=0,bandMax=0; + bool musicGate=true; for(double rate:{44100.,48000.}) for(bool room:{false,true}) for(Program input:{Program::Mono,Program::AntiPhase,Program::Left, @@ -137,8 +138,7 @@ int main(){ broadMax=std::max(broadMax,std::abs(gain)); std::printf("P84_PROGRAM,%.0f,room=%d,%s,physical_dB=%.3f,clarity_dB=%.3f\n", rate,room,label(input),relativeDb(energy(physical),energy(anchor)),gain); - require(std::isfinite(gain)&&std::abs(gain)<=1.5, - "whole-program level loss or boost beyond 1.5 dB"); + musicGate &= std::isfinite(gain)&&std::abs(gain)<=1.5; for(double hz:{83.,157.,311.,461.,719.,1139.,1703.,2891.,5387.,9301.}){ const double before=probe(anchor,rate,hz); if(before<1.e-9)continue; @@ -146,8 +146,7 @@ int main(){ bandMax=std::max(bandMax,std::abs(db)); std::printf("P84_PROBE,%.0f,room=%d,%s,%.0fHz,delta_dB=%.3f\n", rate,room,label(input),hz,db); - require(std::isfinite(db)&&std::abs(db)<=2.5, - "specific music frequency deviation >2.5 dB"); + musicGate &= std::isfinite(db)&&std::abs(db)<=2.5; } for(std::size_t i=0;i.005&&cue<.5,"world yaw positional variation bounded and nonzero"); } } + require(musicGate,"music fidelity FAILED: per-band or RMS deviation exceeds P8.2 quality guard"); std::printf("PASS P84 RESEARCH: 44.1/48 kHz P82 byte bypass, six stereo programs, " "room ON/OFF, 10 frequencies, chunk and yaw; worst_broad=%.3fdB " "worst_frequency=%.3fdB; listening and ASIO NOT PROVEN\n", From 24553abd6080c1cb4f8f237d8e0d00a29b491c11 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 03:56:35 +0700 Subject: [PATCH 07/43] refine(sonku): constrain P8.4 coloration via measured 12 percent directional-contrast candidate --- ...KU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md | 16 ++++++++++++++-- engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h | 2 +- tests/sonku_p84_clarity_candidate_test.cpp | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md b/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md index eda9523f2..378a8225d 100644 --- a/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md +++ b/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md @@ -20,12 +20,12 @@ The rejected 'positionedMode' explicitly bypassed P8.2's transparent stereo bass New isolated experimental class: engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h -Formula: output = P8.2 + 0.18 * highpass_750Hz(P8.3Physical - P8.2) +Formula: output = P8.2 + 0.12 * highpass_750Hz(P8.3Physical - P8.2) - P8.2 is the primary music signal; influence zero is **bit exact**. - Direct P8.3 world-fixed HRTF directional contrast is a small HF research term, with no fabricated LF matrix, makeup gain, correlation detector or extra room tail. - A 1-pole differentiator crossover is bounded, allocation-free, lock-free, and has no lookahead. -- 0.18 is a **research candidate**, not perceptually optimized. +- 0.12 is a **research candidate**, not perceptually optimized. - Important physical limitation: the P8.2 anchor remains head-locked while the difference follows head-relative orientation. This is NOT a fully consistent measured BRIR or a demonstrated externalized room. Its purpose is rejecting or supporting the feasibility of a music-preserving localizer. - Two native SonKuSpatialCore instances are used ONLY in an OFFLINE analytical test. The full dual-core processing overhead is forbidden in production. If validated, fuse to a single native DSP graph before JUCE integration. @@ -41,3 +41,15 @@ This is only a necessary *source qualification*. Passing tone and RMS checks doe 4. **Before** Windows portable/merge/public release, physical level-matched headphone tests against P8.2 and dearVR with multiple songs, blind directions including front/back, externalization and overhead false-positive ratings, ASIO XRUN evidence. Do not merge/release PR #701 or this experimental stack without owner-approved headphone FAT. The approved P8.2 listening baseline is preserved. + +## First native response sweep (same-source 44.1/48 kHz) + +The initial 18% directional-contrast strength passed all six broadband +RMS program checks (typical ~-0.45dB relative to P8.2), but failed +timbre spectral limits, with a worst probe at 5387Hz around **-3.21dB** +under ROOM ON at both rates, plus 2891Hz coloration and antiphase +9301Hz dips. The numerical limit is unchanged: +/-2.5dB per measured +frequency and +/-1.5dB broadband per program. The next 12% candidate +is derived from the measured failure, not gain makeup. Whether such a +limited difference produces persuasive headphone localization is +**UNKNOWN**; a spectral PASS must never be called externalization. diff --git a/engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h b/engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h index 507273afb..0008741e4 100644 --- a/engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h +++ b/engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h @@ -11,7 +11,7 @@ namespace armix::sonku::p84 { class ClarityAnchor final { public: - bool prepare(double rate,float influence=.18f,float crossover=750.f) noexcept { + bool prepare(double rate,float influence=.12f,float crossover=750.f) noexcept { if(!std::isfinite(rate)||rate<44000.||rate>48100.|| !std::isfinite(influence)||influence<0.f||influence>.30f|| !std::isfinite(crossover)||crossover<400.f||crossover>2400.f)return false; diff --git a/tests/sonku_p84_clarity_candidate_test.cpp b/tests/sonku_p84_clarity_candidate_test.cpp index a8a55ab36..7eded0d65 100644 --- a/tests/sonku_p84_clarity_candidate_test.cpp +++ b/tests/sonku_p84_clarity_candidate_test.cpp @@ -131,8 +131,8 @@ int main(){ const auto physical=native(rate,room,input,128,Mode::SpeakerMonitor); const auto disabled=blend(rate,anchor,physical,0.f,128); require(difference(anchor,disabled)==0,"zero influence MUST preserve P82 PCM exactly"); - const auto candidate=blend(rate,anchor,physical,.18f,128); - const auto smaller=blend(rate,anchor,physical,.18f,64); + const auto candidate=blend(rate,anchor,physical,.12f,128); + const auto smaller=blend(rate,anchor,physical,.12f,64); require(difference(candidate,smaller)==0,"buffer64/128 parity"); const double gain=relativeDb(energy(candidate),energy(anchor)); broadMax=std::max(broadMax,std::abs(gain)); From f531324cb3f9a93f2f8ed066f0f9cd1914af9883 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:00:13 +0700 Subject: [PATCH 08/43] test(sonku): add 1/3 octave measured impulse-response spectrum fidelity gate --- tests/sonku_p84_clarity_candidate_test.cpp | 30 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/tests/sonku_p84_clarity_candidate_test.cpp b/tests/sonku_p84_clarity_candidate_test.cpp index 7eded0d65..f97e1b3b8 100644 --- a/tests/sonku_p84_clarity_candidate_test.cpp +++ b/tests/sonku_p84_clarity_candidate_test.cpp @@ -16,7 +16,7 @@ using armix::sonku::Settings; using armix::sonku::p83::Mode; using armix::sonku::p84::ClarityAnchor; struct Sound {std::vector l,r;}; -enum class Program {Mono,AntiPhase,Left,Right,Partial,Transient}; +enum class Program {Mono,AntiPhase,Left,Right,Partial,Transient,Impulse}; static constexpr double pi=3.14159265358979323846; static void require(bool yes,const char* msg){ if(!yes){std::fprintf(stderr,"FAIL P84: %s\n",msg);std::abort();} @@ -27,7 +27,8 @@ static const char* label(Program p) { case Program::Left:return "left"; case Program::Right:return "right"; case Program::Partial:return "partial"; - case Program::Transient:return "transient";} + case Program::Transient:return "transient"; + case Program::Impulse:return "impulse";} return "unknown"; } static Sound music(double rate,Program kind,int frames){ @@ -54,6 +55,7 @@ static Sound music(double rate,Program kind,int frames){ case Program::Right:a.r[i]=x;break; case Program::Partial:a.l[i]=x;a.r[i]=.7f*x+.3f*y;break; case Program::Transient:a.l[i]=x;a.r[i]=y;break; + case Program::Impulse:a.l[i]=a.r[i]=i==2048?.18f:0.f;break; } } return a; @@ -126,7 +128,8 @@ int main(){ for(double rate:{44100.,48000.}) for(bool room:{false,true}) for(Program input:{Program::Mono,Program::AntiPhase,Program::Left, - Program::Right,Program::Partial,Program::Transient}){ + Program::Right,Program::Partial,Program::Transient, + Program::Impulse}){ const auto anchor=native(rate,room,input,128,Mode::MusicBedP82); const auto physical=native(rate,room,input,128,Mode::SpeakerMonitor); const auto disabled=blend(rate,anchor,physical,0.f,128); @@ -148,6 +151,25 @@ int main(){ rate,room,label(input),hz,db); musicGate &= std::isfinite(db)&&std::abs(db)<=2.5; } + // Room impulse spectral-response guard. Probes average over each + // 1/3-octave band so narrow reference notches cannot be selectively + // hidden or magnified. This checks *all* audible octave regions, not + // the ten tone frequencies used for the music fixtures. + if(input==Program::Impulse){ + for(double center=90.;center<=12000.;center*=std::pow(2.,1./3.)){ + double referencePower=0.,candidatePower=0.; + for(int step=-2;step<=2;++step){ + const double hz=center*std::pow(2.,step/12.); + referencePower+=probe(anchor,rate,hz); + candidatePower+=probe(candidate,rate,hz); + } + const double color=relativeDb(candidatePower,referencePower); + bandMax=std::max(bandMax,std::abs(color)); + std::printf("P84_BROADBAND_IR,%.0f,room=%d,center=%.1fHz," + "delta_dB=%.3f\n",rate,room,center,color); + musicGate &= std::isfinite(color)&&std::abs(color)<=2.5; + } + } for(std::size_t i=0;i Date: Sun, 15 Nov 2026 04:01:26 +0700 Subject: [PATCH 09/43] docs(sonku): record 1/3 octave impulse and room native source fidelity evidence --- ...P84_CLARITY_FIRST_ARCHITECTURE_20261115.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md b/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md index 378a8225d..8bcc10ff9 100644 --- a/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md +++ b/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md @@ -53,3 +53,28 @@ frequency and +/-1.5dB broadband per program. The next 12% candidate is derived from the measured failure, not gain makeup. Whether such a limited difference produces persuasive headphone localization is **UNKNOWN**; a spectral PASS must never be called externalization. + +## Second evidence milestone: independent broadband room impulse qualification + +P8.4 research source gate at exact commit +`f531324cb3f9a93f2f8ed066f0f9cd1914af9883`: +https://github.com/masarray/arsonmix/actions/runs/43640451156 + +The source now includes an impulse-program FIR/room test and an +integrated one-third-octave spectral-response scan from 90Hz to +approximately 12kHz (11 bands per rate/room, each integrating five +frequency probes). This is independent from the 10 musical tone +frequencies and checks ROOM OFF and ROOM ON separately. + +Native Linux source results: **28 total rate/room/program fixtures** +(44.1/48k, room OFF/ON, seven programs including impulse), **88 +third-octave impulse measurements** and **280 fixed-tone measurements**; +worst impulse-band relative deviation **2.182dB at 3.63kHz** +(48k ROOM OFF), absolute worst program broadband level deviation +**1.267dB** versus P8.2 (impulse fixture), and yaw remains measurable. +Both source quality gates passed without gain normalization or relaxed +thresholds. These tests are not calibrated to a listener's headphones +and still do not establish front/rear realism, distance or commercial +dearVR parity. Next stage must replace dual-core evaluation with a +single physical graph, perform listening and measured BRIR/ear +calibration; do not offer a Windows test until then. From 9df390be0fe0ea20e6385f437b141fe70b661b49 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:35:12 +0700 Subject: [PATCH 10/43] fix(gui): unify approved preview and native console visuals (#703) * fix(gui): unify Preview/native console geometry, fader calibration and subdued gain styling Render EXT rows in the single approved Pages source with browser-only hardware disabled, share routing heights and chrome across WebView2/Pages, reuse native tapered travel in both contexts, and harmonize GAIN metal/LED/LCD to the fader color system. Preserve native ACK/readback, WIRE DSP, PNG knob, zero-detent and snapshot behavior. Add parity/Chromium assertions. * test(gui): move native visual assertions to shared Pages and correct unity pointer position Keep hardware ACK tests intact; fader taper and EXT CSS now belong to canonical Pages, so regression guards must inspect the shared source. Update browser tactile unity test to the same 77% scale used by EXE. * test(gui): expect cyan-steel focus halo instead of legacy green GAIN glow * test(gui): align legacy V7 utility smoke with approved PFL semantic button Legacy helper upgrades SOLO SVG, but approved PFL uses data-hw-kind=pfl / data-action=cue and a PNG in assembled Pages. Check the current semantic fallback instead of the removed cue-key SVG. * test(gui): align V6 hardware-key smoke with current approved PFL semantics Keep historical MUTE and SOLO SVG/CSS coverage; replace retired two-SVG cue assumptions with approved semantic PFL checks. Assembled /preview/ PNG artwork stays authoritative. No GUI or PCM changes. * test(gui): preserve MUTE material contract with current semantic PFL fallback Historical raw Pages uses one SOLO SVG. The real PFL button is PNG-owned in assembled /preview/, not a second SVG. Keep independent mute/solo/PFL action checks. * test(gui): calibrate M1 ruler against shared Preview/EXE physical fader taper * fix(gui): stop calibrated fader ruler numerals overlapping at 1366px * fix(gui): preserve owner-frozen fader hardware while clarifying tapered dB labels * fix(gui): preserve tabular numerals while spacing tapered fader labels * fix(gui): fit shared four-row IN/OUT/EXT routing and preserve Master two-key QA --- scripts/build_approved_native_gui.py | 67 ++---------------- .../assets/mixer-section-controls.css | 68 ++++++++++++++++--- site/preview-v2/index.html | 43 ++++++++++-- tests/approved_native_gui_bundle_test.py | 8 +++ tests/approved_native_m2_contract.test.cjs | 24 ++++--- tests/native_v60_fader_assembly_contract.py | 13 ++-- tests/pages_controls_v6_smoke.py | 30 ++++---- tests/pages_inter_utility_v7_smoke.py | 14 ++-- .../pages_m1_meter_gain_calibration_smoke.py | 13 +++- tests/pages_mute_css_reference_smoke.py | 5 +- tests/pages_v60_fader_wire_tactile_smoke.py | 3 +- tests/preview_v2_v7_visual_smoke.py | 4 +- tests/sof_contextual_console_smoke.py | 22 ++++-- 13 files changed, 198 insertions(+), 116 deletions(-) diff --git a/scripts/build_approved_native_gui.py b/scripts/build_approved_native_gui.py index fc3f502dd..871859770 100644 --- a/scripts/build_approved_native_gui.py +++ b/scripts/build_approved_native_gui.py @@ -3,7 +3,7 @@ Calls scripts/build_pages.py to generate the *same* published index.html and assets. There is no second HTML/CSS assembler, cloned GUI, or alternate skin. -A nonvisual bridge JS is the only native-specific addition. +A nonvisual bridge JS and fail-closed native intent hooks are the only additions. """ from __future__ import annotations @@ -23,21 +23,7 @@ NATIVE_ADAPTER = ROOT / "web" / "approved-native-bridge.js" ADAPTER_MARKER = ('\n' '\n' - '\n' - '') + '\n') SCHEMA = "arsonmix.approved-native-pages-bundle.v2" @@ -70,10 +56,9 @@ def accepted_pages_html() -> str: return (build_public_pages(Path(tmp) / "public") / "index.html").read_text("utf-8") -# Native-only event seam: the original PUBLIC Pages HTML is byte-for-byte -# unchanged. Insert five small control hooks ONLY into the generated WebView2 -# HTML at native build time. Every anchor must occur exactly once: no silent -# breakage if Pages GUI source evolves. No extra layout or simulated PCM. +# Native-only event seam: preserve the public visual hierarchy and DOM while +# injecting verified JUCE controls. Every anchor is fail-closed and reversible; +# no divergent layout, fake PCM, or duplicate HTML skin. NATIVE_EVENT_HOOKS = ( # The mixer shell must remain visible even with zero audio endpoints or # before the first accepted roster. Native control intents are still @@ -81,37 +66,8 @@ def accepted_pages_html() -> str: ("Mixer · Reference Session", "Mixer · Native Session"), ("Interactive visual reference. Changes are local to this mockup.", "Preparing native mixer…"), ("SIMULATED METERS · NO REAL AUDIO", "NATIVE AUDIO"), - # The published /preview/ HTML and its V28 checkpoint are immutable. - # Change ONLY the compiled native WebView's operator fader travel law. - # The DSP gain remains exact dB -> 10^(dB/20), and the mapping is - # invertible at every tick; no new JS audio engine or controller. - ("function faderPercent(value,isSend){return rangePct(value,-60,isSend?6:10);}\n", - "const FADER_TAPER=Object.freeze([[-60,0],[-48,15],[-36,27],[-24,39],[-12,54],[-6,65],[0,77],[6,92],[10,100]]);\n" - "function faderPercent(value,isSend){\n" - " if(isSend)return rangePct(value,-60,6);\n" - " const db=Math.max(-60,Math.min(10,Number(value)));\n" - " for(let i=1;i{\n", @@ -122,15 +78,6 @@ def accepted_pages_html() -> str: " return window.__ARMIX_NATIVE_M2__?.inputChoices?.(t)||['None'];\n" " if(type==='output'&&window.__JUCE__?.backend)\n" " return window.__ARMIX_NATIVE_M2__?.outputChoices?.(t)||[t.output];\n"), - (" code+=sectionFx(t)+sectionSend(t);\n", - " if(t.kind!=='master'){\n" - " if(!code.endsWith(''))throw Error('Native O1 route anchor drift');\n" - " const extRow='
EXT'+\n" - " '
';\n" - " code=code.slice(0,-6)+extRow+'';\n" - " }\n" - " code+=sectionFx(t)+sectionSend(t);\n"), ("function wireGraphCommit(ops,{record=true}={}){\n", "function wireGraphCommit(ops,{record=true}={}){\n" " if(window.__JUCE__?.backend){window.__ARMIX_NATIVE_M2__?.consumeWire?.(ops);return false;}\n"), diff --git a/site/preview-v2/assets/mixer-section-controls.css b/site/preview-v2/assets/mixer-section-controls.css index 32b30ddd2..e2ac43e89 100644 --- a/site/preview-v2/assets/mixer-section-controls.css +++ b/site/preview-v2/assets/mixer-section-controls.css @@ -107,7 +107,7 @@ .console-body .strip .fx-section.is-gain-view, .console-body .strip .fx-section.is-sof-view{ display:flex;flex-direction:column;min-height:0;overflow:hidden; - background:linear-gradient(180deg,#21343d,#172832); + background:linear-gradient(180deg,#1a2b35,#142630); } /* GAIN is one compact hardware control cluster, not a full-width FX surface. Only these visual tokens vary with viewport height; neither the dial's @@ -149,12 +149,12 @@ content:"";position:absolute;inset:0;border-radius:50%; } .console-body .strip .gain-dial-arc::before{ - background:repeating-conic-gradient(from 225deg,#20372f 0deg 6deg,transparent 6deg 9deg); + background:repeating-conic-gradient(from 225deg,#2b4148 0deg 6deg,transparent 6deg 9deg); -webkit-mask:conic-gradient(from 225deg,#000 0deg 270deg,transparent 270deg 360deg); mask:conic-gradient(from 225deg,#000 0deg 270deg,transparent 270deg 360deg); } .console-body .strip .gain-dial-arc::after{ - background:repeating-conic-gradient(from 225deg,#51f4a0 0deg 6deg,transparent 6deg 9deg); + background:repeating-conic-gradient(from 225deg,#81b8c6 0deg 6deg,transparent 6deg 9deg); -webkit-mask:conic-gradient(from 225deg,#000 0deg calc(135deg + var(--gain-rotation,0deg)),transparent 0deg 360deg); mask:conic-gradient(from 225deg,#000 0deg calc(135deg + var(--gain-rotation,0deg)),transparent 0deg 360deg); } @@ -165,13 +165,13 @@ .console-body .strip .gain-dial-pointer::before{ content:"";position:absolute;top:8%;left:50%;width:3px;height:23%; transform:translateX(-50%);border-radius:3px; - background:linear-gradient(90deg,#137a47,#deffe5 47%,#4dffa0); - box-shadow:0 0 2px #9cffc8,0 0 6px #15ef85,0 0 9px #20d77c8c; + background:linear-gradient(90deg,#50727e,#e2f1f5 47%,#8ebdcb); + box-shadow:0 0 2px #c2dbe1,0 0 4px #6ca7b76b; } .console-body .strip .gain-dial-pointer::after{ content:"";position:absolute;top:7%;left:50%; width:4px;height:4px;transform:translateX(-50%);border-radius:50%; - background:#eaffed;box-shadow:0 0 4px 1px #42f9a8; + background:#edf6f8;box-shadow:0 0 3px 1px #8ebdcb88; } .console-body .strip .gain-dial input{ position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0; @@ -179,7 +179,7 @@ cursor:ns-resize;writing-mode:vertical-lr;direction:rtl;pointer-events:none; } .console-body .strip .gain-dial:focus-within{ - outline:8px solid #7ce7ba14;outline-offset:-2px; + outline:8px solid #8ebdcb18;outline-offset:-2px; } .console-body .strip .gain-dial:has(input:disabled){opacity:.55;cursor:not-allowed} .console-body .strip .gain-dial input:disabled{cursor:not-allowed} @@ -189,10 +189,10 @@ min-height:var(--gain-lcd-height); padding:2px 4px;overflow:hidden;border:0;border-radius:5px; /* An actual recessed black display: no outlined textbox or luminous rim. */ - background:#020503; + background:#050d12; box-shadow:inset 0 3px 5px #000f,inset 2px 0 3px #000b, inset -2px 0 3px #000b,0 1px 0 #93bba51a; - color:#74fda0;text-shadow:0 0 5px #43f78b88; + color:#a5dae4;text-shadow:0 0 4px #6bafc047; font:600 12px/17px Consolas,'Lucida Console',monospace; font-variant-numeric:tabular-nums;letter-spacing:.01em;white-space:nowrap; } @@ -209,7 +209,7 @@ .console-body.gain-view-active .section-rail .rail-cell.fx .rail-gain-caption{ display:block;writing-mode:vertical-rl;transform:rotate(180deg); font:600 11px/1 'Segoe UI',Arial,sans-serif;letter-spacing:.16em; - color:#b7f2d1;text-shadow:0 0 4px #38ca8a33; + color:#afd6df;text-shadow:0 0 3px #6bafc033; } @media(max-height:680px){ .console-body .strip .gain-view-body{ @@ -261,3 +261,51 @@ @media(max-height:610px){ .console-body .strip .sof-info small{display:none} } + +/* Console Visual Harmony: ONE geometry contract for /preview/ and JUCE. + The native ASIO EXT field is visible but disabled in the browser reference. + Preserve collapsed route precedence and the identical rail/master heights. */ +.console-body:not(.collapsed-route){--route-h:94px!important} +.console-body[data-density="standard"]:not(.collapsed-route){--route-h:91px!important} +.console-body[data-density="compact"]:not(.collapsed-route){--route-h:81px!important} +.console-body .external-out-field .route-caption{color:#8baebc} +.console-body .external-out-field .route-select{border-color:#3f5966;background:#142731} +.console-body .external-out-field .route-select:disabled{color:#8398a3;opacity:.72;cursor:not-allowed} +.console-body .external-out-field .route-select[aria-busy="true"]{border-color:#ddb576} +.console-body .external-out-field .route-select[data-status="NEEDS_REMAP"]{color:#d5aa8b} +.console-body .external-out-state{font:500 9px/1.2 system-ui,sans-serif;letter-spacing:.025em;color:#aabdc3} +.console-body .external-out-state:empty{display:none} +.console-body .external-out-state[data-status="LIVE"]{color:#9bd3b8} +.console-body .external-out-state[data-status="PENDING"]{color:#e7c081} +.console-body .external-out-state[data-status="MUTED"]{color:#abbcc2} +.console-body .external-out-state[data-status="NEEDS_REMAP"]{color:#e0a18b} + +/* Shared physical-taper micro-ruler legibility. Owner-frozen fader/PNG asset + remains byte-identical; this narrowly scoped type correction prevents + -24/-36/-48 dB ink collisions on 1366x768 without moving hardware ticks. */ +.console-body .strip .fader-section .gain-tick span{ + top:-4.5px!important; + line-height:9px!important; +} + +/* Route has four rows in the shared Pages/EXE renderer (title + IN/OUT/EXT). + Compact internal spacing rather than clipping the live EXT control or + inflating the panel: rail and strip retain their shared 94/91/81px heights. */ +.console-body:not(.collapsed-route) .strip .route-section{ + padding:2px 6px 2px;gap:1px; +} +.console-body[data-density="standard"]:not(.collapsed-route) .strip .route-select{ + height:21px; +} +.console-body[data-density="compact"]:not(.collapsed-route) .strip .route-section{ + padding:1px 3px;gap:1px; +} +.console-body[data-density="compact"]:not(.collapsed-route) .strip .route-top{ + height:15px;min-height:15px;flex-basis:15px; +} +.console-body[data-density="compact"]:not(.collapsed-route) .strip .route-field{ + min-height:18px; +} +.console-body[data-density="compact"]:not(.collapsed-route) .strip .route-select{ + height:18px; +} diff --git a/site/preview-v2/index.html b/site/preview-v2/index.html index 64eb2b049..1dcc61587 100644 --- a/site/preview-v2/index.html +++ b/site/preview-v2/index.html @@ -695,12 +695,31 @@ function formatDb(n){return n<=-60?'-∞':(n>0?'+':'')+Number(n).toFixed(1);} function panLabel(n){return Number(n)===0?'C':n<0?'L'+Math.abs(n):'R'+n;} function panStyle(n){const left=Math.min(50,50+n/2),right=Math.max(50,50+n/2);return '--pan-start:'+left+'%;--pan-end:'+right+'%';} -/* M1: one calibrated linear-dB position model for gain, ruler ticks and - UI-only dBFS preview. Physical fader travel and actual DSP are untouched. */ +/* One shared visual travel contract for fader, ticks, pointer and detent. + dBFS meter calibration is separate; neither GUI is an audio DSP authority. */ const METER_DBFS_MIN=-60, METER_DBFS_MAX=0; function rangePct(v,min,max){return Math.max(0,Math.min(100,100*(Number(v)-min)/(max-min)));} function scaleTopPct(db,min,max){return 100-rangePct(db,min,max);} -function faderPercent(value,isSend){return rangePct(value,-60,isSend?6:10);} +/* Shared console fader travel law for Pages and JUCE WebView2. + Preview and native must display the SAME physical position at equal dB. + SEND faders retain their independent -60..+6 linear send law. */ +const FADER_TAPER=Object.freeze([[-60,0],[-48,15],[-36,27],[-24,39],[-12,54],[-6,65],[0,77],[6,92],[10,100]]); +function faderPercent(value,isSend){ + if(isSend)return rangePct(value,-60,6); + const db=Math.max(-60,Math.min(10,Number(value))); + for(let i=1;i{ const major=v!==-6; - return ''+(major?(v>0?'+'+v:v):'')+''; + return ''+(major?(v>0?'+'+v:v):'')+''; }).join(''); return '
'+(isSend?'SEND ':'')+formatDb(value)+' dB
' +'
' @@ -787,7 +806,17 @@ if(t.kind==='audio')code+='
IN
'; else if(t.kind==='bus'||t.kind==='fx')code+='
IN'+(t.kind==='bus'?'GROUP':'FX RETURN')+'
'; else code+='
INSUM BUS
'; - code+='
OUT
'; + code+='
OUT
'; + // Same external-output field and channel geometry in Preview and native. + // Browser preview is a non-audio reference: leave hardware controls disabled. + if(t.kind!=='master'){ + const hasNativeOutputs=!!window.__JUCE__?.backend; + code+='
EXT'+ + ''+ + '
'; + } + code+='
'; code+=sectionFx(t)+sectionSend(t); code+='
PAN'+panLabel(t.pan)+'
'; @@ -2141,8 +2170,8 @@ if(!travel||travel.height<=0)return; const max=Number(input.max)||10,min=Number(input.min)||-60; const frac=Math.max(0,Math.min(1,(ev.clientY-travel.top)/travel.height)); - let gain=Math.round((max-(max-min)*frac)*10)/10; - const unityY=travel.top+travel.height*(max/(max-min)); + let gain=Math.round(faderDbFromTravelPercent(100*(1-frac),max===6)*10)/10; + const unityY=travel.top+travel.height*(1-faderPercent(0,max===6)/100); const tolerance=gesture.unityLatched?FADER_UNITY_RELEASE_PX:FADER_UNITY_CAPTURE_PX; if(!ev.altKey&&Math.abs(ev.clientY-unityY)<=tolerance){ gain=0;gesture.unityLatched=true; diff --git a/tests/approved_native_gui_bundle_test.py b/tests/approved_native_gui_bundle_test.py index 8e6cd958c..98ed40812 100644 --- a/tests/approved_native_gui_bundle_test.py +++ b/tests/approved_native_gui_bundle_test.py @@ -22,6 +22,14 @@ def test_native_is_exact_assembled_public_pages_plus_nonvisual_native_seam(self) approved = (source / "index.html").read_text("utf-8") native = (out / "index.html").read_text("utf-8") self.assertEqual(bundle.public_from_native(native), approved) + # Structural parity: route/EXT, fader taper and hardware look are + # composed once into published Pages, never inserted as native CSS. + self.assertIn("external-out-field", approved) + self.assertEqual(approved.count("external-out-field"), native.count("external-out-field")) + self.assertIn("FADER_TAPER=Object.freeze", approved) + self.assertEqual(approved.count("FADER_TAPER=Object.freeze"), 1) + self.assertEqual(native.count("FADER_TAPER=Object.freeze"), 1) + self.assertNotIn('data-armix-o1="physical-output"', native) self.assertNotIn("__ARMIX_NATIVE_M2__", approved) self.assertIn("__ARMIX_NATIVE_M2__", native) # Never let a missing ASIO driver or delayed native snapshot diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 8e09afd3d..02a428f75 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -852,10 +852,11 @@ test("P0 typed mono-stereo, PAN detent, fader geometry & FX failure diagnostics" const main=read("src/Main.cpp"); const snapshot=read("integration/ApprovedNativeRuntimeSnapshot.h"); const nativeBundle=read("scripts/build_approved_native_gui.py"); - assert.match(nativeBundle,/const FADER_TAPER=Object\.freeze/); - assert.match(nativeBundle,/function faderDbFromTravelPercent\(percent,isSend\)/); - assert.match(nativeBundle,/faderDbFromTravelPercent\(100\*\(1-frac\),max===6\)/); - assert.doesNotMatch(page,/FADER_TAPER/, "public Pages reference remains immutable"); + assert.match(page,/const FADER_TAPER=Object\.freeze/); + assert.match(page,/function faderDbFromTravelPercent\(percent,isSend\)/); + assert.match(page,/faderDbFromTravelPercent\(100\*\(1-frac\),max===6\)/); + assert.doesNotMatch(nativeBundle,/const FADER_TAPER=Object\.freeze/, + "A native-only fader law would break /preview/ parity"); assert.match(bridge,/function previewNativePan\(t,el,event\)/); assert.match(bridge,/const width=event\.type==="change"\?18:latched\?22:14/); assert.match(bridge,/readout\.textContent=value===0\?"C"/); @@ -1772,8 +1773,10 @@ test("M3/V60 Windows bundle dispatches exactly one fader release through native assert.ok(builder.includes("window.__ARMIX_NATIVE_M2__?.consumeField?.(event);return;")); assert.ok(!builder.includes("consumeField?.({target:g.input,type:'change'})"), "V60 source already emits the final change; native must not double-publish"); - assert.ok(builder.includes("faderDbFromTravelPercent(100*(1-frac),max===6)")); - assert.ok(builder.includes("faderPercent(0,max===6)/100")); + assert.ok(preview.includes("faderDbFromTravelPercent(100*(1-frac),max===6)")); + assert.ok(preview.includes("faderPercent(0,max===6)/100")); + assert.ok(!builder.includes("const FADER_TAPER=Object.freeze"), + "Both visual surfaces must use one Pages taper, not another native renderer"); assert.ok(builder.includes("function fxNativeTransactionRequired")); assert.ok(builder.includes("__ARMIX_NATIVE_SCOPE__")); assert.ok(bridge.includes("scope.installGraph(nextTracks,nextMaster,edges)")); @@ -2056,7 +2059,12 @@ test("O2 independent per-track external ASIO transactions and clear rejected ACK assert.match(src,/if\(!pendingExternal\.has\(id\)\)select\.removeAttribute/); assert.match(src,/SHARED with /); assert.match(src,/signals SUM/); - assert.match(builder,/external-out-state/); + const page=read("site/preview-v2/index.html"); + const css=read("site/preview-v2/assets/mixer-section-controls.css"); + assert.match(page,/external-out-state/); + assert.match(css,/external-out-state/); + assert.doesNotMatch(builder,/class=\\\"route-field external-out-field/, + "Native should never append its own EXT DOM"); }); test("O2 SOURCE ONLY confirmed ASIO EXTERNAL OUT auto-arms without a second Monitor click",()=>{ @@ -2081,7 +2089,7 @@ test("O2 SOURCE ONLY confirmed ASIO EXTERNAL OUT auto-arms without a second Moni test("O2 external OUT never reports LIVE while driver output is muted",()=>{ const bridge=read("web/approved-native-bridge.js"); - const css=read("scripts/build_approved_native_gui.py"); + const css=read("site/preview-v2/assets/mixer-section-controls.css"); assert.match(bridge,/const pcmInstalled=row\?\.status==="LIVE"&&match/); assert.match(bridge,/next\?\.device\?\.outputArmed===true\?"LIVE":"MUTED"/); assert.match(bridge,/state==="MUTED"\?"ASIO pair connected/); diff --git a/tests/native_v60_fader_assembly_contract.py b/tests/native_v60_fader_assembly_contract.py index 26fee4571..b59cce478 100644 --- a/tests/native_v60_fader_assembly_contract.py +++ b/tests/native_v60_fader_assembly_contract.py @@ -17,11 +17,14 @@ def run(): public = bundle.accepted_pages_html() native = bundle.native_html(public) assert bundle.public_from_native(native) == public, "Native Pages not reversible" - assert " let gain=Math.round((max-(max-min)*frac)*10)/10;" in public - assert " let gain=Math.round(faderDbFromTravelPercent(100*(1-frac),max===6)*10)/10;" in native - assert " const unityY=travel.top+travel.height*(max/(max-min));" in public - assert " const unityY=travel.top+travel.height*(1-faderPercent(0,max===6)/100);" in native - assert "FADER_TAPER=Object.freeze" in native + assert "FADER_TAPER=Object.freeze" in public + assert public.count("FADER_TAPER=Object.freeze")==1 + assert native.count("FADER_TAPER=Object.freeze")==1 + assert " let gain=Math.round(faderDbFromTravelPercent(100*(1-frac),max===6)*10)/10;" in public + assert " const unityY=travel.top+travel.height*(1-faderPercent(0,max===6)/100);" in public + assert "scaleTopPct(v,-60,gainMax)" not in public + assert 'external-out-field' in public and 'external-out-field' in native + assert "data-armix-o1" not in native assert native.count("handleField({target:g.input,type:'change',altKey:!!ev.altKey});")==1 assert native.count("if(window.__JUCE__?.backend){window.__ARMIX_NATIVE_M2__?.consumeField?.(event);return;}")==1 assert "consumeField?.({target:g.input,type:'change'})" not in native diff --git a/tests/pages_controls_v6_smoke.py b/tests/pages_controls_v6_smoke.py index e9b824cb6..1a55e96e9 100644 --- a/tests/pages_controls_v6_smoke.py +++ b/tests/pages_controls_v6_smoke.py @@ -27,7 +27,7 @@ def assert_ownership(): assert css.count(".mx-hw-row>button.mx-hw-key")>=5 assert "Owner-approved V5" not in css and ".codepen-buttons-wrapper" not in css assert "filter:blur" not in css.replace(" ","").lower() - # SOLO/PFL retain SVG masks; MUTE is rendered by CSS only. + # V6 SOLO retains its SVG mask; the approved PFL is a semantic key. assert "!!window.ArSonMixHardwareKeys && !!document.querySelector('#tracks .strip[data-id="1"] .mx-mute-face') && - document.querySelectorAll('#tracks .strip[data-id="1"] svg.mx-hw-face').length===2""") + document.querySelectorAll('#tracks .strip[data-id="1"] svg.mx-hw-face').length===1""") rows=await page.locator(".mx-hw-row").count() assert rows>=6,(width,rows) assert await page.locator(".codepen-buttons-wrapper,.hw-switch-socket").count()==0 @@ -64,7 +64,7 @@ async def assert_mixer(page, width): const cssFace=e.querySelector('.mx-mute-face'); return { kind:e.dataset.hwKind,action:e.dataset.action, - label:svg?.querySelector('mask text')?.textContent||e.querySelector('.mx-mute-legend')?.textContent, + label:svg?.querySelector('mask text')?.textContent||e.querySelector('.mx-mute-legend')?.textContent||e.querySelector('.mx-hw-fallback')?.textContent, masks:svg?.querySelectorAll('mask').length||0, texts:svg?.querySelectorAll('mask text').length||0, ambient:!!svg?.querySelector('rect[fill="#edf6fa"]'), @@ -79,21 +79,26 @@ async def assert_mixer(page, width): background:s.backgroundImage,focus:e.getAttribute('aria-label') }; })""") - assert [d["kind"] for d in details]==["mute","solo","cue"],details + assert [d["kind"] for d in details]==["mute","solo","pfl"],details assert [d["action"] for d in details]==["mute","solo","cue"],details assert [d["label"] for d in details]==["MUTE","SOLO","PFL"],details - assert [d["led"] for d in details]==["255,78,90","255,207,68","101,210,236"],details + assert [d["led"] for d in details]==["255,78,90","255,207,68","209,224,231"],details assert details[0]["cssFace"] and details[0]["masks"]==0,details assert "linear-gradient" in details[0]["faceGradient"],details assert details[0]["background"]=="none",details - assert all(d["masks"]==1 and d["texts"]==1 and d["ambient"] and d["cap"] and d["shine"] - for d in details[1:]),details + # V6 source paints SOLO as SVG; approved PFL is an independent semantic + # key whose PNG material belongs to the assembled public /preview/. + assert details[1]["masks"]==1 and details[1]["texts"]==1,details + assert all(details[1][k] for k in ("ambient","cap","shine")),details + assert details[2]["masks"]==0 and details[2]["texts"]==0,details + assert details[2]["action"]=="cue" and details[2]["label"]=="PFL",details assert all(abs(d["h"]-29)<.7 and d["w"]>=26 for d in details),details assert max(d["y"] for d in details)-min(d["y"] for d in details)<.6,details assert max(d["w"] for d in details)-min(d["w"] for d in details)<1.7,details assert all(details[i]["x"]+details[i]["w"]<=details[i+1]["x"]+.3 for i in range(2)),details assert all(d["filter"]=="none" for d in details),details - assert all(d["glow"]=="0" and d["lamp"]=="0" for d in details[1:]),details + assert details[1]["glow"]=="0" and details[1]["lamp"]=="0",details + assert details[2]["glow"]=="0" and details[2]["lamp"] is None,details assert all(d["focus"] for d in details),details before=await keys.nth(0).evaluate("(e)=>getComputedStyle(e.querySelector('.mx-mute-face'),'::before').backgroundImage") await keys.nth(0).hover() @@ -115,8 +120,9 @@ async def assert_mixer(page, width): }; })""") assert on[0]["face"] and on[0]["legend"]=="rgb(242, 231, 231)",on - assert all(x["glow"]=="1" and x["lamp"]=="1" for x in on[1:]),on - assert [x["rgb"] for x in on[1:]]==["rgb(255, 207, 68)","rgb(101, 210, 236)"],on + assert on[1]["glow"]=="1" and on[1]["lamp"]=="1",on + assert on[2]["glow"]=="1" and on[2]["lamp"] is None,on + assert [x["rgb"] for x in on[1:]]==["rgb(255, 207, 68)",None],on if width==1680: await page.screenshot(path="pages-mixer-v6-ON-1680.png") await keys.nth(0).click() @@ -126,7 +132,7 @@ async def assert_mixer(page, width): await page.locator('#tracks .strip[data-id="1"] button[data-action="solo"]').click() await page.wait_for_function("""()=>{ const row=document.querySelector('#tracks .strip[data-id="1"] .mx-hw-row'); - return !!row?.querySelector('.mx-mute-face') && row.querySelectorAll('svg.mx-hw-face').length===2; + return !!row?.querySelector('.mx-mute-face') && row.querySelectorAll('svg.mx-hw-face').length===1; }""") assert await page.locator('#tracks .strip[data-id="1"] .mx-hw-row>button').count()==3 @@ -143,7 +149,7 @@ async def main(): assert not errors,(width,errors) await page.close() await browser.close() - print("PASS: CSS-built MUTE, V6 SOLO/PFL masked icons, stable 29px keys, OFF/ON toggle, WIRE intact") + print("PASS: MUTE CSS, SOLO SVG, PFL semantics, stable 29px hardware keys, OFF/ON and WIRE") if __name__=="__main__": asyncio.run(main()) diff --git a/tests/pages_inter_utility_v7_smoke.py b/tests/pages_inter_utility_v7_smoke.py index 14762750b..a86585f67 100644 --- a/tests/pages_inter_utility_v7_smoke.py +++ b/tests/pages_inter_utility_v7_smoke.py @@ -116,15 +116,21 @@ async def visual(page,width): assert await row.locator('[data-util-kind="fx-main"]').get_attribute('aria-pressed')==before if width==1680: await page.screenshot(path='pages-v7-embedded-inter-utility-1680.png') - # MUTE is an independent CSS/HTML caption; SOLO/PFL retain SVG masks. - for k in ('mute','solo','cue'): + # Historic seed uses a semantic PFL button (action=cue), not the + # removed hw-kind=cue. The shipped /preview/ assembler supplies approved + # PNG hardware sprites; never demand an obsolete SVG face from this seed. + for k in ('mute','solo','pfl'): key=row.locator(f'.mx-hw-row button[data-hw-kind="{k}"]') - assert await key.count()==1 + assert await key.count()==1, (width,k,'approved semantic key missing') if k=='mute': assert await key.locator('.mx-mute-face .mx-mute-legend').inner_text()=='MUTE' assert await key.locator('svg,img').count()==0 - else: + elif k=='solo': assert await key.locator('svg.mx-hw-face mask text').count()==1 + else: + assert await key.get_attribute('data-action')=='cue' + assert await key.locator('.mx-hw-fallback').inner_text()=='PFL' + assert await key.locator('svg.mx-hw-face').count()==0 async def main(): source_contract() diff --git a/tests/pages_m1_meter_gain_calibration_smoke.py b/tests/pages_m1_meter_gain_calibration_smoke.py index ff075e657..628095a53 100644 --- a/tests/pages_m1_meter_gain_calibration_smoke.py +++ b/tests/pages_m1_meter_gain_calibration_smoke.py @@ -98,8 +98,19 @@ def geometry(page, density, label): gain_values=[10,0,-6,-12,-24,-36,-48,-60] vu_values=[0,-6,-12,-18,-24,-36,-48,-60] assert len(out["gain"])==8 and len(out["vu"])==8 + # The single approved Pages/native fader uses a calibrated, monotonic + # physical travel taper, NOT the old linear-dB ruler. Derive the expected + # positions independently of the UI's faderPercent implementation so a + # visible mismatch between tick, pointer and 0 dB detent still fails. + taper=[(-60,0),(-48,15),(-36,27),(-24,39),(-12,54), + (-6,65),(0,77),(6,92),(10,100)] + def fader_top(db): + for (lo_db,lo_pct),(hi_db,hi_pct) in zip(taper,taper[1:]): + if db<=hi_db: + return 100-(lo_pct+(db-lo_db)*(hi_pct-lo_pct)/(hi_db-lo_db)) + return 0 for item,db in zip(out["gain"],gain_values): - expected=(10-db)/70*100 + expected=fader_top(db) close(item["top"],expected,.03) close(item["y"],out["travel"]["y"]+out["travel"]["h"]*expected/100,.8) for item,db in zip(out["vu"],vu_values): diff --git a/tests/pages_mute_css_reference_smoke.py b/tests/pages_mute_css_reference_smoke.py index 16b24090c..8f97fd515 100644 --- a/tests/pages_mute_css_reference_smoke.py +++ b/tests/pages_mute_css_reference_smoke.py @@ -78,13 +78,14 @@ async def state(): off2=await state() assert off2["pressed"]=="false" and off2["faceBg"]==off["faceBg"],off2 assert off2["lamp"]!="none" and off2["lowerReflection"]=="0",off2 - # SOLO and PFL are independent from the MUTE material and state. + # SOLO still has V6 SVG; PFL is its own semantic button with PNG + # material in the compiled /preview/, not a synthetic SVG face here. siblings=await page.locator('#tracks .strip[data-id="1"] .mx-hw-row>button').evaluate_all( "xs=>xs.map(x=>({action:x.dataset.action,hasSVG:!!x.querySelector('svg.mx-hw-face')}))") assert siblings==[ {"action":"mute","hasSVG":False}, {"action":"solo","hasSVG":True}, - {"action":"cue","hasSVG":True}, + {"action":"cue","hasSVG":False}, ],siblings diff --git a/tests/pages_v60_fader_wire_tactile_smoke.py b/tests/pages_v60_fader_wire_tactile_smoke.py index 75ea14eca..c06783394 100644 --- a/tests/pages_v60_fader_wire_tactile_smoke.py +++ b/tests/pages_v60_fader_wire_tactile_smoke.py @@ -101,7 +101,8 @@ def exercise(page,width,height): travel=strip.locator(".fader-travel").bounding_box() fader=strip.locator('input[data-field="level"]') x=box["x"]+box["width"]/2 - zero=travel["y"]+travel["height"]*(10/70) + # Shared Pages/native physical taper positions unity at 77% of travel. + zero=travel["y"]+travel["height"]*(1-77/100) page.mouse.move(x,zero+5) page.mouse.down() assert abs(float(fader.input_value()))<.001,(width,"unity detent failed") diff --git a/tests/preview_v2_v7_visual_smoke.py b/tests/preview_v2_v7_visual_smoke.py index 9f9f4d10e..c1f474f00 100644 --- a/tests/preview_v2_v7_visual_smoke.py +++ b/tests/preview_v2_v7_visual_smoke.py @@ -42,7 +42,9 @@ def audit_geometry(page, title): if(a!==b)problems.push('top/bottom channel color mismatch '+tag); } const controls=[...t.querySelectorAll('.switch-section.mx-hw-row > button.mx-hw-key')]; - if(controls.length!==3)problems.push('MUTE/SOLO/PFL count !=3 '+tag); + // MASTER is the approved two-key MUTE/SOLO strip, never PFL. + const expectedKeys=t.classList.contains('master')?2:3; + if(controls.length!==expectedKeys)problems.push('MUTE/SOLO/PFL count !='+expectedKeys+' '+tag); else { if(Math.max(...controls.map(c=>r(c).width))-Math.min(...controls.map(c=>r(c).width))>1.8) problems.push('inconsistent V6 button widths '+tag); diff --git a/tests/sof_contextual_console_smoke.py b/tests/sof_contextual_console_smoke.py index 79156a5ab..a2588884d 100644 --- a/tests/sof_contextual_console_smoke.py +++ b/tests/sof_contextual_console_smoke.py @@ -54,6 +54,16 @@ def run() -> None: page.goto(html.as_uri()) first = page.locator('#tracks .strip[data-id="1"]') first.wait_for(timeout=15000) + ext = first.locator('.external-out-field [data-field="external"]') + assert ext.count() == 1 and ext.is_disabled(), ( + "Preview must share native EXT geometry without fake hardware access") + route = first.locator(".route-section").bounding_box() + rail = page.locator(".section-rail .rail-cell.route").bounding_box() + assert route and rail and abs(route["height"] - rail["height"]) <= 1, ( + "Route rail/strip height must match", width, route, rail) + assert abs(route["height"] - 94) <= 1, ( + "Route must reserve same third row as native", width, route) + assert page.locator("#master .external-out-field").count() == 0 gain = page.locator("#gainView") fx = page.locator("#fxView") assert gain.get_attribute("aria-pressed") == "false" @@ -109,7 +119,7 @@ def run() -> None: assert "radial-gradient" in leds["cap"], leds assert "conic-gradient" in leds["inactiveMask"], leds assert "conic-gradient" in leds["activeMask"], leds - assert "rgb(32, 55, 47)" in leds["inactive"], leds + assert "rgb(43, 65, 72)" in leds["inactive"], leds pointer = first.locator(".gain-dial-pointer") before_turn = pointer.evaluate("el => getComputedStyle(el).transform") before_led_mask = arc.evaluate("el => getComputedStyle(el, '::after').maskImage") @@ -132,9 +142,9 @@ def run() -> None: radius: getComputedStyle(el).borderRadius, shadow: getComputedStyle(el).boxShadow })""") - assert lcd_skin["background"] == "rgb(2, 5, 3)", (width, lcd_skin) + assert lcd_skin["background"] == "rgb(5, 13, 18)", (width, lcd_skin) assert lcd_skin["backgroundImage"] == "none", (width, lcd_skin) - assert lcd_skin["text"] == "rgb(116, 253, 160)", (width, lcd_skin) + assert lcd_skin["text"] == "rgb(165, 218, 228)", (width, lcd_skin) assert lcd_skin["border"] == "0px", (width, lcd_skin) assert lcd_skin["radius"] == "5px", (width, lcd_skin) assert "inset" in lcd_skin["shadow"], (width, lcd_skin) @@ -180,8 +190,10 @@ def run() -> None: })""") assert focused_css["width"] == "8px", focused_css assert focused_css["offset"] == "-2px", focused_css - assert "0.078" in focused_css["color"] or ( - "0.08" in focused_css["color"]), focused_css + assert focused_css["color"].startswith( + "rgba(142, 189, 203, "), focused_css + focus_alpha=float(focused_css["color"].rsplit(",", 1)[1].strip(" )")) + assert 0.08 <= focus_alpha <= 0.12, focused_css # Strong hysteresis: capture ±1.6, hold until ±3.2. # Keyboard/Shift can deliberately escape the notch. def set_gain(value, field_type="input"): From 8fd84e5f3ce79b4058a5d5870ca8475d2812aa3b Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:35:38 +0700 Subject: [PATCH 11/43] feat(sonku): add bounded high-pass HRTF difference kernel fusion for one PCM graph --- .../builtin_fx/sonku/SonKuP84FusedMusicHrir.h | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 engine/builtin_fx/sonku/SonKuP84FusedMusicHrir.h diff --git a/engine/builtin_fx/sonku/SonKuP84FusedMusicHrir.h b/engine/builtin_fx/sonku/SonKuP84FusedMusicHrir.h new file mode 100644 index 000000000..3e8322ede --- /dev/null +++ b/engine/builtin_fx/sonku/SonKuP84FusedMusicHrir.h @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include +#include +#include + +// SonKu P8.4 single-graph research kernel compositor. +// Fuse center music-safe HRIR + bounded HIGH-PASS direction differences +// BEFORE the existing 2x2 FIR loop: one PCM publisher, no second core. +// A first-order high-pass is calculated by convolving a difference FIR +// with a one-pole low-pass. Kernel support remains bounded at N taps; +// the truncated LP tail must be included in independent impulse tests. +// Preparation: control only. merge(): target-update every 16 frames; +// no allocation, mutex, sleep, IO, FFT or extra audio callback. +namespace armix::sonku::p84 { +class FusedMusicHrir final { +public: + bool prepare(double rate,float strength=.12f,float cutoffHz=750.f) noexcept { + if(!std::isfinite(rate)||rate<44000.||rate>48100.|| + !std::isfinite(strength)||strength<0.f||strength>.30f|| + !std::isfinite(cutoffHz)||cutoffHz<400.f||cutoffHz>2400.f) + return false; + strength_=strength; + alpha_=static_cast(1.-std::exp( + -2.*3.14159265358979323846*cutoffHz/rate)); + return true; + } + template + void merge(const std::array,2>& musicCenter, + std::array,2>& leftSpeaker, + std::array,2>& rightSpeaker) const noexcept { + for(int ear=0;ear<2;++ear){ + float leftLow=0.f,rightLow=0.f; + for(std::size_t tap=0;tap Date: Sun, 15 Nov 2026 04:36:01 +0700 Subject: [PATCH 12/43] feat(sonku): fuse P8.4 music-preserving HRTF into one native 2x2 FIR callback --- engine/builtin_fx/sonku/SonKuSpatialCore.h | 55 +++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/engine/builtin_fx/sonku/SonKuSpatialCore.h b/engine/builtin_fx/sonku/SonKuSpatialCore.h index d3c0a17c6..301dc6742 100644 --- a/engine/builtin_fx/sonku/SonKuSpatialCore.h +++ b/engine/builtin_fx/sonku/SonKuSpatialCore.h @@ -12,6 +12,14 @@ #include "SonKuP83SpeakerScene.h" #include "SonKuP83LowFrequencyTransfer.h" #endif +#if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH +#if !defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) || !SONKU_P83_PHYSICAL_SPEAKER_RESEARCH || \ + !defined(SONKU_P80_TRANSPARENT_BASS_RESEARCH) || !SONKU_P80_TRANSPARENT_BASS_RESEARCH || \ + !defined(SONKU_P75_MUSIC_SAFE_RESEARCH) || !SONKU_P75_MUSIC_SAFE_RESEARCH +#error P8.4 single-graph music fusion requires the explicitly measured P8.2/P8.3 engine +#endif +#include "SonKuP84FusedMusicHrir.h" +#endif #if defined(SONKU_P80_TRANSPARENT_BASS_RESEARCH) && SONKU_P80_TRANSPARENT_BASS_RESEARCH #include "SonKuHrtfTonalCalibration.h" #endif @@ -139,6 +147,9 @@ class SonKuSpatialCore final { #if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH if(!p83LowFrequency_.prepare(rate))return false; #endif +#if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH + if(!p84MusicKernel_.prepare(rate))return false; +#endif #if defined(SONKU_P71_DIRECT_XYZ_RESEARCH) && SONKU_P71_DIRECT_XYZ_RESEARCH // The special elevation control is not serialized or published to // a public host. Downgrading the prepared profile clears it. @@ -287,6 +298,21 @@ class SonKuSpatialCore final { bool researchSpeakerMusicLowFrequency() const noexcept { return p83MusicCompatibleLf_; } +#if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH + // OFFLINE SOURCE RESEARCH ONLY. A portable/native JUCE v4 host does + // NOT expose this and cannot silently activate it via .smix. + // P8.2 stereo bass/SIDE and room mixing remain authoritative. + bool setResearchFusedMusicClarity(bool enabled) noexcept { + if(!ready_ || researchPcmStarted_ || + p83Mode_!=p83::Mode::MusicBedP82 || + room_.preparedProfile()!=SonKuReflectionProfile::SixSurfaceKemarResearch) + return false; + p84FusedMusic_=enabled; + reset(); // pre-PCM only: no heavy audio callback mutation + return true; + } + bool researchFusedMusicClarity() const noexcept{return p84FusedMusic_;} +#endif bool setResearchHeadYaw(float yaw) noexcept { if(!ready_ || researchPcmStarted_ || !p83::validYaw(yaw) || room_.preparedProfile()!=SonKuReflectionProfile::SixSurfaceKemarResearch) @@ -412,6 +438,11 @@ class SonKuSpatialCore final { room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch && !positionedMode; #else constexpr bool musicSafe=false; +#endif +#if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH + const bool musicFused=musicSafe&&p84FusedMusic_; +#else + constexpr bool musicFused=false; #endif // Deliberate music-monitor compensation: real distance perception // still comes from direct/reflected ratio and high-frequency cues, @@ -486,7 +517,7 @@ class SonKuSpatialCore final { auto& r1=kernels_[1][1][tap]; l0+=filterSlew_*(targets_[0][0][tap]-l0); r0+=filterSlew_*(targets_[0][1][tap]-r0); - if(musicSafe) { + if(musicSafe && !musicFused) { // Both musical input channels share exactly one centered // measured HRIR. No dual-HRTF center interference; the // unprocessed SIDE is returned in its own stereo axis. @@ -719,6 +750,24 @@ class SonKuSpatialCore final { return; } #endif +#if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH + if(p84FusedMusic_ && p83Mode_==p83::Mode::MusicBedP82 && + room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch){ + // One 2x2 FIR graph. Preserve the EXACT P8.2 mixed-channel + // foundation while injecting only a bounded high-frequency + // measured directional difference into each source HRIR. + // Avoid LF480: no invented bass matrix or additional DSP core. + interpolate(centerTarget_,degrees_); + const auto positions=p83::stereo(static_cast(degrees_), + settings_.stereoSpreadDegrees,p83HeadYaw_); + interpolate(targets_[0],positions.leftHead); + interpolate(targets_[1],positions.rightHead); + p84MusicKernel_.merge(centerTarget_,targets_[0],targets_[1]); + if(!haveKernel_)kernels_=targets_; + haveKernel_=true; + return; + } +#endif #if defined(SONKU_P75_MUSIC_SAFE_RESEARCH) && SONKU_P75_MUSIC_SAFE_RESEARCH if(room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch) { // Control evidence no longer gates musical MID coefficients: @@ -802,6 +851,10 @@ class SonKuSpatialCore final { bool p83MusicCompatibleLf_=false; float p83HeadYaw_=0.f; #endif +#if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH + p84::FusedMusicHrir p84MusicKernel_{}; + bool p84FusedMusic_=false; // research opt-in only; P8.2 default untouched +#endif #if defined(SONKU_P71_DIRECT_XYZ_RESEARCH) && SONKU_P71_DIRECT_XYZ_RESEARCH float researchElevationDegrees_=0.f; bool researchPcmStarted_=false; From 0afd154f28aba382f6c6528b7d39f6c8960be006 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:36:49 +0700 Subject: [PATCH 13/43] test(sonku): one-core fused native P8.2 quality, impulse-band, yaw and parity source gates --- tests/sonku_p84_fused_single_core_test.cpp | 177 +++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 tests/sonku_p84_fused_single_core_test.cpp diff --git a/tests/sonku_p84_fused_single_core_test.cpp b/tests/sonku_p84_fused_single_core_test.cpp new file mode 100644 index 000000000..180b6c176 --- /dev/null +++ b/tests/sonku_p84_fused_single_core_test.cpp @@ -0,0 +1,177 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// P8.4 source qualification: one actual SonKuSpatialCore per render, fused +// direct HRIR 2x2, existing P8.2 bass/SIDE and room intact. +#include "../engine/builtin_fx/sonku/SonKuSpatialCore.h" +#include "../engine/builtin_fx/sonku/SonKuP84FusedMusicHrir.h" +#include +#include +#include +#include +#include +#include +#include +#include +using armix::sonku::SonKuSpatialCore; +using armix::sonku::SonKuReflectionProfile; +using armix::sonku::Settings; +using armix::sonku::p83::Mode; +struct Sound {std::vector l,r;}; +enum class Program {Mono,AntiPhase,Left,Right,Partial,Transient,Impulse}; +static constexpr double pi=3.14159265358979323846; +static void require(bool yes,const char* msg){ + if(!yes){std::fprintf(stderr,"FAIL P84: %s\n",msg);std::abort();} +} +static const char* label(Program p) { + switch(p){case Program::Mono:return "mono"; + case Program::AntiPhase:return "antiphase"; + case Program::Left:return "left"; + case Program::Right:return "right"; + case Program::Partial:return "partial"; + case Program::Transient:return "transient"; + case Program::Impulse:return "impulse";} + return "unknown"; +} +static Sound music(double rate,Program kind,int frames){ + Sound a{{std::vector(frames)},{std::vector(frames)}}; + const double hz[]={83,157,311,461,719,1139,1703,2891,5387,9301}; + const double amp[]={.056,.026,.021,.038,.022,.015,.032,.012,.019,.008}; + for(int i=0;i(amp[k]*std::sin(2*pi*hz[k]*t+.15*k)); + y+=static_cast(amp[k]*std::sin(2*pi*hz[k]*t+.11*k+.30)); + } + if(kind==Program::Transient){ + const int age=i%2304; + const float strike=age<128? + static_cast(.18*std::exp(-age*.055)*std::sin(2*pi*3000*t)):0.f; + x+=strike;y-=.7f*strike; + } + switch(kind) { + case Program::Mono:a.l[i]=a.r[i]=x;break; + case Program::AntiPhase:a.l[i]=x;a.r[i]=-x;break; + case Program::Left:a.l[i]=x;break; + case Program::Right:a.r[i]=x;break; + case Program::Partial:a.l[i]=x;a.r[i]=.7f*x+.3f*y;break; + case Program::Transient:a.l[i]=x;a.r[i]=y;break; + case Program::Impulse:a.l[i]=a.r[i]=i==2048?.18f:0.f;break; + } + } + return a; +} +static Sound native(double rate,bool room,Program kind,int block, + Mode mode,float yaw=0.f,bool fused=false) { + auto dsp=std::make_unique(); + require(dsp->prepare(rate,SonKuReflectionProfile::SixSurfaceKemarResearch),"prepare"); + Settings s{}; + s.moving=false;s.startAzimuthDegrees=0.f;s.stereoSpreadDegrees=60.f; + s.directElevationDegrees=0.f;s.spatialMix=1.f;s.outputTrim=.75f; + s.spacePreset=room?1:0;s.sourceDistanceMeters=1.6f; + s.roomAmount=room?.55f:0.f;s.ambience=room?.30f:0.f; + require(dsp->setSettings(s),"settings"); + require(dsp->setResearchRenderMode(mode),"mode"); + require(dsp->setResearchHeadYaw(yaw),"yaw"); + require(dsp->setResearchFusedMusicClarity(fused),"fused source research admission"); + Sound out=music(rate,kind,room?16384:8192); + const int frames=static_cast(out.l.size()); + for(int i=0;iprocess(out.l.data()+i,out.r.data()+i,std::min(block,frames-i)); + return out; +} +static double energy(const Sound& a){ + double e=0; + for(std::size_t i=0;i(a.l[i])*a.l[i]+ + static_cast(a.r[i])*a.r[i]; + return e; +} +static double difference(const Sound& a,const Sound& b){ + require(a.l.size()==b.l.size(),"matched"); + double e=0; + for(std::size_t i=0;i rot(std::cos(2*pi*hz/rate), + -std::sin(2*pi*hz/rate)); + std::complex phase{1,0},L{},R{}; + for(std::size_t i=0;i=1024){L+=static_cast(a.l[i])*phase; + R+=static_cast(a.r[i])*phase;} + phase*=rot; + } + return std::norm(L)+std::norm(R); +} +int main(){ + std::setvbuf(stdout,nullptr,_IONBF,0); // retain diagnostic evidence on gate abort + double broadMax=0,bandMax=0; + bool musicGate=true; + for(double rate:{44100.,48000.}) + for(bool room:{false,true}) + for(Program input:{Program::Mono,Program::AntiPhase,Program::Left, + Program::Right,Program::Partial,Program::Transient, + Program::Impulse}){ + const auto anchor=native(rate,room,input,128,Mode::MusicBedP82); + const auto physical=native(rate,room,input,128,Mode::SpeakerMonitor); + const auto disabled=native(rate,room,input,128,Mode::MusicBedP82,0.f,false); + require(difference(anchor,disabled)==0,"default P82 MUST be byte exact"); + const auto candidate=native(rate,room,input,128,Mode::MusicBedP82,0.f,true); + const auto smaller=native(rate,room,input,64,Mode::MusicBedP82,0.f,true); + require(difference(candidate,smaller)==0,"buffer64/128 parity"); + const double gain=relativeDb(energy(candidate),energy(anchor)); + broadMax=std::max(broadMax,std::abs(gain)); + std::printf("P84_SINGLE_PROGRAM,%.0f,room=%d,%s,physical_dB=%.3f,clarity_dB=%.3f\n", + rate,room,label(input),relativeDb(energy(physical),energy(anchor)),gain); + musicGate &= std::isfinite(gain)&&std::abs(gain)<=1.5; + for(double hz:{83.,157.,311.,461.,719.,1139.,1703.,2891.,5387.,9301.}){ + const double before=probe(anchor,rate,hz); + if(before<1.e-9)continue; + const double db=relativeDb(probe(candidate,rate,hz),before); + bandMax=std::max(bandMax,std::abs(db)); + std::printf("P84_SINGLE_PROBE,%.0f,room=%d,%s,%.0fHz,delta_dB=%.3f\n", + rate,room,label(input),hz,db); + musicGate &= std::isfinite(db)&&std::abs(db)<=2.5; + } + // Room impulse spectral-response guard. Probes average over each + // 1/3-octave band so narrow reference notches cannot be selectively + // hidden or magnified. This checks *all* audible octave regions, not + // the ten tone frequencies used for the music fixtures. + if(input==Program::Impulse){ + for(double center=90.;center<=12000.;center*=std::pow(2.,1./3.)){ + double referencePower=0.,candidatePower=0.; + for(int step=-2;step<=2;++step){ + const double hz=center*std::pow(2.,step/12.); + referencePower+=probe(anchor,rate,hz); + candidatePower+=probe(candidate,rate,hz); + } + const double color=relativeDb(candidatePower,referencePower); + bandMax=std::max(bandMax,std::abs(color)); + std::printf("P84_SINGLE_BROADBAND_IR,%.0f,room=%d,center=%.1fHz," + "delta_dB=%.3f\n",rate,room,center,color); + musicGate &= std::isfinite(color)&&std::abs(color)<=2.5; + } + } + for(std::size_t i=0;i.005&&cue<.5,"world yaw positional variation bounded and nonzero"); + } + } + require(musicGate,"music fidelity FAILED: per-band or RMS deviation exceeds P8.2 quality guard"); + std::printf("PASS P84 SINGLE CORE: 44.1/48 kHz P82 byte bypass, seven programs including impulse, " + "room ON/OFF, 10 frequencies, chunk and yaw; worst_broad=%.3fdB " + "worst_frequency=%.3fdB; listening and ASIO NOT PROVEN\n", + broadMax,bandMax); +} From 9e6a7e6c79cbe751768fcb4cbaf50ec3d46f8770 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:37:01 +0700 Subject: [PATCH 14/43] ci(sonku): independently gate P8.4 single native PCM graph and preserve P8.2 original --- .../workflows/sonku-p84-clarity-research.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/sonku-p84-clarity-research.yml b/.github/workflows/sonku-p84-clarity-research.yml index eed3b68e8..f0c164a80 100644 --- a/.github/workflows/sonku-p84-clarity-research.yml +++ b/.github/workflows/sonku-p84-clarity-research.yml @@ -4,7 +4,10 @@ on: pull_request: paths: - 'engine/builtin_fx/sonku/SonKuP84ClarityAnchor.h' + - 'engine/builtin_fx/sonku/SonKuP84FusedMusicHrir.h' + - 'engine/builtin_fx/sonku/SonKuSpatialCore.h' - 'tests/sonku_p84_clarity_candidate_test.cpp' + - 'tests/sonku_p84_fused_single_core_test.cpp' - 'docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md' - '.github/workflows/sonku-p84-clarity-research.yml' workflow_dispatch: @@ -33,3 +36,19 @@ jobs: tests/sonku_p84_clarity_candidate_test.cpp -o /tmp/sonku-p84 /tmp/sonku-p84 | tee /tmp/sonku-p84.log grep -q '^PASS P84 RESEARCH:' /tmp/sonku-p84.log + - name: REAL one-PCM-graph 2x2 fused HRTF and P8.2 no-regression gate + shell: bash + run: | + set -euo pipefail + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 \ + -DSONKU_P72_NATIVE_XYZ_RT=1 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 \ + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 \ + -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 \ + -DSONKU_P84_SINGLE_CORE_FUSION_RESEARCH=1 \ + tests/sonku_p84_fused_single_core_test.cpp -o /tmp/sonku-p84-fused + /tmp/sonku-p84-fused | tee /tmp/sonku-p84-fused.log + grep -q '^PASS P84 SINGLE CORE:' /tmp/sonku-p84-fused.log From f6ab70505d8fa18d8c7f1f61f1446aed5f67ffc8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:37:46 +0700 Subject: [PATCH 15/43] fix(sonku): disabling isolated P8.4 fusion is an idempotent no-op for physical reference test --- engine/builtin_fx/sonku/SonKuSpatialCore.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/builtin_fx/sonku/SonKuSpatialCore.h b/engine/builtin_fx/sonku/SonKuSpatialCore.h index 301dc6742..5fd5aebb2 100644 --- a/engine/builtin_fx/sonku/SonKuSpatialCore.h +++ b/engine/builtin_fx/sonku/SonKuSpatialCore.h @@ -304,9 +304,10 @@ class SonKuSpatialCore final { // P8.2 stereo bass/SIDE and room mixing remain authoritative. bool setResearchFusedMusicClarity(bool enabled) noexcept { if(!ready_ || researchPcmStarted_ || - p83Mode_!=p83::Mode::MusicBedP82 || + (enabled && p83Mode_!=p83::Mode::MusicBedP82) || room_.preparedProfile()!=SonKuReflectionProfile::SixSurfaceKemarResearch) return false; + if(p84FusedMusic_==enabled)return true; p84FusedMusic_=enabled; reset(); // pre-PCM only: no heavy audio callback mutation return true; From 43d85445332fb8f7d240229446bec1af768ca084 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:39:10 +0700 Subject: [PATCH 16/43] feat(sonku): keep world-fixed early reflection yaw aligned with P8.4 fused HRTF motion --- engine/builtin_fx/sonku/SonKuSpatialCore.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/engine/builtin_fx/sonku/SonKuSpatialCore.h b/engine/builtin_fx/sonku/SonKuSpatialCore.h index 5fd5aebb2..df40e51f6 100644 --- a/engine/builtin_fx/sonku/SonKuSpatialCore.h +++ b/engine/builtin_fx/sonku/SonKuSpatialCore.h @@ -547,7 +547,11 @@ class SonKuSpatialCore final { degrees_,transparentBass?settings_.stereoSpreadDegrees: ((musicSafe||monoObject)?0.f:settings_.stereoSpreadDegrees) #if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH +#if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH + ,(positionedMode||musicFused)?p83HeadYaw_:0.f +#else ,positionedMode?p83HeadYaw_:0.f +#endif #endif ) :SonKuEarlyReflections::Ears{}; From 176c4b12e4e22b3e44ef352f94e0f9f0d8d4d626 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:39:29 +0700 Subject: [PATCH 17/43] perf(sonku): measure single-core P8.4 versus P8.2 at 44.1/48k 1-4 inserts --- .../sonku_p84_fused_hosted_cpu_benchmark.cpp | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tests/sonku_p84_fused_hosted_cpu_benchmark.cpp diff --git a/tests/sonku_p84_fused_hosted_cpu_benchmark.cpp b/tests/sonku_p84_fused_hosted_cpu_benchmark.cpp new file mode 100644 index 000000000..23ea96fe2 --- /dev/null +++ b/tests/sonku_p84_fused_hosted_cpu_benchmark.cpp @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Hosted CPU evidence only: NOT a Windows ASIO realtime guarantee. +#include "../engine/builtin_fx/sonku/SonKuSpatialCore.h" +#include +#include +#include +#include +#include +#include +#include +#include +using armix::sonku::SonKuSpatialCore; +using armix::sonku::SonKuReflectionProfile; +using armix::sonku::Settings; +struct Time {double p50=0.,p95=0.,p99=0.;int late=0;}; +static Time run(double rate,int frames,int instances,bool fusion){ + std::array,4> cores{}; + Settings settings{}; + settings.moving=false;settings.spatialMix=1.f;settings.outputTrim=.75f; + settings.stereoSpreadDegrees=60.f;settings.spacePreset=1; + settings.sourceDistanceMeters=1.6f; + settings.roomAmount=.55f;settings.ambience=.3f; + for(int j=0;j(); + if(!cores[j]->prepare(rate,SonKuReflectionProfile::SixSurfaceKemarResearch) || + !cores[j]->setSettings(settings) || + !cores[j]->setResearchFusedMusicClarity(fusion)) + std::abort(); + } + std::array,4> l{},rr{}; + std::vector measurements;measurements.reserve(96); + for(int frame=0;frame<120;++frame){ + for(int j=0;j(.06*std::sin(2.*3.141592653589793*311*t)+ + .02*std::sin(2.*3.141592653589793*1211*t)); + rr[j][i]=static_cast(.04*std::sin(2.*3.141592653589793*719*t)- + .015*std::sin(2.*3.141592653589793*2833*t)); + } + const auto start=std::chrono::steady_clock::now(); + for(int j=0;jprocess(l[j].data(),rr[j].data(),frames); + const auto end=std::chrono::steady_clock::now(); + if(frame>=24) + measurements.push_back(std::chrono::duration( + end-start).count()); + } + std::sort(measurements.begin(),measurements.end()); + const auto q=[&](double v){return measurements[ + static_cast(v*(measurements.size()-1))];}; + const double deadline=1.e6*frames/rate; + const int late=static_cast(std::count_if(measurements.begin(), + measurements.end(),[&](double d){return d>deadline;})); + return {q(.5),q(.95),q(.99),late}; +} +int main(){ + bool withinBound=true; + for(double rate:{44100.,48000.}) + for(int buffer:{64,128,256}) + for(int inserts:{1,2,4}){ + const Time base=run(rate,buffer,inserts,false); + const Time fused=run(rate,buffer,inserts,true); + const double medianRatio=fused.p50/std::max(base.p50,1.); + std::printf("P84_SINGLE_CPU,rate=%.0f,buffer=%d,inserts=%d," + "p82_p50_us=%.2f,p82_p99_us=%.2f,p84_p50_us=%.2f,p84_p95_us=%.2f," + "p84_p99_us=%.2f,median_ratio=%.3f,p84_over_deadline=%d\n", + rate,buffer,inserts,base.p50,base.p99,fused.p50,fused.p95, + fused.p99,medianRatio,fused.late); + // One 4-FIR core instead of 2-FIR Music Bed can be slower, but + // must not grow beyond 2.6x median CPU. p99 & XRUN remain evidence + // not an actionable hosted-VM failure due to scheduler variance. + withinBound &= std::isfinite(medianRatio)&&medianRatio<=2.6; + } + if(!withinBound) { + std::fputs("FAIL P84 SINGLE CPU: complexity regression vs P8.2 exceeds 2.6x\n",stderr); + return 1; + } + std::puts("PASS P84 SINGLE CPU: single PCM core P8.2 vs P8.4 44.1/48k " + "64/128/256 1/2/4 native inserts, median ratio bounded; " + "real ASIO XRUN and UI restart NOT PROVEN"); +} From 528406a2ab14c4e9dce1c2dded17ae53494e33cf Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:39:43 +0700 Subject: [PATCH 18/43] test(sonku): verify P8.4 source and six-wall room orientation under world-fixed head yaw --- tests/sonku_p84_fused_single_core_test.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/sonku_p84_fused_single_core_test.cpp b/tests/sonku_p84_fused_single_core_test.cpp index 180b6c176..559f542ac 100644 --- a/tests/sonku_p84_fused_single_core_test.cpp +++ b/tests/sonku_p84_fused_single_core_test.cpp @@ -162,8 +162,11 @@ int main(){ require(std::isfinite(candidate.l[i])&&std::isfinite(candidate.r[i])&& std::abs(candidate.l[i])<1.f&&std::abs(candidate.r[i])<1.f, "finite, unclipped native audio"); - if(input==Program::Left&&!room){ - const auto changed=native(rate,false,input,128,Mode::MusicBedP82,60.f,true); + if(input==Program::Left){ + // World yaw now reaches BOTH the fused source HRIR and the + // original six-wall scene's source-to-listener geometric delay. + // Room OFF and ON are both required to have bounded variation. + const auto changed=native(rate,room,input,128,Mode::MusicBedP82,60.f,true); const double cue=std::sqrt(difference(changed,candidate)/(energy(anchor)+1.e-20)); std::printf("P84_SINGLE_YAW,%.0f,head_turned=60,relative_pcm_difference=%.6f\n",rate,cue); require(cue>.005&&cue<.5,"world yaw positional variation bounded and nonzero"); From 98b96e956ab80e3514e7f64c42399064356977ec Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:40:00 +0700 Subject: [PATCH 19/43] ci(sonku): prove byte-identical P8.2 and benchmark P8.4 1-4 inserts before Windows FAT --- .../workflows/sonku-p84-clarity-research.yml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/sonku-p84-clarity-research.yml b/.github/workflows/sonku-p84-clarity-research.yml index f0c164a80..17ae68bfe 100644 --- a/.github/workflows/sonku-p84-clarity-research.yml +++ b/.github/workflows/sonku-p84-clarity-research.yml @@ -8,6 +8,7 @@ on: - 'engine/builtin_fx/sonku/SonKuSpatialCore.h' - 'tests/sonku_p84_clarity_candidate_test.cpp' - 'tests/sonku_p84_fused_single_core_test.cpp' + - 'tests/sonku_p84_fused_hosted_cpu_benchmark.cpp' - 'docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md' - '.github/workflows/sonku-p84-clarity-research.yml' workflow_dispatch: @@ -52,3 +53,30 @@ jobs: tests/sonku_p84_fused_single_core_test.cpp -o /tmp/sonku-p84-fused /tmp/sonku-p84-fused | tee /tmp/sonku-p84-fused.log grep -q '^PASS P84 SINGLE CORE:' /tmp/sonku-p84-fused.log + - name: Cross-build bit-exact P8.2 when P8.4 compiled OFF versus compiled ON + shell: bash + run: | + set -euo pipefail + COMMON="-std=c++20 -O2 -Wall -Wextra -Werror -pedantic -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 -DSONKU_P72_NATIVE_XYZ_RT=1 -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1" + g++ $COMMON tests/sonku_p83_music_bed_byte_parity.cpp -o /tmp/p82-off + g++ $COMMON -DSONKU_P84_SINGLE_CORE_FUSION_RESEARCH=1 tests/sonku_p83_music_bed_byte_parity.cpp -o /tmp/p82-on + /tmp/p82-off /tmp/p82-reference.pcm + /tmp/p82-on /tmp/p82-fused-disabled.pcm + cmp -s /tmp/p82-reference.pcm /tmp/p82-fused-disabled.pcm + echo "PASS P84 BIT EXACT P82: 44.1/48k room OFF/ON mono/anti-phase bytewise identical" + - name: Hosted CPU 1-4 inserts 64-256 buffer research (not ASIO XRUN) + shell: bash + run: | + set -euo pipefail + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 \ + -DSONKU_P72_NATIVE_XYZ_RT=1 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 \ + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 \ + -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 \ + -DSONKU_P84_SINGLE_CORE_FUSION_RESEARCH=1 \ + tests/sonku_p84_fused_hosted_cpu_benchmark.cpp -o /tmp/p84-cpu + /tmp/p84-cpu | tee /tmp/p84-cpu.log + grep -q '^PASS P84 SINGLE CPU:' /tmp/p84-cpu.log From 541115e3189ce16d4156d5a842602449759d0592 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:43:00 +0700 Subject: [PATCH 20/43] test(sonku): quantify frontal rear ILD/IACC and world-fixed room impulse evidence --- ...onku_p84_spatial_impulse_evidence_test.cpp | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 tests/sonku_p84_spatial_impulse_evidence_test.cpp diff --git a/tests/sonku_p84_spatial_impulse_evidence_test.cpp b/tests/sonku_p84_spatial_impulse_evidence_test.cpp new file mode 100644 index 000000000..76581cc35 --- /dev/null +++ b/tests/sonku_p84_spatial_impulse_evidence_test.cpp @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Real one-core native P8.4 spatial impulse diagnostics. +// Distinct measured ITD/ILD, frontal/rear spectral cues and world-yaw room +// tails are NECESSARY source-level evidence, NOT headphone externalization. +// No JUCE, no human perception, no fabricated second PCM engine. +#if defined(NDEBUG) +#undef NDEBUG +#endif +#include "../engine/builtin_fx/sonku/SonKuSpatialCore.h" +#include +#include +#include +#include +#include +#include +#include +using armix::sonku::SonKuSpatialCore; +using armix::sonku::SonKuReflectionProfile; +using armix::sonku::Settings; +struct Sound {std::vector l,r;}; +static void gate(bool v,const char* s) { + if(!v){std::fprintf(stderr,"FAIL P84 SPATIAL: %s\n",s);std::abort();} +} +static Sound impulse(double rate,float az,float yaw,bool room) { + auto dsp=std::make_unique(); + gate(dsp->prepare(rate,SonKuReflectionProfile::SixSurfaceKemarResearch),"prepare"); + Settings s{};s.moving=false;s.startAzimuthDegrees=az; + s.stereoSpreadDegrees=60.f;s.spatialMix=1.f;s.outputTrim=.75f; + s.sourceDistanceMeters=1.6f;s.spacePreset=room?1:0; + s.roomAmount=.55f;s.ambience=.30f; + gate(dsp->setSettings(s),"settings"); + gate(dsp->setResearchHeadYaw(yaw),"yaw"); + gate(dsp->setResearchFusedMusicClarity(true),"fusion admission"); + constexpr int n=8192; + Sound a{{std::vector(n)},{std::vector(n)}}; + a.l[1024]=.20f;a.r[1024]=.20f; // true mono program: no SIDE rescue + for(int i=0;iprocess(a.l.data()+i,a.r.data()+i,128); + return a; +} +static double e(const Sound& a,int begin,int end,int ear=-1) { + double sum=0; + for(int i=begin;i(a.l[i])*a.l[i]; + if(ear!=0)sum+=static_cast(a.r[i])*a.r[i]; + } + return sum; +} +static double d(const Sound& a,const Sound& b,int begin,int end) { + double sum=0; + for(int i=begin;i(a.l[i])*a.r[i+lag]; + const double c=std::abs(sum)/norm; + if(c>out.value)out={std::min(1.,c),lag}; + } + return out; +} +int main(){ + for(double rate:{44100.,48000.}){ + const auto front=impulse(rate,0.f,0.f,false); + const auto rear=impulse(rate,180.f,0.f,false); + const auto left=impulse(rate,-90.f,0.f,false); + const auto right=impulse(rate,90.f,0.f,false); + const auto frontRoom=impulse(rate,0.f,0.f,true); + const auto frontRoomTurned=impulse(rate,0.f,90.f,true); + const auto frontTurned=impulse(rate,0.f,90.f,false); + constexpr int start=1024, directEnd=1250; + const double frontRear=std::sqrt(d(front,rear,start,directEnd)/ + (e(front,start,directEnd)+1.e-20)); + const double leftRight=std::sqrt(d(left,right,start,directEnd)/ + (e(left,start,directEnd)+1.e-20)); + const double leftIld=db(e(left,start,directEnd,1), + e(left,start,directEnd,0)); + const double rightIld=db(e(right,start,directEnd,1), + e(right,start,directEnd,0)); + const Iacc l=iacc(left,start,directEnd); + const Iacc rr=iacc(right,start,directEnd); + // Early/late acoustic tail is isolated after the direct ~140-tap HRIR + // and after the 220-Hz mono bass lowpass has decayed. + constexpr int tailStart=1600,tailEnd=4700; + const double tailRoom=e(frontRoom,tailStart,tailEnd); + const double tailDry=e(front,tailStart,tailEnd); + const double tailMotion=d(frontRoom,frontRoomTurned,tailStart,tailEnd); + const double motionDirect=d(front,frontTurned,start,directEnd); + const double approxDrr=db(e(frontRoom,start,directEnd),tailRoom); + std::printf("P84_SPATIAL,rate=%.0f,front_rear_diff=%.6f,left_right_diff=%.6f," + "left_ILD_dB=%.3f,right_ILD_dB=%.3f,left_IACC=%.5f,left_lag=%d," + "right_IACC=%.5f,right_lag=%d,room_DRR_window_dB=%.3f," + "room_tail=%.9g,dry_tail=%.9g,world_yaw_tail_delta=%.9g," + "world_yaw_direct_delta=%.9g\n", + rate,frontRear,leftRight,leftIld,rightIld,l.value,l.lag, + rr.value,rr.lag,approxDrr,tailRoom,tailDry,tailMotion,motionDirect); + gate(std::isfinite(frontRear)&&frontRear>.05,"front/back source HRIR cannot be identical"); + gate(std::isfinite(leftRight)&&leftRight>.10,"left/right source HRIR cannot be identical"); + gate(leftIld<-.3&&rightIld>.3,"signed left-right HRTF ILD must be directional"); + gate(l.value>0.&&l.value<=1.&&rr.value>0.&&rr.value<=1.,"bounded direct IACC"); + gate(tailRoom>1.e-12&&tailRoom>tailDry*1.1, + "room must produce actual delayed binaural energy"); + gate(tailMotion>1.e-14&&motionDirect>1.e-12, + "both ROOM and direct must respond to world-fixed head yaw"); + } + std::puts("PASS P84 SPATIAL SOURCE: measured front/rear and left/right," + " ILD/IACC, delayed room energy and room+direct head yaw; " + "NO HUMAN EXTERNALIZATION OR HEAD TRACKING CLAIM"); +} From 4f2e0ecf66e4aacc303d2559edb4a0e56766cae3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:43:11 +0700 Subject: [PATCH 21/43] ci(sonku): gate real binaural ILD/IACC and early reflection motion source evidence --- .../workflows/sonku-p84-clarity-research.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/sonku-p84-clarity-research.yml b/.github/workflows/sonku-p84-clarity-research.yml index 17ae68bfe..2c3c3f551 100644 --- a/.github/workflows/sonku-p84-clarity-research.yml +++ b/.github/workflows/sonku-p84-clarity-research.yml @@ -9,6 +9,7 @@ on: - 'tests/sonku_p84_clarity_candidate_test.cpp' - 'tests/sonku_p84_fused_single_core_test.cpp' - 'tests/sonku_p84_fused_hosted_cpu_benchmark.cpp' + - 'tests/sonku_p84_spatial_impulse_evidence_test.cpp' - 'docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md' - '.github/workflows/sonku-p84-clarity-research.yml' workflow_dispatch: @@ -64,6 +65,22 @@ jobs: /tmp/p82-on /tmp/p82-fused-disabled.pcm cmp -s /tmp/p82-reference.pcm /tmp/p82-fused-disabled.pcm echo "PASS P84 BIT EXACT P82: 44.1/48k room OFF/ON mono/anti-phase bytewise identical" + - name: Source binaural orientation ILD IACC and early reflection evidence + shell: bash + run: | + set -euo pipefail + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 \ + -DSONKU_P72_NATIVE_XYZ_RT=1 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 \ + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 \ + -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 \ + -DSONKU_P84_SINGLE_CORE_FUSION_RESEARCH=1 \ + tests/sonku_p84_spatial_impulse_evidence_test.cpp -o /tmp/p84-spatial + /tmp/p84-spatial | tee /tmp/p84-spatial.log + grep -q '^PASS P84 SPATIAL SOURCE:' /tmp/p84-spatial.log - name: Hosted CPU 1-4 inserts 64-256 buffer research (not ASIO XRUN) shell: bash run: | From af9532065d48c02903abfeffa48dfb638a957374 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:44:21 +0700 Subject: [PATCH 22/43] test(sonku): correct offline yaw stimulus to use same 12 percent contrast as reference candidate --- tests/sonku_p84_clarity_candidate_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sonku_p84_clarity_candidate_test.cpp b/tests/sonku_p84_clarity_candidate_test.cpp index f97e1b3b8..356959c99 100644 --- a/tests/sonku_p84_clarity_candidate_test.cpp +++ b/tests/sonku_p84_clarity_candidate_test.cpp @@ -176,7 +176,7 @@ int main(){ "finite, unclipped native audio"); if(input==Program::Left&&!room){ const auto rotated=native(rate,false,input,128,Mode::SpeakerMonitor,60.f); - const auto changed=blend(rate,anchor,rotated,.18f,128); + const auto changed=blend(rate,anchor,rotated,.12f,128); const double cue=std::sqrt(difference(changed,candidate)/(energy(anchor)+1.e-20)); std::printf("P84_YAW,%.0f,head_turned=60,relative_pcm_difference=%.6f\n",rate,cue); require(cue>.005&&cue<.5,"world yaw positional variation bounded and nonzero"); From 56c5ce1b777106522dba3862e359a45f3d5aaf1e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 04:46:11 +0700 Subject: [PATCH 23/43] tool(sonku): render actual music WAV through P8.2 golden vs single-core P8.4 with simulated head yaw --- tools/sonku_p84_offline_audition.cpp | 257 +++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100644 tools/sonku_p84_offline_audition.cpp diff --git a/tools/sonku_p84_offline_audition.cpp b/tools/sonku_p84_offline_audition.cpp new file mode 100644 index 000000000..0f438511b --- /dev/null +++ b/tools/sonku_p84_offline_audition.cpp @@ -0,0 +1,257 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// P8.4 single-core fused native SonKu music audition; OFFLINE ONLY. +// Same source WAV through ONE real SonKuSpatialCore for each output. +// Not an installed plugin, Windows mixer, commercial Clarity, or ear FAT. +// Exact SonKuSpatialCore research audition; OFFLINE ONLY, no JUCE device, +// ASIO, second mixer graph, WebAudio or proprietary music/HRIR content. +// Stereo RIFF WAV PCM16/24/32, float32, and DAW WAVEFORMATEXTENSIBLE, 44.1/48k. +// Each output uses the SAME source input, trim, position and room settings. +// Raw render levels are preserved: use independent loudness matching in FAT. +#include "../engine/builtin_fx/sonku/SonKuSpatialCore.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace fs=std::filesystem; +using armix::sonku::SonKuSpatialCore; +using armix::sonku::Settings; +namespace p83=armix::sonku::p83; + +struct WaveInfo { + int rate=0,format=0,bits=0,align=0; + std::uint64_t offset=0,frames=0; +}; +static std::uint16_t le16(const std::uint8_t* p) { + return static_cast(p[0]|(std::uint16_t(p[1])<<8)); +} +static std::uint32_t le32(const std::uint8_t* p) { + return std::uint32_t(p[0])|(std::uint32_t(p[1])<<8)| + (std::uint32_t(p[2])<<16)|(std::uint32_t(p[3])<<24); +} +static void putLe(std::ostream& o,std::uint32_t value,int bytes) { + for(int i=0;i(value>>(8*i))); +} +static WaveInfo inspect(std::ifstream& f) { + f.seekg(0,std::ios::end); + const auto end=f.tellg(); + if(end<44)throw std::runtime_error("Input too small for RIFF WAV"); + const auto size=static_cast(end); + f.seekg(0,std::ios::beg); + std::array riff{}; + f.read(riff.data(),riff.size()); + if(!f||std::memcmp(riff.data(),"RIFF",4)!=0 || + std::memcmp(riff.data()+8,"WAVE",4)!=0) + throw std::runtime_error("Requires uncompressed RIFF/WAVE, not W64/RF64"); + WaveInfo w{}; + std::uint64_t dataBytes=0; + bool hasFmt=false,hasData=false; + for(std::uint64_t at=12;at+8<=size;){ + f.seekg(static_cast(at),std::ios::beg); + std::array head{}; + f.read(reinterpret_cast(head.data()),head.size()); + if(!f)throw std::runtime_error("Truncated WAV chunk header"); + const auto length=static_cast(le32(head.data()+4)); + const auto body=at+8; + if(length>size-body)throw std::runtime_error("Truncated WAV chunk"); + if(std::memcmp(head.data(),"fmt ",4)==0) { + if(hasFmt||length<16)throw std::runtime_error("Invalid fmt chunk"); + std::array fmt{}; + const auto count=static_cast(length>=40?40:16); + f.read(reinterpret_cast(fmt.data()),count); + if(!f)throw std::runtime_error("Truncated PCM format"); + w.format=le16(fmt.data()); + const int channels=le16(fmt.data()+2); + w.rate=static_cast(le32(fmt.data()+4)); + w.align=le16(fmt.data()+12); + w.bits=le16(fmt.data()+14); + if(w.format==0xfffe) { + // Microsoft KSDATAFORMAT_SUBTYPE_PCM / _IEEE_FLOAT. + // Reject unknown vendor GUID rather than guess sample data. + if(length<40 || le16(fmt.data()+16)<22) + throw std::runtime_error("Malformed WAVEFORMATEXTENSIBLE"); + constexpr std::array guidTail{{ + 0,0,0x10,0,0x80,0,0,0xaa,0,0x38,0x9b,0x71}}; + if(!std::equal(guidTail.begin(),guidTail.end(),fmt.data()+28)) + throw std::runtime_error("Unsupported extensible WAV GUID"); + const auto sub=le32(fmt.data()+24); + const auto valid=le16(fmt.data()+18); + if((sub!=1&&sub!=3) || (valid!=0&&valid!=w.bits)) + throw std::runtime_error("Unsupported WAV subtype/validBits"); + w.format=static_cast(sub); + } + if(channels!=2 || (w.rate!=44100&&w.rate!=48000) || + (w.format!=1&&w.format!=3) || + !(w.format==1?(w.bits==16||w.bits==24||w.bits==32): + (w.bits==32)) || + w.align!=2*(w.bits/8)) + throw std::runtime_error("Supports stereo PCM16/24/32 or float32 at 44.1/48k"); + hasFmt=true; + }else if(std::memcmp(head.data(),"data",4)==0) { + if(hasData)throw std::runtime_error("Multiple WAV data chunks"); + w.offset=body; + dataBytes=length; + hasData=true; + } + at=body+length+(length&1u); + } + if(!hasFmt||!hasData||dataBytes==0 || + dataBytes%static_cast(w.align)!=0) + throw std::runtime_error("Missing/misaligned PCM data"); + w.frames=dataBytes/static_cast(w.align); + if(w.frames>(0xFFFFFFFFull-48ull)/8ull) + throw std::runtime_error("Output exceeds standard 4GB RIFF limit"); + return w; +} +static float decode(const std::uint8_t* p,int format,int bits){ + if(format==3){ + const auto raw=le32(p); + float x=0.f; + std::memcpy(&x,&raw,sizeof(x)); + if(!std::isfinite(x)||std::abs(x)>1.f) + throw std::runtime_error("Nonfinite/clipped input float32 WAV"); + return x; + } + if(bits==16) { + const auto raw=static_cast(le16(p)); + return static_cast(raw>=32768?raw-65536:raw)/32768.f; + } + if(bits==24) { + const auto raw=static_cast(p[0]|(int(p[1])<<8)|(int(p[2])<<16)); + return static_cast(raw>=0x800000?raw-0x1000000:raw)/8388608.f; + } + const auto raw=le32(p); + const auto sample=raw>=0x80000000u + ?static_cast(raw)-0x100000000ll + :static_cast(raw); + return static_cast(static_cast(sample)/2147483648.); +} +static void beginFloatWav(std::ofstream& f,int rate,std::uint64_t frames){ + const auto n=static_cast(frames*8); + f.write("RIFF",4);putLe(f,48+n,4);f.write("WAVE",4); + f.write("fmt ",4);putLe(f,16,4);putLe(f,3,2);putLe(f,2,2); + putLe(f,static_cast(rate),4); + putLe(f,static_cast(rate*8),4); + putLe(f,8,2);putLe(f,32,2); + // IEEE_FLOAT WAV should have a fact sample-count chunk. + f.write("fact",4);putLe(f,4,4);putLe(f,static_cast(frames),4); + f.write("data",4);putLe(f,n,4); +} +static void pushFloat(std::uint8_t* p,float x) { + if(!std::isfinite(x))throw std::runtime_error("Nonfinite native SonKu output"); + std::uint32_t bits{}; + std::memcpy(&bits,&x,sizeof(bits)); + for(int i=0;i<4;++i)p[i]=static_cast(bits>>(8*i)); +} +struct Result {double rms=0.,peak=0.;}; +static Result render(const fs::path& input,const WaveInfo& w, + const fs::path& output,p83::Mode mode, + bool musicLf,bool withRoom, + bool fused=false,float headYaw=0.f){ + auto core=std::make_unique(); + if(!core->prepare(w.rate,armix::sonku::SonKuReflectionProfile::SixSurfaceKemarResearch)) + throw std::runtime_error("Native SonKu prepare failed"); + Settings s{}; + s.moving=false;s.startAzimuthDegrees=0.f; + s.stereoSpreadDegrees=60.f; + s.spatialMix=1.f;s.outputTrim=.75f; + s.spacePreset=withRoom?1:0;s.sourceDistanceMeters=1.6f; + s.roomAmount=.55f;s.ambience=.30f;s.directElevationDegrees=0.f; + if(!core->setSettings(s)||!core->setResearchRenderMode(mode)|| + !core->setResearchSpeakerMusicLowFrequency(musicLf) || + !core->setResearchHeadYaw(headYaw) || + !core->setResearchFusedMusicClarity(fused)) + throw std::runtime_error("Native research scene admission failed"); + std::ifstream f(input,std::ios::binary); + std::ofstream o(output,std::ios::binary); + if(!f||!o)throw std::runtime_error("Cannot open input/output WAV"); + beginFloatWav(o,w.rate,w.frames); + constexpr std::uint64_t block=128; + std::array l{},r{}; + std::array encoded{}; + std::array decoded{}; + double sum=0.,peak=0.; + for(std::uint64_t frame=0;frame(std::min(block,w.frames-frame)); + const auto bytes=static_cast(n*w.align); + f.seekg(static_cast( + w.offset+frame*static_cast(w.align)),std::ios::beg); + f.read(reinterpret_cast(encoded.data()),bytes); + if(!f||f.gcount()!=bytes)throw std::runtime_error("Short WAV read"); + for(int i=0;iprocess(l.data(),r.data(),n); + for(int i=0;i(l[i]),b=static_cast(r[i]); + sum+=a*a+b*b; + peak=std::max(peak,std::max(std::abs(a),std::abs(b))); + pushFloat(decoded.data()+i*8,l[i]); + pushFloat(decoded.data()+i*8+4,r[i]); + } + o.write(reinterpret_cast(decoded.data()), + static_cast(n*8)); + if(!o)throw std::runtime_error("Short WAV write"); + } + return {std::sqrt(sum/(2.*static_cast(w.frames))),peak}; +} +int main(int argc,char** argv){ + try { + if(argc<3 || argc>4) + throw std::runtime_error("Usage: sonku-p84-ab input_stereo.wav output_directory [--room=off|--room=on]"); + const auto input=fs::path(argv[1]); + const auto output=fs::path(argv[2]); + bool room=false; + if(argc==4) { + const std::string option(argv[3]); + if(option=="--room=on")room=true; + else if(option!="--room=off")throw std::runtime_error("Unknown room option"); + } + std::ifstream stream(input,std::ios::binary); + if(!stream)throw std::runtime_error("Cannot open input WAV"); + const auto w=inspect(stream); + fs::create_directories(output); + std::ofstream csv(output/"sonku_p84_music_audition_metrics.csv"); + if(!csv)throw std::runtime_error("Cannot open A/B metrics"); + csv<<"variant,rate_hz,frames,room,head_yaw_degrees,output_rms,output_peak,relative_rms_db_vs_p82\n"; + struct Variant {const char* name;float headYaw;bool fused;}; + constexpr std::array options{{ + {"P82_Golden",0.f,false}, + {"P84_FusedYaw0",0.f,true}, + {"P84_FusedYawPlus60",60.f,true}, + {"P84_FusedYawMinus60",-60.f,true} + }}; + std::cout<1.e-12? + 20.*std::log10(std::max(metrics.rms,1.e-12)/referenceRms):0.; + csv< "< Date: Sun, 15 Nov 2026 04:46:36 +0700 Subject: [PATCH 24/43] ci(sonku): smoke real stereo WAV music A/B with P82 golden and P84 fused source engine --- .../workflows/sonku-p84-clarity-research.yml | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/.github/workflows/sonku-p84-clarity-research.yml b/.github/workflows/sonku-p84-clarity-research.yml index 2c3c3f551..480153b36 100644 --- a/.github/workflows/sonku-p84-clarity-research.yml +++ b/.github/workflows/sonku-p84-clarity-research.yml @@ -10,6 +10,7 @@ on: - 'tests/sonku_p84_fused_single_core_test.cpp' - 'tests/sonku_p84_fused_hosted_cpu_benchmark.cpp' - 'tests/sonku_p84_spatial_impulse_evidence_test.cpp' + - 'tools/sonku_p84_offline_audition.cpp' - 'docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md' - '.github/workflows/sonku-p84-clarity-research.yml' workflow_dispatch: @@ -81,6 +82,58 @@ jobs: tests/sonku_p84_spatial_impulse_evidence_test.cpp -o /tmp/p84-spatial /tmp/p84-spatial | tee /tmp/p84-spatial.log grep -q '^PASS P84 SPATIAL SOURCE:' /tmp/p84-spatial.log + - name: Actual one-core WAV audition CLI, ROOM ON/OFF and four calibrated-input files + shell: bash + run: | + set -euo pipefail + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 \ + -DSONKU_P72_NATIVE_XYZ_RT=1 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 \ + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 \ + -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 \ + -DSONKU_P84_SINGLE_CORE_FUSION_RESEARCH=1 \ + tools/sonku_p84_offline_audition.cpp -o /tmp/p84-wav-audition + python3 - <<'PY' + import wave, struct, math + with wave.open('/tmp/p84-original.wav','wb') as o: + o.setnchannels(2);o.setsampwidth(2);o.setframerate(48000) + pcm=bytearray() + for i in range(8192): + t=i/48000 + bass=.16*math.sin(2*math.pi*83*t) + vocal=.10*math.sin(2*math.pi*461*t) + side=.11*math.sin(2*math.pi*1703*t) + l=bass+vocal+side + r=bass+vocal-side + pcm+=struct.pack(' Date: Sun, 15 Nov 2026 04:48:08 +0700 Subject: [PATCH 25/43] docs(sonku): reconcile real P8.4 single-core, CPU, binaural evidence and auditable FAT veto --- ...P84_CLARITY_FIRST_ARCHITECTURE_20261115.md | 92 ++++++++++++++++++- 1 file changed, 90 insertions(+), 2 deletions(-) diff --git a/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md b/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md index 8bcc10ff9..fdc18979c 100644 --- a/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md +++ b/docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md @@ -29,11 +29,11 @@ Formula: output = P8.2 + 0.12 * highpass_750Hz(P8.3Physical - P8.2) - Important physical limitation: the P8.2 anchor remains head-locked while the difference follows head-relative orientation. This is NOT a fully consistent measured BRIR or a demonstrated externalized room. Its purpose is rejecting or supporting the feasibility of a music-preserving localizer. - Two native SonKuSpatialCore instances are used ONLY in an OFFLINE analytical test. The full dual-core processing overhead is forbidden in production. If validated, fuse to a single native DSP graph before JUCE integration. -Test: tests/sonku_p84_clarity_candidate_test.cpp — actual C++ SonKu DSP, not WebAudio or mocked responses. Tested 44.1/48k, six program types (mono, anti-phase, hard L/R, partially correlated, transient), ROOM ON and OFF, ten frequencies (83–9301Hz), PCM 64/128 parity, full-band output RMS <=1.5dB difference to P8.2, each applicable tone <=2.5dB, finite/no clipping, byte-exact zero-influence P8.2 bypass and head-yaw differential. +Test: tests/sonku_p84_clarity_candidate_test.cpp — actual C++ SonKu DSP, not WebAudio or mocked responses. Tested 44.1/48k, seven program types including impulse, (mono, anti-phase, hard L/R, partially correlated, transient), ROOM ON and OFF, ten frequencies (83–9301Hz), PCM 64/128 parity, full-band output RMS <=1.5dB difference to P8.2, each applicable tone <=2.5dB, finite/no clipping, byte-exact zero-influence P8.2 bypass and head-yaw differential. This is only a necessary *source qualification*. Passing tone and RMS checks does not demonstrate natural timbre on real music, front/back separation, externalization, IACC, headphone-specific frequency response, or good CPU p99. -## Next architectural gates (NOT completed) +## Original next gates (status updated in single-core milestone below) 1. Run wideband multi-content FFT/erb spectral distance, ITD, ILD, transient and phase checks, room DRR and measured direct/early/late impulse responses, with P8.2 and the rejected P8.3 as controls. Avoid tuning only to hand-picked tones. 2. Use a properly licensed SOFA/AES69 measured near-field BRIR dataset and, later, personalized headphone compensation and live head tracking. Ensure all scene signals respond consistently to world-fixed yaw; distinguish stereo speaker monitoring from 3D audio object spatialization. @@ -78,3 +78,91 @@ and still do not establish front/rear realism, distance or commercial dearVR parity. Next stage must replace dual-core evaluation with a single physical graph, perform listening and measured BRIR/ear calibration; do not offer a Windows test until then. + +## Stage 2: single-PCM-core fusion — completed SOURCE research, not JUCE FAT + +Implemented new, independently opt-in +`SONKU_P84_SINGLE_CORE_FUSION_RESEARCH=1`: +- `engine/builtin_fx/sonku/SonKuP84FusedMusicHrir.h`: + `H_fused(source, ear) = H_P82_center + 0.12 * HP750(H_measured_speaker - H_P82_center)` + in **140-tap finite impulse coefficient space**, recomputed at existing + 16-sample target updates. This truncates the IIR high-pass tail at 140 + taps; tests independently measure the induced spectral effect. Exactly + **one original SonKuSpatialCore** processes the PCM, using four direct + FIRs; the second P83/independent PCM engine is gone from the hot path. +- Preserves P8.2 transparent stereo bass, headphone SIDE, music-safe + center anchor and room gain law. No LF480 invented matrix, no AGC, + no copied proprietary Clarity, no extra dry playback route, no + allocations/locks/FFT in the sample callback. +- Research setter `setResearchFusedMusicClarity()` is allowed only + while quiescent, explicitly enabled, and on a real six-wall KEMAR + native profile; no public GUI, v4 schema or session changes. +- Room EARLY geometry gets the same simulated head yaw as the fused + directional HRTF. The P8.2 center music anchor remains head-locked; + this is still NOT a genuinely head-tracked whole-scene BRIR. +- Current code depends on historical *rejected* P8.3 source headers. + **PR #704 is stacked on rejected PR #701 and must NOT be merged via + that chain**. If ear tests approve the new approach, extract the + fused transfer and necessary geometry alone into an approved + P8.2-based branch; discard the rejected physical/LF480 renderer and + legacy failed host modes. Avoid premature code migration. + +### Reproducible source CI — exact current candidate + +[Source run 43644299478](https://github.com/masarray/arsonmix/actions/runs/43644299478): +28 actual native music-like/impulse render cases at 44.1/48k, ROOM +ON/OFF, 280 fixed-frequency and 88 one-third-octave IR comparisons, +worst RMS deviation **1.264 dB**, max frequency deviation **2.204 dB** +relative to P8.2, within strict gates. 64/128 block PCM parity and +simulated yaw changes with both ROOM ON/OFF pass. +Cross-compilation with P8.4 macro OFF versus ON when fusion disabled +produces **bit-identical** P8.2 raw PCM at both sample rates, ROOM ON +and OFF, mono and anti-phase. + +48k native mono impulsive direction diagnostic: ±90 degree ILD +**-16.602/+16.602 dB**, signed ITD-correlation lag **±35 samples**, +IACC magnitude **0.39053** at ±90, front/rear impulse difference +nonzero, and room/direct motion both respond to static simulated yaw. +Measured energy ratio direct window vs late tail window +**19.257 dB**, NOT a standardized calibrated DRR measurement and +NOT proof of real-room externalization. + +### CPU evidence and real-music A/B tool + +[Full source run 43644595928](https://github.com/masarray/arsonmix/actions/runs/43644595928) +PASS: 44.1/48k, buffer 64/128/256 and 1/2/4 native instances, +18 cases (baseline vs fused). In one hosted Linux run for 48k, buffer +64, **4 inserts**, P8.2 p50 **744.20 µs**, P8.4 p50 **785.80 µs**, +P8.4 p99 **833.16 µs**, no deadline misses in sampled blocks. Median +overhead was typically ~5%, not a measured Windows ASIO CPU/XRUN +guarantee. + +New `tools/sonku_p84_offline_audition.cpp` accepts a supplied +stereo WAV (PCM16/24/32 or float32, 44.1/48k, including standard +WAVEFORMATEXTENSIBLE), preserves its original RMS and identical +render settings, and outputs four float32 WAVs: +`P82_Golden.wav`, `P84_FusedYaw0.wav`, +`P84_FusedYawPlus60.wav`, `P84_FusedYawMinus60.wav`, +plus CSV relative RMS/peak. CI smoke validates both ROOM ON and OFF +and each file's IEEE-float RIFF/fact payload. No loudness makeup, +master processing or proprietary recordings. Real-song headphone +review remains indispensable; CI uses only synthetic probes. + +### Remaining qualification gates + +* Multi-song real-music PCM: loudness, timbre, drums, attack, phase, + interaural coherence, tonal fatigue, reliable audition A/B, blinded + ear-level calibration and signal provenance. +* True natural externalization: correctly matched listener HRTF, + headphone EQ, speaker distance/source directivity and + measured/licensed BRIR; plausible reflection levels and 3D motion. + Research on frontal BRIR externalization and early-reflection level + provides hypotheses, **not universal gain presets**: + https://pmc.ncbi.nlm.nih.gov/articles/PMC13451706/ +* Low-latency head tracking with world-fixed direct + early + late + cues, SPSC/ACK, smoothed control and .smix versioning only after + source and physical audio acceptance. +* Single native JUCE host, ASIO p50/p95/p99, actual headphone + front/back/elevation confusion matrix and direct dearVR A/B. + A source-ci PASS alone does NOT authorize Windows portable or public + release. PR #701 remains rejected and P8.2 golden untouched. From fa40eaa7206570fdea68aea5b0db3b32e9f3e218 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 05:08:01 +0700 Subject: [PATCH 26/43] fix(gui): eliminate IN/OUT/EXT clipping on shared Preview/native console (#705) * test(gui): early real route overflow diagnosis for shared Preview/EXE * fix(gui): fit shared IN/OUT/EXT rows in all console densities * test(gui): align legacy PAN detent smoke with approved V61 hysteresis --- .github/workflows/ui-smoke.yml | 6 ++--- .../assets/mixer-section-controls.css | 27 ++++++++++++------- tests/preview_v2_v7_visual_smoke.py | 18 ++++++++++--- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ui-smoke.yml b/.github/workflows/ui-smoke.yml index 85554cc3a..4dae65547 100644 --- a/.github/workflows/ui-smoke.yml +++ b/.github/workflows/ui-smoke.yml @@ -453,6 +453,9 @@ jobs: python -m pip install --upgrade pip python -m pip install playwright python -m playwright install --with-deps chromium + - name: Verify Preview V2 V7 physical visual geometry and modeless mixer workflow + if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && startsWith(github.head_ref, 'integration/product-')) }} + run: python tests/preview_v2_v7_visual_smoke.py - name: Verify opt-in actual /preview/ GUI profiling, default OFF run: python tests/approved_gui_perf_stage_a_smoke.py - name: Validate Stage B native meter dirty-write / authoritative Pages parity @@ -733,9 +736,6 @@ jobs: run: python tests/pages_m3_operator_visual_interaction_smoke.py - name: Run mixer UI smoke tests run: python tests/ui_smoke.py - - name: Verify Preview V2 V7 physical visual geometry and modeless mixer workflow - if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && startsWith(github.head_ref, 'integration/product-')) }} - run: python tests/preview_v2_v7_visual_smoke.py - name: Verify V40 WIRE proximity, focus release and full-tray channel selection if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && startsWith(github.head_ref, 'integration/product-')) }} run: python tests/pages_wire_focus_v40_smoke.py diff --git a/site/preview-v2/assets/mixer-section-controls.css b/site/preview-v2/assets/mixer-section-controls.css index e2ac43e89..74ba8f3a9 100644 --- a/site/preview-v2/assets/mixer-section-controls.css +++ b/site/preview-v2/assets/mixer-section-controls.css @@ -288,24 +288,33 @@ line-height:9px!important; } -/* Route has four rows in the shared Pages/EXE renderer (title + IN/OUT/EXT). - Compact internal spacing rather than clipping the live EXT control or - inflating the panel: rail and strip retain their shared 94/91/81px heights. */ +/* One shared four-row route geometry (title + IN/OUT/EXT) for + /preview/ and JUCE WebView2. Earlier physical chrome locked the legacy + three-row field height at 24px!important; override only expanded routes. + Keep rail heights, MAX three hardware destinations, and collapsed + 23px state unchanged. Geometry budget at comfort: 17 + 3*22 + 3*1 + + 2*2 = 90px within the 94px route panel. */ .console-body:not(.collapsed-route) .strip .route-section{ - padding:2px 6px 2px;gap:1px; + padding:2px 4px!important;gap:1px; +} +.console-body:not(.collapsed-route) .strip .route-field{ + height:22px!important;min-height:22px!important;flex:0 0 22px!important; +} +.console-body[data-density="standard"]:not(.collapsed-route) .strip .route-field{ + height:21px!important;min-height:21px!important;flex:0 0 21px!important; } .console-body[data-density="standard"]:not(.collapsed-route) .strip .route-select{ - height:21px; + height:21px!important;min-height:21px!important;line-height:19px!important; } .console-body[data-density="compact"]:not(.collapsed-route) .strip .route-section{ - padding:1px 3px;gap:1px; + padding:1px 3px!important;gap:1px; } .console-body[data-density="compact"]:not(.collapsed-route) .strip .route-top{ - height:15px;min-height:15px;flex-basis:15px; + height:15px!important;min-height:15px!important;flex:0 0 15px!important; } .console-body[data-density="compact"]:not(.collapsed-route) .strip .route-field{ - min-height:18px; + height:18px!important;min-height:18px!important;flex:0 0 18px!important; } .console-body[data-density="compact"]:not(.collapsed-route) .strip .route-select{ - height:18px; + height:18px!important;min-height:18px!important;line-height:16px!important; } diff --git a/tests/preview_v2_v7_visual_smoke.py b/tests/preview_v2_v7_visual_smoke.py index c1f474f00..f77059139 100644 --- a/tests/preview_v2_v7_visual_smoke.py +++ b/tests/preview_v2_v7_visual_smoke.py @@ -59,8 +59,16 @@ def audit_geometry(page, title): if(!cap||Math.abs(r(cap).width-cw)>.75||Math.abs(r(cap).height-ch)>.75) problems.push('M2 '+cw+'x'+ch+' physical fader cap missing '+tag); const route=t.querySelector('.route-section'); - if(route&&route.scrollHeight>route.clientHeight+3) - problems.push('IN/OUT clipped '+tag); + if(route&&route.scrollHeight>route.clientHeight+3){ + const cs=getComputedStyle(route); + const children=[...route.children].map(e=>{ + const b=r(e); + return e.className+':'+Math.round(b.height)+'@'+Math.round(b.top-r(route).top); + }).join(','); + problems.push('IN/OUT/EXT clipped '+tag+' scroll='+route.scrollHeight+ + ' client='+route.clientHeight+' padding='+cs.padding+ + ' gap='+cs.gap+' children=['+children+']'); + } if(!t.querySelector('.meter-box .vu-bars'))problems.push('missing meter '+tag); if(t.querySelector('.eq-section,.trim-section,[data-field="sendPan"]')) problems.push('legacy DAW or TRIM UI leaked '+tag); @@ -316,8 +324,10 @@ def audit_p0_pan_center(page, name): return read(); }; const initial=read(); + // Current approved V61 PAN: capture ±14, hold ±22, release ±18. + // The V7 expectation at 18 sat inside the newer hold zone. const farLeft=send(-35),capture=send(-6),held=send(10), - released=send(18),nearRelease=send(11,'change'); + released=send(24),nearRelease=send(17,'change'); input.dataset.panAltPointer='true'; const bypass=send(5); delete input.dataset.panAltPointer; @@ -331,7 +341,7 @@ def audit_p0_pan_center(page, name): p=result[key] assert p['value']==0 and p['centered'] and p['label']=='C' and p['text']=='Center',( name,key,'PAN center detent failed',result) - assert result['released']['value']==18 and not result['released']['centered'],( + assert result['released']['value']==24 and not result['released']['centered'],( name,'PAN release threshold failed',result) assert result['bypass']['value']==5,(name,'Alt-pointer center bypass failed',result) assert result['unchanged'],(name,'PAN remounted during gesture') From 63695e2b777da97041a05994a84e2847cd673063 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:06:29 +0700 Subject: [PATCH 27/43] feat(sonku): reserve typed P8.4 native render mode 3 behind research flag --- engine/builtin_fx/sonku/SonKuP83SpeakerScene.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h b/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h index e5a02c844..c563cb59e 100644 --- a/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h +++ b/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h @@ -6,11 +6,20 @@ // Research-only speaker positions are fixed in WORLD, head yaw is separate. // No IO, tracker, threads, heap or additional PCM authority. namespace armix::sonku::p83 { -enum class Mode : std::uint8_t { MusicBedP82=0, MonoObject=1, SpeakerMonitor=2 }; +enum class Mode : std::uint8_t { + MusicBedP82=0, MonoObject=1, SpeakerMonitor=2, +#if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH + MusicSpatialP84=3 +#endif +}; enum class Stem : std::uint8_t { Combined=0, Direct=1, Early=2, Late=3 }; inline bool valid(Mode m) noexcept { return m==Mode::MusicBedP82 || m==Mode::MonoObject || - m==Mode::SpeakerMonitor; + m==Mode::SpeakerMonitor +#if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH + || m==Mode::MusicSpatialP84 +#endif + ; } inline bool valid(Stem s) noexcept { return s==Stem::Combined || s==Stem::Direct || From 2efc15ac41a39e7e3ccd27908e24e511ba88afc3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:06:32 +0700 Subject: [PATCH 28/43] feat(sonku): realtime P8.4 mode 3 uses preserved P8.2 bass SIDE and one fused HRTF graph --- engine/builtin_fx/sonku/SonKuSpatialCore.h | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/engine/builtin_fx/sonku/SonKuSpatialCore.h b/engine/builtin_fx/sonku/SonKuSpatialCore.h index df40e51f6..58864b81a 100644 --- a/engine/builtin_fx/sonku/SonKuSpatialCore.h +++ b/engine/builtin_fx/sonku/SonKuSpatialCore.h @@ -86,7 +86,12 @@ inline bool valid(const Settings& s) noexcept { std::isfinite(s.roomAmount) && s.roomAmount>=0.f && s.roomAmount<=1.f && std::isfinite(s.ambience) && s.ambience>=0.f && s.ambience<=1.f && #if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH - s.renderMode>=0 && s.renderMode<=2 && + s.renderMode>=0 && +#if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH + s.renderMode<=3 && (s.renderMode!=3 || !s.musicCompatibleLowFrequency) && +#else + s.renderMode<=2 && +#endif p83::validYaw(s.headYawDegrees) && (s.renderMode!=2 || (s.stereoSpreadDegrees>=20.f && s.stereoSpreadDegrees<=120.f)) && @@ -417,7 +422,11 @@ class SonKuSpatialCore final { #if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH const bool positionedMode= room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch && - p83Mode_!=p83::Mode::MusicBedP82; + p83Mode_!=p83::Mode::MusicBedP82 +#if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH + && p83Mode_!=p83::Mode::MusicSpatialP84 +#endif + ; const bool monoObject=positionedMode && p83Mode_==p83::Mode::MonoObject; #else constexpr bool positionedMode=false,monoObject=false; @@ -441,7 +450,8 @@ class SonKuSpatialCore final { constexpr bool musicSafe=false; #endif #if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH - const bool musicFused=musicSafe&&p84FusedMusic_; + const bool musicFused=musicSafe && + (p84FusedMusic_ || p83Mode_==p83::Mode::MusicSpatialP84); #else constexpr bool musicFused=false; #endif @@ -734,8 +744,11 @@ class SonKuSpatialCore final { } void updateKernels() noexcept { #if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH - if(p83Mode_!=p83::Mode::MusicBedP82 && - room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch) { + if(p83Mode_!=p83::Mode::MusicBedP82 +#if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH + && p83Mode_!=p83::Mode::MusicSpatialP84 +#endif + && room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch) { // 2x2 measured source-to-ear transfer. No MID center // projection, no headphone SIDE, no coherence-dependent mode. const auto positions=p83::stereo(static_cast(degrees_), @@ -756,7 +769,8 @@ class SonKuSpatialCore final { } #endif #if defined(SONKU_P84_SINGLE_CORE_FUSION_RESEARCH) && SONKU_P84_SINGLE_CORE_FUSION_RESEARCH - if(p84FusedMusic_ && p83Mode_==p83::Mode::MusicBedP82 && + if((p83Mode_==p83::Mode::MusicSpatialP84 || + (p84FusedMusic_ && p83Mode_==p83::Mode::MusicBedP82)) && room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch){ // One 2x2 FIR graph. Preserve the EXACT P8.2 mixed-channel // foundation while injecting only a bounded high-frequency From 6157ac3424de3a9ed3eae58319c5d63884f90a63 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:06:50 +0700 Subject: [PATCH 29/43] feat(sonku): version 5 native FX state, safe v1-v4 restoration and physical-mode rollback --- engine/builtin_fx/SonKuSpatialProcessor.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/engine/builtin_fx/SonKuSpatialProcessor.h b/engine/builtin_fx/SonKuSpatialProcessor.h index eb4b16913..33084962d 100644 --- a/engine/builtin_fx/SonKuSpatialProcessor.h +++ b/engine/builtin_fx/SonKuSpatialProcessor.h @@ -157,7 +157,11 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, out.writeInt(0x534F4E4B); // SONK #if defined(ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT) && ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT #if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT + out.writeInt(5); // same 59-byte layout as v4, new P8.4 mode +#else out.writeInt(4); +#endif #else out.writeInt(3); #endif @@ -204,6 +208,9 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, &&version!=3 #if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT &&version!=4 +#if defined(ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT + &&version!=5 +#endif #endif #endif ) || (version==1&&size!=30)||(version==2&&size!=46) @@ -211,6 +218,9 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, ||(version==3&&size!=50) #if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT ||(version==4&&size!=59) +#if defined(ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT + ||(version==5&&size!=59) +#endif #endif #endif )return false; @@ -237,12 +247,23 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, if(version>=3)next.directElevationDegrees=in.readFloat(); #endif #if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT - if(version==4){ + if(version>=4){ next.renderMode=in.readInt(); const int music=in.readByte(); if(music!=0&&music!=1)return false; next.musicCompatibleLowFrequency=music!=0; next.headYawDegrees=in.readFloat(); +#if defined(ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT + // Critical headphone FAT v4 backward-safety: old P8.3 + // physical/mono session must NOT silently restore the + // owner-rejected renderer in the new research candidate. + // Explicitly migrate old v4 non-P8.2 to golden Music Bed. + if(version==4 && next.renderMode!=0){ + next.renderMode=0; + next.musicCompatibleLowFrequency=false; + next.headYawDegrees=0.f; + } +#endif } #endif // v1 OFF, v2 original scene; experimental v3 includes direct From 5345052532eaf0f07c3c559e11bb051e7dbb0137 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:07:06 +0700 Subject: [PATCH 30/43] feat(sonku): truthful v5 control plane exposes only P8.2 golden and fused P8.4 --- src/SonKuNativeBridgeContract.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/SonKuNativeBridgeContract.h b/src/SonKuNativeBridgeContract.h index 8ad578d9e..df2df890f 100644 --- a/src/SonKuNativeBridgeContract.h +++ b/src/SonKuNativeBridgeContract.h @@ -8,7 +8,9 @@ #include namespace armix::builtin_fx::sonku_bridge { inline constexpr int schemaVersion() noexcept { -#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT + return 5; +#elif defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT return 4; #elif defined(ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT) && ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT return 3; @@ -75,6 +77,13 @@ inline bool decodeSettings(const juce::var& values,armix::sonku::Settings& out) if(!values.getProperty("renderMode",{}).isVoid() || !values.getProperty("musicCompatibleLowFrequency",{}).isVoid() || !values.getProperty("headYawDegrees",{}).isVoid())return false; +#endif +#if defined(ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT + // Rejected P8.3 physical/mono path is not an exposed option in + // the P8.4 research binary. A/B is only P8.2 golden vs fused. + if(proposed.renderMode!=0 && proposed.renderMode!=3)return false; + if(proposed.renderMode==3 && proposed.musicCompatibleLowFrequency) + return false; #endif if(!armix::sonku::valid(proposed))return false; out=proposed; From 56c22447f11fd3abff6a6422bb5f7a4cf7dff32f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:07:27 +0700 Subject: [PATCH 31/43] fix(sonku): reject unqualified physical modes in native v5 state restore --- engine/builtin_fx/SonKuSpatialProcessor.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engine/builtin_fx/SonKuSpatialProcessor.h b/engine/builtin_fx/SonKuSpatialProcessor.h index 33084962d..05a89e46b 100644 --- a/engine/builtin_fx/SonKuSpatialProcessor.h +++ b/engine/builtin_fx/SonKuSpatialProcessor.h @@ -263,6 +263,12 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, next.musicCompatibleLowFrequency=false; next.headYawDegrees=0.f; } + if(version==5 && + (next.renderMode!=0 && next.renderMode!=3)) + return false; + if(version==5 && next.renderMode==3 && + next.musicCompatibleLowFrequency) + return false; #endif } #endif From 4ab765308861f5f78d54eb7ac5c0b81006c709f0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:07:32 +0700 Subject: [PATCH 32/43] feat(sonku): native instance-bound P8.4 research capability in real mixer GUI --- src/Main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Main.cpp b/src/Main.cpp index 58f62aa90..443330ccf 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -3046,7 +3046,11 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr armix::sonku::SonKuReflectionProfile::SixSurfaceKemarResearch) reply->setProperty("p8TransparentBass",true); #endif -#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT + if(processor && processor->preparedReflectionProfile()== + armix::sonku::SonKuReflectionProfile::SixSurfaceKemarResearch) + reply->setProperty("p84MusicFusion",true); +#elif defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT if(processor && processor->preparedReflectionProfile()== armix::sonku::SonKuReflectionProfile::SixSurfaceKemarResearch) reply->setProperty("p83SpeakerModes",true); From f14e79a0dc3c8a224abf1a4dec70411b52aac9c8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:08:03 +0700 Subject: [PATCH 33/43] feat(sonku): native v5 GUI A/B P8.2 golden vs P8.4 music fusion with real ACK, hide rejected P8.3 controls --- site/preview-v2/assets/mixer-native-sonku.js | 56 ++++++++++++++------ 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/site/preview-v2/assets/mixer-native-sonku.js b/site/preview-v2/assets/mixer-native-sonku.js index fb3ed5394..c2cf4deb5 100644 --- a/site/preview-v2/assets/mixer-native-sonku.js +++ b/site/preview-v2/assets/mixer-native-sonku.js @@ -53,7 +53,7 @@ const valid=s=>s && Number.isFinite(s.startAzimuthDegrees) && 1.45+s.sourceDistanceMeters*Math.sin(s.directElevationDegrees*Math.PI/180)<= roomHeights[s.spacePreset]-.5)) && (s.renderMode===undefined || ( - Number.isInteger(s.renderMode)&&s.renderMode>=0&&s.renderMode<=2 && + Number.isInteger(s.renderMode)&&s.renderMode>=0&&s.renderMode<=3 && typeof s.musicCompatibleLowFrequency==="boolean" && Number.isFinite(s.headYawDegrees)&&Math.abs(s.headYawDegrees)<=360 && (s.renderMode!==2 || (s.stereoSpreadDegrees>=20&&s.stereoSpreadDegrees<=120)))); @@ -187,7 +187,7 @@ const depthLayers={far:$("skFarSources"),near:$("skNearSources")}; const mount=()=>{if(!root.isConnected)document.body.append(root)}; if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",mount,{once:true});else mount(); let current=null,accepted=defaults(),draft=defaults(),pending=null,latest=null, - xyzCapable=false,p83Capable=false,musicSafeStereo=false,p8TransparentBass=false,p82MultibandRoom=false, + xyzCapable=false,p83Capable=false,p84Capable=false,musicSafeStereo=false,p8TransparentBass=false,p82MultibandRoom=false, readId="",readSentAt=0,seq=1,clock=null,frame=null,observed=0,observedAt=0, drag=null,dialDrag=null,rangeEdits=new Set(),gestureStart=new Map(), visualPhase=0,visualAt=0,liveTimer=null,lastLiveAt=0; @@ -204,9 +204,24 @@ const context=()=>{ }; function render(){ const s=draft; - const row=$("skRenderRow");row.hidden=!p83Capable; - if(p83Capable){ - const v=s.renderMode===1?"mono":s.renderMode===2? + const row=$("skRenderRow");row.hidden=!(p83Capable||p84Capable); + if(p83Capable||p84Capable){ + const picker=$("skRenderMode"); + if(p84Capable && picker.dataset.nativeModeSet!=="p84"){ + picker.innerHTML=''+ + ''; + picker.dataset.nativeModeSet="p84"; + root.querySelector(".sk-render-label").textContent="RENDER MODE · P8.4 HEADPHONE FAT"; + }else if(p83Capable && picker.dataset.nativeModeSet!=="p83"){ + picker.innerHTML=''+ + ''+ + ''+ + ''; + picker.dataset.nativeModeSet="p83"; + root.querySelector(".sk-render-label").textContent="RENDER MODE · P8.3 TEST"; + } + const v=p84Capable?(s.renderMode===3?"clarity":"music"): + s.renderMode===1?"mono":s.renderMode===2? (s.musicCompatibleLowFrequency?"musiclf":"physical"):"music"; $("skRenderMode").value=v; $("skHeadYaw").value=String(s.headYawDegrees); @@ -254,7 +269,9 @@ function render(){ if(!rangeEdits.has("skElevation"))elevation.value=String(s.directElevationDegrees); $("skElevationValue").textContent=s.directElevationDegrees.toFixed(1)+"°"; } - root.querySelector(".sk-stage-caption").textContent=p83Capable&&s.renderMode===2? + root.querySelector(".sk-stage-caption").textContent=p84Capable&&s.renderMode===3? + "P8.4 FUSED HRIR · MUSIC-FIRST RESEARCH · NOT DEARVR QUALIFIED": + p83Capable&&s.renderMode===2? (s.musicCompatibleLowFrequency?"P8.3 MUSIC LF480 · SOURCE-POSITIONED COMPROMISE": "P8.3 PHYSICAL 2×2 · MEASURED HRIR"): p83Capable&&s.renderMode===1?"P8.3 MONO OBJECT · LEFT INPUT": @@ -265,7 +282,7 @@ function render(){ :xyzCapable?"HEADPHONES · MEASURED 3D HRIR · 44.1 / 48 kHz" :"HEADPHONES · HRIR 0° ELEVATION · 44.1 / 48 kHz"; $("skSpread").closest("label").querySelector(".sk-param-name").textContent= - p83Capable&&s.renderMode!==0?"SPEAKER ANGLE": + (p83Capable||p84Capable)&&s.renderMode!==0?"SPEAKER ANGLE": musicSafeStereo?"SIDE WIDTH":"SPREAD"; root.querySelector(".sk-guide").textContent=musicSafeStereo ?"Stereo WIDTH adjusts preserved L/R SIDE, not two separately located HRIR emitters" @@ -283,7 +300,8 @@ function render(){ // redrawn at 60 Hz. The native audio callback remains the time authority. drawSpeakers(); $("skMode").textContent=native()?(context()? - (p83Capable&&s.renderMode!==0?"NATIVE P8.3 SPEAKERS · RESEARCH": + (p84Capable&&s.renderMode===3?"NATIVE P8.4 MUSIC FUSION · TEST": + p83Capable&&s.renderMode!==0?"NATIVE P8.3 SPEAKERS · RESEARCH": p82MultibandRoom?"NATIVE P8.2 ROOM · RESEARCH": p8TransparentBass?"NATIVE P8 ACOUSTICS · RESEARCH": musicSafeStereo?"NATIVE MUSIC SAFE · RESEARCH":"NATIVE HRTF"): @@ -361,7 +379,7 @@ function requestSnapshot(force=false){ const LIVE_INTERVAL_MS=40; const sameSettings=(a,b)=>a&&b&&Object.keys(defaults()).every(k=>a[k]===b[k]) && (!xyzCapable || a.directElevationDegrees===b.directElevationDegrees) && - (!p83Capable || (a.renderMode===b.renderMode && + (!(p83Capable||p84Capable) || (a.renderMode===b.renderMode && a.musicCompatibleLowFrequency===b.musicCompatibleLowFrequency && a.headYawDegrees===b.headYawDegrees)); function send(next,continuous=false){ @@ -427,7 +445,8 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ r.channelId!==c.channelId||r.instanceId!==c.instanceId|| String(r.deviceEpoch)!==String(c.deviceEpoch)|| String(r.graphRevision)!==String(c.graphRevision))return; - const measured=(r.schemaVersion===3 || r.schemaVersion===4) && + const measured=(r.schemaVersion===3 || r.schemaVersion===4 || + r.schemaVersion===5) && Number.isFinite(r.settings?.directElevationDegrees); if(r.schemaVersion!==2&&!measured)return; const incoming=normalizeSettings(r.settings); @@ -439,7 +458,13 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ Number.isInteger(incoming.renderMode) && typeof incoming.musicCompatibleLowFrequency==="boolean" && Number.isFinite(incoming.headYawDegrees); - if(!p83Capable){ + p84Capable=r.schemaVersion===5 && r.p84MusicFusion===true && + Number.isInteger(incoming.renderMode) && + (incoming.renderMode===0||incoming.renderMode===3) && + typeof incoming.musicCompatibleLowFrequency==="boolean" && + incoming.musicCompatibleLowFrequency===false && + Number.isFinite(incoming.headYawDegrees); + if(!(p83Capable||p84Capable)){ delete incoming.renderMode; delete incoming.musicCompatibleLowFrequency; delete incoming.headYawDegrees; @@ -475,9 +500,10 @@ $("skClose").addEventListener("click",()=>{root.hidden=true;current=null;xyzCapa if(clock!==null){clearInterval(clock);clock=null;} if(frame!==null){cancelAnimationFrame(frame);frame=null;}}); $("skRenderMode").addEventListener("change",()=>{ - if(!p83Capable)return; + if(!(p83Capable||p84Capable))return; const v=$("skRenderMode").value; - const mode=v==="mono"?1:v==="physical"||v==="musiclf"?2:0; + const mode=p84Capable?(v==="clarity"?3:0): + v==="mono"?1:v==="physical"||v==="musiclf"?2:0; const scene={...draft,renderMode:mode,musicCompatibleLowFrequency:v==="musiclf"}; if(mode!==0){ scene.moving=false; @@ -489,7 +515,7 @@ $("skRenderMode").addEventListener("change",()=>{ if(!send(scene))render(); }); $("skHeadYaw").addEventListener("change",()=>{ - if(!p83Capable)return; + if(!(p83Capable||p84Capable))return; if(!send({...draft,headYawDegrees:Number($("skHeadYaw").value)}))render(); }); $("skMotion").addEventListener("click",()=>send({...draft,moving:!draft.moving})); @@ -640,7 +666,7 @@ const api={ cancelLiveTimer();pending=null;latest=null;readId="";readSentAt=0;dialDrag=null; observedAt=0;visualAt=0;visualPhase=0;lastLiveAt=0; drag=null;rangeEdits.clear();gestureStart.clear(); - accepted=defaults();draft=defaults();xyzCapable=false;p83Capable=false;musicSafeStereo=false;p8TransparentBass=false; + accepted=defaults();draft=defaults();xyzCapable=false;p83Capable=false;p84Capable=false;musicSafeStereo=false;p8TransparentBass=false; current={track,slot,instanceId:null}; const s=snapshot(),id=window.__ARMIX_NATIVE_M2__?.nativeIdFor?.(track); const fx=s?.graph?.channels?.find(x=>x.id===id)?.inserts?.[slot]; From 54b996816ff8e144581c3f8844fffad1bbb88c2c Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:08:40 +0700 Subject: [PATCH 34/43] build(sonku): opt-in P8.4 native v5 app with real JUCE and single-core PCM CTests --- CMakeLists.txt | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 50dbac9ab..5d90da3b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,14 @@ if(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT AND NOT ARMIX_SONKU_EXPERIMENTAL_P82_ROOM) message(FATAL_ERROR "P8.3 native speaker research requires P8.2 room ON") endif() +# P8.4 v5, ONLY in private/research FAT binaries. Not a public default. +option(ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT + "Enable P8.4 single-core music-fused native v5 research (headphone FAT only)" + OFF) +if(ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT AND + NOT ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) + message(FATAL_ERROR "P8.4 research requires P8.3 typed native host as transport; old P8.3 modes remain hidden/rejected") +endif() set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -248,7 +256,9 @@ target_compile_definitions(ARMixConsole PRIVATE $<$:SONKU_P80_TRANSPARENT_BASS_RESEARCH=1> $<$:SONKU_P82_MULTIBAND_ROOM_RESEARCH=1> $<$:ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT=1> - $<$:SONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1>) + $<$:SONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1> + $<$:ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT=1> + $<$:SONKU_P84_SINGLE_CORE_FUSION_RESEARCH=1>) if(WIN32) # Windows retains its proven ASIO-first / WASAPI / static WebView2 distribution. # Never link Windows loader or sound APIs into macOS/Linux builds. @@ -447,6 +457,43 @@ if(BUILD_TESTING) SONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1) add_test(NAME NativeSonKuP83JuceV4AudioAckLegacyRestoreAndHeadYaw COMMAND ARMixSonKuP83NativeTests) + if(ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT) + add_executable(ARMixSonKuP84LiveSourceTests + tests/sonku_p84_fused_single_core_test.cpp) + target_compile_features(ARMixSonKuP84LiveSourceTests PRIVATE cxx_std_20) + target_compile_definitions(ARMixSonKuP84LiveSourceTests PRIVATE + SONKU_P7_MEASURED_ELEVATION_RESEARCH=1 + SONKU_P71_DIRECT_XYZ_RESEARCH=1 + SONKU_P72_NATIVE_XYZ_RT=1 + SONKU_P75_MUSIC_SAFE_RESEARCH=1 + SONKU_P80_TRANSPARENT_BASS_RESEARCH=1 + SONKU_P82_MULTIBAND_ROOM_RESEARCH=1 + SONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 + SONKU_P84_SINGLE_CORE_FUSION_RESEARCH=1) + add_test(NAME NativeSonKuP84SingleCoreMusicFidelityAndWorldYaw + COMMAND ARMixSonKuP84LiveSourceTests) + juce_add_console_app(ARMixSonKuP84NativeTests + PRODUCT_NAME "ArSonMix SonKu P84 Native JUCE v5 Tests") + target_sources(ARMixSonKuP84NativeTests PRIVATE + tests/sonku_p84_native_juce_v5_test.cpp) + target_compile_features(ARMixSonKuP84NativeTests PRIVATE cxx_std_20) + target_link_libraries(ARMixSonKuP84NativeTests PRIVATE + juce::juce_audio_processors juce::juce_recommended_config_flags) + target_compile_definitions(ARMixSonKuP84NativeTests PRIVATE + ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT=1 + ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT=1 + ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT=1 + SONKU_P7_MEASURED_ELEVATION_RESEARCH=1 + SONKU_P71_DIRECT_XYZ_RESEARCH=1 + SONKU_P72_NATIVE_XYZ_RT=1 + SONKU_P75_MUSIC_SAFE_RESEARCH=1 + SONKU_P80_TRANSPARENT_BASS_RESEARCH=1 + SONKU_P82_MULTIBAND_ROOM_RESEARCH=1 + SONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 + SONKU_P84_SINGLE_CORE_FUSION_RESEARCH=1) + add_test(NAME NativeSonKuP84JuceV5AudioAckLegacySafeRestore + COMMAND ARMixSonKuP84NativeTests) + endif() endif() endif() endif() From 5e275dc00c3689da029a66fd23a7731addbf4e00 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:09:29 +0700 Subject: [PATCH 35/43] test(sonku): real JUCE v5 single-core P8.4 A/B, PCM ACK and legacy v4 physical migration --- tests/sonku_p84_native_juce_v5_test.cpp | 187 ++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 tests/sonku_p84_native_juce_v5_test.cpp diff --git a/tests/sonku_p84_native_juce_v5_test.cpp b/tests/sonku_p84_native_juce_v5_test.cpp new file mode 100644 index 000000000..0d6f09902 --- /dev/null +++ b/tests/sonku_p84_native_juce_v5_test.cpp @@ -0,0 +1,187 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// REAL native Windows JUCE v5 SonKu P8.4 headphone research: +// P8.2 -> native queued v5 -> fading -> AUDIO APPLIED ACK -> readback, +// v1..v5 .smix state, old v4 rejected physical rollback and no extra graph. +#if defined(NDEBUG) +#undef NDEBUG +#endif +#if !defined(ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT) || !ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT +#error Native JUCE v5 test requires explicit private P8.4 research build +#endif +#include "../engine/builtin_fx/SonKuSpatialProcessor.h" +#include "../src/SonKuNativeBridgeContract.h" +#include +#include +#include +#include +#include +using armix::builtin_fx::SonKuSpatialProcessor; +using armix::sonku::Settings; +using namespace armix::builtin_fx::sonku_bridge; +static constexpr float pi=3.14159265358979323846f; +static double render(SonKuSpatialProcessor& fx,int sampleOffset) { + juce::AudioBuffer pcm(2,128); + juce::MidiBuffer midi; + for(int i=0;i<128;++i){ + const float t=static_cast(sampleOffset+i)/48000.f; + const float main=.14f*std::sin(2*pi*311*t)+.08f*std::sin(2*pi*719*t); + const float side=.08f*std::sin(2*pi*1703*t); + pcm.setSample(0,i,main+side); + pcm.setSample(1,i,main-side); + } + fx.processBlock(pcm,midi); + double e=0; + for(int i=0;i<128;++i){ + const auto L=pcm.getSample(0,i),R=pcm.getSample(1,i); + assert(std::isfinite(L)&&std::isfinite(R)); + assert(std::abs(L)<1.f&&std::abs(R)<1.f); + e+=L*L+R*R; + } + return e; +} +static void complete(SonKuSpatialProcessor& fx,std::uint64_t id,int seed) { + SonKuSpatialProcessor::Completion ack{}; + bool ok=false; + for(int n=0;n<36;++n){ + render(fx,(seed+n)*128); + if(fx.pollCompletion(ack)){ + assert(ack.requestId==id && ack.applied); + ok=true;break; + } + } + assert(ok && "P84 must ACK only after native PCM applies settings"); + for(int n=0;n<20;++n) render(fx,(seed+40+n)*128); + assert(fx.stateSnapshotQuiescent()); +} +static juce::MemoryBlock legacy(int version,int oldMode=2){ + juce::MemoryBlock bytes; + juce::MemoryOutputStream o(bytes,false); + o.writeInt(0x534f4e4b);o.writeInt(version); + o.writeFloat(0.f);o.writeFloat(12.f);o.writeFloat(60.f); + o.writeFloat(1.f);o.writeFloat(.75f); + o.writeByte(0);o.writeByte(1); + if(version>=2){ + o.writeInt(1);o.writeFloat(1.6f);o.writeFloat(.55f); + o.writeFloat(.30f); + } + if(version>=3)o.writeFloat(0.f); + if(version>=4){ + o.writeInt(oldMode);o.writeByte(1);o.writeFloat(0.f); + } + assert(bytes.getSize()==static_cast( + version==1?30:version==2?46:version==3?50:59)); + return bytes; +} +int main(){ + static_assert(schemaVersion()==5); + auto fx=std::make_unique(); + fx->prepareToPlay(48000.,128); + assert(fx->isReady()); + assert(fx->preparedReflectionProfile()== + armix::sonku::SonKuReflectionProfile::SixSurfaceKemarResearch); + fx->sealForRealtime(); + Settings s=fx->acceptedSettings(); + assert(s.renderMode==0); + s.moving=false;s.startAzimuthDegrees=0.f; + s.stereoSpreadDegrees=60.f;s.spatialMix=1.f;s.outputTrim=.75f; + s.spacePreset=1;s.sourceDistanceMeters=1.6f;s.roomAmount=.55f;s.ambience=.3f; + s.headYawDegrees=0.f;s.musicCompatibleLowFrequency=false;s.renderMode=3; + auto json=acceptedSettings(s); + Settings decoded{}; + assert(decodeSettings(json,decoded)&&decoded.renderMode==3); + for(int rejected:{-1,1,2,4,63}){ + auto bad=acceptedSettings(s); + bad.getDynamicObject()->setProperty("renderMode",rejected); + assert(!decodeSettings(bad,decoded)); + } + auto bad=acceptedSettings(s); + bad.getDynamicObject()->setProperty("musicCompatibleLowFrequency",true); + assert(!decodeSettings(bad,decoded)); + bad=acceptedSettings(s); + bad.getDynamicObject()->setProperty("headYawDegrees","invalid"); + assert(!decodeSettings(bad,decoded)); + assert(fx->queueSettings(s,801)); + SonKuSpatialProcessor::Completion ack{}; + assert(!fx->pollCompletion(ack)); + render(*fx,0); + assert(!fx->pollCompletion(ack)); + assert(!fx->stateSnapshotQuiescent()); + assert(fx->acceptedSettings().renderMode==0); + complete(*fx,801,1); + assert(fx->acceptedSettings().renderMode==3); + juce::MemoryBlock snapshot; + fx->getStateInformation(snapshot); + assert(snapshot.getSize()==59); + juce::MemoryInputStream input(snapshot.getData(),snapshot.getSize(),false); + assert(input.readInt()==0x534f4e4b&&input.readInt()==5); + auto restored=std::make_unique(); + restored->prepareToPlay(44100.,128); + assert(restored->restoreUnpublishedState( + snapshot.getData(),static_cast(snapshot.getSize()))); + assert(restored->acceptedSettings().renderMode==3); + restored->prepareToPlay(48000.,256); + assert(restored->isReady() && restored->acceptedSettings().renderMode==3); + // Actual direct FIR must distinguish P8.4 from P8.2 without double engine. + auto golden=std::make_unique(); + golden->prepareToPlay(48000.,128); + auto g=s;g.renderMode=0; + assert(golden->queueSettings(g,811)); + golden->consumeRealtimeEdits(); + assert(golden->pollCompletion(ack)&&ack.applied&&ack.requestId==811); + double reference=0,fused=0; + for(int n=0;n<50;++n){ + reference+=render(*golden,(n+200)*128); + fused+=render(*restored,(n+200)*128); + } + assert(reference>0.1 && fused>0.1); + assert(std::abs(fused-reference)>0.0002); + const double relativeDb=10.*std::log10(fused/reference); + assert(std::abs(relativeDb)<1.5); + // Audio-thread head-yaw change is a separate accepted v5 transaction. + s.headYawDegrees=60.f; + assert(fx->queueSettings(s,802)); + complete(*fx,802,400); + assert(fx->acceptedSettings().renderMode==3); + assert(fx->acceptedSettings().headYawDegrees==60.f); + s.renderMode=0;s.headYawDegrees=0.f; + assert(fx->queueSettings(s,803)); + complete(*fx,803,480); + assert(fx->acceptedSettings().renderMode==0); + // Unpublished workspace has no PCM clock: edits ACK without fade. + auto offline=std::make_unique(); + offline->prepareToPlay(48000.,128); + s.renderMode=3; + assert(offline->queueSettings(s,901)); + offline->consumeRealtimeEdits(); + assert(offline->pollCompletion(ack)&&ack.applied&&ack.requestId==901); + assert(offline->acceptedSettings().renderMode==3); + assert(offline->stateSnapshotQuiescent()); + // Old v4 SpeakerPhysical and music-LF480 are REJECTED acoustically. + // When migrated into a v5 research binary, they explicitly fall back P8.2. + for(int version:{1,2,3,4}){ + const auto old=legacy(version); + auto dest=std::make_unique(); + dest->prepareToPlay(48000.,128); + assert(dest->restoreUnpublishedState(old.getData(),static_cast(old.getSize()))); + assert(dest->acceptedSettings().renderMode==0); + if(version==4){ + assert(!dest->acceptedSettings().musicCompatibleLowFrequency); + assert(dest->acceptedSettings().headYawDegrees==0.f); + } + } + auto broken=std::make_unique(); + broken->prepareToPlay(48000.,128); + assert(!broken->restoreUnpublishedState(snapshot.getData(),58)); + juce::MemoryBlock corrupt(snapshot); + auto* ptr=static_cast(corrupt.getData()); + ptr[54]=0xff; // signed JUCE bool, 0xff must never become true + assert(!broken->restoreUnpublishedState(corrupt.getData(),59)); + corrupt=snapshot;ptr=static_cast(corrupt.getData()); + ptr[50]=2;ptr[51]=ptr[52]=ptr[53]=0; // old physical mode in v5 forbidden + assert(!broken->restoreUnpublishedState(corrupt.getData(),59)); + restored->sealForRealtime(); + assert(!restored->restoreUnpublishedState(snapshot.getData(),59)); + std::printf("PASS P84 JUCE v5: audio ACK fade, single native graph A/B, " + "safe v1-v4 migration, v5 59-byte state and device reopen; " + "P84_vs_P82_RMS_dB=%.3f; ASIO/headphone NOT PROVEN\n",relativeDb); +} From 964f9f41584b8cd1a428bcaf95fbe17d12d05140 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:10:36 +0700 Subject: [PATCH 36/43] ci(sonku): gated native Windows x64 P8.4 v5 mixer portable research FAT --- .github/workflows/sonku-p84-windows-field.yml | 251 ++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 .github/workflows/sonku-p84-windows-field.yml diff --git a/.github/workflows/sonku-p84-windows-field.yml b/.github/workflows/sonku-p84-windows-field.yml new file mode 100644 index 000000000..c05326f2a --- /dev/null +++ b/.github/workflows/sonku-p84-windows-field.yml @@ -0,0 +1,251 @@ +name: SonKu P8.4 actual native mixer portable FAT x64 +# Private JUCE app; no public release. Real v5 P8.2/P8.4 A/B. +on: + pull_request: + paths: + - '.github/workflows/sonku-p84-windows-field.yml' + workflow_dispatch: +permissions: + contents: read +concurrency: + group: sonku-p84-field-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + preflight: + name: Isolated fast PCM and GUI preflight + runs-on: ubuntu-latest + timeout-minutes: 8 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + persist-credentials: false + - name: Strict P8.4 PCM timbre and spatial source qualification + run: | + set -euo pipefail + FLAGS="-std=c++20 -O2 -Wall -Wextra -Werror -pedantic -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 -DSONKU_P72_NATIVE_XYZ_RT=1 -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 -DSONKU_P84_SINGLE_CORE_FUSION_RESEARCH=1" + g++ $FLAGS tests/sonku_p84_fused_single_core_test.cpp -o /tmp/p84-native + /tmp/p84-native | tee /tmp/p84-source.log + grep -q '^PASS P84 SINGLE CORE:' /tmp/p84-source.log + g++ $FLAGS tests/sonku_p84_spatial_impulse_evidence_test.cpp -o /tmp/p84-spatial + /tmp/p84-spatial | tee /tmp/p84-spatial.log + grep -q '^PASS P84 SPATIAL SOURCE:' /tmp/p84-spatial.log + - name: Native JS and source GUI capability checks + run: | + set -euo pipefail + node --check site/preview-v2/assets/mixer-native-sonku.js + node tests/sonku_p73_gui_contract_test.js + grep -q "'FIELD_PREVIEW_FULL_CTEST_NOT_RUN'" scripts/m3e_fat_evidence_gate.mjs + python -m unittest discover -s tests -p native_peq_assembly_test.py + - name: 44.1 and 48 kHz prepared PCM source regression + run: | + set -euo pipefail + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 \ + -DSONKU_P72_NATIVE_XYZ_RT=1 \ + tests/sonku_p72_realtime_xyz_test.cpp -o /tmp/sonku-p75-pcm + /tmp/sonku-p75-pcm + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 \ + -DSONKU_P72_NATIVE_XYZ_RT=1 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + tests/sonku_p75_stereo_integrity_test.cpp -o /tmp/sonku-p75-music + /tmp/sonku-p75-music + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 \ + -DSONKU_P72_NATIVE_XYZ_RT=1 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 \ + tests/sonku_p80_tonal_room_evidence_test.cpp -o /tmp/sonku-p80-evidence + /tmp/sonku-p80-evidence | tee /tmp/sonku-p80-acoustic-evidence.csv + grep -q '^PASS P8:' /tmp/sonku-p80-acoustic-evidence.csv + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 \ + -DSONKU_P72_NATIVE_XYZ_RT=1 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 \ + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 \ + tests/sonku_p82_sixsurface_multiband_room_test.cpp -o /tmp/sonku-p82-room + /tmp/sonku-p82-room | tee /tmp/sonku-p82-room-evidence.csv + grep -q '^PASS P8.2:' /tmp/sonku-p82-room-evidence.csv + windows-field: + name: Actual full Windows JUCE executable and verified portable field ZIP + needs: preflight + runs-on: windows-2022 + timeout-minutes: 55 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + persist-credentials: false + - name: Verify immutable PR head and physical candidate identity + shell: pwsh + env: + EXPECTED_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + run: | + $actual = (& git rev-parse HEAD).Trim() + if ($LASTEXITCODE -ne 0 -or $actual -ne $env:EXPECTED_SHA -or $actual -notmatch '^[0-9a-f]{40}$') { + throw "SONKU_P83_SOURCE_MISMATCH:$actual" + } + Write-Host "SONKU_P84_EXACT_SOURCE=$actual" + - uses: actions/checkout@v4 + with: + repository: juce-framework/JUCE + ref: 8.0.15 + path: third_party/JUCE + persist-credentials: false + - name: Obtain pinned WebView2 compilation SDK + shell: pwsh + run: | + nuget install Microsoft.Web.WebView2 -Version 1.0.3485.44 -OutputDirectory .deps -NonInteractive + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + - name: Configure full native app with research XYZ explicit ON + shell: pwsh + run: | + cmake -S . -B build -G "Visual Studio 17 2022" -A x64 ` + -DJUCE_ROOT="$env:GITHUB_WORKSPACE/third_party/JUCE" ` + -DJUCE_WEBVIEW2_PACKAGE_LOCATION="$env:GITHUB_WORKSPACE/.deps" ` + -DARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_MUSIC_SAFE=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P8_TRANSPARENT_BASS=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P82_ROOM=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT=ON ` + -DBUILD_TESTING=ON + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + $cache = Get-Content -LiteralPath build/CMakeCache.txt -Raw + if ($cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT:BOOL=ON' -or + $cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_MUSIC_SAFE:BOOL=ON' -or + $cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P8_TRANSPARENT_BASS:BOOL=ON' -or + $cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P82_ROOM:BOOL=ON' -or + $cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT:BOOL=ON' -or + $cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT:BOOL=ON') { + throw "SONKU_P83_RESEARCH_NOT_ENABLED" + } + $tests = (& ctest --test-dir build -C Release --show-only=json-v1 | Out-String | ConvertFrom-Json) + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + $required = @('NativeSonKuP72AtomicXyzLiveEditSource', + 'NativeSonKuP72JuceV3XyzLiveAckV1V2Restore', + 'NativeSonKuSessionV1V2AndAudioAppliedAck', + 'NativeSonKuP75MusicStereoPhaseNoNullAndChunkParity', + 'NativeSonKuP80TransparentBassStereoPhaseAndRoomDiagnostic', + 'NativeSonKuP82SixWallThreeBandRoomTimingDecayAndParity', + 'NativeSonKuP83RealtimeModeSourceAndMusicIntegrity', + 'NativeSonKuP83JuceV4AudioAckLegacyRestoreAndHeadYaw', + 'NativeSonKuP84SingleCoreMusicFidelityAndWorldYaw', + 'NativeSonKuP84JuceV5AudioAckLegacySafeRestore') + $available = @($tests.tests | ForEach-Object { $_.name }) + foreach ($test in $required) { + if ($test -notin $available) { throw "SONKU_P82_MISSING_CTEST:$test" } + } + - name: Compile actual ARMixConsole Windows GUI and focused real JUCE tests + shell: pwsh + run: | + cmake --build build --config Release --parallel 2 --target ` + ARMixConsole ARMixSonKuP72SourceTests ARMixSonKuP72NativeTests ARMixSonKuNativeStateTests ARMixSonKuP75MusicIntegrityTests ARMixSonKuP80TonalEvidenceTests ARMixSonKuP82RoomTests ARMixSonKuP83LiveSourceTests ARMixSonKuP83NativeTests ARMixSonKuP84LiveSourceTests ARMixSonKuP84NativeTests + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + $exe = 'build/ARMixConsole_artefacts/Release/AR MIX Studio.exe' + if (-not (Test-Path -LiteralPath $exe -PathType Leaf)) { throw "SONKU_P83_NO_GUI_EXE" } + if ((Get-Item -LiteralPath $exe).Length -lt 4MB) { throw "SONKU_P83_WRONG_GUI_TARGET" } + - name: Scoped native XYZ state, callback ACK and legacy restoration + shell: pwsh + run: | + ctest --test-dir build -C Release --output-on-failure ` + -R '^NativeSonKu(P72AtomicXyzLiveEditSource|P72JuceV3XyzLiveAckV1V2Restore|SessionV1V2AndAudioAppliedAck|P75MusicStereoPhaseNoNullAndChunkParity|P80TransparentBassStereoPhaseAndRoomDiagnostic|P82SixWallThreeBandRoomTimingDecayAndParity|P83RealtimeModeSourceAndMusicIntegrity|P83JuceV4AudioAckLegacyRestoreAndHeadYaw|P84SingleCoreMusicFidelityAndWorldYaw|P84JuceV5AudioAckLegacySafeRestore)$' + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + - name: Package real native portable mixer, never an installer + shell: pwsh + run: | + & ./scripts/package_native_windows.ps1 -BuildDir build -OutputDir dist + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + python scripts/factoryfx_release_bundle.py stage --lock config/factoryfx-approved-releases.json --output dist --best-effort + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + - name: Record exact experiment and physical qualification pending + shell: pwsh + run: | + $path = 'dist/BUILD_PROVENANCE.json' + $p = Get-Content -LiteralPath $path -Raw -Encoding utf8 | ConvertFrom-Json + $sha = (& git rev-parse HEAD).Trim() + if ($p.sourceCommit -ne $sha) { throw "SONKU_P83_ARTIFACT_SHA_MISMATCH" } + $p.fatStatus = 'FIELD_PREVIEW_FULL_CTEST_NOT_RUN' + $p | Add-Member -NotePropertyName sonkuExperiment -NotePropertyValue @{ + enabled = $true + nativeXYZ = $true + musicSafeStereo = $true + p8TransparentBass = $true + p82MultibandRoom = $true + p83NativeSpeakers = $false + p84FusedNative = $true + p84RenderModes = @('MusicBedP82','MusicSpatialP84') + p83HeadYaw = 'DETERMINISTIC_MANUAL_NO_SENSOR' + p84FusionDifferenceHighpassHz = 750 + p84MeasuredHrirContrast = 0.12 + legacyP83V4Migration = 'OLD_SPEAKER_TO_P82' + p83AudioAppliedAck = $true + p83RealtimeModeCrossfade = '12ms_OUT_AND_IN_NATIVE_SINGLE_PCM_GRAPH' + p82RoomBandsHz = @(250,4800) + p82MaterialCalibration = 'ORIGINAL_ILLUSTRATIVE_NOT_MEASURED_RIR' + p82Rt60StudioSeconds = @(0.717,0.392,0.231) + p82Rt60ChamberSeconds = @(0.933,0.802,0.483) + p82Rt60HallSeconds = @(1.716,1.219,0.650) + p8LowBandCrossoverHz = 220 + musicSafeAlgorithm = 'MEASURED_CENTER_MID_PLUS_UNCONDITIONAL_STEREO_SIDE_RESEARCH' + stateSchema = 5 + fullWindowsExecutable = $true + publicRelease = $false + physicalAsioQualified = $false + dearVrPerceptualParityProven = $false + qualification = 'SONKU_P84_FULL_JUCE_10_SCOPED_CTEST_SOFTWARE_ONLY_HEADPHONE_FAT_PENDING' + licenseRedistributionApproval = $false + mitKemarNoticeSha256 = (Get-FileHash -LiteralPath docs/THIRD_PARTY_8D_SONKU_HRTF.md -Algorithm SHA256).Hash.ToLowerInvariant() + fieldFatGuideSha256 = (Get-FileHash -LiteralPath docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md -Algorithm SHA256).Hash.ToLowerInvariant() + } -Force + $p | ConvertTo-Json -Depth 20 | Set-Content -LiteralPath $path -Encoding utf8 + - name: Independent GUI PE, approved resources, provenance and ZIP verification + shell: pwsh + run: | + & ./scripts/verify_native_windows_artifact.ps1 -OutputDir dist + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + $p = Get-Content -LiteralPath dist/BUILD_PROVENANCE.json -Raw | ConvertFrom-Json + if (-not $p.sonkuExperiment.enabled -or + -not $p.sonkuExperiment.musicSafeStereo -or + -not $p.sonkuExperiment.p8TransparentBass -or + -not $p.sonkuExperiment.p82MultibandRoom -or + -not $p.sonkuExperiment.p84FusedNative -or + $p.sonkuExperiment.stateSchema -ne 5 -or $p.sonkuExperiment.publicRelease) { + throw 'SONKU_P84_WRONG_FIELD_ARTIFACT' + } + - name: Include mandatory MIT KEMAR notice and physical FAT guide + shell: pwsh + run: | + # Standard distribution allowlist was verified above. Field-only notice. + Copy-Item -LiteralPath docs/THIRD_PARTY_8D_SONKU_HRTF.md -Destination dist/THIRD_PARTY_8D_SONKU_HRTF.md + Copy-Item -LiteralPath docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md -Destination dist/SONKU_P84_FIELD_FAT.md + $p = Get-Content -LiteralPath dist/BUILD_PROVENANCE.json -Raw | ConvertFrom-Json + $checks = @{ + 'THIRD_PARTY_8D_SONKU_HRTF.md' = [string]$p.sonkuExperiment.mitKemarNoticeSha256 + 'SONKU_P84_FIELD_FAT.md' = [string]$p.sonkuExperiment.fieldFatGuideSha256 + } + foreach ($item in $checks.GetEnumerator()) { + $file = Join-Path dist $item.Key + if ($item.Value -notmatch '^[0-9a-f]{64}$' -or + -not (Test-Path -LiteralPath $file -PathType Leaf)) { + throw "SONKU_P83_FIELD_NOTICE_MISSING:$($item.Key)" + } + $actual = (Get-FileHash -LiteralPath $file -Algorithm SHA256).Hash.ToLowerInvariant() + if ($actual -ne $item.Value) { throw "SONKU_P83_FIELD_NOTICE_HASH_MISMATCH:$($item.Key)" } + } + if (Test-Path -LiteralPath dist/Studio) { throw 'SONKU_FIELD_USER_DATA_MUST_NOT_SHIP' } + Write-Host 'SONKU_P84_FIELD_READY: GUI EXE + verified MIT notice + FAT guide' + - uses: actions/upload-artifact@v4 + name: Upload isolated SonKu Windows x64 field candidate + with: + name: ArSonMix-SonKu-P84-Native-Mixer-Windows-x64-${{ github.run_id }} + path: dist/ + if-no-files-found: error + retention-days: 21 + compression-level: 0 From 775489d690ae95714bd72f64811906e8d2e94cad Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:12:26 +0700 Subject: [PATCH 37/43] test(sonku): gate real P8.4 v5 renderMode3 A/B and 64/128 native PCM parity --- tests/sonku_p84_live_v5_modes_source_test.cpp | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tests/sonku_p84_live_v5_modes_source_test.cpp diff --git a/tests/sonku_p84_live_v5_modes_source_test.cpp b/tests/sonku_p84_live_v5_modes_source_test.cpp new file mode 100644 index 000000000..afbb56dee --- /dev/null +++ b/tests/sonku_p84_live_v5_modes_source_test.cpp @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// P8.4 real-time renderMode=3: SAME native SonKuSpatialCore as JUCE. +// Gate the source-mode path, not only the earlier pre-PCM research setter. +#if defined(NDEBUG) +#undef NDEBUG +#endif +#include "../engine/builtin_fx/sonku/SonKuSpatialCore.h" +#include +#include +#include +#include +#include +#include +using armix::sonku::SonKuSpatialCore; +using armix::sonku::Settings; +using armix::sonku::SonKuReflectionProfile; +struct Audio {std::vector l,r;}; +static Audio render(bool fused,int rate,bool room,int block) { + const int N=16384; + Audio a{{std::vector(N)},{std::vector(N)}}; + auto core=std::make_unique(); + assert(core->prepare(rate,SonKuReflectionProfile::SixSurfaceKemarResearch)); + Settings s{};s.moving=false;s.startAzimuthDegrees=0.f; + s.stereoSpreadDegrees=60.f;s.spatialMix=1.f;s.outputTrim=.75f; + s.spacePreset=room?1:0;s.sourceDistanceMeters=1.6f; + s.roomAmount=.55f;s.ambience=.30f; + s.renderMode=fused?3:0;s.musicCompatibleLowFrequency=false; + assert(core->setSettings(s)); + for(int i=0;i(rate); + const float m=static_cast(.12*std::sin(2*3.141592653589793*83*t) + +.06*std::sin(2*3.141592653589793*461*t)); + const float side=static_cast(.055*std::sin(2*3.141592653589793*1703*t)); + a.l[i]=m+side; + a.r[i]=m-side; + } + for(int i=0;iprocess(a.l.data()+i,a.r.data()+i,std::min(block,N-i)); + return a; +} +static double energy(const Audio& x) { + double sum=0; + for(std::size_t i=0;i(x.l[i])*x.l[i]+static_cast(x.r[i])*x.r[i]; + } + return sum; +} +static double difference(const Audio& x,const Audio& y) { + double e=0; + for(std::size_t i=0;i.004 && contrast<.5); + } + std::puts("PASS P84 V5 NATIVE SOURCE: real render mode 3, golden A/B, 44.1/48k room OFF/ON PCM 64/128 exact parity"); +} From c7bd3904d5d44e661c56472486a8e40b12437812 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:12:57 +0700 Subject: [PATCH 38/43] ci(sonku): verify P8.4 live mode 3 actual callback before Windows native build --- .github/workflows/sonku-p84-clarity-research.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/sonku-p84-clarity-research.yml b/.github/workflows/sonku-p84-clarity-research.yml index 480153b36..b593eaa73 100644 --- a/.github/workflows/sonku-p84-clarity-research.yml +++ b/.github/workflows/sonku-p84-clarity-research.yml @@ -10,6 +10,7 @@ on: - 'tests/sonku_p84_fused_single_core_test.cpp' - 'tests/sonku_p84_fused_hosted_cpu_benchmark.cpp' - 'tests/sonku_p84_spatial_impulse_evidence_test.cpp' + - 'tests/sonku_p84_live_v5_modes_source_test.cpp' - 'tools/sonku_p84_offline_audition.cpp' - 'docs/SONKU_P84_CLARITY_FIRST_ARCHITECTURE_20261115.md' - '.github/workflows/sonku-p84-clarity-research.yml' @@ -134,6 +135,21 @@ jobs: assert abs(float(rows[0]['relative_rms_db_vs_p82']))<1e-12 print('PASS P84 REAL WAV CLI: PCM16 source, float32 fact, four same-input native variants, ROOM ON/OFF') PY + - name: Explicit P8.4 v5 live mode 3 stereo PCM source equivalence + run: | + set -euo pipefail + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 \ + -DSONKU_P72_NATIVE_XYZ_RT=1 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 \ + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 \ + -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 \ + -DSONKU_P84_SINGLE_CORE_FUSION_RESEARCH=1 \ + tests/sonku_p84_live_v5_modes_source_test.cpp -o /tmp/p84-v5-mode + /tmp/p84-v5-mode | tee /tmp/p84-v5-mode.log + grep -q '^PASS P84 V5 NATIVE SOURCE:' /tmp/p84-v5-mode.log - name: Hosted CPU 1-4 inserts 64-256 buffer research (not ASIO XRUN) shell: bash run: | From c16666ac3ffa6247ac00a9673fed3ee150504f43 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:26:39 +0700 Subject: [PATCH 39/43] test(sonku): finalize JUCE MemoryOutputStream before checking legacy state byte lengths --- tests/sonku_p84_native_juce_v5_test.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/sonku_p84_native_juce_v5_test.cpp b/tests/sonku_p84_native_juce_v5_test.cpp index 0d6f09902..36b92f918 100644 --- a/tests/sonku_p84_native_juce_v5_test.cpp +++ b/tests/sonku_p84_native_juce_v5_test.cpp @@ -55,8 +55,9 @@ static void complete(SonKuSpatialProcessor& fx,std::uint64_t id,int seed) { } static juce::MemoryBlock legacy(int version,int oldMode=2){ juce::MemoryBlock bytes; - juce::MemoryOutputStream o(bytes,false); - o.writeInt(0x534f4e4b);o.writeInt(version); + { + juce::MemoryOutputStream o(bytes,false); + o.writeInt(0x534f4e4b);o.writeInt(version); o.writeFloat(0.f);o.writeFloat(12.f);o.writeFloat(60.f); o.writeFloat(1.f);o.writeFloat(.75f); o.writeByte(0);o.writeByte(1); @@ -65,9 +66,10 @@ static juce::MemoryBlock legacy(int version,int oldMode=2){ o.writeFloat(.30f); } if(version>=3)o.writeFloat(0.f); - if(version>=4){ - o.writeInt(oldMode);o.writeByte(1);o.writeFloat(0.f); - } + if(version>=4){ + o.writeInt(oldMode);o.writeByte(1);o.writeFloat(0.f); + } + } // MemoryOutputStream must flush byte count before asserting the block. assert(bytes.getSize()==static_cast( version==1?30:version==2?46:version==3?50:59)); return bytes; From 6beb2918fdb98105c46f8c50393d259a3aff7e79 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:27:02 +0700 Subject: [PATCH 40/43] fix(sonku): quarantine legacy LF480 flags in all v4 sessions and reject LF480 in v5 --- engine/builtin_fx/SonKuSpatialProcessor.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/engine/builtin_fx/SonKuSpatialProcessor.h b/engine/builtin_fx/SonKuSpatialProcessor.h index 05a89e46b..1df9ba678 100644 --- a/engine/builtin_fx/SonKuSpatialProcessor.h +++ b/engine/builtin_fx/SonKuSpatialProcessor.h @@ -258,16 +258,19 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, // physical/mono session must NOT silently restore the // owner-rejected renderer in the new research candidate. // Explicitly migrate old v4 non-P8.2 to golden Music Bed. - if(version==4 && next.renderMode!=0){ - next.renderMode=0; + if(version==4) { + // All legacy v4 Speaker LF flags are discarded, even for + // a v4 P8.2 MusicBed session. P8.4 v5 exposes NO LF480 path. next.musicCompatibleLowFrequency=false; - next.headYawDegrees=0.f; + if(next.renderMode!=0) { + next.renderMode=0; + next.headYawDegrees=0.f; + } } if(version==5 && (next.renderMode!=0 && next.renderMode!=3)) return false; - if(version==5 && next.renderMode==3 && - next.musicCompatibleLowFrequency) + if(version==5 && next.musicCompatibleLowFrequency) return false; #endif } From 47d168ab804320b38be8ef40be78d9971e327502 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:27:12 +0700 Subject: [PATCH 41/43] fix(sonku): native v5 control-plane always rejects rejected P8.3 LF480 flags --- src/SonKuNativeBridgeContract.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SonKuNativeBridgeContract.h b/src/SonKuNativeBridgeContract.h index df2df890f..c1f7beff6 100644 --- a/src/SonKuNativeBridgeContract.h +++ b/src/SonKuNativeBridgeContract.h @@ -82,8 +82,8 @@ inline bool decodeSettings(const juce::var& values,armix::sonku::Settings& out) // Rejected P8.3 physical/mono path is not an exposed option in // the P8.4 research binary. A/B is only P8.2 golden vs fused. if(proposed.renderMode!=0 && proposed.renderMode!=3)return false; - if(proposed.renderMode==3 && proposed.musicCompatibleLowFrequency) - return false; + if(proposed.musicCompatibleLowFrequency) + return false; // P8.3 LF480 is forbidden throughout native v5. #endif if(!armix::sonku::valid(proposed))return false; out=proposed; From adcb4f003689e809a0ffb47c701fbf8c5db2aaa2 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:27:28 +0700 Subject: [PATCH 42/43] test(sonku): verify old v4 P8.2 with stale LF480 flag sanitizes on v5 import --- tests/sonku_p84_native_juce_v5_test.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/sonku_p84_native_juce_v5_test.cpp b/tests/sonku_p84_native_juce_v5_test.cpp index 36b92f918..cd4e4258a 100644 --- a/tests/sonku_p84_native_juce_v5_test.cpp +++ b/tests/sonku_p84_native_juce_v5_test.cpp @@ -171,6 +171,15 @@ int main(){ assert(dest->acceptedSettings().headYawDegrees==0.f); } } + // Even legacy v4 MusicBed with a stale LF480 toggle must be sanitized + // so the new v5 research UI always discovers truthful P8.4 capability. + const auto v4GoldenWithLf=legacy(4,0); + auto downgrade=std::make_unique(); + downgrade->prepareToPlay(48000.,128); + assert(downgrade->restoreUnpublishedState( + v4GoldenWithLf.getData(),static_cast(v4GoldenWithLf.getSize()))); + assert(downgrade->acceptedSettings().renderMode==0); + assert(!downgrade->acceptedSettings().musicCompatibleLowFrequency); auto broken=std::make_unique(); broken->prepareToPlay(48000.,128); assert(!broken->restoreUnpublishedState(snapshot.getData(),58)); From 641b4eaec653b2ecacc997200356a53aa98c4339 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 15 Nov 2026 06:27:42 +0700 Subject: [PATCH 43/43] ci(sonku): fail-fast JUCE v5 state/ACK test before full Windows GUI compile, gate live mode3 source --- .github/workflows/sonku-p84-windows-field.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/sonku-p84-windows-field.yml b/.github/workflows/sonku-p84-windows-field.yml index c05326f2a..ad2aee766 100644 --- a/.github/workflows/sonku-p84-windows-field.yml +++ b/.github/workflows/sonku-p84-windows-field.yml @@ -30,6 +30,9 @@ jobs: g++ $FLAGS tests/sonku_p84_spatial_impulse_evidence_test.cpp -o /tmp/p84-spatial /tmp/p84-spatial | tee /tmp/p84-spatial.log grep -q '^PASS P84 SPATIAL SOURCE:' /tmp/p84-spatial.log + g++ $FLAGS tests/sonku_p84_live_v5_modes_source_test.cpp -o /tmp/p84-live-mode + /tmp/p84-live-mode | tee /tmp/p84-live-mode.log + grep -q '^PASS P84 V5 NATIVE SOURCE:' /tmp/p84-live-mode.log - name: Native JS and source GUI capability checks run: | set -euo pipefail @@ -142,6 +145,13 @@ jobs: foreach ($test in $required) { if ($test -notin $available) { throw "SONKU_P82_MISSING_CTEST:$test" } } + - name: Fail fast — compile and execute real JUCE v5 state + PCM ACK first + shell: pwsh + run: | + cmake --build build --config Release --parallel 2 --target ARMixSonKuP84NativeTests + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + ctest --test-dir build -C Release --output-on-failure -R '^NativeSonKuP84JuceV5AudioAckLegacySafeRestore$' + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - name: Compile actual ARMixConsole Windows GUI and focused real JUCE tests shell: pwsh run: |