diff --git a/.github/workflows/sonku-p89-windows-field.yml b/.github/workflows/sonku-p89-windows-field.yml new file mode 100644 index 000000000..8e5a52a77 --- /dev/null +++ b/.github/workflows/sonku-p89-windows-field.yml @@ -0,0 +1,333 @@ +name: SonKu P8.9 room-anchored stereo native mixer portable FAT x64 +# Private JUCE app, no release. Native v10 A/B P8.2/P8.4/P8.5/P8.6/P8.7/P8.8/P8.9. +on: + pull_request: + paths: + - '.github/workflows/sonku-p89-windows-field.yml' + workflow_dispatch: +permissions: + contents: read +concurrency: + group: sonku-p89-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 + 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 + g++ $FLAGS -DSONKU_P85_WORLD_COHERENCE_RESEARCH=1 tests/sonku_p85_world_locked_source_test.cpp -o /tmp/p85-source + /tmp/p85-source | tee /tmp/p85-source.log + grep -q '^PASS P85 WORLD LOCK:' /tmp/p85-source.log + g++ $FLAGS -DSONKU_P85_WORLD_COHERENCE_RESEARCH=1 -DSONKU_P86_HORIZONTAL_FOCUS_RESEARCH=1 tests/sonku_p86_horizontal_focus_native_source_test.cpp -o /tmp/p86-source + /tmp/p86-source | tee /tmp/p86-source.log + grep -q '^PASS P86 HORIZONTAL FOCUS:' /tmp/p86-source.log + g++ $FLAGS -DSONKU_P85_WORLD_COHERENCE_RESEARCH=1 -DSONKU_P86_HORIZONTAL_FOCUS_RESEARCH=1 -DSONKU_P87_MUSIC_BODY_RESEARCH=1 tests/sonku_p87_musical_air_body_source_test.cpp -o /tmp/p87-source + /tmp/p87-source | tee /tmp/p87-source.log + grep -q '^PASS P87 MUSICAL AIR BODY:' /tmp/p87-source.log + g++ $FLAGS -DSONKU_P85_WORLD_COHERENCE_RESEARCH=1 -DSONKU_P86_HORIZONTAL_FOCUS_RESEARCH=1 -DSONKU_P87_MUSIC_BODY_RESEARCH=1 -DSONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH=1 tests/sonku_p88_height_distance_source_test.cpp -o /tmp/p88-source + /tmp/p88-source | tee /tmp/p88-source.log + grep -q '^PASS P88 HEIGHT DISTANCE:' /tmp/p88-source.log + g++ $FLAGS -DSONKU_P85_WORLD_COHERENCE_RESEARCH=1 -DSONKU_P86_HORIZONTAL_FOCUS_RESEARCH=1 -DSONKU_P87_MUSIC_BODY_RESEARCH=1 -DSONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH=1 -DSONKU_P89_DEPTH_COHERENCE_RESEARCH=1 tests/sonku_p89_stereo_room_depth_source_test.cpp -o /tmp/p89-source + /tmp/p89-source | tee /tmp/p89-source.log + grep -q '^PASS P89 ROOM ANCHOR:' /tmp/p89-source.log + - name: Native JS and source GUI capability checks + run: | + set -euo pipefail + node --check site/preview-v2/assets/mixer-native-sonku.js + python - <<'PY' + import re + from pathlib import Path + for path in ("engine/builtin_fx/SonKuSpatialProcessor.h", + "engine/builtin_fx/sonku/SonKuSpatialCore.h"): + depth=0 + for line in Path(path).read_text().splitlines(): + if re.match(r'^\s*#\s*(?:if|ifdef|ifndef)\b',line): + depth+=1 + elif re.match(r'^\s*#\s*endif\b',line): + depth-=1 + assert depth>=0,(path,"excess endif") + assert depth==0,(path,"missing endif",depth) + print("P89_NATIVE_HEADER_PREPROCESSOR_BALANCED") + PY + grep -q 'r.schemaVersion===10' site/preview-v2/assets/mixer-native-sonku.js + # A mode8 enum without fused FIR dispatch silently changes P8.8 timbre. + # This source contract prevents another fallback-to-wrong-kernel regression. + python - <<'PY' + from pathlib import Path + core=Path("engine/builtin_fx/sonku/SonKuSpatialCore.h").read_text() + section=core.split("if((p83Mode_==p83::Mode::MusicSpatialP84 ||",1)[1].split("p84MusicKernel_.merge(",1)[0] + assert "p83Mode_==p83::Mode::MusicSpatialP89 ||" in section + assert "p83Mode_==p83::Mode::MusicSpatialP88 ||" in section + print("SONKU_P89_NATIVE_FUSED_FIR_DISPATCH_VERIFIED") + PY + grep -q 'skHrtfAlign' 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 ` + -DARMIX_SONKU_EXPERIMENTAL_P85_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P86_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P87_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P89_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' -or + $cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P85_NATIVE_RT:BOOL=ON' -or + $cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P86_NATIVE_RT:BOOL=ON' -or + $cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P87_NATIVE_RT:BOOL=ON' -or + $cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT:BOOL=ON' -or + $cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P89_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', + 'NativeSonKuP85WorldCoherentMidYawSourceAndFidelity', + 'NativeSonKuP85JuceV6AudioAckLegacySafeRestore', + 'NativeSonKuP86SixWallHorizontalFocusAndMusicIntegrity', + 'NativeSonKuP86JuceV7AudioAckAndV6Restore', + 'NativeSonKuP87MusicalAirBodyP86DryParityAndFdnBass', + 'NativeSonKuP87JuceV8AudioAppliedAckV7Restore', + 'NativeSonKuP88MeasuredEarHeightAndDistanceDrr', + 'NativeSonKuP88JuceV9AppliedAckAndV8Restore', + 'NativeSonKuP89RoomAnchoredStereoAndP88GoldenParity', + 'NativeSonKuP89JuceV10AppliedAckAndV9Restore') + $available = @($tests.tests | ForEach-Object { $_.name }) + 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 ARMixSonKuP89NativeTests + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + ctest --test-dir build -C Release --output-on-failure -R '^NativeSonKuP89JuceV10AppliedAckAndV9Restore$' + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + - 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 ARMixSonKuP85WorldSourceTests ARMixSonKuP85NativeTests ARMixSonKuP86FocusSourceTests ARMixSonKuP86NativeTests ARMixSonKuP87MusicSourceTests ARMixSonKuP87NativeTests ARMixSonKuP88SourceTests ARMixSonKuP88NativeTests ARMixSonKuP89SourceTests ARMixSonKuP89NativeTests + 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|P85WorldCoherentMidYawSourceAndFidelity|P85JuceV6AudioAckLegacySafeRestore|P86SixWallHorizontalFocusAndMusicIntegrity|P86JuceV7AudioAckAndV6Restore|P87MusicalAirBodyP86DryParityAndFdnBass|P87JuceV8AudioAppliedAckV7Restore|P88MeasuredEarHeightAndDistanceDrr|P88JuceV9AppliedAckAndV8Restore|P89RoomAnchoredStereoAndP88GoldenParity|P89JuceV10AppliedAckAndV9Restore)$' + 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 + p85WorldLockedMid = $true + p86HorizontalFocus = $true + p87MusicalAirBody = $true + p88PerceptualAlignment = $true + p89StereoRoomDepth = $true + p84RenderModes = @('MusicBedP82','MusicSpatialP84','MusicSpatialP85','MusicSpatialP86','MusicSpatialP87','MusicSpatialP88','MusicSpatialP89') + 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 = 10 + fullWindowsExecutable = $true + publicRelease = $false + physicalAsioQualified = $false + dearVrPerceptualParityProven = $false + qualification = 'SONKU_P89_SCOPED_NATIVE_PCM_JUCE_20_CTESTS_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_P89_ROOM_ANCHORED_STEREO_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 + -not $p.sonkuExperiment.p85WorldLockedMid -or + -not $p.sonkuExperiment.p86HorizontalFocus -or + -not $p.sonkuExperiment.p87MusicalAirBody -or + -not $p.sonkuExperiment.p88PerceptualAlignment -or + -not $p.sonkuExperiment.p89StereoRoomDepth -or + $p.sonkuExperiment.stateSchema -ne 10 -or $p.sonkuExperiment.publicRelease) { + throw 'SONKU_P89_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_P89_ROOM_ANCHORED_STEREO_20261115.md -Destination dist/SONKU_P89_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_P89_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_P89_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-P89-Room-Anchored-Stereo-Windows-x64-${{ github.run_id }} + path: dist/ + if-no-files-found: error + retention-days: 21 + compression-level: 0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c8d10566..1e7340aad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,14 @@ if(ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT AND NOT ARMIX_SONKU_EXPERIMENTAL_P87_NATIVE_RT) message(FATAL_ERROR "P8.8 needs private P8.7 music-body research") endif() +# P8.9 keeps old modes and original stereo, moves bounded far-field +# emphasis toward measured directional early reflections. +option(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT + "Private P8.9 headphone stereo/room coherence research" OFF) +if(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT AND + NOT ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT) + message(FATAL_ERROR "P8.9 requires P8.8 perceptual alignment") +endif() set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -293,7 +301,9 @@ target_compile_definitions(ARMixConsole PRIVATE $<$:ARMIX_SONKU_EXPERIMENTAL_P87_NATIVE_RT=1> $<$:SONKU_P87_MUSIC_BODY_RESEARCH=1> $<$:ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT=1> - $<$:SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH=1>) + $<$:SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH=1> + $<$:ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT=1> + $<$:SONKU_P89_DEPTH_COHERENCE_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. @@ -702,6 +712,58 @@ if(BUILD_TESTING) SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH=1) add_test(NAME NativeSonKuP88JuceV9AppliedAckAndV8Restore COMMAND ARMixSonKuP88NativeTests) + if(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) + add_executable(ARMixSonKuP89SourceTests + tests/sonku_p89_stereo_room_depth_source_test.cpp) + target_compile_features(ARMixSonKuP89SourceTests PRIVATE cxx_std_20) + target_compile_definitions(ARMixSonKuP89SourceTests 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 + SONKU_P85_WORLD_COHERENCE_RESEARCH=1 + SONKU_P86_HORIZONTAL_FOCUS_RESEARCH=1 + SONKU_P87_MUSIC_BODY_RESEARCH=1 + SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH=1 + SONKU_P89_DEPTH_COHERENCE_RESEARCH=1) + add_test(NAME NativeSonKuP89RoomAnchoredStereoAndP88GoldenParity + COMMAND ARMixSonKuP89SourceTests) + juce_add_console_app(ARMixSonKuP89NativeTests + PRODUCT_NAME "ArSonMix SonKu P89 JUCE v10 State Tests") + target_sources(ARMixSonKuP89NativeTests PRIVATE + tests/sonku_p89_native_juce_v10_test.cpp) + target_compile_features(ARMixSonKuP89NativeTests PRIVATE cxx_std_20) + target_link_libraries(ARMixSonKuP89NativeTests PRIVATE + juce::juce_audio_processors juce::juce_recommended_config_flags) + target_compile_definitions(ARMixSonKuP89NativeTests PRIVATE + ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT=1 + ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT=1 + ARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT=1 + ARMIX_SONKU_EXPERIMENTAL_P85_NATIVE_RT=1 + ARMIX_SONKU_EXPERIMENTAL_P86_NATIVE_RT=1 + ARMIX_SONKU_EXPERIMENTAL_P87_NATIVE_RT=1 + ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT=1 + ARMIX_SONKU_EXPERIMENTAL_P89_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 + SONKU_P85_WORLD_COHERENCE_RESEARCH=1 + SONKU_P86_HORIZONTAL_FOCUS_RESEARCH=1 + SONKU_P87_MUSIC_BODY_RESEARCH=1 + SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH=1 + SONKU_P89_DEPTH_COHERENCE_RESEARCH=1) + add_test(NAME NativeSonKuP89JuceV10AppliedAckAndV9Restore + COMMAND ARMixSonKuP89NativeTests) + endif() endif() endif() endif() diff --git a/docs/SONKU_P89_ROOM_ANCHORED_STEREO_20261115.md b/docs/SONKU_P89_ROOM_ANCHORED_STEREO_20261115.md new file mode 100644 index 000000000..9b37eb60a --- /dev/null +++ b/docs/SONKU_P89_ROOM_ANCHORED_STEREO_20261115.md @@ -0,0 +1,27 @@ +# SonKu P8.9 — Room-Anchored Stereo, Owner Headphone FAT +Private research, 2026-11-15. No merge to main, no public release. + +## Why: source-derived cause, not invented sound preset +At 7.3m, SPACE LARGE 28.8m, P8.7 user reports in-head/up/too close even with elevation -7.4°, ER100, reverb100. P8.8 correctly separates physical XYZ elevation from measured generic KEMAR spectral-HRTF trim and makes distant HRTF/high direct and original LF quieter. However, **the full high-passed stereo SIDE is returned directly in headphone left/right, unscaled by source distance** (SonKuSpatialCore::process sideRescue, at all yaw/azimuth). This preserves anti-phase music and was necessary to avoid the rejected P8.3 regression, but is a strong nonspatial near-head reference. Room reflections already have measured directional KEMAR HRIR and world/head yaw transforms, so it is preferable to reallocate a bounded small part of far-field emphasis toward existing binaural horizontal early reflections, not saturate the late reverb or invent ITD. + +Sources outside repo: +- Best et al., 'Sound Externalization: A Review of Recent Research' (2020), https://pmc.ncbi.nlm.nih.gov/articles/PMC7488874/ — binaural differences in reflections and fluctuations in interaural coherence crucial; simply diotic reverb is insufficient; generic KEMAR cannot guarantee subjective externalization. +- Choe and Choi, JASA 2023, DOI 10.1121/10.0023095 — DRR and IACC contributions interact with head motion/source direction. +- 'Enhancing Externalization of Frontal Virtual Sound Sources ...' (2026), https://pmc.ncbi.nlm.nih.gov/articles/PMC13451706/ — reflections 20-80ms and binaural differences frequently matter more than late reverb >80-100ms. +- AES 2021 Jot et al., https://audio.rightmark.org/lukin/pub/aes_extern/ — preserving music fidelity with minimal changes is essential for stereo post-processing. + +## Isolated P8.9 mode8, actual native callbacks +- P8.2=0, P8.4=3, P8.5=4, P8.6=5, P8.7=6, P8.8=7 remain unchanged. Owner-rejected P8.3 1/2 remain blocked. P8.9 opt-in **mode8**, no automatic preset selection, no new audio engine, no extra HRIR FIR, no heap/locks/threads/device changes. +- Native stereo high-frequency SIDE is scaled by `1 - 0.22*d` only in mode8 + ROOM ON, where `d=clamp((distance-1.6)/6.4,0,1)`. Thus **minimum 78% SIDE** at maximum distance, **100% at close1.6m and ROOM OFF**. Stereo anti-phase stays audible; no mid-only collapse or surprise mono. +- Already-built **six-wall measured binaural early reflections**, horizontal first 4 and subdued floor+ceiling, receive a stage-only factor `1 + .24*d` atop P8.6's existing horizontal weighting. Fixed geometry, image timing, head yaw and source placement remain. At user7.3m, d≈.89 => 1.214. +- Diffuse existing stereo FDN tail receives `1 - .08*d` to avoid reverb100% becoming washy. At user7.3m factor≈.929. The actual FDN spectra, room60/early KEMAR and P8.7 LF warmth/air all untouched. +- The scalar direct HRTF and LF distance laws of P8.8 stay. HRTF trim separately controls perceived height without changing physical XYZ or floor/ceiling path. No psychoacoustic guarantee, individual HRTF/headphone response remains unknown. +- SIDE/room coefficients precomputed once per native PCM block; scalars only per sample. No new 140-tap convolution. +- Native typed bridge schema **v10**; **63-byte state layout identical to v9**. v9 restores P8.8 mode7/trim, v8 P8.7 mode6, v7 P8.6, v6 P8.5, v5 P8.4, v1..4 safe migration. Explicit P8.9 capability flag only when exact native JUCE KEMAR profile ready. GUI option appears only after v10 source readback and accepted ACK. + +## Required software and headphone acceptance +- Source PCM at 44.1k and 48k, 64/128: ROOM OFF mode8 **bit-identical** P8.8 mode7 at azimuth24, head yaw0/60/180, correlated and anti-phase; ROOM ON near1.6m also bit-identical, including reverb100. Dry mix 0 is bit-identical; no clip/silence. +- FAR7.3m large room: all-channel music, anti-phase and correlated must remain finite and audible, stereo SIDE preserved and measured early reflected energy increased relative to P8.8; late FDN not amplified. +- Real JUCE native v10 tests native SPSC audio-applied ACK, v10 63-byte save and reopen, old v9 P8.8 preserve mode7/trim without downgrade, v1..8 session migration. Windows x64 full GUI exe, exact embedded GUI resources, standalone ZIP and SHA256 only if all scoped CTests pass. +- **Owner headphone FAT**: choose STATIC, head yaw0°, speaker angle60°, SOURCE ELEVATION=0° physical. P8.8 vs P8.9 matched output gain: ROOM OFF (must sound identical); SMALL/LARGE with distance1.6 then 3 then 7.3m, ER55 then100, reverb47 then100, HRTF ear calibration same between modes. Judge whether guitar/transient/vocal detail and stereo width remain musical while the stage separates from ears. Then test yaw±60/90/180, motion and realtime device reopen. Do not compare with unlevel-matched loudness. +- Do not claim that laboratory test establishes user perceptual immersive sound; generic HRTF, headphone EQ and actual head-motion still need FAT. **Do not merge stacked research ancestry (includes dormant rejected P8.3 code) to main.** No external device monitor toggles and no auto mute/master edits; audio continuity PR713 remains separate. diff --git a/engine/builtin_fx/SonKuSpatialProcessor.h b/engine/builtin_fx/SonKuSpatialProcessor.h index 0d467bd90..e762a02da 100644 --- a/engine/builtin_fx/SonKuSpatialProcessor.h +++ b/engine/builtin_fx/SonKuSpatialProcessor.h @@ -162,7 +162,11 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, #if defined(ARMIX_SONKU_EXPERIMENTAL_P86_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P86_NATIVE_RT #if defined(ARMIX_SONKU_EXPERIMENTAL_P87_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P87_NATIVE_RT #if defined(ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT + out.writeInt(10); // 63 bytes v9 layout, opt-in mode 8 +#else out.writeInt(9); // v8 59-byte state + 4-byte HRTF trim +#endif #else out.writeInt(8); // same 59-byte layout; modes 0/3/4/5/6 #endif @@ -241,6 +245,9 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, &&version!=8 #if defined(ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT &&version!=9 +#if defined(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT + &&version!=10 +#endif #endif #endif #endif @@ -263,6 +270,9 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, ||(version==8&&size!=59) #if defined(ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT ||(version==9&&size!=63) +#if defined(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT + ||(version==10&&size!=63) +#endif #endif #endif #endif @@ -337,6 +347,12 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, #if defined(ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT if(version==9 && next.renderMode!=0 && next.renderMode!=3 && next.renderMode!=4 && next.renderMode!=5 && next.renderMode!=6 && next.renderMode!=7)return false; if(version==9 && next.musicCompatibleLowFrequency)return false; +#if defined(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT + if(version==10 && next.renderMode!=0 && next.renderMode!=3 && + next.renderMode!=4 && next.renderMode!=5 && next.renderMode!=6 && + next.renderMode!=7 && next.renderMode!=8)return false; + if(version==10 && next.musicCompatibleLowFrequency)return false; +#endif #endif #endif #endif diff --git a/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h b/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h index b4cd1be1d..3b7e3781e 100644 --- a/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h +++ b/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h @@ -18,6 +18,9 @@ enum class Mode : std::uint8_t { ,MusicSpatialP87=6 #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH ,MusicSpatialP88=7 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + ,MusicSpatialP89=8 +#endif #endif #endif #endif @@ -38,6 +41,9 @@ inline bool valid(Mode m) noexcept { || m==Mode::MusicSpatialP87 #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH || m==Mode::MusicSpatialP88 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + || m==Mode::MusicSpatialP89 +#endif #endif #endif #endif diff --git a/engine/builtin_fx/sonku/SonKuSpatialCore.h b/engine/builtin_fx/sonku/SonKuSpatialCore.h index 774a92285..8876ef41f 100644 --- a/engine/builtin_fx/sonku/SonKuSpatialCore.h +++ b/engine/builtin_fx/sonku/SonKuSpatialCore.h @@ -98,7 +98,11 @@ inline bool valid(const Settings& s) noexcept { #if defined(SONKU_P86_HORIZONTAL_FOCUS_RESEARCH) && SONKU_P86_HORIZONTAL_FOCUS_RESEARCH #if defined(SONKU_P87_MUSIC_BODY_RESEARCH) && SONKU_P87_MUSIC_BODY_RESEARCH #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + s.renderMode<=8 && ((s.renderMode!=3 && s.renderMode!=4 && s.renderMode!=5 && s.renderMode!=6 && s.renderMode!=7 && s.renderMode!=8) || !s.musicCompatibleLowFrequency) && +#else s.renderMode<=7 && ((s.renderMode!=3 && s.renderMode!=4 && s.renderMode!=5 && s.renderMode!=6 && s.renderMode!=7) || !s.musicCompatibleLowFrequency) && +#endif #else s.renderMode<=6 && ((s.renderMode!=3 && s.renderMode!=4 && s.renderMode!=5 && s.renderMode!=6) || !s.musicCompatibleLowFrequency) && #endif @@ -117,8 +121,12 @@ inline bool valid(const Settings& s) noexcept { #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH std::isfinite(s.hrtfElevationTrimDegrees) && s.hrtfElevationTrimDegrees>=-30.f && s.hrtfElevationTrimDegrees<=20.f && - (s.renderMode!=7 || (s.directElevationDegrees+s.hrtfElevationTrimDegrees>=-40.f && - s.directElevationDegrees+s.hrtfElevationTrimDegrees<=60.f)) && + ((s.renderMode!=7 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + && s.renderMode!=8 +#endif + ) || (s.directElevationDegrees+s.hrtfElevationTrimDegrees>=-40.f && + s.directElevationDegrees+s.hrtfElevationTrimDegrees<=60.f)) && #endif p83::validYaw(s.headYawDegrees) && (s.renderMode!=2 || (s.stereoSpreadDegrees>=20.f && @@ -474,6 +482,9 @@ class SonKuSpatialCore final { && p83Mode_!=p83::Mode::MusicSpatialP87 #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH && p83Mode_!=p83::Mode::MusicSpatialP88 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + && p83Mode_!=p83::Mode::MusicSpatialP89 +#endif #endif #endif #endif @@ -513,6 +524,9 @@ class SonKuSpatialCore final { || p83Mode_==p83::Mode::MusicSpatialP87 #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH || p83Mode_==p83::Mode::MusicSpatialP88 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + || p83Mode_==p83::Mode::MusicSpatialP89 +#endif #endif #endif #endif @@ -528,6 +542,9 @@ class SonKuSpatialCore final { || p83Mode_==p83::Mode::MusicSpatialP87 #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH || p83Mode_==p83::Mode::MusicSpatialP88 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + || p83Mode_==p83::Mode::MusicSpatialP89 +#endif #endif #endif ; @@ -535,6 +552,9 @@ class SonKuSpatialCore final { const bool musicalBody=p83Mode_==p83::Mode::MusicSpatialP87 #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH || p83Mode_==p83::Mode::MusicSpatialP88 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + || p83Mode_==p83::Mode::MusicSpatialP89 +#endif #endif ; #endif @@ -547,7 +567,11 @@ class SonKuSpatialCore final { const float targetDistance=roomEnabled? 1.f/(1.f+ #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH - (p83Mode_==p83::Mode::MusicSpatialP88?0.27f:0.13f)* + ((p83Mode_==p83::Mode::MusicSpatialP88 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + || p83Mode_==p83::Mode::MusicSpatialP89 +#endif + )?0.27f:0.13f)* #else 0.13f* #endif @@ -556,8 +580,22 @@ class SonKuSpatialCore final { // attenuates it gently while preserving stereo LF weight. #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH const float targetBassDistance=roomEnabled&& - p83Mode_==p83::Mode::MusicSpatialP88? + (p83Mode_==p83::Mode::MusicSpatialP88 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + || p83Mode_==p83::Mode::MusicSpatialP89 +#endif + )? 1.f/(1.f+0.10f*(settings_.sourceDistanceMeters-1.6f)):1.f; +#endif +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + // Room-energy transfer is computed once per callback block; no new + // FIR/filter memory. 1.6m/ROOM OFF keeps exact P8.8 PCM. + const bool p89Stage=p83Mode_==p83::Mode::MusicSpatialP89; + const float p89Depth=p89Stage&&roomEnabled? + std::clamp((settings_.sourceDistanceMeters-1.6f)/6.4f,0.f,1.f):0.f; + const float p89SideGain=1.f-.22f*p89Depth; + const float p89DirectionalRoom=1.f+.24f*p89Depth; + const float p89DiffuseRoom=1.f-.08f*p89Depth; #endif for(int i=0;i=78% at maximum distance; early + // world-locked measured reflections shoulder the extra space. + sideRescue*=p89SideGain; #endif history_[0][write_]=x0; history_[1][write_]=x1; @@ -733,9 +776,21 @@ class SonKuSpatialCore final { #endif (2.2f+4.0f*settings_.ambience):1.f; smoothedErPresence_+=distanceSlew_* - (targetErPresence-smoothedErPresence_); + ( +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + targetErPresence*p89DirectionalRoom +#else + targetErPresence +#endif + -smoothedErPresence_); smoothedTailPresence_+=distanceSlew_* - (targetTailPresence-smoothedTailPresence_); + ( +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + targetTailPresence*p89DiffuseRoom +#else + targetTailPresence +#endif + -smoothedTailPresence_); float spatialL=smoothedDistanceGain_*ears[0]+ smoothedErPresence_*reflection.left+ smoothedTailPresence_*late.left; @@ -852,7 +907,11 @@ class SonKuSpatialCore final { if(room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch && (researchElevationDegrees_!=0.f #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH - || (p83Mode_==p83::Mode::MusicSpatialP88 && + || ((p83Mode_==p83::Mode::MusicSpatialP88 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + || p83Mode_==p83::Mode::MusicSpatialP89 +#endif + ) && settings_.hrtfElevationTrimDegrees!=0.f) #endif )){ @@ -860,7 +919,11 @@ class SonKuSpatialCore final { // very same truly measured direct elevation, no third FIR. const float spectralElevation=researchElevationDegrees_ #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH - +(p83Mode_==p83::Mode::MusicSpatialP88? + +((p83Mode_==p83::Mode::MusicSpatialP88 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + || p83Mode_==p83::Mode::MusicSpatialP89 +#endif + )? settings_.hrtfElevationTrimDegrees:0.f) #endif ; @@ -901,6 +964,9 @@ class SonKuSpatialCore final { && p83Mode_!=p83::Mode::MusicSpatialP87 #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH && p83Mode_!=p83::Mode::MusicSpatialP88 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + && p83Mode_!=p83::Mode::MusicSpatialP89 +#endif #endif #endif #endif @@ -936,6 +1002,9 @@ class SonKuSpatialCore final { p83Mode_==p83::Mode::MusicSpatialP87 || #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH p83Mode_==p83::Mode::MusicSpatialP88 || +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + p83Mode_==p83::Mode::MusicSpatialP89 || +#endif #endif #endif #endif @@ -958,6 +1027,9 @@ class SonKuSpatialCore final { || p83Mode_==p83::Mode::MusicSpatialP87 #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH || p83Mode_==p83::Mode::MusicSpatialP88 +#if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH + || p83Mode_==p83::Mode::MusicSpatialP89 +#endif #endif #endif #endif diff --git a/site/preview-v2/assets/mixer-native-sonku.js b/site/preview-v2/assets/mixer-native-sonku.js index 3ba04ab29..e5d6c1428 100644 --- a/site/preview-v2/assets/mixer-native-sonku.js +++ b/site/preview-v2/assets/mixer-native-sonku.js @@ -14,7 +14,7 @@ const elevationLimits=s=>{ const distance=s.sourceDistanceMeters; const height=roomHeights[s.spacePreset]; if(!Number.isFinite(distance)||!height)return {min:0,max:0}; - const spectralOffset=s.renderMode===7?(s.hrtfElevationTrimDegrees??0):0; + const spectralOffset=(s.renderMode===7||s.renderMode===8)?(s.hrtfElevationTrimDegrees??0):0; const bottom=Math.max(-40-spectralOffset,Math.asin(Math.max(-1,Math.min(1,(.5-1.45)/distance)))*180/Math.PI); const top=Math.min(60-spectralOffset,Math.asin(Math.max(-1,Math.min(1,(height-.5-1.45)/distance)))*180/Math.PI); // Keep a 0.1 degree safety margin for C++ float boundary rounding. @@ -54,12 +54,12 @@ 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<=7 && + Number.isInteger(s.renderMode)&&s.renderMode>=0&&s.renderMode<=8 && typeof s.musicCompatibleLowFrequency==="boolean" && (s.hrtfElevationTrimDegrees===undefined || ( Number.isFinite(s.hrtfElevationTrimDegrees) && s.hrtfElevationTrimDegrees>=-30 && s.hrtfElevationTrimDegrees<=20 && - (s.renderMode!==7 || (s.directElevationDegrees+s.hrtfElevationTrimDegrees>=-40 && + ((s.renderMode!==7&&s.renderMode!==8) || (s.directElevationDegrees+s.hrtfElevationTrimDegrees>=-40 && s.directElevationDegrees+s.hrtfElevationTrimDegrees<=60)))) && Number.isFinite(s.headYawDegrees)&&Math.abs(s.headYawDegrees)<=360 && (s.renderMode!==2 || (s.stereoSpreadDegrees>=20&&s.stereoSpreadDegrees<=120)))); @@ -195,7 +195,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,musicSafeStereo=false,p8TransparentBass=false,p82MultibandRoom=false, + xyzCapable=false,p83Capable=false,p84Capable=false,p85Capable=false,p86Capable=false,p87Capable=false,p88Capable=false,p89Capable=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; @@ -215,7 +215,17 @@ function render(){ const row=$("skRenderRow");row.hidden=!(p83Capable||p84Capable); if(p83Capable||p84Capable){ const picker=$("skRenderMode"); - if(p88Capable && picker.dataset.nativeModeSet!=="p88"){ + if(p89Capable && picker.dataset.nativeModeSet!=="p89"){ + picker.innerHTML=''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''; + picker.dataset.nativeModeSet="p89"; + root.querySelector(".sk-render-label").textContent="RENDER MODE · P8.9 HEADPHONE FAT"; + }else if(!p89Capable && p88Capable && picker.dataset.nativeModeSet!=="p88"){ picker.innerHTML=''+ ''+ ''+ @@ -258,7 +268,8 @@ function render(){ picker.dataset.nativeModeSet="p83"; root.querySelector(".sk-render-label").textContent="RENDER MODE · P8.3 TEST"; } - const v=p88Capable?(s.renderMode===7?"align":s.renderMode===6?"body":s.renderMode===5?"focus":s.renderMode===4?"coherence":s.renderMode===3?"clarity":"music"): + const v=p89Capable?(s.renderMode===8?"depth":s.renderMode===7?"align":s.renderMode===6?"body":s.renderMode===5?"focus":s.renderMode===4?"coherence":s.renderMode===3?"clarity":"music"): + p88Capable?(s.renderMode===7?"align":s.renderMode===6?"body":s.renderMode===5?"focus":s.renderMode===4?"coherence":s.renderMode===3?"clarity":"music"): p87Capable?(s.renderMode===6?"body":s.renderMode===5?"focus":s.renderMode===4?"coherence":s.renderMode===3?"clarity":"music"): p86Capable?(s.renderMode===5?"focus":s.renderMode===4?"coherence":s.renderMode===3?"clarity":"music"): p85Capable?(s.renderMode===4?"coherence":s.renderMode===3?"clarity":"music"): @@ -312,7 +323,7 @@ function render(){ $("skElevationValue").textContent=s.directElevationDegrees.toFixed(1)+"°"; } const alignRow=$("skHrtfAlignRow"),align=$("skHrtfAlign"); - alignRow.hidden=!(p88Capable&&s.renderMode===7); + alignRow.hidden=!(p88Capable&&(s.renderMode===7||s.renderMode===8)); if(!alignRow.hidden){ const min=Math.max(-30,-40-s.directElevationDegrees); const max=Math.min(20,60-s.directElevationDegrees); @@ -320,7 +331,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=p88Capable&&s.renderMode===7? + root.querySelector(".sk-stage-caption").textContent=p89Capable&&s.renderMode===8? + "P8.9 ROOM-ANCHORED STEREO · DIRECT MUSICAL BODY PRESERVED · FAT REQUIRED": + p88Capable&&s.renderMode===7? "P8.8 EAR-LEVEL HRTF ALIGNMENT · PHYSICAL XYZ INDEPENDENT · FAT REQUIRED": p87Capable&&s.renderMode===6? "P8.7 FOCUSED MUSIC · DIRECT AIR + DIFFUSE LF BODY · FAT REQUIRED": @@ -359,7 +372,8 @@ function render(){ // redrawn at 60 Hz. The native audio callback remains the time authority. drawSpeakers(); $("skMode").textContent=native()?(context()? - (p88Capable&&s.renderMode===7?"NATIVE P8.8 EAR ALIGN + DISTANCE · TEST": + (p89Capable&&s.renderMode===8?"NATIVE P8.9 STEREO + ROOM · TEST": + p88Capable&&s.renderMode===7?"NATIVE P8.8 EAR ALIGN + DISTANCE · TEST": p87Capable&&s.renderMode===6?"NATIVE P8.7 MUSICAL AIR + BODY · TEST": p86Capable&&s.renderMode===5?"NATIVE P8.6 HORIZONTAL FOCUS · TEST": p85Capable&&s.renderMode===4?"NATIVE P8.5 WORLD COHERENCE · TEST": @@ -509,7 +523,7 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ String(r.deviceEpoch)!==String(c.deviceEpoch)|| String(r.graphRevision)!==String(c.graphRevision))return; const measured=(r.schemaVersion===3 || r.schemaVersion===4 || - r.schemaVersion===5 || r.schemaVersion===6 || r.schemaVersion===7 || r.schemaVersion===8 || r.schemaVersion===9) && + r.schemaVersion===5 || r.schemaVersion===6 || r.schemaVersion===7 || r.schemaVersion===8 || r.schemaVersion===9 || r.schemaVersion===10) && Number.isFinite(r.settings?.directElevationDegrees); if(r.schemaVersion!==2&&!measured)return; const incoming=normalizeSettings(r.settings); @@ -521,7 +535,9 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ Number.isInteger(incoming.renderMode) && typeof incoming.musicCompatibleLowFrequency==="boolean" && Number.isFinite(incoming.headYawDegrees); - p88Capable=r.schemaVersion===9 && r.p88PerceptualAlignment===true && + p89Capable=r.schemaVersion===10 && r.p89StereoRoomDepth===true && + Number.isFinite(incoming.hrtfElevationTrimDegrees); + p88Capable=(r.schemaVersion===9||p89Capable) && r.p88PerceptualAlignment===true && Number.isFinite(incoming.hrtfElevationTrimDegrees); p87Capable=(r.schemaVersion===8||p88Capable) && r.p87MusicalAirBody===true; p86Capable=(r.schemaVersion===7 || p87Capable) && r.p86HorizontalFocus===true; @@ -532,7 +548,8 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ (p85Capable&&incoming.renderMode===4)|| (p86Capable&&incoming.renderMode===5)|| (p87Capable&&incoming.renderMode===6)|| - (p88Capable&&incoming.renderMode===7)) && + (p88Capable&&incoming.renderMode===7)|| + (p89Capable&&incoming.renderMode===8)) && typeof incoming.musicCompatibleLowFrequency==="boolean" && incoming.musicCompatibleLowFrequency===false && Number.isFinite(incoming.headYawDegrees); @@ -567,7 +584,7 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ } render(); }); -$("skClose").addEventListener("click",()=>{root.hidden=true;current=null;xyzCapable=false;p85Capable=false;p86Capable=false;p87Capable=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;musicSafeStereo=false;p8TransparentBass=false;p82MultibandRoom=false; cancelLiveTimer();pending=null;latest=null;readId="";readSentAt=0;dialDrag=null; drag=null;rangeEdits.clear();gestureStart.clear();lastLiveAt=0; if(clock!==null){clearInterval(clock);clock=null;} @@ -575,7 +592,8 @@ $("skClose").addEventListener("click",()=>{root.hidden=true;current=null;xyzCapa $("skRenderMode").addEventListener("change",()=>{ if(!(p83Capable||p84Capable))return; const v=$("skRenderMode").value; - const mode=p88Capable?(v==="align"?7:v==="body"?6:v==="focus"?5:v==="coherence"?4:v==="clarity"?3:0): + const mode=p89Capable?(v==="depth"?8:v==="align"?7:v==="body"?6:v==="focus"?5:v==="coherence"?4:v==="clarity"?3:0): + p88Capable?(v==="align"?7:v==="body"?6:v==="focus"?5:v==="coherence"?4:v==="clarity"?3:0): p87Capable?(v==="body"?6:v==="focus"?5:v==="coherence"?4:v==="clarity"?3:0): p86Capable?(v==="focus"?5:v==="coherence"?4:v==="clarity"?3:0): p85Capable?(v==="coherence"?4:v==="clarity"?3:0): diff --git a/src/Main.cpp b/src/Main.cpp index efbca21f1..5618ac7b0 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -3046,7 +3046,17 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr armix::sonku::SonKuReflectionProfile::SixSurfaceKemarResearch) reply->setProperty("p8TransparentBass",true); #endif -#if defined(ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT + if(processor && processor->preparedReflectionProfile()== + armix::sonku::SonKuReflectionProfile::SixSurfaceKemarResearch) { + reply->setProperty("p84MusicFusion",true); + reply->setProperty("p85AcousticCoherence",true); + reply->setProperty("p86HorizontalFocus",true); + reply->setProperty("p87MusicalAirBody",true); + reply->setProperty("p88PerceptualAlignment",true); + reply->setProperty("p89StereoRoomDepth",true); + } +#elif defined(ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT if(processor && processor->preparedReflectionProfile()== armix::sonku::SonKuReflectionProfile::SixSurfaceKemarResearch) { reply->setProperty("p84MusicFusion",true); diff --git a/src/SonKuNativeBridgeContract.h b/src/SonKuNativeBridgeContract.h index d9f6b7c02..9c9924e78 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_P88_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT + return 10; +#elif defined(ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT return 9; #elif defined(ARMIX_SONKU_EXPERIMENTAL_P87_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P87_NATIVE_RT return 8; @@ -98,7 +100,11 @@ inline bool decodeSettings(const juce::var& values,armix::sonku::Settings& out) #if defined(ARMIX_SONKU_EXPERIMENTAL_P86_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P86_NATIVE_RT #if defined(ARMIX_SONKU_EXPERIMENTAL_P87_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P87_NATIVE_RT #if defined(ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT + if(proposed.renderMode!=0 && proposed.renderMode!=3 && proposed.renderMode!=4 && proposed.renderMode!=5 && proposed.renderMode!=6 && proposed.renderMode!=7 && proposed.renderMode!=8)return false; +#else if(proposed.renderMode!=0 && proposed.renderMode!=3 && proposed.renderMode!=4 && proposed.renderMode!=5 && proposed.renderMode!=6 && proposed.renderMode!=7)return false; +#endif #else if(proposed.renderMode!=0 && proposed.renderMode!=3 && proposed.renderMode!=4 && proposed.renderMode!=5 && proposed.renderMode!=6)return false; #endif diff --git a/tests/sonku_p89_native_juce_v10_test.cpp b/tests/sonku_p89_native_juce_v10_test.cpp new file mode 100644 index 000000000..dd2fbf37a --- /dev/null +++ b/tests/sonku_p89_native_juce_v10_test.cpp @@ -0,0 +1,242 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// REAL native Windows JUCE v10 SonKu P8.9 headphone research: +// P8.2 -> native queued v10 -> fading -> AUDIO APPLIED ACK -> readback, +// v1..v10 .smix state, old v4 rejected physical rollback, v9 HRTF trim intact and no extra graph. +#if defined(NDEBUG) +#undef NDEBUG +#endif +#if !defined(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) || !ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT +#error Native JUCE v10 test requires explicit private P8.9 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 && "P89 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(version>=5?0:1);o.writeFloat(0.f); + } + if(version>=9)o.writeFloat(-12.f); + } // MemoryOutputStream must flush byte count before asserting the block. + assert(bytes.getSize()==static_cast( + version==1?30:version==2?46:version==3?50:version>=9?63:59)); + return bytes; +} +int main(){ + static_assert(schemaVersion()==10); + 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=8;s.hrtfElevationTrimDegrees=-12.f; + auto json=acceptedSettings(s); + Settings decoded{}; + assert(decodeSettings(json,decoded)&&decoded.renderMode==8); + for(int rejected:{-1,1,2,9,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==8); + juce::MemoryBlock snapshot; + fx->getStateInformation(snapshot); + assert(snapshot.getSize()==63); + juce::MemoryInputStream input(snapshot.getData(),snapshot.getSize(),false); + assert(input.readInt()==0x534f4e4b&&input.readInt()==10); + auto restored=std::make_unique(); + restored->prepareToPlay(44100.,128); + assert(restored->restoreUnpublishedState( + snapshot.getData(),static_cast(snapshot.getSize()))); + assert(restored->acceptedSettings().renderMode==8); + assert(restored->acceptedSettings().hrtfElevationTrimDegrees==-12.f); + restored->prepareToPlay(48000.,256); + assert(restored->isReady() && restored->acceptedSettings().renderMode==8); + // 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 v10 transaction. + s.headYawDegrees=60.f; + assert(fx->queueSettings(s,802)); + complete(*fx,802,400); + assert(fx->acceptedSettings().renderMode==8); + 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=8; + assert(offline->queueSettings(s,901)); + offline->consumeRealtimeEdits(); + assert(offline->pollCompletion(ack)&&ack.applied&&ack.requestId==901); + assert(offline->acceptedSettings().renderMode==8); + assert(offline->stateSnapshotQuiescent()); + // Old v4 SpeakerPhysical and music-LF480 are REJECTED acoustically. + // When migrated into a v10 research binary, they explicitly fall back P8.2. + // Backward-compatible v5 P8.4 session must keep exact mode 3. + { + const auto v5=legacy(5,3); + auto p84=std::make_unique(); + p84->prepareToPlay(48000.,128); + assert(p84->restoreUnpublishedState(v5.getData(),static_cast(v5.getSize()))); + assert(p84->acceptedSettings().renderMode==3); + } + // v6 P8.5 world-coherence sessions restore unchanged; never rewritten as focus. + { + const auto v6=legacy(6,4); + auto p85=std::make_unique(); + p85->prepareToPlay(48000.,128); + assert(p85->restoreUnpublishedState(v6.getData(),static_cast(v6.getSize()))); + assert(p85->acceptedSettings().renderMode==4); + } + // v7 P8.6 focused music session must retain render mode 5, not 6. + { + const auto v7=legacy(7,5); + auto p86=std::make_unique(); + p86->prepareToPlay(48000.,128); + assert(p86->restoreUnpublishedState(v7.getData(),static_cast(v7.getSize()))); + assert(p86->acceptedSettings().renderMode==5); + } + // v8 P8.7 session must preserve mode 6, and no HRTF trim is invented. + { + const auto v8=legacy(8,6); + auto p87=std::make_unique(); + p87->prepareToPlay(48000.,128); + assert(p87->restoreUnpublishedState(v8.getData(),static_cast(v8.getSize()))); + assert(p87->acceptedSettings().renderMode==6); + assert(p87->acceptedSettings().hrtfElevationTrimDegrees==0.f); + } + // Exact v9 P8.8 session must retain mode 7 and HRTF trim -12°. + { + const auto v9=legacy(9,7); + auto p88=std::make_unique(); + p88->prepareToPlay(48000.,128); + assert(p88->restoreUnpublishedState(v9.getData(),static_cast(v9.getSize()))); + assert(p88->acceptedSettings().renderMode==7); + assert(p88->acceptedSettings().hrtfElevationTrimDegrees==-12.f); + } + 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); + } + } + // Even legacy v4 MusicBed with a stale LF480 toggle must be sanitized + // so the new v10 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(),62)); + 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(),63)); + corrupt=snapshot;ptr=static_cast(corrupt.getData()); + ptr[50]=2;ptr[51]=ptr[52]=ptr[53]=0; // old physical mode in v10 forbidden + assert(!broken->restoreUnpublishedState(corrupt.getData(),63)); + restored->sealForRealtime(); + assert(!restored->restoreUnpublishedState(snapshot.getData(),63)); + std::printf("PASS P89 JUCE v10: audio ACK fade, single native graph A/B, " + "safe v1-v9 migration, v10 63-byte state and device reopen; " + "P89_vs_P82_RMS_dB=%.3f; ASIO/headphone NOT PROVEN\n",relativeDb); +} diff --git a/tests/sonku_p89_stereo_room_depth_source_test.cpp b/tests/sonku_p89_stereo_room_depth_source_test.cpp new file mode 100644 index 000000000..28c2e296c --- /dev/null +++ b/tests/sonku_p89_stereo_room_depth_source_test.cpp @@ -0,0 +1,137 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// P8.9 P8.8 AB: no head-locked stereo collapse, no muted music, no reverb-only fake stage. +#if defined(NDEBUG) +#undef NDEBUG +#endif +#if !defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) || !SONKU_P89_DEPTH_COHERENCE_RESEARCH +#error P8.9 real native source build gate required +#endif +#include "../engine/builtin_fx/sonku/SonKuSpatialCore.h" +#include +#include +#include +#include +#include +#include +using armix::sonku::SonKuSpatialCore; +using armix::sonku::SonKuReflectionProfile; +using armix::sonku::Settings; +struct Stereo{std::vector left,right;}; +static constexpr float pi=3.14159265358979323846f; +static Stereo render(int mode,int rate,int chunk,int room,float distance, + float early,float tail,float yaw,bool anti=false, + float spectralTrim=-10.f,float mix=1.f){ + constexpr int frames=16384; + auto fx=std::make_unique(); + assert(fx->prepare(rate,SonKuReflectionProfile::SixSurfaceKemarResearch)); + Settings s{};s.renderMode=mode;s.spacePreset=room; + s.sourceDistanceMeters=distance;s.roomAmount=early;s.ambience=tail; + s.moving=false;s.startAzimuthDegrees=24.f;s.stereoSpreadDegrees=60.f; + s.headYawDegrees=yaw;s.directElevationDegrees=0.f; + s.hrtfElevationTrimDegrees=spectralTrim;s.spatialMix=mix;s.outputTrim=.75f; + assert(fx->setSettings(s)); + Stereo out{std::vector(frames),std::vector(frames)}; + for(int i=0;i(i)/static_cast(rate); + const float mid=.17f*std::sin(2*pi*87.f*t)+.11f*std::sin(2*pi*640.f*t) + +.05f*std::sin(2*pi*4800.f*t); + const float side=.07f*std::sin(2*pi*1700.f*t); + out.left[i]=mid+side+(i==31?.09f:0.f); + out.right[i]=anti?-out.left[i]:mid-side+(i==31?.09f:0.f); + } + for(int i=0;iprocess(out.left.data()+i,out.right.data()+i,std::min(chunk,frames-i)); + return out; +} +static double power(const Stereo& s,int first=4096){ + double result=0; + for(std::size_t i=0;i=static_cast(first)) + result+=double(s.left[i])*s.left[i]+double(s.right[i])*s.right[i]; + } + return result; +} +static double difference(const Stereo& x,const Stereo& y){ + assert(x.left.size()==y.left.size());double d=0; + for(std::size_t i=0;i.002); + } + // NO arbitrary added coloration at the approved close 1.6m, even with + // measured wall HRIR and FDN live. Only farther listening changes balance. + for(bool anti:{false,true}){ + auto old=render(7,rate,128,3,1.6f,1.f,1.f,0.f,anti); + auto now=render(8,rate,128,3,1.6f,1.f,1.f,0.f,anti); + assert(difference(old,now)==0.); + } + // At 7.3m direct only, full antiphase music SIDE remains strongly audible, + // but headlocked SIDE becomes less dominant. Bass is retained by P8.8 LF. + auto oldDirect=render(7,rate,128,3,7.3f,0.f,0.f,0.f,true); + auto newDirect=render(8,rate,128,3,7.3f,0.f,0.f,0.f,true); + assert(power(oldDirect)>.001&&power(newDirect)>.001); + const double ratio=power(newDirect)/power(oldDirect); + assert(ratio>.42&&ratio<.99); + // Horizontal measured early wall reflections gain relevance relative to + // the headphone SIDE. Test the real difference, not unrendered coefficients. + const auto p88Wet=render(7,rate,128,3,7.3f,1.f,0.f,0.f,false); + const auto p88Dry=render(7,rate,128,3,7.3f,0.f,0.f,0.f,false); + const auto p89Wet=render(8,rate,128,3,7.3f,1.f,0.f,0.f,false); + const auto p89Dry=render(8,rate,128,3,7.3f,0.f,0.f,0.f,false); + const double refEr=earlyDifferencePower(p88Wet,p88Dry); + const double focusedEr=earlyDifferencePower(p89Wet,p89Dry); + assert(refEr>1.e-10&&focusedEr>refEr*1.01); + // Owner stress: 100% early and reverb, measured HRTF, 7.3m LARGE; + // chunk independence, no zero output, no NaN, no output hard clipping. + for(bool anti:{false,true}){ + const auto stressed=render(8,rate,128,3,7.3f,1.f,1.f,0.f,anti); + const auto smaller=render(8,rate,64,3,7.3f,1.f,1.f,0.f,anti); + assert(difference(stressed,smaller)==0.); + assert(power(stressed)>.005); + } + // Legacy/offline dry mix still bit-identical and independent of P8.9. + auto dry=render(8,rate,128,3,7.3f,1.f,1.f,0.f,false,-10.f,0.f); + auto dryP88=render(7,rate,128,3,7.3f,1.f,1.f,0.f,false,-10.f,0.f); + // A 0%-mix edit is deliberately smoothed from the initial active DSP + // value. Compare settled dry PCM after the crossfade, not startup wet. + assert(differenceAfter(dry,dryP88,8192)==0.); + Settings invalid{};invalid.renderMode=8;invalid.spacePreset=3; + invalid.sourceDistanceMeters=7.3f;invalid.hrtfElevationTrimDegrees=-10.f; + assert(armix::sonku::valid(invalid)); + invalid.hrtfElevationTrimDegrees=-35.f; + assert(!armix::sonku::valid(invalid)); + std::printf("P89_DEPTH_RATE,%d,anti_side_ratio=%.6f,ER_ratio=%.6f\n", + rate,ratio,focusedEr/refEr); + } + std::puts("PASS P89 ROOM ANCHOR: 44.1/48k exact P88 OFF and close-field, live far directional ER vs headphone SIDE, phase-safe MUSIC, 64/128"); +}