diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index ffbc64605..0c1b189af 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -687,6 +687,18 @@ jobs: if [[ "${{ github.head_ref }}" == feat/sonku-p95-* ]]; then g++ $FLAGS -DSONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1 -DSONKU_P95_MUSICAL_PRESENCE_RESEARCH=1 tests/sonku_p95_musical_presence_source_test.cpp -o /tmp/sonku-p95 /tmp/sonku-p95 + if [[ "${{ github.head_ref }}" == feat/sonku-p95-p96-* ]]; then + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic tests/sonku_p96_distance_reinforcement_source_test.cpp -o /tmp/sonku-p96-bands + /tmp/sonku-p96-bands + g++ $FLAGS -DSONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1 -DSONKU_P95_MUSICAL_PRESENCE_RESEARCH=1 -DSONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH=1 tests/sonku_p95_musical_presence_source_test.cpp -o /tmp/sonku-p96-full + /tmp/sonku-p96-full + g++ $FLAGS -DSONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1 -DSONKU_P95_MUSICAL_PRESENCE_RESEARCH=1 tests/sonku_p96_integrated_bands_test.cpp -o /tmp/sonku-p96-reference + /tmp/sonku-p96-reference > /tmp/sonku-p96-reference.csv + g++ $FLAGS -DSONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1 -DSONKU_P95_MUSICAL_PRESENCE_RESEARCH=1 -DSONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH=1 tests/sonku_p96_integrated_bands_test.cpp -o /tmp/sonku-p96-candidate + /tmp/sonku-p96-candidate > /tmp/sonku-p96-candidate.csv + cat /tmp/sonku-p96-reference.csv /tmp/sonku-p96-candidate.csv + python3 scripts/verify_sonku_p96_bands.py /tmp/sonku-p96-reference.csv /tmp/sonku-p96-candidate.csv + fi fi g++ $FLAGS tests/sonku_p89_stereo_room_depth_source_test.cpp -o /tmp/sonku-p89 /tmp/sonku-p89 @@ -718,6 +730,7 @@ jobs: shell: pwsh run: | $p95flag = if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-*') { 'ON' } else { 'OFF' } + $p96flag = if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-p96-*') { 'ON' } else { 'OFF' } 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" ` @@ -735,6 +748,7 @@ jobs: -DARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT=ON ` -DARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH=ON ` -DARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE=$p95flag ` + -DARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT=$p96flag ` -DBUILD_TESTING=ON if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } $cache = Get-Content build/CMakeCache.txt -Raw @@ -749,6 +763,7 @@ jobs: run: | $targets = @('ARMixSonKuP94SourceTests','ARMixSonKuP94ReferenceTests','ARMixSonKuP91P92MusicBassTests','ARMixSonKuP90NativeTests','ARMixSonKuP90SourceTests','ARMixSonKuP89NativeTests','ARMixSonKuP89SourceTests','ARMixConsole') if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-*') { $targets += 'ARMixSonKuP95MusicTests' } + if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-p96-*') { $targets += 'ARMixSonKuP96DistanceTests' } cmake --build build --config Release --parallel 2 --target $targets if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } if (-not (Test-Path -LiteralPath 'build/ARMixConsole_artefacts/Release/AR MIX Studio.exe' -PathType Leaf)) { @@ -756,6 +771,7 @@ jobs: } $tests = '^NativeSonKuP(89RoomAnchoredStereoAndP88GoldenParity|89JuceV10AppliedAckAndV9Restore|90StereoExternalizationSource|90JuceV11AppliedAckAndLegacyRestore|91P92MusicFidelityWorldBassAndRoom|94FrontBackDepthA_BSource|94LevelMatchedAB' if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-*') { $tests += '|95MusicPresenceVenue' } + if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-p96-*') { $tests += '|96DistanceBassAndTrebleRetention' } $tests += ')$' ctest --test-dir build -C Release --output-on-failure -R $tests if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } @@ -774,13 +790,16 @@ jobs: Copy-Item docs/SONKU_P94_FRONT_REAR_EXTERNALIZATION_FAT_20261116.md dist/SONKU_P94_FRONT_REAR_FAT.md if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-*') { Copy-Item docs/SONKU_P95_IMMERSIVE_MUSIC_VENUE_FAT_20261116.md dist/SONKU_P95_MUSIC_VENUE_FAT.md + if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-p96-*') { + Copy-Item docs/SONKU_P96_DISTANCE_REINFORCEMENT_FAT_20261116.md dist/SONKU_P96_DISTANCE_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 = if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-*') { 'P9.5_IMMERSIVE_MUSIC_VENUE_FOUNDATION' } else { 'P9.4_FRONT_REAR_DEPTH_EXPERIMENT' } + mode = if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-p96-*') { 'P9.6_STAGE_BASS_AIR_DISTANCE_RESEARCH' } elseif ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-*') { 'P9.5_IMMERSIVE_MUSIC_VENUE_FOUNDATION' } else { 'P9.4_FRONT_REAR_DEPTH_EXPERIMENT' } stateSchema = 11 headphoneFat = 'PENDING' publicRelease = $false diff --git a/CMakeLists.txt b/CMakeLists.txt index a7619472a..fce8f49c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,6 +110,13 @@ if(ARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE AND NOT ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT) message(FATAL_ERROR "P9.5 requires P9 measured spatial engine") endif() +# Private stage-speaker reinforcement, isolated from P9.5 production. +option(ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT + "Private P9.6 stage-speaker LF/HF distance retention over 2m" OFF) +if(ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT AND + NOT ARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE) + message(FATAL_ERROR "P9.6 requires P9.5 musical presence and P9 world speaker") +endif() set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -330,7 +337,9 @@ target_compile_definitions(ARMixConsole PRIVATE $<$:SONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1> $<$:ARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH=1> $<$:ARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE=1> - $<$:SONKU_P95_MUSICAL_PRESENCE_RESEARCH=1>) + $<$:SONKU_P95_MUSICAL_PRESENCE_RESEARCH=1> + $<$:SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH=1> + $<$:ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT=1>) if(WIN32) # Windows retains its proven ASIO-first / WASAPI / static WebView2 distribution. # Never link Windows loader or sound APIs into macOS/Linux builds. @@ -864,10 +873,18 @@ if(BUILD_TESTING) target_compile_definitions(ARMixSonKuP95MusicTests PRIVATE $ SONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1 - SONKU_P95_MUSICAL_PRESENCE_RESEARCH=1) + SONKU_P95_MUSICAL_PRESENCE_RESEARCH=1 + $<$:SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH=1>) add_test(NAME NativeSonKuP95MusicPresenceVenue COMMAND ARMixSonKuP95MusicTests) endif() + if(ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT) + add_executable(ARMixSonKuP96DistanceTests + tests/sonku_p96_distance_reinforcement_source_test.cpp) + target_compile_features(ARMixSonKuP96DistanceTests PRIVATE cxx_std_20) + add_test(NAME NativeSonKuP96DistanceBassAndTrebleRetention + COMMAND ARMixSonKuP96DistanceTests) + endif() juce_add_console_app(ARMixSonKuP90NativeTests PRODUCT_NAME "ArSonMix SonKu P90 JUCE v11 State Tests") target_sources(ARMixSonKuP90NativeTests PRIVATE diff --git a/docs/SONKU_P96_DISTANCE_REINFORCEMENT_FAT_20261116.md b/docs/SONKU_P96_DISTANCE_REINFORCEMENT_FAT_20261116.md new file mode 100644 index 000000000..34c916af7 --- /dev/null +++ b/docs/SONKU_P96_DISTANCE_REINFORCEMENT_FAT_20261116.md @@ -0,0 +1,25 @@ +# SonKu P9.6 — Distance Without Losing Bass & Air (PRIVATE FAT, 2026-11-16) + +**Research branch, not approved sound, no public release.** Child of P9.5 PR #725 exact head b895d92c1706ab0e098bfe49447fa7b83058f865. Do not merge competing P9.5 #724 changes or alter frozen operator-approved P9.1/P9.2 checkpoint 763706a1. Preserve approved visual ellipse and P9.5 bypass/GUI fixes. + +## Proven source root cause + +In native P9 mode 9, with ROOM enabled, the complete direct KEMAR ear pressure is multiplied by 1/(1+0.27*(distanceMeters-1.6)), reaching **0.306x at 10m**. World-speaker LF shares the attenuation, while independent room returns can still dominate midrange. P9.5 RMS makeup / output trim do not selectively restore LF / HF. This identifies an engineering mechanism, not a listening-quality proof. + +Research basis: https://pmc.ncbi.nlm.nih.gov/articles/PMC5479918/ finds atmospheric HF loss in the 1–15m range relatively small; https://pmc.ncbi.nlm.nih.gov/articles/PMC4744263/ discusses distance/DRR. The target is a **sound-reinforced concert speaker** rather than literal free-field attenuation. + +## Narrow change + +- OFF-by-default native flag ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT, requires P9.5 and P9 world source. P9.5 with flag OFF is preserved. +- P9 mode 9 only, with room ON and distance above 2m: split SAME HRTF-positioned direct ear pressure with causal 170Hz and 4.2kHz complementary first-order filters; retain more bass and air while preserving early/late wet and original source position. +- Slowly ramp distance retention over 35ms, no headlocked dry bass, no second graph, no extra FIR/delay/FFT/heap. P9.4 front/rear calibration remains multiplicative outside this band split. +- At 10m, target LF/mid/HF direct pressure gains ~0.83/0.50/0.77 before crossover rolloffs; locally tested sinus probes are approximately 0.79 at 70Hz, 0.50 at 800Hz and 0.65 at 7.5kHz. NOT verified final-output/headphone loudness. +- ROOM OFF / <=2m preserves original direct samples after transition settles; schema v11 unchanged. Native capability p96DistanceReinforcement is emitted only from the opted-in native build. +- Existing limiter (linked 0.98 sample peak), P9.5 music presence and saved sessions are unchanged. + +## Acceptance before merge or release + +1. 44.1/48k isolated native tests: ROOM OFF, <=2m exact direct samples, LF/MID/HF spectral energy, anti-phase, finite output; full P9.5 core P96-on source compile/render at 0/90/180/270 and 64/256 buffers. +2. Exact-head Windows JUCE/native ACK/CTest and source-provenance bundle. Do not claim CI or audio-device FAT until inspected. +3. A/B reference P9.5 versus P9.6 on headphones at 2m / 5m / 7.5m / 10m, identical input, source angle and gain; compare measured band RMS, LUFS/crest/peak protection, then loudness-match for subjective depth. +4. REJECT if distance collapses, highs become harsh, kick masks vocal, reverb becomes dry or limiter pumps. Do not claim dearVR parity without headphone evidence. diff --git a/engine/builtin_fx/sonku/SonKuP96DistanceReinforcement.h b/engine/builtin_fx/sonku/SonKuP96DistanceReinforcement.h new file mode 100644 index 000000000..a32fb6e6f --- /dev/null +++ b/engine/builtin_fx/sonku/SonKuP96DistanceReinforcement.h @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include +#include +#include + +// Private P9.6 sound-reinforcement hypothesis, downstream of the SAME measured +// two-loudspeaker HRIR and world-anchored LF handover. Split only DIRECT ear +// pressure, not late/early reflections, the original L/R music or dry side. +// The 170 Hz / 4.2 kHz complementary crossovers are causal one-poles; their +// components sum to the exact unfiltered ear signal at equal gains. +// No allocations, FFT, virtual mono sub, added latency or callback trig. +namespace armix::sonku::p96 { +class DistanceReinforcement final { +public: + struct Ears {float left=0.f,right=0.f;}; + bool prepare(double rate) noexcept { + if(!std::isfinite(rate) || + (std::abs(rate-44100.)>.1 && std::abs(rate-48000.)>.1))return false; + constexpr double pi=3.14159265358979323846; + lowAlpha_=static_cast(1.-std::exp(-2.*pi*170./rate)); + highAlpha_=static_cast(1.-std::exp(-2.*pi*4200./rate)); + depthAlpha_=static_cast(1.-std::exp(-1./(rate*.035))); + reset(); + return true; + } + void reset() noexcept {low_.fill(0.f);wide_.fill(0.f);depth_=0.f;} + bool active() const noexcept {return depth_!=0.f;} + Ears process(float left,float right,float distanceGain, + float distanceMeters,bool roomEnabled) noexcept { + // Preserve OFF and <=2m P9.5 PCM exactly. The state filters still + // warm every sample, preventing stale memory on a live distance edit. + const float target=roomEnabled? + std::clamp((distanceMeters-2.f)/8.f,0.f,1.f):0.f; + depth_+=depthAlpha_*(target-depth_); + if(std::abs(depth_-target)<1.e-6f)depth_=target; + const std::array ears{left,right}; + std::array out{}; + for(int c=0;c<2;++c){ + low_[c]+=lowAlpha_*(ears[c]-low_[c]); + wide_[c]+=highAlpha_*(ears[c]-wide_[c]); + } + if(depth_==0.f) + return {distanceGain*left,distanceGain*right}; + // The normal distance cue remains in the mid-band and in the native + // early/late DRR. Reinforced speaker direct LF and HF retain musical + // body/air instead of making 10m sound like only a midrange reverb. + // This is NOT a physical free-field SPL model or a loudness guarantee. + const float reinforcible=std::max(0.f,1.f-distanceGain)*depth_; + const float midGain=distanceGain+.24f*reinforcible; + const float lowLift=.52f*reinforcible; // total LF retention 0.76 + const float highLift=.43f*reinforcible; // total HF retention 0.67 + for(int c=0;c<2;++c) + out[c]=midGain*ears[c]+lowLift*low_[c]+highLift*(ears[c]-wide_[c]); + return {out[0],out[1]}; + } +private: + std::array low_{},wide_{}; + float lowAlpha_=0.f,highAlpha_=0.f,depthAlpha_=0.f,depth_=0.f; +}; +} // namespace armix::sonku::p96 diff --git a/engine/builtin_fx/sonku/SonKuSpatialCore.h b/engine/builtin_fx/sonku/SonKuSpatialCore.h index 0f6ed196b..8b54a27b0 100644 --- a/engine/builtin_fx/sonku/SonKuSpatialCore.h +++ b/engine/builtin_fx/sonku/SonKuSpatialCore.h @@ -25,6 +25,9 @@ #if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH #include "SonKuP95MusicalPresence.h" #endif +#if defined(SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH) && SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH +#include "SonKuP96DistanceReinforcement.h" +#endif #if defined(SONKU_P94_FRONT_BACK_DEPTH_RESEARCH) && SONKU_P94_FRONT_BACK_DEPTH_RESEARCH #include "SonKuP94FrontBackDepthCue.h" #endif @@ -210,6 +213,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_P96_DISTANCE_REINFORCEMENT_RESEARCH) && SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH + if(!p96Reinforcement_.prepare(rate))return false; +#endif #if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH if(!p95Presence_.prepare(rate))return false; #endif @@ -284,6 +290,9 @@ class SonKuSpatialCore final { #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH p90Decoder_.reset(); p92Bass_.reset(); +#if defined(SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH) && SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH + p96Reinforcement_.reset(); +#endif #if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH p95Presence_.reset(); #endif @@ -341,6 +350,9 @@ class SonKuSpatialCore final { if((s.renderMode==9)!=(settings_.renderMode==9)){ p90Decoder_.reset(); p92Bass_.reset(); +#if defined(SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH) && SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH + p96Reinforcement_.reset(); +#endif #if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH p95Presence_.reset(); #endif @@ -904,10 +916,27 @@ class SonKuSpatialCore final { #else constexpr float calibratedDirect=1.f,calibratedEarly=1.f; #endif - float spatialL=smoothedDistanceGain_*calibratedDirect*ears[0]+ + float directL=smoothedDistanceGain_*calibratedDirect*ears[0]; + float directR=smoothedDistanceGain_*calibratedDirect*ears[1]; +#if defined(SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH) && SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH + if(p90World){ + // Same KEMAR world speakers; do not EQ/repan wet returns. + // P94's independent directional calibration stays outside. + const auto reinforced=p96Reinforcement_.process( + ears[0],ears[1],smoothedDistanceGain_, + settings_.sourceDistanceMeters,roomEnabled); + // Keep P9.5 floating-point operation order bit-exact + // whenever ROOM OFF or <=2m has no P9.6 reinforcement. + if(p96Reinforcement_.active()){ + directL=calibratedDirect*reinforced.left; + directR=calibratedDirect*reinforced.right; + } + } +#endif + float spatialL=directL+ smoothedErPresence_*calibratedEarly*reflection.left+ smoothedTailPresence_*late.left; - float spatialR=smoothedDistanceGain_*calibratedDirect*ears[1]+ + float spatialR=directR+ smoothedErPresence_*calibratedEarly*reflection.right+ smoothedTailPresence_*late.right; #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH @@ -1296,6 +1325,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_P96_DISTANCE_REINFORCEMENT_RESEARCH) && SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH + p96::DistanceReinforcement p96Reinforcement_{}; +#endif #if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH p95::MusicalPresence p95Presence_{}; #endif diff --git a/scripts/verify_sonku_p96_bands.py b/scripts/verify_sonku_p96_bands.py new file mode 100644 index 000000000..18ab6470c --- /dev/null +++ b/scripts/verify_sonku_p96_bands.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +"""Compare real native P9.5 versus P9.6 mode-9 PCM without hiding a mismatch.""" +import sys +from pathlib import Path + +def read(path): + rows = {} + for line in Path(path).read_text().splitlines(): + if not line.startswith("P96_FULL,"): + continue + p = line.split(",") + assert len(p) == 9, (path, line) + key = (int(p[1]), int(p[2]), int(p[3]), float(p[4])) + assert key not in rows + rows[key] = (tuple(float(x) for x in p[5:8]), p[8]) + assert len(rows) == 12, (path, len(rows)) + return rows + +def main(): + assert len(sys.argv) == 3 + baseline, candidate = read(sys.argv[1]), read(sys.argv[2]) + assert baseline.keys() == candidate.keys() + for key, (base, hash_old) in baseline.items(): + other, hash_new = candidate[key] + rate, az, room, meters = key + if room == 0 or meters <= 2.0: + assert hash_old == hash_new, f"P9.5 exact PCM regression: {key}" + continue + relative = [new / old for old, new in zip(base, other)] + print(f"P96_FULL_BAND_CHANGE rate={rate} az={az} d={meters}: bass={relative[0]:.3f} mid={relative[1]:.3f} treble={relative[2]:.3f}") + assert relative[0] > 1.25, (key, relative) + assert relative[2] > 1.15, (key, relative) + assert relative[0] / relative[1] > 1.16, (key, relative) + assert relative[2] / relative[1] > 1.10, (key, relative) + print("SONKU_P96_INTEGRATED_SPECTRAL_AND_EXACT_LEGACY_PCM_PASSED") + +if __name__ == "__main__": + main() diff --git a/site/preview-v2/assets/mixer-native-sonku.js b/site/preview-v2/assets/mixer-native-sonku.js index 34817b757..d903b451e 100644 --- a/site/preview-v2/assets/mixer-native-sonku.js +++ b/site/preview-v2/assets/mixer-native-sonku.js @@ -232,7 +232,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,p94Capable=false,p95Capable=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,p95Capable=false,p96Capable=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; @@ -434,7 +434,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=p95Capable&&s.renderMode===9? + root.querySelector(".sk-stage-caption").textContent=p96Capable&&s.renderMode===9? + "IMMERSIVE STAGE · REINFORCED BASS + AIR · CINEMA / VENUE": + p95Capable&&s.renderMode===9? "IMMERSIVE SPATIAL · MUSIC PRESENCE · WORLD BASS · CINEMA / VENUE": p94Capable&&s.renderMode===9? "LATEST SPATIAL · FRONT/REAR DEPTH · MUSIC FIDELITY · WORLD BASS": @@ -485,7 +487,8 @@ function render(){ // redrawn at 60 Hz. The native audio callback remains the time authority. drawSpeakers(); $("skMode").textContent=native()?(context()? - (p95Capable&&s.renderMode===9?"NATIVE IMMERSIVE · MUSIC PRESENCE · WORLD BASS": + (p96Capable&&s.renderMode===9?"NATIVE IMMERSIVE · STAGE BASS + AIR": + p95Capable&&s.renderMode===9?"NATIVE IMMERSIVE · MUSIC PRESENCE · WORLD BASS": p94Capable&&s.renderMode===9?"NATIVE IMMERSIVE SPATIAL · WORLD BASS": p91p92Capable&&s.renderMode===9?"NATIVE P9.1+P9.2 WORLD BASS · FAT": p90Capable&&s.renderMode===9?"NATIVE P9.0 TRUE EXTERNAL · TEST": @@ -660,6 +663,7 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ // can claim the *experimental* depth calibration, not P9.1 baseline. p94Capable=p91p92Capable && r.p94FrontBackDepthCue===true; p95Capable=p91p92Capable && r.p95MusicalPresence===true; + p96Capable=p95Capable && r.p96DistanceReinforcement===true; p89Capable=(r.schemaVersion===10||p90Capable) && r.p89StereoRoomDepth===true && Number.isFinite(incoming.hrtfElevationTrimDegrees); p88Capable=(r.schemaVersion===9||p89Capable) && r.p88PerceptualAlignment===true && @@ -765,7 +769,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;p94Capable=false;p95Capable=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;p95Capable=false;p96Capable=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;} @@ -964,7 +968,7 @@ const api={ drag=null;rangeEdits.clear();gestureStart.clear(); accepted=defaults();draft=defaults();xyzCapable=false; p83Capable=p84Capable=p85Capable=p86Capable=p87Capable=p88Capable= - p89Capable=p90Capable=p91p92Capable=p94Capable=p95Capable=false; + p89Capable=p90Capable=p91p92Capable=p94Capable=p95Capable=p96Capable=false; musicSafeStereo=p8TransparentBass=p82MultibandRoom=false; current={track,slot,instanceId:null}; const s=snapshot(),id=window.__ARMIX_NATIVE_M2__?.nativeIdFor?.(track); diff --git a/src/Main.cpp b/src/Main.cpp index 6429e4b9e..547e55ae1 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -3129,6 +3129,9 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr #if defined(ARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE) && ARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE reply->setProperty("p95MusicalPresence",true); #endif +#if defined(ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT) && ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT + reply->setProperty("p96DistanceReinforcement",true); +#endif #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. diff --git a/tests/sonku_p96_distance_reinforcement_source_test.cpp b/tests/sonku_p96_distance_reinforcement_source_test.cpp new file mode 100644 index 000000000..9dcddb833 --- /dev/null +++ b/tests/sonku_p96_distance_reinforcement_source_test.cpp @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#if defined(NDEBUG) +#undef NDEBUG +#endif +#include "../engine/builtin_fx/sonku/SonKuP96DistanceReinforcement.h" +#include +#include +#include +#include +using armix::sonku::p96::DistanceReinforcement; +static double render(double rate,float hz,float meters,float direct,bool on, + bool antiphase=false) { + DistanceReinforcement p; + assert(p.prepare(rate)); + const int count=static_cast(rate); + constexpr double pi=3.14159265358979323846; + double sum=0.,cross=0.; + for(int i=0;i(std::sin(2.*pi*hz*i/rate)); + const auto y=p.process(x,antiphase?-x:x,direct,meters,on); + assert(std::isfinite(y.left)&&std::isfinite(y.right)); + assert(std::abs(y.left)<1.f&&std::abs(y.right)<1.f); + if(!on){ + assert(y.left==direct*x); + assert(y.right==direct*(antiphase?-x:x)); + } + if(antiphase)assert(std::abs(y.left+y.right)<1.e-6f); + if(i>count/2){sum+=double(y.left)*y.left;cross+=double(x)*x;} + } + return std::sqrt(sum/cross); +} +int main(){ + DistanceReinforcement bad; + assert(!bad.prepare(96000.)); + for(double rate:{44100.,48000.}){ + for(float hz:{70.f,800.f,7500.f}){ + // No ROOM, 2m or less: EXACT direct signal, no extra EQ. + assert(std::abs(render(rate,hz,10.f,1.f,false)-1.f)<1.e-5); + assert(std::abs(render(rate,hz,2.f,.9f,true)-.9f)<1.e-5); + assert(std::abs(render(rate,hz,10.f,.306f,false)-.306f)<1.e-5); + } + const auto lf=render(rate,70.f,10.f,.306f,true,true); + const auto mid=render(rate,800.f,10.f,.306f,true); + const auto hf=render(rate,7500.f,10.f,.306f,true); + std::printf("P96 bands rate=%.0f bass=%.5f mid=%.5f treble=%.5f\n",rate,lf,mid,hf); + assert(lf>.67&&lf<.93); + assert(mid>.44&&mid<.61); + assert(hf>.64&&hf<.88); + assert(lf>mid*1.25&&hf>mid*1.20); + // Compare low/air retention against P9.5's uniformly attenuated direct. + assert(lf>.306f*2.f&&hf>.306f*1.9f); + } +} diff --git a/tests/sonku_p96_integrated_bands_test.cpp b/tests/sonku_p96_integrated_bands_test.cpp new file mode 100644 index 000000000..5e334b52c --- /dev/null +++ b/tests/sonku_p96_integrated_bands_test.cpp @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#if defined(NDEBUG) +#undef NDEBUG +#endif +#include "../engine/builtin_fx/sonku/SonKuSpatialCore.h" +#include +#include +#include +#include +#include +#include +#include +#include +using namespace armix::sonku; + +static void measure(int rate,int angle,int room,float meters) { + auto core=std::make_unique(); + assert(core->prepare(rate,SonKuReflectionProfile::SixSurfaceKemarResearch)); + Settings s{}; + s.renderMode=9; + s.moving=false; + s.startAzimuthDegrees=static_cast(angle); + s.stereoSpreadDegrees=82.f; + s.spatialMix=1.f; + s.outputTrim=1.2f; + s.spacePreset=room; + s.sourceDistanceMeters=meters; + s.roomAmount=0.f; // ROOM geometry ON; wet OFF isolates measured direct + s.ambience=0.f; + assert(valid(s) && core->setSettings(s)); + const int n=rate; + constexpr double pi=3.1415926535897932384626433832795; + std::vector l(n),r(n); + for(int i=0;i(i)/rate; + const float x=.08f*std::sin(2*pi*70*t)+ + .055f*std::sin(2*pi*800*t)+ + .028f*std::sin(2*pi*7500*t); + l[i]=x; + r[i]=.8f*x+.008f*std::sin(2*pi*1770*t); + } + for(int i=0;iprocess(l.data()+i,r.data()+i,std::min(256,n-i)); + std::uint64_t hash=14695981039346656037ull; + for(int i=0;i(value); + hash*=1099511628211ull; + } + } + constexpr std::array freqs{70,800,7500}; + std::array amps{}; + for(int b=0;b<3;++b){ + double sinSum=0.,cosSum=0.; + for(int i=n/2;i0.); + } + std::printf("P96_FULL,%d,%d,%d,%.1f,%.9f,%.9f,%.9f,%016llx\n", + rate,angle,room,meters,amps[0],amps[1],amps[2], + static_cast(hash)); +} +int main(){ + for(int rate:{44100,48000}) + for(int angle:{0,180}){ + measure(rate,angle,0,10.f); // ROOM OFF exact hash parity + measure(rate,angle,3,2.f); // <=2m exact hash parity + measure(rate,angle,3,10.f); // far stage spectral retention + } +}