From 6e599aca62bec83f9cd400618a5a0b24d0365aee Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 08:57:36 +0700 Subject: [PATCH 01/15] feat(sonku): opt-in constant-radius front/rear DRR calibration with realtime-safe 45ms smoothing --- .../sonku/SonKuP94FrontBackDepthCue.h | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 engine/builtin_fx/sonku/SonKuP94FrontBackDepthCue.h diff --git a/engine/builtin_fx/sonku/SonKuP94FrontBackDepthCue.h b/engine/builtin_fx/sonku/SonKuP94FrontBackDepthCue.h new file mode 100644 index 000000000..f0f88088c --- /dev/null +++ b/engine/builtin_fx/sonku/SonKuP94FrontBackDepthCue.h @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include +#include +#include +#include + +// P9.4 private acoustic A/B (NOT a measured BRIR / dearVR clone). +// A front/rear source can collapse inside the head with non-individual KEMAR. +// At CONSTANT physical radius, adjust only the direct/first-reflection +// energy balance near the interaural median plane; measured HRIR spectra, +// ITD/ILD, speaker azimuth, low-frequency world transfer and tail stay intact. +// Must be validated by loudness-matched headphone FAT before release. +namespace armix::sonku::p94 { +class FrontBackDepthCue final { +public: + struct Gains {float direct=1.f,early=1.f;}; + bool prepare(double sampleRate) noexcept { + if(!std::isfinite(sampleRate) || + (std::abs(sampleRate-44100.)>.1 && std::abs(sampleRate-48000.)>.1)) + return false; + constexpr double pi=3.1415926535897932384626433832795; + slew_=static_cast(1.-std::exp(-1./(sampleRate*.045))); + for(std::size_t i=0;i((c*c)*(c*c)); + } + reset(); + return true; + } + void reset() noexcept {target_=0.f;weight_=0.f;enabled_=false;} + // Called at the existing every-16-sample HRTF retarget. Angle MUST be + // center WORLD azimuth - head yaw, never the ellipse's 2D SVG position. + void retarget(float headRelativeAzimuth,bool roomWithEarly) noexcept { + enabled_=roomWithEarly; + if(!enabled_ || !std::isfinite(headRelativeAzimuth)){ + target_=0.f;return; + } + // p83::toHead returns [-180,180], bounded wrap avoids RT fmod/cos. + float d=std::clamp(headRelativeAzimuth,-360.f,360.f); + if(d<0.f)d+=360.f; + if(d>=360.f)d-=360.f; + const int lo=std::clamp(static_cast(d),0,359); + const float frac=d-lo; + target_=shape_[lo]*(1.f-frac)+shape_[lo+1]*frac; + } + Gains next() noexcept { + weight_+=slew_*(target_-weight_); + if(std::abs(weight_-target_)<1.e-6f)weight_=target_; + // Room OFF / ER zero must never perturb the golden P9 PCM. + if(!enabled_)return {}; + const float w=std::clamp(weight_,0.f,1.f); + // At 0/180: direct -0.40 dB, early +2.14 dB. Ratio shifts by + // ~2.54 dB; NOT a source distance or headphone gain multiplier. + // At ±90 the output is mathematically bit-identical to P9.1/P9.2. + return {1.f-.045f*w,1.f+.28f*w}; + } +private: + std::array shape_{}; + float slew_=0.f,target_=0.f,weight_=0.f; + bool enabled_=false; +}; +} // namespace armix::sonku::p94 From d48541cc8828aef8746ebcbfc0b4a129eb0fdaf0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 08:58:05 +0700 Subject: [PATCH 02/15] feat(sonku): isolate P9.4 front/back depth cue to measured P9 direct/early scene only --- engine/builtin_fx/sonku/SonKuSpatialCore.h | 36 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/engine/builtin_fx/sonku/SonKuSpatialCore.h b/engine/builtin_fx/sonku/SonKuSpatialCore.h index 5b8e26eaf..abbcf4695 100644 --- a/engine/builtin_fx/sonku/SonKuSpatialCore.h +++ b/engine/builtin_fx/sonku/SonKuSpatialCore.h @@ -22,6 +22,9 @@ #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH #include "SonKuP90StereoDecoder.h" #include "SonKuP91P92WorldBassFoundation.h" +#if defined(SONKU_P94_FRONT_BACK_DEPTH_RESEARCH) && SONKU_P94_FRONT_BACK_DEPTH_RESEARCH +#include "SonKuP94FrontBackDepthCue.h" +#endif #endif #endif #if defined(SONKU_P87_MUSIC_BODY_RESEARCH) && SONKU_P87_MUSIC_BODY_RESEARCH @@ -204,6 +207,9 @@ class SonKuSpatialCore final { #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH if(!p90Decoder_.prepare(rate))return false; if(!p92Bass_.prepare(rate))return false; +#if defined(SONKU_P94_FRONT_BACK_DEPTH_RESEARCH) && SONKU_P94_FRONT_BACK_DEPTH_RESEARCH + if(!p94Depth_.prepare(rate))return false; +#endif #endif #endif #if defined(SONKU_P87_MUSIC_BODY_RESEARCH) && SONKU_P87_MUSIC_BODY_RESEARCH @@ -272,6 +278,9 @@ class SonKuSpatialCore final { #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH p90Decoder_.reset(); p92Bass_.reset(); +#if defined(SONKU_P94_FRONT_BACK_DEPTH_RESEARCH) && SONKU_P94_FRONT_BACK_DEPTH_RESEARCH + p94Depth_.reset(); +#endif #endif #if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH p83LowFrequency_.reset(); @@ -323,6 +332,9 @@ class SonKuSpatialCore final { if((s.renderMode==9)!=(settings_.renderMode==9)){ p90Decoder_.reset(); p92Bass_.reset(); +#if defined(SONKU_P94_FRONT_BACK_DEPTH_RESEARCH) && SONKU_P94_FRONT_BACK_DEPTH_RESEARCH + p94Depth_.reset(); +#endif } #endif settings_=s; @@ -871,11 +883,20 @@ class SonKuSpatialCore final { targetTailPresence #endif -smoothedTailPresence_); - float spatialL=smoothedDistanceGain_*ears[0]+ - smoothedErPresence_*reflection.left+ +#if defined(SONKU_P94_FRONT_BACK_DEPTH_RESEARCH) && SONKU_P94_FRONT_BACK_DEPTH_RESEARCH + // Private P9.4: no angle-dependent output gain, HRTF phase + // edits, artificial delay or changed orbit geometry. + const auto depthCue=p90World?p94Depth_.next():p94::FrontBackDepthCue::Gains{}; + const float calibratedDirect=depthCue.direct; + const float calibratedEarly=depthCue.early; +#else + constexpr float calibratedDirect=1.f,calibratedEarly=1.f; +#endif + float spatialL=smoothedDistanceGain_*calibratedDirect*ears[0]+ + smoothedErPresence_*calibratedEarly*reflection.left+ smoothedTailPresence_*late.left; - float spatialR=smoothedDistanceGain_*ears[1]+ - smoothedErPresence_*reflection.right+ + float spatialR=smoothedDistanceGain_*calibratedDirect*ears[1]+ + smoothedErPresence_*calibratedEarly*reflection.right+ smoothedTailPresence_*late.right; #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH if(p90World){ @@ -1149,6 +1170,10 @@ class SonKuSpatialCore final { if(p83Mode_==p83::Mode::MusicSpatialP90){ p90Decoder_.compose(centerTarget_,targets_[0],targets_[1]); p92Bass_.updateDirections(positions.leftHead,positions.rightHead); +#if defined(SONKU_P94_FRONT_BACK_DEPTH_RESEARCH) && SONKU_P94_FRONT_BACK_DEPTH_RESEARCH + p94Depth_.retarget(p83::toHead(static_cast(degrees_),p83HeadYaw_), + settings_.spacePreset!=0 && settings_.roomAmount>0.f); +#endif } else #endif @@ -1249,6 +1274,9 @@ class SonKuSpatialCore final { #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH p90::StereoDecoder p90Decoder_{}; p92::WorldBassFoundation p92Bass_{}; +#if defined(SONKU_P94_FRONT_BACK_DEPTH_RESEARCH) && SONKU_P94_FRONT_BACK_DEPTH_RESEARCH + p94::FrontBackDepthCue p94Depth_{}; +#endif #endif #if defined(SONKU_P87_MUSIC_BODY_RESEARCH) && SONKU_P87_MUSIC_BODY_RESEARCH p87::MusicalAirBody p87Body_{}; From b41be8a42e53236418543b8fca6f0b6182f67251 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 08:59:02 +0700 Subject: [PATCH 03/15] build(sonku): opt-in P9.4 front/back calibration default OFF and isolated native source CTest --- CMakeLists.txt | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d8491880c..85758767d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,13 @@ if(ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT AND NOT ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) message(FATAL_ERROR "P9.0 requires P8.9 research branch baseline") endif() +# Private P9.4 perceptual A/B: default OFF and never silently changes P9.1. +option(ARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH + "Private front/back HRTF/early reflection depth calibration experiment" OFF) +if(ARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH AND + NOT ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT) + message(FATAL_ERROR "P9.4 depth cue requires the P9 measured two-speaker engine") +endif() set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -312,7 +319,9 @@ target_compile_definitions(ARMixConsole PRIVATE $<$:ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT=1> $<$:SONKU_P89_DEPTH_COHERENCE_RESEARCH=1> $<$:ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT=1> - $<$:SONKU_P90_TRUE_EXTERNAL_RESEARCH=1>) + $<$:SONKU_P90_TRUE_EXTERNAL_RESEARCH=1> + $<$:SONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1> + $<$:ARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH=1>) if(WIN32) # Windows retains its proven ASIO-first / WASAPI / static WebView2 distribution. # Never link Windows loader or sound APIs into macOS/Linux builds. @@ -817,6 +826,18 @@ if(BUILD_TESTING) SONKU_P90_TRUE_EXTERNAL_RESEARCH=1) add_test(NAME NativeSonKuP91P92MusicFidelityWorldBassAndRoom COMMAND ARMixSonKuP91P92MusicBassTests) + if(ARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH) + add_executable(ARMixSonKuP94SourceTests + tests/sonku_p94_front_back_depth_source_test.cpp) + target_compile_features(ARMixSonKuP94SourceTests PRIVATE cxx_std_20) + # Reuse the proven exact P9.1/P9.2 native flag set. + # Do not duplicate a parallel DSP/test configuration. + target_compile_definitions(ARMixSonKuP94SourceTests PRIVATE + $ + SONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1) + add_test(NAME NativeSonKuP94FrontBackDepthA_BSource + COMMAND ARMixSonKuP94SourceTests) + endif() juce_add_console_app(ARMixSonKuP90NativeTests PRODUCT_NAME "ArSonMix SonKu P90 JUCE v11 State Tests") target_sources(ARMixSonKuP90NativeTests PRIVATE From 816cd95b9586e633962987b0ac7a7cdfe9b8de83 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 08:59:44 +0700 Subject: [PATCH 04/15] test(sonku): 44.1/48k real P9 front/rear DRR proxy, room OFF neutrality, anti-phase and block parity --- ...sonku_p94_front_back_depth_source_test.cpp | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 tests/sonku_p94_front_back_depth_source_test.cpp diff --git a/tests/sonku_p94_front_back_depth_source_test.cpp b/tests/sonku_p94_front_back_depth_source_test.cpp new file mode 100644 index 000000000..9358a55be --- /dev/null +++ b/tests/sonku_p94_front_back_depth_source_test.cpp @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Real P9.4 native source test; NO audio hardware or browser mocks. +#if defined(NDEBUG) +#undef NDEBUG +#endif +#if !defined(SONKU_P94_FRONT_BACK_DEPTH_RESEARCH) || !SONKU_P94_FRONT_BACK_DEPTH_RESEARCH +#error P9.4 source test must not silently run against P9.1-only DSP +#endif +#include "../engine/builtin_fx/sonku/SonKuSpatialCore.h" +#include "../engine/builtin_fx/sonku/SonKuP94FrontBackDepthCue.h" +#include +#include +#include +#include +#include +#include +using namespace armix::sonku; +using Stereo=std::array,2>; +static void depthWeights(int rate){ + p94::FrontBackDepthCue cue; + assert(cue.prepare(rate)); + auto settle=[&](float headAzimuth,bool enabled){ + cue.retarget(headAzimuth,enabled); + p94::FrontBackDepthCue::Gains g{}; + for(int i=0;i.950f&&front.direct<.957f); + assert(front.early>1.275f&&front.early<1.281f); + const double shift=20.*std::log10(front.direct/front.early); + assert(shift< -2.45 && shift> -2.7); + const auto right=settle(90.f,true); + assert(right.direct==1.f&&right.early==1.f); + const auto rear=settle(180.f,true); + assert(std::abs(rear.direct-front.direct)<.0001f); + assert(std::abs(rear.early-front.early)<.0001f); + const auto left=settle(-90.f,true); + assert(left.direct==1.f&&left.early==1.f); + const auto disabled=settle(0.f,false); + assert(disabled.direct==1.f&&disabled.early==1.f); + for(int i=0;i<360;i++){ + cue.retarget(float(i),true); + const auto g=cue.next(); + assert(std::isfinite(g.direct)&&std::isfinite(g.early)); + assert(g.direct>=.9549f&&g.direct<=1.f); + assert(g.early>=1.f&&g.early<=1.2801f); + } + // The model is relative to head direction, never rotated with the GUI + // ellipse. An observer turning +90 maps world FRONT to head LEFT. + const auto turned=settle(-90.f,true); + assert(turned.direct==1.f&&turned.early==1.f); + std::printf("P94_WEIGHT,%d,front_direct=%.6f,front_er=%.6f,DRR_shift_dB=%.3f\n", + rate,front.direct,front.early,shift); +} +static Stereo run(int rate,float azimuth,bool room,int frames,int block,bool anti){ + auto core=std::make_unique(); + assert(core->prepare(rate,SonKuReflectionProfile::SixSurfaceKemarResearch)); + Settings s{}; + s.renderMode=9; + s.moving=false; + s.startAzimuthDegrees=azimuth; + s.stereoSpreadDegrees=82.f; + s.outputTrim=1.f; + s.spatialMix=1.f; + s.sourceDistanceMeters=1.6f; + s.spacePreset=room?3:0; + s.roomAmount=room?.78f:0.f; + s.ambience=room?.33f:0.f; + assert(valid(s)&&core->setSettings(s)); + Stereo a{std::vector(frames),std::vector(frames)}; + constexpr float pi=3.14159265358979323846f; + for(int i=0;iprocess(a[0].data()+i,a[1].data()+i,std::min(block,frames-i)); + for(int ear=0;ear<2;++ear)for(float v:a[ear]) + assert(std::isfinite(v)&&std::abs(v)<.981f); + return a; +} +static double rms(const Stereo& a,int trim){ + double sum=0.; + for(int c=0;c<2;++c)for(int i=trim;i cardinal{0.f,90.f,180.f,270.f}; + for(float angle:cardinal){ + const auto ref=run(rate,angle,true,rate,64,false); + const auto block=run(rate,angle,true,rate,256,false); + assert(difference(ref,block)==0. && "Audio output depends on host block size"); + const auto dry=run(rate,angle,false,rate,64,false); + assert(rms(ref,rate/4)>.015 && rms(dry,rate/4)>.015); + // No static front/back input stereo collapse in the full path. + const auto anti=run(rate,angle,true,rate/2,128,true); + assert(rms(anti,rate/10)>.0001); + std::printf("P94_PCM,%d,az=%g,room_rms=%.6f,off_rms=%.6f\n", + rate,double(angle),rms(ref,rate/4),rms(dry,rate/4)); + } + } + std::puts("PASS P94 front/back cue: no geometry change, 2.54dB DRR proxy, room OFF neutral, 44.1/48k PCM, 64/256 exact parity, phase and peak guard"); +} From bd403a362412e134a33ae97711d52837667a5de0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 09:00:40 +0700 Subject: [PATCH 05/15] feat(sonku): native v11 readback advertises optional P9.4 front/rear depth calibration honestly --- src/Main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Main.cpp b/src/Main.cpp index b2fec3726..b12156bc1 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -3126,6 +3126,11 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr // This capability is emitted only by the new reconciled DSP build. // Older v11 P9.0 binaries must NOT be advertised as P9.1+P9.2. reply->setProperty("p91p92MusicBassFoundation",true); +#if defined(ARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH) && ARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH + // Branch-only measured-engine A/B. A previous v11 binary cannot + // advertise this front/rear perceptual depth research capability. + reply->setProperty("p94FrontBackDepthCue",true); +#endif } #elif defined(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT if(processor && processor->preparedReflectionProfile()== From e6b47c635c4e098758140092b3f3f61bc99d8d3e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 09:01:09 +0700 Subject: [PATCH 06/15] ui(sonku): capability-gated P9.4 experimental label with P9.1/P9.2 fallback and unchanged perspective ellipse --- site/preview-v2/assets/mixer-native-sonku.js | 27 +++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/site/preview-v2/assets/mixer-native-sonku.js b/site/preview-v2/assets/mixer-native-sonku.js index 1b5ada41b..03d1f8042 100644 --- a/site/preview-v2/assets/mixer-native-sonku.js +++ b/site/preview-v2/assets/mixer-native-sonku.js @@ -229,7 +229,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,p84Capable=false,p85Capable=false,p86Capable=false,p87Capable=false,p88Capable=false,p89Capable=false,p90Capable=false,p91p92Capable=false,musicSafeStereo=false,p8TransparentBass=false,p82MultibandRoom=false, + xyzCapable=false,p83Capable=false,p84Capable=false,p85Capable=false,p86Capable=false,p87Capable=false,p88Capable=false,p89Capable=false,p90Capable=false,p91p92Capable=false,p94Capable=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; @@ -286,7 +286,7 @@ function render(){ const row=$("skRenderRow");row.hidden=!(p83Capable||p84Capable); if(p83Capable||p84Capable){ const picker=$("skRenderMode"); - if(p90Capable && picker.dataset.nativeModeSet!==(p91p92Capable?"p91p92":"p90")){ + if(p90Capable && picker.dataset.nativeModeSet!==(p94Capable?"p94":p91p92Capable?"p91p92":"p90")){ picker.innerHTML=''+ ''+ ''+ @@ -294,11 +294,14 @@ function render(){ ''+ ''+ ''+ - (p91p92Capable? + (p94Capable? + '': + p91p92Capable? '': ''); - picker.dataset.nativeModeSet=p91p92Capable?"p91p92":"p90"; - root.querySelector(".sk-render-label").textContent=p91p92Capable? + picker.dataset.nativeModeSet=p94Capable?"p94":p91p92Capable?"p91p92":"p90"; + root.querySelector(".sk-render-label").textContent=p94Capable? + "RENDER MODE · P9.4 EXPERIMENT":p91p92Capable? "RENDER MODE · P9.1 + P9.2 FAT":"RENDER MODE · P9.0 HEADPHONE FAT"; }else if(!p90Capable && p89Capable && picker.dataset.nativeModeSet!=="p89"){ picker.innerHTML=''+ @@ -419,7 +422,9 @@ function render(){ if(!rangeEdits.has("skHrtfAlign"))align.value=String(s.hrtfElevationTrimDegrees); $("skHrtfAlignValue").textContent=(s.hrtfElevationTrimDegrees>=0?"+":"")+s.hrtfElevationTrimDegrees.toFixed(1)+"°"; } - root.querySelector(".sk-stage-caption").textContent=p91p92Capable&&s.renderMode===9? + root.querySelector(".sk-stage-caption").textContent=p94Capable&&s.renderMode===9? + "P9.4 · FRONT/REAR ROOM DEPTH · SAME 3D MOTION · HEADPHONE FAT REQUIRED": + p91p92Capable&&s.renderMode===9? "P9.1 + P9.2 · MUSIC FIDELITY · WORLD BASS · ROOM MODES · FAT REQUIRED": p90Capable&&s.renderMode===9? "P9.0 · MEASURED TWIN-SPEAKER HRIR · HEADPHONE FAT REQUIRED": @@ -466,7 +471,8 @@ function render(){ // redrawn at 60 Hz. The native audio callback remains the time authority. drawSpeakers(); $("skMode").textContent=native()?(context()? - (p91p92Capable&&s.renderMode===9?"NATIVE P9.1+P9.2 WORLD BASS · FAT": + (p94Capable&&s.renderMode===9?"NATIVE P9.4 FRONT/REAR DEPTH · A/B FAT": + p91p92Capable&&s.renderMode===9?"NATIVE P9.1+P9.2 WORLD BASS · FAT": p90Capable&&s.renderMode===9?"NATIVE P9.0 TRUE EXTERNAL · TEST": p89Capable&&s.renderMode===8?"NATIVE P8.9 STEREO + ROOM · TEST": p88Capable&&s.renderMode===7?"NATIVE P8.8 EAR ALIGN + DISTANCE · TEST": @@ -635,6 +641,9 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ Number.isFinite(incoming.hrtfElevationTrimDegrees); // Separate from schema v11: old P9.0 DSP must not receive the P9.1/9.2 label. p91p92Capable=p90Capable && r.p91p92MusicBassFoundation===true; + // Independent of schema version: only this exact measured native DSP + // can claim the *experimental* depth calibration, not P9.1 baseline. + p94Capable=p91p92Capable && r.p94FrontBackDepthCue===true; p89Capable=(r.schemaVersion===10||p90Capable) && r.p89StereoRoomDepth===true && Number.isFinite(incoming.hrtfElevationTrimDegrees); p88Capable=(r.schemaVersion===9||p89Capable) && r.p88PerceptualAlignment===true && @@ -740,7 +749,7 @@ $("skPreset").addEventListener("change",()=>{ musicCompatibleLowFrequency:false}); if(!send(scene))render(); }); -$("skClose").addEventListener("click",()=>{root.hidden=true;current=null;xyzCapable=false;p85Capable=false;p86Capable=false;p87Capable=false;p88Capable=false;p89Capable=false;p90Capable=false;p91p92Capable=false;musicSafeStereo=false;p8TransparentBass=false;p82MultibandRoom=false; +$("skClose").addEventListener("click",()=>{root.hidden=true;current=null;xyzCapable=false;p85Capable=false;p86Capable=false;p87Capable=false;p88Capable=false;p89Capable=false;p90Capable=false;p91p92Capable=false;p94Capable=false;musicSafeStereo=false;p8TransparentBass=false;p82MultibandRoom=false; cancelLiveTimer();pending=null;latest=null;readId="";readSentAt=0;dialDrag=null; drag=null;windowGesture=null;rangeEdits.clear();gestureStart.clear();lastLiveAt=0; if(clock!==null){clearInterval(clock);clock=null;} @@ -939,7 +948,7 @@ const api={ drag=null;rangeEdits.clear();gestureStart.clear(); accepted=defaults();draft=defaults();xyzCapable=false; p83Capable=p84Capable=p85Capable=p86Capable=p87Capable=p88Capable= - p89Capable=p90Capable=p91p92Capable=false; + p89Capable=p90Capable=p91p92Capable=p94Capable=false; musicSafeStereo=p8TransparentBass=p82MultibandRoom=false; current={track,slot,instanceId:null}; const s=snapshot(),id=window.__ARMIX_NATIVE_M2__?.nativeIdFor?.(track); From 33c30456f6755fbcaaf0bef819f63a3dfa2cb929 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 09:02:03 +0700 Subject: [PATCH 07/15] test(sonku): P9.4 native flag truth, stable 40-readback dropdown, P9.1 fallback and legacy guards --- tests/sonku_p90_dropdown_stability_test.cjs | 22 ++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/sonku_p90_dropdown_stability_test.cjs b/tests/sonku_p90_dropdown_stability_test.cjs index b583c0686..e9ae4c859 100644 --- a/tests/sonku_p90_dropdown_stability_test.cjs +++ b/tests/sonku_p90_dropdown_stability_test.cjs @@ -7,13 +7,13 @@ const assert=require("node:assert/strict"); const fs=require("node:fs"); const vm=require("node:vm"); const source=fs.readFileSync("site/preview-v2/assets/mixer-native-sonku.js","utf8"); -const start=source.indexOf(' if(p90Capable && picker.dataset.nativeModeSet!==(p91p92Capable?"p91p92":"p90")){'); +const start=source.indexOf(' if(p90Capable && picker.dataset.nativeModeSet!==(p94Capable?"p94":p91p92Capable?"p91p92":"p90")){'); const end=source.indexOf(" const v=p90Capable?",start); assert(start!==-1&&end>start,"Locate actual native SonKu mode menu reconciliation"); const actualReconcile=source.slice(start,end); const renderMenu=vm.runInNewContext( '(function(picker,root,cap){ const {'+ - 'p90Capable,p91p92Capable,p89Capable,p88Capable,p87Capable,p86Capable,'+ + 'p90Capable,p91p92Capable,p94Capable,p89Capable,p88Capable,p87Capable,p86Capable,'+ 'p85Capable,p84Capable,p83Capable}=cap;\n'+ actualReconcile+'\n})',{} ); @@ -45,7 +45,7 @@ const label={textContent:""}; const root={querySelector(selector){ assert.equal(selector,".sk-render-label");return label; }}; -const full={p90Capable:true,p91p92Capable:true,p89Capable:true,p88Capable:true, +const full={p90Capable:true,p91p92Capable:true,p94Capable:false,p89Capable:true,p88Capable:true, p87Capable:true,p86Capable:true,p85Capable:true,p84Capable:true, p83Capable:false}; renderMenu(picker,root,full); @@ -102,4 +102,20 @@ assert.match(nativeSource,/reply->setProperty\("p91p92MusicBassFoundation",true\ assert.match(source,/p91p92Capable=p90Capable && r\.p91p92MusicBassFoundation===true;/); assert.match(source,/p91p92Capable&&s\.renderMode===9/); assert.match(source,/NATIVE P9\.1\+P9\.2 WORLD BASS/); +assert.match(nativeSource,/reply->setProperty\("p94FrontBackDepthCue",true\)/); +assert.match(source,/p94Capable=p91p92Capable && r\.p94FrontBackDepthCue===true;/); +const p94={...full,p94Capable:true}; +renderMenu(picker,root,p94); +assert.equal(picker.dataset.nativeModeSet,"p94"); +assert.equal(optionWrites.length,6); +assert.match(picker.innerHTML,/P9\.4 · FRONT\/REAR DEPTH/); +assert.match(label.textContent,/P9\.4 EXPERIMENT/); +picker.isOpen=true; +for(let i=0;i<40;++i){renderMenu(picker,root,p94);syncSelection(picker,"external");} +picker.isOpen=false; +assert.equal(optionWrites.length,6,"P9.4 must not flicker in native readback"); +renderMenu(picker,root,full); +assert.equal(picker.dataset.nativeModeSet,"p91p92"); +assert.equal(optionWrites.length,7); +assert.doesNotMatch(picker.innerHTML,/P9\.4/); console.log("PASS P91P92 dropdown: native capability-gated milestone, stable 40 readbacks, P9.0 fallback, correct one-time transitions"); From 47fc43dffadea196b8cdf427b3584d45b6356ef4 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 09:02:39 +0700 Subject: [PATCH 08/15] test(sonku): let 45ms smoothing reach exact neutral target before bit-exact lateral assertion --- tests/sonku_p94_front_back_depth_source_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sonku_p94_front_back_depth_source_test.cpp b/tests/sonku_p94_front_back_depth_source_test.cpp index 9358a55be..e6fffb48a 100644 --- a/tests/sonku_p94_front_back_depth_source_test.cpp +++ b/tests/sonku_p94_front_back_depth_source_test.cpp @@ -22,7 +22,7 @@ static void depthWeights(int rate){ auto settle=[&](float headAzimuth,bool enabled){ cue.retarget(headAzimuth,enabled); p94::FrontBackDepthCue::Gains g{}; - for(int i=0;i Date: Mon, 16 Nov 2026 09:03:38 +0700 Subject: [PATCH 09/15] docs(sonku): preserve approved 3D ellipse and define measurable front/rear externalization A/B rejection criteria --- ...FRONT_REAR_EXTERNALIZATION_FAT_20261116.md | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/SONKU_P94_FRONT_REAR_EXTERNALIZATION_FAT_20261116.md diff --git a/docs/SONKU_P94_FRONT_REAR_EXTERNALIZATION_FAT_20261116.md b/docs/SONKU_P94_FRONT_REAR_EXTERNALIZATION_FAT_20261116.md new file mode 100644 index 000000000..d0f7d7ded --- /dev/null +++ b/docs/SONKU_P94_FRONT_REAR_EXTERNALIZATION_FAT_20261116.md @@ -0,0 +1,43 @@ +# SonKu P9.4 — Front/Rear Externalization A/B (2026-11-16) + +**STATUS: PRIVATE HEADPHONE FAT CANDIDATE / DRAFT, NOT ACOUSTICALLY VERIFIED.** + +## Baselines / preservation +- Production main: `37985f02caecd93b22f853183888d81e18dc6736`. +- Operator-confirmed P9.1/P9.2: `763706a15a2617a10d23b5e2e43eb5689e454ccb`, frozen at `checkpoint/sonku-p91-p92-operator-confirmed-20261116`, issue #720. +- P9.3 GUI: draft PR #721; original perspective **ellipse** (148×83 SVG) is the APPROVED 3D oblique view of a circular 360° audio orbit. It is not the fault. Its movable modeless window, accepted FX Power, preset scenes and SPACE layout are inherited without changes. +- P9.4 starts from PR #721 head and adds *only* an explicitly opt-in spatial-depth experiment to the actual P9 native renderer. No upstream PR/main/checkpoint source is changed. + +## What the listener actually reported +At equal physical source radius and continuous 360° orbit, front (0°) and rear (180°) are perceived too close to the listener while ±90° lateral positions feel farther away. A person perceives a *flattened acoustic orbit*, **not a faulty UI ellipse**. + +The P9.1 renderer already uses a world-anchored two-speaker KEMAR 2×2 measured-HRIR field and LF foundation. It centres correlated stereo content at the actual median-plane HRIR. With a non-individualized HRTF, front/back spectral cues and distance externalization can be weak despite geometrically correct source angles. Older P9 direct/ER/tail levels have no head-relative angular externalization compensation. This is a perceptual limitation to investigate, not proof the DSP position calculation is elliptical. + +## P9.4 A/B hypothesis and code contract +Research in binaural externalization relates localization to HRTF pinna fine structure, listener/head rotation, individualized headphone calibration, binaural reflections and direct-to-reverberant ratio (DRR); increasing diffuse reverb alone is not proven to fix it. A published 2026 frontal-source study also discusses direct and reflection level adjustment in generic BRIRs. Such research motivates a **bounded test**, not any claim of dearVR parity. + +`SonKuP94FrontBackDepthCue.h` is a fixed-size, 45ms-slewed median-plane angular weighting computed on the existing 16-sample HRTF retarget cadence. It uses a 361-entry table prepared once, no allocation, locks, timers, FFT, or trigonometry in the per-sample audio callback. + +- Head-relative centre azimuth: `p83::toHead(worldCenter, yaw)`. Never use SVG pixel coordinates or pretend the speaker moved closer. +- Weight: `cos^4(theta)`: 1 at 0° and 180°, 0 at ±90°; smooth and periodic at the wrap. +- For P9 only and if room + early reflection wet are ON: multiply the **already measured HRTF direct pressure** by `1-0.045*w` (max −0.40 dB), and its **directional early reflections** by `1+0.28*w` (max +2.14 dB). Late reverb, bass room modes, KEMAR spectral coefficients, ITD, ILD, source distance, orbit phase, output gain and stereo MID/SIDE graph are unchanged. The front/rear direct/early pressure-ratio proxy changes by at most about −2.54 dB. The ROOM OFF / ER=0 return is exactly neutral. This is **not** a measured personalized BRIR, not a cabinet resonance model and not a substitute for head tracking. +- The feature is compiled only with `-DARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH=ON` and P9 already enabled. Default builds OFF, compile-time guard rejects P9.4 without P9. +- No state schema/ABI change: `renderMode=9` remains authoritative, but native readback `p94FrontBackDepthCue=true` specifically identifies this experimental build. UI label `P9.4 · FRONT/REAR DEPTH (A/B)` appears only for that genuine capability. P9.1-only builds still say P9.1+P9.2. + +## Automated acceptance & safety boundaries +- Test real source PCM at 44.1/48 kHz, static 0/90/180/270 with ROOM ON/OFF, mono-like stereo and strict anti-phase, 64 vs 256-frame bit-parity, finite output + existing 0.98 linked peak guard. +- Isolate the curve itself: equal front/rear gains, lateral exactly neutral once smoothed, bounded ratio correction, head-yaw turns world FRONT into head SIDE, wrap continuity. Re-run existing P9.1/P9.2 PCM, P9.0 coherence, P8.9, GUI dropdown and Chromium tests. +- Exact source build of Windows native mixer + CTest and portable artifact must PASS before operator FAT. Keep draft, do not merge to main. + +## Mandatory headphone FAT / rejection conditions +- Compare ***original checkpoint P9.1+P9.2***, PR #721 GUI-only and P9.4 at matching integrated loudness (±0.5 LU) on the SAME device/headphones. Play actual music: kick, bass guitar, low-level room content, vocals, percussive transients, and 30–180Hz anti-phase material. +- Orbit static stepped 0, ±45, ±90, ±135, 180; then continuous slow 6–12s with head yaw 0/90/180 and fixed 1.6/3.1m source distance. Record perceived distance (front/right/back/left), front-back reversals, tonal degradation, and whether room returns become echoes/boom. +- Inspect measured signal energy and short-time binaural interaural coherence per direction, direct/ER cross-correlation, potential transient smearing, limiter gain reduction, and true loudness against raw music. +- **Reject P9.4** if user perceives no appreciable improvement, music becomes more reverberant/distant but not externalized, integrated level moves >0.5 LU without intentional user gain, or bass/treble/phase and ASIO stability regress. Retain accepted checkpoint. Real HRTF personalization/head tracking/BRIR options remain future work. + +## References / cautions +- Sound Externalization: A Review of Recent Research. https://pmc.ncbi.nlm.nih.gov/articles/PMC7488874/ +- Auditory localization: a comprehensive practical review. https://pmc.ncbi.nlm.nih.gov/articles/PMC11267622/ +- Enhancing Externalization of Frontal Virtual Sound Sources in Binaural Synthesis via Level and Reflection Adjustment of Non-individualized BRIRs (2026). https://doi.org/10.1177/23312165261468752 + +No claims that these articles establish the optimal numeric .045/.28 values: those are **research calibration candidates** requiring controlled audio comparison. From 5f43cda9e165e25b1ba5807ea7e49d4754f82f2f Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 09:04:46 +0700 Subject: [PATCH 10/15] ci(sonku): opt-in P9.4 native source and Windows JUCE/6-CTest FAT with accurate provenance --- .github/workflows/p1-windows.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 15b89f70c..9e6365f8e 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -660,7 +660,7 @@ jobs: sonku-p90-source: # Runs only on the P9 research PR, even while its production jobs skip. name: SonKu P9 exact-source C++ PCM preflight - if: ${{ github.event_name == 'pull_request' && (startsWith(github.event.pull_request.head.ref, 'research/sonku-p90-') || (startsWith(github.event.pull_request.head.ref, 'research/sonku-p91-p92-') || startsWith(github.event.pull_request.head.ref, 'feat/sonku-p93-'))) }} + if: ${{ github.event_name == 'pull_request' && (startsWith(github.event.pull_request.head.ref, 'research/sonku-p90-') || (startsWith(github.event.pull_request.head.ref, 'research/sonku-p91-p92-') || (startsWith(github.event.pull_request.head.ref, 'feat/sonku-p93-') || startsWith(github.event.pull_request.head.ref, 'research/sonku-p94-')))) }} runs-on: ubuntu-latest timeout-minutes: 10 steps: @@ -680,6 +680,8 @@ jobs: /tmp/sonku-p90 g++ $FLAGS tests/sonku_p91_p92_music_bass_foundation_test.cpp -o /tmp/sonku-p91p92 /tmp/sonku-p91p92 + g++ $FLAGS -DSONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1 tests/sonku_p94_front_back_depth_source_test.cpp -o /tmp/sonku-p94 + /tmp/sonku-p94 g++ $FLAGS tests/sonku_p89_stereo_room_depth_source_test.cpp -o /tmp/sonku-p89 /tmp/sonku-p89 echo "SONKU_P90_NATIVE_SOURCE_CTEST_PASSED" @@ -687,7 +689,7 @@ jobs: sonku-p90-windows-fat: name: SonKu P9 actual JUCE / GUI portable x64 needs: sonku-p90-source - if: ${{ github.event_name == 'pull_request' && (startsWith(github.event.pull_request.head.ref, 'research/sonku-p90-') || (startsWith(github.event.pull_request.head.ref, 'research/sonku-p91-p92-') || startsWith(github.event.pull_request.head.ref, 'feat/sonku-p93-'))) }} + if: ${{ github.event_name == 'pull_request' && (startsWith(github.event.pull_request.head.ref, 'research/sonku-p90-') || (startsWith(github.event.pull_request.head.ref, 'research/sonku-p91-p92-') || (startsWith(github.event.pull_request.head.ref, 'feat/sonku-p93-') || startsWith(github.event.pull_request.head.ref, 'research/sonku-p94-')))) }} runs-on: windows-2022 timeout-minutes: 55 steps: @@ -724,21 +726,25 @@ jobs: -DARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT=ON ` -DARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT=ON ` -DARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH=ON ` -DBUILD_TESTING=ON if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } $cache = Get-Content build/CMakeCache.txt -Raw if ($cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT:BOOL=ON') { throw 'SONKU_P90_WRONG_NATIVE_CONFIGURATION' } + if ($cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH:BOOL=ON') { + throw 'SONKU_P94_WRONG_NATIVE_CONFIGURATION' + } - name: Build real native JUCE PCM, state ACK, and Windows GUI shell: pwsh run: | - cmake --build build --config Release --parallel 2 --target ARMixSonKuP91P92MusicBassTests ARMixSonKuP90NativeTests ARMixSonKuP90SourceTests ARMixSonKuP89NativeTests ARMixSonKuP89SourceTests ARMixConsole + cmake --build build --config Release --parallel 2 --target ARMixSonKuP94SourceTests ARMixSonKuP91P92MusicBassTests ARMixSonKuP90NativeTests ARMixSonKuP90SourceTests ARMixSonKuP89NativeTests ARMixSonKuP89SourceTests ARMixConsole if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } if (-not (Test-Path -LiteralPath 'build/ARMixConsole_artefacts/Release/AR MIX Studio.exe' -PathType Leaf)) { throw 'SONKU_P90_NATIVE_GUI_EXE_MISSING' } - ctest --test-dir build -C Release --output-on-failure -R '^NativeSonKuP(89RoomAnchoredStereoAndP88GoldenParity|89JuceV10AppliedAckAndV9Restore|90StereoExternalizationSource|90JuceV11AppliedAckAndLegacyRestore|91P92MusicFidelityWorldBassAndRoom)$' + ctest --test-dir build -C Release --output-on-failure -R '^NativeSonKuP(89RoomAnchoredStereoAndP88GoldenParity|89JuceV10AppliedAckAndV9Restore|90StereoExternalizationSource|90JuceV11AppliedAckAndLegacyRestore|91P92MusicFidelityWorldBassAndRoom|94FrontBackDepthA_BSource)$' if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - name: Verified portable package, no installer or release shell: pwsh @@ -752,12 +758,13 @@ jobs: Copy-Item docs/THIRD_PARTY_8D_SONKU_HRTF.md dist/THIRD_PARTY_8D_SONKU_HRTF.md Copy-Item docs/SONKU_P90_TRUE_EXTERNAL_SPEAKER_FAT_20261115.md dist/SONKU_P90_FIELD_FAT.md Copy-Item docs/SONKU_P91_P92_RECONCILED_MUSIC_FIDELITY_BASS_FAT_20261116.md dist/SONKU_P91_P92_FIELD_FAT.md + Copy-Item docs/SONKU_P94_FRONT_REAR_EXTERNALIZATION_FAT_20261116.md dist/SONKU_P94_FRONT_REAR_FAT.md $provenance = Get-Content -LiteralPath dist/BUILD_PROVENANCE.json -Raw | ConvertFrom-Json if ($provenance.sourceCommit -ne (git rev-parse HEAD).Trim()) { throw 'SONKU_P90_SOURCE_COMMIT_MISMATCH' } $provenance | Add-Member -Force -NotePropertyName sonkuExperiment -NotePropertyValue @{ - mode = 'P9.1_P9.2_MUSIC_FIDELITY_PHYSICAL_BASS' + mode = 'P9.4_FRONT_REAR_DEPTH_EXPERIMENT' stateSchema = 11 headphoneFat = 'PENDING' publicRelease = $false @@ -767,7 +774,7 @@ jobs: $provenance | ConvertTo-Json -Depth 20 | Set-Content dist/BUILD_PROVENANCE.json -Encoding utf8 - uses: actions/upload-artifact@v4 with: - name: ArSonMix-SonKu-P90-Windows-x64-${{ github.run_id }} + name: ArSonMix-SonKu-P94-FrontRear-Research-Windows-x64-${{ github.run_id }} path: dist/ if-no-files-found: error retention-days: 21 From 936c5cdc7a3fdf19fcd1b8f29cc086e64e892dc0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 09:06:17 +0700 Subject: [PATCH 11/15] test(sonku): align P9.4 menu fixture with actual render selection before opening popup --- tests/sonku_p90_dropdown_stability_test.cjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/sonku_p90_dropdown_stability_test.cjs b/tests/sonku_p90_dropdown_stability_test.cjs index e9ae4c859..880f40e4d 100644 --- a/tests/sonku_p90_dropdown_stability_test.cjs +++ b/tests/sonku_p90_dropdown_stability_test.cjs @@ -110,6 +110,8 @@ assert.equal(picker.dataset.nativeModeSet,"p94"); assert.equal(optionWrites.length,6); assert.match(picker.innerHTML,/P9\.4 · FRONT\/REAR DEPTH/); assert.match(label.textContent,/P9\.4 EXPERIMENT/); +// The real render() immediately sets the accepted native mode after rebuilding. +syncSelection(picker,"external"); picker.isOpen=true; for(let i=0;i<40;++i){renderMenu(picker,root,p94);syncSelection(picker,"external");} picker.isOpen=false; From e47dc9579b4e1f843e300f37b2a086b6b7de45af Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 09:08:30 +0700 Subject: [PATCH 12/15] test(sonku): compile identical P9 native stimulus as baseline and experimental binaries --- tests/sonku_p94_front_back_depth_source_test.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/sonku_p94_front_back_depth_source_test.cpp b/tests/sonku_p94_front_back_depth_source_test.cpp index e6fffb48a..4022faad0 100644 --- a/tests/sonku_p94_front_back_depth_source_test.cpp +++ b/tests/sonku_p94_front_back_depth_source_test.cpp @@ -3,8 +3,13 @@ #if defined(NDEBUG) #undef NDEBUG #endif -#if !defined(SONKU_P94_FRONT_BACK_DEPTH_RESEARCH) || !SONKU_P94_FRONT_BACK_DEPTH_RESEARCH -#error P9.4 source test must not silently run against P9.1-only DSP +// Compile this SAME native PCM test twice: unchanged P9.1/P9.2 reference +// versus P9.4 opt-in. A separate comparator checks exact lateral/ROOM-OFF +// identity and bounded frontal/rear level shifts, not just test self-parity. +#if defined(SONKU_P94_FRONT_BACK_DEPTH_RESEARCH) && SONKU_P94_FRONT_BACK_DEPTH_RESEARCH +#define SONKU_P94_TEST_ACTIVE 1 +#else +#define SONKU_P94_TEST_ACTIVE 0 #endif #include "../engine/builtin_fx/sonku/SonKuSpatialCore.h" #include "../engine/builtin_fx/sonku/SonKuP94FrontBackDepthCue.h" @@ -116,5 +121,5 @@ int main(){ rate,double(angle),rms(ref,rate/4),rms(dry,rate/4)); } } - std::puts("PASS P94 front/back cue: no geometry change, 2.54dB DRR proxy, room OFF neutral, 44.1/48k PCM, 64/256 exact parity, phase and peak guard"); + std::puts("PASS P94 reference/candidate native source, optional cue: no geometry change, 2.54dB DRR proxy, room OFF neutral, 44.1/48k PCM, 64/256 exact parity, phase and peak guard"); } From 10f548093d168b25885aedf99632a2bfacb93fd3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 09:09:15 +0700 Subject: [PATCH 13/15] test(sonku): compare actual P9.1 vs P9.4 PCM RMS at 0/90/180/270, enforce level and lateral parity --- scripts/verify_sonku_p94_acoustic_levels.py | 71 +++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 scripts/verify_sonku_p94_acoustic_levels.py diff --git a/scripts/verify_sonku_p94_acoustic_levels.py b/scripts/verify_sonku_p94_acoustic_levels.py new file mode 100644 index 000000000..1635dba8d --- /dev/null +++ b/scripts/verify_sonku_p94_acoustic_levels.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +"""P9.4 head-relative depth cue: compare actual native reference and candidate PCM. + +Inputs: two C++ executables generated from the SAME source, baseline P9.1+P9.2 +(default macro OFF), research P9.4 ON. No golden files or mock DSP. +""" +import math +import re +import subprocess +import sys + +ROW = re.compile( + r"^P94_PCM,(44100|48000),az=(0|90|180|270)," + r"room_rms=([0-9]+\.[0-9]+),off_rms=([0-9]+\.[0-9]+)$" +) + +def run(executable): + done = subprocess.run([executable], capture_output=True, + text=True, check=True, timeout=90) + result = {} + for line in done.stdout.splitlines(): + match = ROW.fullmatch(line.strip()) + if not match: + continue + rate, angle, wet, dry = match.groups() + key = int(rate), int(angle) + if key in result: + raise AssertionError(f"duplicate PCM metric {key}") + result[key] = float(wet), float(dry) + if len(result) != 8: + raise AssertionError(f"expected eight PCM rows from {executable}, " + f"found {len(result)}\n{done.stdout[-2500:]}") + return result + +def db_ratio(candidate, baseline): + if candidate <= 0 or baseline <= 0: + raise AssertionError("silent or invalid PCM") + return 20 * math.log10(candidate / baseline) + +def main(): + if len(sys.argv) != 3: + raise SystemExit("usage: verify_sonku_p94_acoustic_levels.py " + " ") + base = run(sys.argv[1]) + experiment = run(sys.argv[2]) + for key in sorted(base): + rate, angle = key + (before, before_off) = base[key] + (after, after_off) = experiment[key] + shift = db_ratio(after, before) + dry_shift = db_ratio(after_off, before_off) + # ROOM=OFF must be precisely identical: P9.4 cannot create new sound + # or change the accepted HRTF-only signal in its absence. + if before_off != after_off: + raise AssertionError(f"ROOM OFF changed {key}: {before_off} -> {after_off}") + # At ±90° it must be audio-transparent, not a disguised global boost. + if angle in (90, 270) and before != after: + raise AssertionError(f"lateral reference changed {key}: {shift:.4f} dB") + # A/B normalized reference levels are an ELECTRICAL/RMS guard, + # not music LUFS or headphone SPL. Reject >0.5dB direct+wet deviation. + if abs(shift) > 0.5: + raise AssertionError(f"unbalanced P9.4 {key}: {shift:.3f}dB") + if abs(dry_shift) > 0.001: + raise AssertionError(f"unexpected dry-level drift at {key}") + print(f"P94_MATCH,rate={rate},angle={angle}," + f"delta_room_db={shift:.4f},delta_dry_db={dry_shift:.4f}") + print("PASS P94 real native A/B: 8 angles/rates, ROOM OFF exact, " + "lateral PCM exactly unchanged, median-plane ±0.5dB level guard") + +if __name__ == "__main__": + main() From f55e4358d219bb4fb5078230ca18f032d83dba68 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 09:09:42 +0700 Subject: [PATCH 14/15] test(sonku): two native P9 binaries + automated same-source level-matched CTest reference/candidate --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85758767d..9340baf61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -827,6 +827,11 @@ if(BUILD_TESTING) add_test(NAME NativeSonKuP91P92MusicFidelityWorldBassAndRoom COMMAND ARMixSonKuP91P92MusicBassTests) if(ARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH) + add_executable(ARMixSonKuP94ReferenceTests + tests/sonku_p94_front_back_depth_source_test.cpp) + target_compile_features(ARMixSonKuP94ReferenceTests PRIVATE cxx_std_20) + target_compile_definitions(ARMixSonKuP94ReferenceTests PRIVATE + $) add_executable(ARMixSonKuP94SourceTests tests/sonku_p94_front_back_depth_source_test.cpp) target_compile_features(ARMixSonKuP94SourceTests PRIVATE cxx_std_20) @@ -837,6 +842,11 @@ if(BUILD_TESTING) SONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1) add_test(NAME NativeSonKuP94FrontBackDepthA_BSource COMMAND ARMixSonKuP94SourceTests) + add_test(NAME NativeSonKuP94LevelMatchedAB + COMMAND "${Python3_EXECUTABLE}" + "${CMAKE_SOURCE_DIR}/scripts/verify_sonku_p94_acoustic_levels.py" + "$" + "$") endif() juce_add_console_app(ARMixSonKuP90NativeTests PRODUCT_NAME "ArSonMix SonKu P90 JUCE v11 State Tests") From 766b8d722ac18354e5c8e6eaa4e81f40ba42bcc8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Mon, 16 Nov 2026 09:10:00 +0700 Subject: [PATCH 15/15] ci(sonku): compare P9.4 opt-in against golden P9.1 same-source PCM on Linux and Windows --- .github/workflows/p1-windows.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 9e6365f8e..8ff1428ba 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -680,8 +680,10 @@ jobs: /tmp/sonku-p90 g++ $FLAGS tests/sonku_p91_p92_music_bass_foundation_test.cpp -o /tmp/sonku-p91p92 /tmp/sonku-p91p92 + g++ $FLAGS tests/sonku_p94_front_back_depth_source_test.cpp -o /tmp/sonku-p94-reference g++ $FLAGS -DSONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1 tests/sonku_p94_front_back_depth_source_test.cpp -o /tmp/sonku-p94 /tmp/sonku-p94 + python3 scripts/verify_sonku_p94_acoustic_levels.py /tmp/sonku-p94-reference /tmp/sonku-p94 g++ $FLAGS tests/sonku_p89_stereo_room_depth_source_test.cpp -o /tmp/sonku-p89 /tmp/sonku-p89 echo "SONKU_P90_NATIVE_SOURCE_CTEST_PASSED" @@ -739,12 +741,12 @@ jobs: - name: Build real native JUCE PCM, state ACK, and Windows GUI shell: pwsh run: | - cmake --build build --config Release --parallel 2 --target ARMixSonKuP94SourceTests ARMixSonKuP91P92MusicBassTests ARMixSonKuP90NativeTests ARMixSonKuP90SourceTests ARMixSonKuP89NativeTests ARMixSonKuP89SourceTests ARMixConsole + cmake --build build --config Release --parallel 2 --target ARMixSonKuP94SourceTests ARMixSonKuP94ReferenceTests ARMixSonKuP91P92MusicBassTests ARMixSonKuP90NativeTests ARMixSonKuP90SourceTests ARMixSonKuP89NativeTests ARMixSonKuP89SourceTests ARMixConsole if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } if (-not (Test-Path -LiteralPath 'build/ARMixConsole_artefacts/Release/AR MIX Studio.exe' -PathType Leaf)) { throw 'SONKU_P90_NATIVE_GUI_EXE_MISSING' } - ctest --test-dir build -C Release --output-on-failure -R '^NativeSonKuP(89RoomAnchoredStereoAndP88GoldenParity|89JuceV10AppliedAckAndV9Restore|90StereoExternalizationSource|90JuceV11AppliedAckAndLegacyRestore|91P92MusicFidelityWorldBassAndRoom|94FrontBackDepthA_BSource)$' + ctest --test-dir build -C Release --output-on-failure -R '^NativeSonKuP(89RoomAnchoredStereoAndP88GoldenParity|89JuceV10AppliedAckAndV9Restore|90StereoExternalizationSource|90JuceV11AppliedAckAndLegacyRestore|91P92MusicFidelityWorldBassAndRoom|94FrontBackDepthA_BSource|94LevelMatchedAB)$' if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - name: Verified portable package, no installer or release shell: pwsh