diff --git a/.github/workflows/sonku-p74-windows-field.yml b/.github/workflows/sonku-p74-windows-field.yml index c717caa42..6ba708ca6 100644 --- a/.github/workflows/sonku-p74-windows-field.yml +++ b/.github/workflows/sonku-p74-windows-field.yml @@ -21,6 +21,9 @@ concurrency: cancel-in-progress: true jobs: preflight: + # Stacked P8 releases must NOT rebuild three old full JUCE Windows hosts. + # The corresponding workflow remains manually dispatchable at any SHA. + if: ${{ github.event_name == 'workflow_dispatch' || github.head_ref == 'integration/sonku-p74-windows-field-20261114' }} name: Isolated fast PCM and GUI preflight runs-on: ubuntu-latest timeout-minutes: 8 diff --git a/.github/workflows/sonku-p75-windows-field.yml b/.github/workflows/sonku-p75-windows-field.yml index adad0dc3f..bdfafb211 100644 --- a/.github/workflows/sonku-p75-windows-field.yml +++ b/.github/workflows/sonku-p75-windows-field.yml @@ -22,6 +22,9 @@ concurrency: cancel-in-progress: true jobs: preflight: + # Stacked P8 releases must NOT rebuild three old full JUCE Windows hosts. + # The corresponding workflow remains manually dispatchable at any SHA. + if: ${{ github.event_name == 'workflow_dispatch' || github.head_ref == 'fix/sonku-p75-phase-safe-music-20261114' }} name: Isolated fast PCM and GUI preflight runs-on: ubuntu-latest timeout-minutes: 8 diff --git a/.github/workflows/sonku-p80-acoustic-field.yml b/.github/workflows/sonku-p80-acoustic-field.yml index 8bec9f26b..c12468d81 100644 --- a/.github/workflows/sonku-p80-acoustic-field.yml +++ b/.github/workflows/sonku-p80-acoustic-field.yml @@ -24,6 +24,9 @@ concurrency: cancel-in-progress: true jobs: preflight: + # Stacked P8 releases must NOT rebuild three old full JUCE Windows hosts. + # The corresponding workflow remains manually dispatchable at any SHA. + if: ${{ github.event_name == 'workflow_dispatch' || github.head_ref == 'feat/sonku-p80-measured-acoustics-timbre-20261114' }} name: Isolated fast PCM and GUI preflight runs-on: ubuntu-latest timeout-minutes: 8 diff --git a/.github/workflows/sonku-p82-room-field.yml b/.github/workflows/sonku-p82-room-field.yml new file mode 100644 index 000000000..c5111daac --- /dev/null +++ b/.github/workflows/sonku-p82-room-field.yml @@ -0,0 +1,283 @@ +name: SonKu P8.2 geometric late-room Windows acoustic field candidate +# Isolated opt-in full JUCE app build; no public installer, tag or release. +on: + pull_request: + types: [opened, reopened, synchronize] + paths: + - '.github/workflows/sonku-p75-windows-field.yml' + - 'src/Main.cpp' + - 'src/SonKuNativeBridgeContract.h' + - 'src/LiveAudioEngine.h' + - 'engine/builtin_fx/SonKuSpatialProcessor.h' + - 'engine/builtin_fx/sonku/**' + - 'site/preview-v2/assets/mixer-native-sonku.js' + - 'CMakeLists.txt' + - 'tests/sonku_p72_*' + - 'tests/sonku_p75_*' + - 'tests/sonku_p80_*' + - 'tests/sonku_p82_*' + - 'scripts/sonku_p82_room_evidence.py' + - 'scripts/sonku_p80_evidence.py' + workflow_dispatch: +permissions: + contents: read +concurrency: + group: sonku-p82-room-${{ 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: Native JS and source GUI capability checks + run: | + set -euo pipefail + node --check site/preview-v2/assets/mixer-native-sonku.js + node tests/sonku_p73_gui_contract_test.js + grep -q "'FIELD_PREVIEW_FULL_CTEST_NOT_RUN'" scripts/m3e_fat_evidence_gate.mjs + python -m unittest discover -s tests -p native_peq_assembly_test.py + - name: 44.1 and 48 kHz prepared PCM source regression + run: | + set -euo pipefail + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 \ + -DSONKU_P72_NATIVE_XYZ_RT=1 \ + tests/sonku_p72_realtime_xyz_test.cpp -o /tmp/sonku-p80-legacy-pcm + /tmp/sonku-p80-legacy-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 + # Baseline and measured P8.0 compile the SAME source tree with + # exactly one flag changed. Compare every source and ROOM scene. + mkdir -p evidence + 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_p80_acoustic_probe.cpp -o /tmp/sonku-p80-baseline + /tmp/sonku-p80-baseline evidence + 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_MEASURED_TIMBRE_RESEARCH=1 \ + tests/sonku_p80_acoustic_probe.cpp -o /tmp/sonku-p80-measured + /tmp/sonku-p80-measured evidence + 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_MEASURED_TIMBRE_RESEARCH=1 \ + tests/sonku_p80_timbre_calibration_test.cpp -o /tmp/sonku-p80-qa + /tmp/sonku-p80-qa + python scripts/sonku_p80_evidence.py evidence + # Add only a physics-grounded late-onset ring; every source and + # timbre flag is identical to P8.0 reference. + 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_MEASURED_TIMBRE_RESEARCH=1 \ + -DSONKU_P82_GEOMETRIC_LATE_RESEARCH=1 \ + tests/sonku_p80_acoustic_probe.cpp -o /tmp/sonku-p82-measured + /tmp/sonku-p82-measured evidence + g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P82_GEOMETRIC_LATE_RESEARCH=1 \ + tests/sonku_p82_geometry_predelay_test.cpp -o /tmp/sonku-p82-room-test + /tmp/sonku-p82-room-test + python scripts/sonku_p82_room_evidence.py evidence + git rev-parse HEAD > evidence/SOURCE_SHA.txt + - name: Upload inspectable source-side acoustic evidence + uses: actions/upload-artifact@v4 + with: + name: SonKu-P82-Objective-Evidence-${{ github.run_id }} + path: evidence/ + retention-days: 21 + if-no-files-found: error + 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_P82_SOURCE_MISMATCH:$actual" + } + Write-Host "SONKU_P82_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_P80_TIMBRE=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P82_ROOM=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_P80_TIMBRE:BOOL=ON' -or + $cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P82_ROOM:BOOL=ON') { + throw "SONKU_P82_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', + 'NativeSonKuP80MeasuredHrtfTimbreAndChunkParity', + 'NativeSonKuP82GeometryLateArrivalAndFreshTail') + $available = @($tests.tests | ForEach-Object { $_.name }) + foreach ($test in $required) { + if ($test -notin $available) { throw "SONKU_P82_MISSING_CTEST:$test" } + } + - name: Compile actual ARMixConsole Windows GUI and focused real JUCE tests + shell: pwsh + run: | + cmake --build build --config Release --parallel 2 --target ` + ARMixConsole ARMixSonKuP72SourceTests ARMixSonKuP72NativeTests ARMixSonKuNativeStateTests ARMixSonKuP75MusicIntegrityTests ARMixSonKuP80MeasuredTimbreTests ARMixSonKuP82RoomTests + 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_P82_NO_GUI_EXE" } + if ((Get-Item -LiteralPath $exe).Length -lt 4MB) { throw "SONKU_P82_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|P80MeasuredHrtfTimbreAndChunkParity|P82GeometryLateArrivalAndFreshTail)$' + 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_P82_ARTIFACT_SHA_MISMATCH" } + $p.fatStatus = 'FIELD_PREVIEW_FULL_CTEST_NOT_RUN' + $p | Add-Member -NotePropertyName sonkuExperiment -NotePropertyValue @{ + enabled = $true + nativeXYZ = $true + musicSafeStereo = $true + measuredTimbre = $true + roomGeometryLate = $true + latePropagationLaw = 'ROOM_WIDTH_METERS_DIVIDED_BY_343_M_PER_S' + measuredTimbreMaxLowShelfDb = 4.5 + measuredHrtfReference = 'KEMAR_0_90_180_BOTH_EARS_125HZ_VS_1000HZ' + musicSafeAlgorithm = 'MEASURED_CENTER_MID_PLUS_UNCONDITIONAL_STEREO_SIDE_RESEARCH' + stateSchema = 3 + fullWindowsExecutable = $true + publicRelease = $false + physicalAsioQualified = $false + dearVrPerceptualParityProven = $false + qualification = 'SONKU_P82_6_FOCUSED_CTESTS_ONLY_REAL_ASIO_MUSIC_DEARVR_PENDING' + licenseRedistributionApproval = $false + mitKemarNoticeSha256 = (Get-FileHash -LiteralPath docs/THIRD_PARTY_8D_SONKU_HRTF.md -Algorithm SHA256).Hash.ToLowerInvariant() + fieldFatGuideSha256 = (Get-FileHash -LiteralPath docs/SONKU_P82_GEOMETRIC_ROOM_FIELD_GUIDE_20261114.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.measuredTimbre -or + -not $p.sonkuExperiment.roomGeometryLate -or + $p.sonkuExperiment.stateSchema -ne 3 -or $p.sonkuExperiment.publicRelease) { + throw 'SONKU_P82_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_P82_GEOMETRIC_ROOM_FIELD_GUIDE_20261114.md -Destination dist/SONKU_P82_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_P82_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_P82_FIELD_NOTICE_MISSING:$($item.Key)" + } + $actual = (Get-FileHash -LiteralPath $file -Algorithm SHA256).Hash.ToLowerInvariant() + if ($actual -ne $item.Value) { throw "SONKU_P82_FIELD_NOTICE_HASH_MISMATCH:$($item.Key)" } + } + if (Test-Path -LiteralPath dist/Studio) { throw 'SONKU_FIELD_USER_DATA_MUST_NOT_SHIP' } + Write-Host 'SONKU_P82_FIELD_READY: GUI EXE + verified MIT notice + FAT guide' + - name: Include same-head objective A/B evidence in the portable tester + uses: actions/download-artifact@v4 + with: + name: SonKu-P82-Objective-Evidence-${{ github.run_id }} + path: dist/P82_objective_evidence + - name: Verify objective artifact belongs to this exact native EXE + shell: pwsh + run: | + $expected = (& git rev-parse HEAD).Trim() + $source = (Get-Content -LiteralPath dist/P82_objective_evidence/SOURCE_SHA.txt -Raw).Trim() + $report = Get-Content -LiteralPath dist/P82_objective_evidence/sonku_p80_evidence.json -Raw | ConvertFrom-Json + $roomReport = Get-Content -LiteralPath dist/P82_objective_evidence/sonku_p82_room_evidence.json -Raw | ConvertFrom-Json + if ($source -ne $expected -or + $report.status -ne 'PASS_OBJECTIVE_SPECTRAL_STEREO_ROOM_PRESENCE_ONLY' -or + $roomReport.status -ne 'PASS_GEOMETRIC_LATE_ONSET_ONLY_NOT_DEARVR_PARITY') { + throw 'SONKU_P82_OBJECTIVE_EVIDENCE_SHA_OR_STATUS_MISMATCH' + } + - uses: actions/upload-artifact@v4 + name: Upload isolated SonKu Windows x64 field candidate + with: + name: ArSonMix-SonKu-P82-Geometric-Room-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 ff2e29617..24adbc524 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,13 @@ if(ARMIX_SONKU_EXPERIMENTAL_P80_TIMBRE AND NOT ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT)) message(FATAL_ERROR "P8.0 measured timbre needs BOTH P7.5 music-safe and P7.2 XYZ research ON") endif() +option(ARMIX_SONKU_EXPERIMENTAL_P82_ROOM + "Research-only P8.2 room geometry late-field predelay on native XYZ" + OFF) +if(ARMIX_SONKU_EXPERIMENTAL_P82_ROOM AND + NOT ARMIX_SONKU_EXPERIMENTAL_P80_TIMBRE) + message(FATAL_ERROR "P8.2 room requires explicit measured P8.0 opt-in") +endif() set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -228,7 +235,8 @@ target_compile_definitions(ARMixConsole PRIVATE $<$:SONKU_P71_DIRECT_XYZ_RESEARCH=1> $<$:SONKU_P72_NATIVE_XYZ_RT=1> $<$:SONKU_P75_MUSIC_SAFE_RESEARCH=1> - $<$:SONKU_P80_MEASURED_TIMBRE_RESEARCH=1>) + $<$:SONKU_P80_MEASURED_TIMBRE_RESEARCH=1> + $<$:SONKU_P82_GEOMETRIC_LATE_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. @@ -375,6 +383,19 @@ if(BUILD_TESTING) SONKU_P80_MEASURED_TIMBRE_RESEARCH=1) add_test(NAME NativeSonKuP80MeasuredHrtfTimbreAndChunkParity COMMAND ARMixSonKuP80MeasuredTimbreTests) + if(ARMIX_SONKU_EXPERIMENTAL_P82_ROOM) + target_compile_definitions(ARMixSonKuP72NativeTests PRIVATE + SONKU_P82_GEOMETRIC_LATE_RESEARCH=1) + target_compile_definitions(ARMixSonKuP80MeasuredTimbreTests PRIVATE + SONKU_P82_GEOMETRIC_LATE_RESEARCH=1) + add_executable(ARMixSonKuP82RoomTests + tests/sonku_p82_geometry_predelay_test.cpp) + target_compile_features(ARMixSonKuP82RoomTests PRIVATE cxx_std_20) + target_compile_definitions(ARMixSonKuP82RoomTests PRIVATE + SONKU_P82_GEOMETRIC_LATE_RESEARCH=1) + add_test(NAME NativeSonKuP82GeometryLateArrivalAndFreshTail + COMMAND ARMixSonKuP82RoomTests) + endif() endif() endif() endif() diff --git a/docs/SONKU_P82_GEOMETRIC_ROOM_FIELD_GUIDE_20261114.md b/docs/SONKU_P82_GEOMETRIC_ROOM_FIELD_GUIDE_20261114.md new file mode 100644 index 000000000..4a059524a --- /dev/null +++ b/docs/SONKU_P82_GEOMETRIC_ROOM_FIELD_GUIDE_20261114.md @@ -0,0 +1,40 @@ +# SonKu P8.2 — six-wall geometry vs late diffuse-field arrival + +**Research-only, NO claim of parity with dearVR PRO 2.** P8.0 fixes a *measured low/mid ratio*; P8.2 fixes a different, measured room-time ordering defect. P7.4 cancellation, P7.5 thin/nasal timbre, and insufficient externalization remain owner reported FAILS until independently re-tested. + +## Why this change has physical grounding + +P8.0 objective impulse through the exact native `SonKuSpatialCore` reference (48 kHz, SQUARE 7.2 m, AZ 35°, roomAmount 65%, ambience 45%, virtual source 1.6 m) produced: +- direct first 20 ms energy ≈ **0.007308**; +- isolated six-wall early reflections energy in 20–100 ms ≈ **4.383×10⁻⁶**; +- isolated late FDN in 20–100 ms ≈ **1.751×10⁻⁴**. + +That is roughly **40:1 energy in favor of late ambience** over first reflections in the same early temporal window. Thus real first wall directions can be masked. It is a *source-derived synthetic impulse observation*, not a microphone measurement, user music or dearVR capture. A solution must not simply amplify the whole reverb. + +For an original hybrid room model we first preserve the six-wall image-source delays unchanged, then give the LATE diffuse FDN an additional causal propagation interval proportional to full room width: distance/speed-of-sound (343 m/s). Prepared control-side, not PCM-side: +- SQUARE 7.2 m: **21 ms** late predelay, +- CHAMBER 14.4 m: **42 ms** late predelay, +- LARGE 28.8 m: **84 ms** late predelay. + +This is a **research hypothesis**, not a claim that dearVR or physical room diffusion necessarily uses the same law. FDN still has its inherent ~44ms first delay. Direct KEMAR and six-wall ER coefficients, XYZ position and prior P8.0 timbre are unchanged. + +## Implementation and CPU rules + +`ARMIX_SONKU_EXPERIMENTAL_P82_ROOM=ON` requires P80 timbre + P7.5 music-safe + P7.2 native XYZ opt-ins. It is **OFF in public**. Uses fixed two-channel 4096-sample predelay rings, per-sample O(1) reads/writes, and 512-frame smooth retarget across active room presets. No heap/mutex/FFT/trig/disk I/O on the audio callback. Device/restart and OFF→ON use a freshness horizon without clearing 32 KiB on the callback. Legacy default room DSP remains byte-identical. + +Native GUI only shows the **NATIVE ROOM P8.2 · RESEARCH** label after a valid identity-matched actual v3 SonKu snapshot including numeric `roomLatePreDelaySamples`. No new serialized state fields or new audio authority. + +## Evidence and FAT + +The CI compares the same commit built with P80 vs P82 room flags, generating `sonku_P80_room.csv` and `sonku_P82_room.csv`. The C++ late-onset test asserts physical room width onset at 44.1/48k for all 3 room sizes and no stale post-reset tail. Python validates that ROOM OFF direct spectra and isolated six-wall ER are numerically unchanged, that late energy in 20–100ms is reduced (not muted), and that late tail after 100ms survives. A full Windows JUCE build (same `ARMixConsole`) with native XYZ ACK and provenance is required. + +Use a headphone interface at low level. Compare baseline P7.5, P8.0 and P8.2 at matched level: +1. ROOM OFF: equal bass fullness and original stereo SIDE; any new cancellation REJECT. +2. SQUARE 7.2m: compare early arrival direction, late onset, sense of cube size vs P8.0, without treating more echo as automatically better. +3. CHAMBER 14.4m and LARGE 28.8m: perceived room size should increase with travel delay; test short transients and acoustic guitar/voice, not only sinusoidal waves. +4. Compare with independently configured dearVR PRO 2 (Clarity, Bass Boost OFF/ON, ER/late separate, wall geometry and room preset logged). A/B headphone actual acoustic judgment is **still mandatory**. +5. Test 44.1/48k, 64/128/256 ASIO and 1/2/4 inserts, WIRE and VST3, Save/Open `.smix`, restart, p95/p99, XRUN. No production admission without physical evidence. + +## What P8.2 does NOT solve + +This change does **not** yet implement a true stereophonic 2-object binaural matrix, calibrated frequency-dependent wall absorption, measured BRIR, room-time multi-band RT60, listener-specific HRTF, or auditory equivalence to dearVR. P8.1 and room-material research must be addressed separately. Never release based on successful sine/impulse CI alone. Original KEMAR attribution: `docs/THIRD_PARTY_8D_SONKU_HRTF.md`. diff --git a/engine/builtin_fx/SonKuSpatialProcessor.h b/engine/builtin_fx/SonKuSpatialProcessor.h index fa31e151f..7ecbea100 100644 --- a/engine/builtin_fx/SonKuSpatialProcessor.h +++ b/engine/builtin_fx/SonKuSpatialProcessor.h @@ -89,6 +89,11 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, float preparedTimbreShelfDb() const noexcept { return core_.p80PreparedShelfDb(); } +#endif +#if defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) && SONKU_P82_GEOMETRIC_LATE_RESEARCH + int preparedRoomLatePreDelaySamples() const noexcept { + return core_.p82PreparedRoomLatePreDelaySamples(); + } #endif float observedAzimuthDegrees() const noexcept { return observedAzimuthDegrees_.load(std::memory_order_relaxed); diff --git a/engine/builtin_fx/sonku/SonKuMusicalReverb.h b/engine/builtin_fx/sonku/SonKuMusicalReverb.h index ab76c230e..f30257692 100644 --- a/engine/builtin_fx/sonku/SonKuMusicalReverb.h +++ b/engine/builtin_fx/sonku/SonKuMusicalReverb.h @@ -4,6 +4,9 @@ #include #include #include +#if defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) && SONKU_P82_GEOMETRIC_LATE_RESEARCH +#include "SonKuP82DiffuseInput.h" +#endif // Compact eight-line stereo FDN for musical late ambience. The 8x8 Hadamard // feedback matrix is orthogonal (unit-energy): stability depends solely on @@ -33,6 +36,18 @@ class SonKuMusicalReverb final { prepared_[1]=makeCoefficients(1.28f,7000.f); prepared_[2]=makeCoefficients(2.05f,6000.f); targetGain_=gain_;targetDamp_=dampCoeff_; +#if defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) && SONKU_P82_GEOMETRIC_LATE_RESEARCH + // Sound travels approximately one room width before a diffuse + // multi-bounce field becomes dominant. Prepared once, NEVER + // evaluate sqrt/pow/trig or allocate on the realtime callback. + constexpr std::array widths{7.2f,14.4f,28.8f}; + for(int k=0;k<3;++k) + preparedPredelay_[k]=std::clamp(static_cast(std::lround( + widths[k]*sampleRate_/343.f)),1,predelayRing-3); + predelayActive_=predelayTarget_=predelayPrevious_=preparedPredelay_[0]; + predelayPending_=-1;predelayRemaining_=0; + if(!diffuser_.prepare(rate))return false; +#endif realtimeMode_=false; reset(); ready_=true; @@ -42,6 +57,13 @@ class SonKuMusicalReverb final { for(auto& line:memory_)line.fill(0.f); lowpass_.fill(0.f); write_=0;amount_=0.f;validFrames_=0; +#if defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) && SONKU_P82_GEOMETRIC_LATE_RESEARCH + for(auto& channel:predelayMemory_)channel.fill(0.f); + predelayWrite_=0;predelayValidFrames_=0; + diffuser_.reset(); + predelayActive_=predelayTarget_;predelayPrevious_=predelayTarget_; + predelayPending_=-1;predelayRemaining_=0; +#endif // The target amount is a CONTROL-side setting and survives resetting // host transport/processor so the same program can restart cleanly. } @@ -59,6 +81,13 @@ class SonKuMusicalReverb final { if(active())return false; preset_=value; configure(); +#if defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) && SONKU_P82_GEOMETRIC_LATE_RESEARCH + // Inactive/offline preset setter must agree with the native runtime + // selector, not silently retain another room's propagation length. + predelayActive_=predelayPrevious_=predelayTarget_= + preparedPredelay_[static_cast(value)]; + predelayPending_=-1;predelayRemaining_=0; +#endif return true; } // Realtime-safe preset/wet update: only POD/table copies, no exponentials, @@ -69,7 +98,36 @@ class SonKuMusicalReverb final { preset!=SonKuReverbPreset::AiryChamber && preset!=SonKuReverbPreset::LargeRoom)|| !std::isfinite(amount)||amount<0.f||amount>1.f)return false; - if(!active() && amount>0.f){validFrames_=0;lowpass_.fill(0.f);} + const bool previouslyActive=active(); + if(!previouslyActive && amount>0.f){ + validFrames_=0;lowpass_.fill(0.f); +#if defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) && SONKU_P82_GEOMETRIC_LATE_RESEARCH + // Freshness horizon, no 32 KiB RT clear and no stale tail. + predelayValidFrames_=0; + diffuser_.invalidate(); +#endif + } +#if defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) && SONKU_P82_GEOMETRIC_LATE_RESEARCH + const int desiredDelay=preparedPredelay_[static_cast(preset)]; + if(!previouslyActive){ + predelayActive_=predelayPrevious_=predelayTarget_=desiredDelay; + predelayRemaining_=0;predelayPending_=-1; + }else if(desiredDelay!=predelayTarget_) { + if(predelayRemaining_==0){ + predelayPrevious_=predelayActive_; + predelayTarget_=desiredDelay; + predelayRemaining_=predelayFadeFrames; + }else{ + // Latest wins without snapping a moving fractional delay; + // finish the audible crossfade before starting the next. + predelayPending_=desiredDelay; + } + }else if(predelayRemaining_>0) { + // A newer edit can cancel a queued retarget: never re-apply an + // obsolete pending room after returning to the active goal. + predelayPending_=-1; + } +#endif const auto& coefficients=prepared_[static_cast(preset)]; targetGain_=coefficients.gains; targetDamp_=coefficients.damping; @@ -82,12 +140,60 @@ class SonKuMusicalReverb final { SonKuReverbPreset preset() const noexcept {return preset_;} bool active() const noexcept {return ready_&&(amount_>0.f||amountTarget_>0.f);} float targetAmount() const noexcept {return amountTarget_;} +#if defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) && SONKU_P82_GEOMETRIC_LATE_RESEARCH + int preparedLatePredelaySamples() const noexcept { + return preparedPredelay_[static_cast(preset_)]; + } +#endif Ears process(float left,float right) noexcept { if(!active())return {}; const float a=std::isfinite(left)?left:0.f; const float b=std::isfinite(right)?right:0.f; const float mid=.5f*(a+b); const float side=.5f*(a-b); +#if defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) && SONKU_P82_GEOMETRIC_LATE_RESEARCH + // Direct and six-wall ER are untouched; only the late FDN input + // takes a physically dimensioned diffuse-field propagation delay. + auto readDelayed=[&](int d,int channel) noexcept { + if(predelayValidFrames_0) { + const float t=1.f-static_cast(predelayRemaining_)/ + predelayFadeFrames; + lateMid=(1.f-t)*readDelayed(predelayPrevious_,0)+t*lateMid; + lateSide=(1.f-t)*readDelayed(predelayPrevious_,1)+t*lateSide; + --predelayRemaining_; + if(predelayRemaining_==0) { + predelayActive_=predelayTarget_; + if(predelayPending_>=0 && + predelayPending_!=predelayActive_) { + predelayPrevious_=predelayActive_; + predelayTarget_=predelayPending_; + predelayRemaining_=predelayFadeFrames; + } + predelayPending_=-1; + } + } + predelayMemory_[0][predelayWrite_]=mid; + predelayMemory_[1][predelayWrite_]=side; + predelayWrite_=(predelayWrite_+1)&(predelayRing-1); + if(predelayValidFrames_ y{},mix{}; if(realtimeMode_)dampCoeff_+=slew_*(targetDamp_-dampCoeff_); for(int i=0;i,2> predelayMemory_{}; + p82::LateInputDiffuser diffuser_{}; + std::array preparedPredelay_{}; + int predelayWrite_=0,predelayValidFrames_=0; + int predelayActive_=0,predelayTarget_=0,predelayPrevious_=0; + int predelayPending_=-1,predelayRemaining_=0; +#endif std::array,lineCount> memory_{}; std::array lowpass_{}; std::array gain_{},targetGain_{}; diff --git a/engine/builtin_fx/sonku/SonKuP82DiffuseInput.h b/engine/builtin_fx/sonku/SonKuP82DiffuseInput.h new file mode 100644 index 000000000..8f09529bf --- /dev/null +++ b/engine/builtin_fx/sonku/SonKuP82DiffuseInput.h @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +// Research-only late-field onset diffuser. Three Schroeder all-pass stages +// distribute impulse energy without replacing the six real image-source +// boundaries or imposing an arbitrary lowpass/EQ. A unity-magnitude allpass +// stage is mathematically energy-preserving in steady state (not a wet boost). +// Incommensurate ~7/12/18ms time constants are prepared OFF the callback. +// This is an original implementation, not dearVR/AMBEO code or BRIR data. +#include +#include +#include + +namespace armix::sonku::p82 { +class LateInputDiffuser final { +public: + static constexpr int ringFrames=1024; + static constexpr int stageCount=3; + static constexpr float feedback=.5f; // |g|<1 guarantees stable allpass + + bool prepare(double sampleRate) noexcept { + if(!std::isfinite(sampleRate) || + (std::abs(sampleRate-44100.)>.1 && + std::abs(sampleRate-48000.)>.1))return false; + constexpr std::array seconds{ + .0073,.0117,.0179}; + for(int s=0;s(std::lround( + seconds[s]*sampleRate)); + if(samples<1||samples>=ringFrames-1)return false; + stages_[s].delay=samples; + } + reset(); + return true; + } + void reset() noexcept { + for(auto& stage:stages_) { + for(auto& channel:stage.data)channel.fill(0.f); + stage.write=0;stage.valid=0; + } + } + // OFF/ON fence: never clear ~24KB from the realtime audio callback. + // Read only samples written since the new activation. + void invalidate() noexcept { + for(auto& stage:stages_)stage.valid=0; + } + void process(float& mid,float& side) noexcept { + for(auto& stage:stages_) { + const int read=(stage.write-stage.delay)&(ringFrames-1); + const bool fresh=stage.valid>=stage.delay; + const float oldM=fresh?stage.data[0][read]:0.f; + const float oldS=fresh?stage.data[1][read]:0.f; + const float nextM=oldM-feedback*mid; + const float nextS=oldS-feedback*side; + stage.data[0][stage.write]=mid+feedback*nextM; + stage.data[1][stage.write]=side+feedback*nextS; + mid=nextM;side=nextS; + stage.write=(stage.write+1)&(ringFrames-1); + if(stage.valid,2> data{}; + int delay=1,write=0,valid=0; + }; + static_assert((ringFrames&(ringFrames-1))==0); + std::array stages_{}; +}; +} // namespace armix::sonku::p82 diff --git a/engine/builtin_fx/sonku/SonKuSpatialCore.h b/engine/builtin_fx/sonku/SonKuSpatialCore.h index 95fbf1c9d..270498e73 100644 --- a/engine/builtin_fx/sonku/SonKuSpatialCore.h +++ b/engine/builtin_fx/sonku/SonKuSpatialCore.h @@ -281,6 +281,11 @@ class SonKuSpatialCore final { float p80PreparedShelfDb() const noexcept { return timbre_.shelfGainDb(); } +#endif +#if defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) && SONKU_P82_GEOMETRIC_LATE_RESEARCH + int p82PreparedRoomLatePreDelaySamples() const noexcept { + return reverb_.preparedLatePredelaySamples(); + } #endif // In-place stereo; caller owns valid, non-overlapping L/R PCM pointers. // No vector, heap, blocking calls, I/O or filter bank allocation. diff --git a/scripts/sonku_p82_room_evidence.py b/scripts/sonku_p82_room_evidence.py new file mode 100644 index 000000000..e5f58054e --- /dev/null +++ b/scripts/sonku_p82_room_evidence.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 +"""P8.2 instrumented (not perceptual) geometry-late room comparison. +P8.0 and P8.2 are compiled from the same exact PR SHA. Room-only change +may NEVER modify direct-only tonal/side behavior or six-boundary early IR. +""" +import csv +import json +import math +import pathlib +import sys + +def load(path, fields): + with path.open(newline="",encoding="utf8") as stream: + data=list(csv.DictReader(stream)) + if not data: + raise ValueError(f"empty input: {path}") + keyed={} + for d in data: + k=tuple(d[p] for p in fields) + if k in keyed: + raise ValueError(f"duplicate row {k}: {path}") + keyed[k]=d + return keyed + +def main(folder): + root=pathlib.Path(folder) + tkeys=("source","room","azimuth","frequency_hz") + t80=load(root/"sonku_P80_tone.csv",tkeys) + t82=load(root/"sonku_P82_tone.csv",tkeys) + if t80.keys()!=t82.keys(): + raise AssertionError("direct source matrix changed") + max_direct_delta=0. + for key in t80: + for ch in ("left_amp","right_amp","mid_amp","side_amp"): + old,new=float(t80[key][ch]),float(t82[key][ch]) + if not math.isfinite(old) or not math.isfinite(new): + raise AssertionError("nonfinite direct transfer") + max_direct_delta=max(max_direct_delta,abs(old-new)) + if max_direct_delta>2.e-7: + raise AssertionError(f"room-only P8.2 altered dry/off direct PCM: {max_direct_delta}") + r80=load(root/"sonku_P80_room.csv",("scene",)) + r82=load(root/"sonku_P82_room.csv",("scene",)) + if r80.keys()!=r82.keys(): + raise AssertionError("room scenes changed") + field=("first20_energy","early20_100_energy","late100_1000_energy") + for scene in ("SCENE_DRY","SCENE_ER_ONLY"): + k=(scene,) + for e in field: + old,new=float(r80[k][e]),float(r82[k][e]) + if abs(old-new)>2.e-7: + raise AssertionError(f"room-only P8.2 changed {scene} {e}: {old}, {new}") + b=float(r80[("SCENE_LATE_ONLY",)]["early20_100_energy"]) + v=float(r82[("SCENE_LATE_ONLY",)]["early20_100_energy"]) + if not (b>0 and v>0 and v-0.7: + raise AssertionError(f"late remains dominant in the 20-100ms window: {ratio_db:.2f} dB") + # Check late field still exists after the geometric propagation delay, + # rather than passing by muting/zeroing the reverb altogether. + late_tail=float(r82[("SCENE_LATE_ONLY",)]["late100_1000_energy"]) + if late_tail<=1.e-9: + raise AssertionError("late tail was muted; this isn't a spatial fix") + record={ + "status":"PASS_GEOMETRIC_LATE_ONSET_ONLY_NOT_DEARVR_PARITY", + "source":"EXACT_PR_SOURCE_DUAL_COMPILE", + "sample_rate":48000, + "late_window_20_to_100ms":{ + "p80_energy":b,"p82_energy":v, + "p82_relative_db":ratio_db}, + "p82_late_energy_100_to_1000ms":late_tail, + "max_direct_off_amplitude_change":max_direct_delta, + "independent_six_wall_er_unchanged":True, + "not_proven":["naturalness","dearVR BRIR parity","stereo object positioning", + "ASIO 64/128/256","subjective externalization"] + } + (root/"sonku_p82_room_evidence.json").write_text( + json.dumps(record,indent=2,sort_keys=True)+"\n",encoding="utf8") + print(json.dumps(record,sort_keys=True,separators=(",",":"))) + return 0 + +if __name__=="__main__": + if len(sys.argv)!=2: + raise SystemExit("usage: sonku_p82_room_evidence.py DIRECTORY") + raise SystemExit(main(sys.argv[1])) diff --git a/site/preview-v2/assets/mixer-native-sonku.js b/site/preview-v2/assets/mixer-native-sonku.js index 9d96064a2..bf20da083 100644 --- a/site/preview-v2/assets/mixer-native-sonku.js +++ b/site/preview-v2/assets/mixer-native-sonku.js @@ -173,7 +173,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,musicSafeStereo=false,p80MeasuredTimbre=false, + xyzCapable=false,musicSafeStereo=false,p80MeasuredTimbre=false,p82RoomGeometry=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; @@ -231,7 +231,9 @@ function render(){ if(!rangeEdits.has("skElevation"))elevation.value=String(s.directElevationDegrees); $("skElevationValue").textContent=s.directElevationDegrees.toFixed(1)+"°"; } - root.querySelector(".sk-stage-caption").textContent=p80MeasuredTimbre + root.querySelector(".sk-stage-caption").textContent=p82RoomGeometry + ?"HEADPHONES · KEMAR + GEOMETRIC LATE ROOM · RESEARCH" + :p80MeasuredTimbre ?"HEADPHONES · MEASURED TIMBRE · 3D KEMAR · RESEARCH" :musicSafeStereo ?"HEADPHONES · MEASURED CENTER 3D HRTF + MUSIC SIDE · EXPERIMENT" @@ -255,7 +257,8 @@ function render(){ // redrawn at 60 Hz. The native audio callback remains the time authority. drawSpeakers(); $("skMode").textContent=native()?(context()? - (p80MeasuredTimbre?"NATIVE TIMBRE P8.0 · RESEARCH": + (p82RoomGeometry?"NATIVE ROOM P8.2 · RESEARCH": + p80MeasuredTimbre?"NATIVE TIMBRE P8.0 · RESEARCH": musicSafeStereo?"NATIVE MUSIC SAFE · RESEARCH":"NATIVE HRTF"): "NATIVE UNAVAILABLE"):"VISUAL ONLY · NO AUDIO"; } @@ -406,6 +409,9 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ p80MeasuredTimbre=musicSafeStereo && r.measuredTimbre===true && Number.isFinite(r.measuredTimbreShelfDb) && r.measuredTimbreShelfDb>=0 && r.measuredTimbreShelfDb<=4.5001; + p82RoomGeometry=p80MeasuredTimbre && r.roomGeometryLate===true && + Number.isInteger(r.roomLatePreDelaySamples) && + r.roomLatePreDelaySamples>0 && r.roomLatePreDelaySamples<=4096; readId="";readSentAt=0; if(pending) { if(!pending.ack || r.appliedRequestId!==pending.requestId){ @@ -428,7 +434,7 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ } render(); }); -$("skClose").addEventListener("click",()=>{root.hidden=true;current=null;xyzCapable=false;musicSafeStereo=false;p80MeasuredTimbre=false; +$("skClose").addEventListener("click",()=>{root.hidden=true;current=null;xyzCapable=false;musicSafeStereo=false;p80MeasuredTimbre=false;p82RoomGeometry=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;} @@ -581,7 +587,7 @@ const api={ cancelLiveTimer();pending=null;latest=null;readId="";readSentAt=0;dialDrag=null; observedAt=0;visualAt=0;visualPhase=0;lastLiveAt=0; drag=null;rangeEdits.clear();gestureStart.clear(); - accepted=defaults();draft=defaults();xyzCapable=false;musicSafeStereo=false;p80MeasuredTimbre=false; + accepted=defaults();draft=defaults();xyzCapable=false;musicSafeStereo=false;p80MeasuredTimbre=false;p82RoomGeometry=false; current={track,slot,instanceId:null}; const s=snapshot(),id=window.__ARMIX_NATIVE_M2__?.nativeIdFor?.(track); const fx=s?.graph?.channels?.find(x=>x.id===id)?.inserts?.[slot]; diff --git a/src/Main.cpp b/src/Main.cpp index 5dd7f6a7f..0f8bf6458 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -3048,6 +3048,14 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr reply->setProperty("measuredTimbreShelfDb", processor->preparedTimbreShelfDb()); } +#endif +#if defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) && SONKU_P82_GEOMETRIC_LATE_RESEARCH + if(processor && processor->preparedReflectionProfile()== + armix::sonku::SonKuReflectionProfile::SixSurfaceKemarResearch) { + reply->setProperty("roomGeometryLate",true); + reply->setProperty("roomLatePreDelaySamples", + processor->preparedRoomLatePreDelaySamples()); + } #endif if(processor) { reply->setProperty("settings", diff --git a/tests/sonku_p80_acoustic_probe.cpp b/tests/sonku_p80_acoustic_probe.cpp index 5f9898dc3..2552eec3b 100644 --- a/tests/sonku_p80_acoustic_probe.cpp +++ b/tests/sonku_p80_acoustic_probe.cpp @@ -19,7 +19,9 @@ using namespace armix::sonku; constexpr double pi=3.141592653589793238462643; static constexpr int fs=48000; static constexpr float inputLevel=.095f; -#if defined(SONKU_P80_MEASURED_TIMBRE_RESEARCH) && SONKU_P80_MEASURED_TIMBRE_RESEARCH +#if defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) && SONKU_P82_GEOMETRIC_LATE_RESEARCH +static constexpr const char* mode="P82"; +#elif defined(SONKU_P80_MEASURED_TIMBRE_RESEARCH) && SONKU_P80_MEASURED_TIMBRE_RESEARCH static constexpr const char* mode="P80"; #else static constexpr const char* mode="P75"; diff --git a/tests/sonku_p82_geometry_predelay_test.cpp b/tests/sonku_p82_geometry_predelay_test.cpp new file mode 100644 index 000000000..114f800ce --- /dev/null +++ b/tests/sonku_p82_geometry_predelay_test.cpp @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Dedicated P8.2 direct algorithm proof: geometry-dependent late onset, +// no stale input/FDN carry across OFF/ON, no callback allocation. +#if defined(NDEBUG) +#undef NDEBUG +#endif +#if !defined(SONKU_P82_GEOMETRIC_LATE_RESEARCH) || !SONKU_P82_GEOMETRIC_LATE_RESEARCH +#error P8.2 standalone test must compile the actual delayed reverb +#endif +#include "../engine/builtin_fx/sonku/SonKuMusicalReverb.h" +#include +#include +#include +#include +#include +using namespace armix::sonku; +static int onset(double sampleRate,SonKuReverbPreset preset) { + auto reverb=std::make_unique(); + assert(reverb->prepare(sampleRate)); + assert(reverb->setRealtimeProgram(preset,.60f)); + const int firstDelay=reverb->preparedLatePredelaySamples(); + const float width= preset==SonKuReverbPreset::StudioGlue?7.2f: + preset==SonKuReverbPreset::AiryChamber?14.4f:28.8f; + const int expected=static_cast(std::lround( + width*sampleRate/343.)); + assert(std::abs(firstDelay-expected)<=1); + const int minimumFdDelay=static_cast(std::lround( + 2111.*sampleRate/48000.)); + int observed=-1; + double power=0.; + for(int i=0;i(sampleRate*.6);++i){ + const auto sample=reverb->process(i==0?.1f:0.f,i==0?.1f:0.f); + assert(std::isfinite(sample.left)&&std::isfinite(sample.right)); + assert(std::abs(sample.left)<.99f&&std::abs(sample.right)<.99f); + if(observed<0 && std::abs(sample.left)+std::abs(sample.right)>1.e-8f) + observed=i; + power+=sample.left*sample.left+sample.right*sample.right; + } + assert(observed>=minimumFdDelay+firstDelay-1); + assert(observed<=minimumFdDelay+firstDelay+1); + assert(power>1.e-9); + std::printf("P82_LATE_ONSET,rate=%.0f,room_width=%.1f,predelay=%d,first_late_sample=%d\n", + sampleRate,width,firstDelay,observed); + // Continuous control transitions must remain finite and bounded. + assert(reverb->setRealtimeProgram(SonKuReverbPreset::LargeRoom,.6f)); + for(int i=0;i<4096;++i){ + const float x=.05f*std::sin(.03f*i); + auto s=reverb->process(x,x); + assert(std::isfinite(s.left)&&std::isfinite(s.right)); + assert(std::abs(s.left)<.99f&&std::abs(s.right)<.99f); + } + // Fresh prepared reset preserves the accepted physical room size while + // guaranteeing silence with an empty source (no previously heard tail). + reverb->reset(); + assert(reverb->setRealtimeProgram(SonKuReverbPreset::StudioGlue,.6f)); + for(int i=0;i(sampleRate*.4);++i){ + auto s=reverb->process(0.f,0.f); + assert(std::abs(s.left)<1.e-8f&&std::abs(s.right)<1.e-8f); + } + return observed; +} +int main(){ + for(const double rate:{44100.,48000.}){ + const int studio=onset(rate,SonKuReverbPreset::StudioGlue); + const int chamber=onset(rate,SonKuReverbPreset::AiryChamber); + const int large=onset(rate,SonKuReverbPreset::LargeRoom); + assert(studio