diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 2dac405ab..681791f93 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -647,7 +647,7 @@ jobs: sonku-p90-source: # Runs only on the P9 research PR, even while its production jobs skip. name: SonKu P9 exact-source C++ PCM preflight - if: ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'research/sonku-p90-') }} + if: ${{ github.event_name == 'pull_request' && (startsWith(github.event.pull_request.head.ref, 'research/sonku-p90-') || startsWith(github.event.pull_request.head.ref, 'research/sonku-p912-')) }} runs-on: ubuntu-latest timeout-minutes: 10 steps: @@ -661,17 +661,20 @@ jobs: set -euo pipefail node --check site/preview-v2/assets/mixer-native-sonku.js node tests/sonku_p90_dropdown_stability_test.cjs + node tests/sonku_p92_dropdown_stability_test.cjs 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 -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 -DSONKU_P90_TRUE_EXTERNAL_RESEARCH=1" g++ $FLAGS tests/sonku_p90_true_external_source_test.cpp -o /tmp/sonku-p90 /tmp/sonku-p90 + g++ $FLAGS -DSONKU_P92_MUSIC_BASS_FOUNDATION=1 tests/sonku_p92_music_bass_source_test.cpp -o /tmp/sonku-p92 + /tmp/sonku-p92 g++ $FLAGS tests/sonku_p89_stereo_room_depth_source_test.cpp -o /tmp/sonku-p89 /tmp/sonku-p89 - echo "SONKU_P90_NATIVE_SOURCE_CTEST_PASSED" + echo "SONKU_P90_AND_P92_NATIVE_SOURCE_CTEST_PASSED" sonku-p90-windows-fat: name: SonKu P9 actual JUCE / GUI portable x64 needs: sonku-p90-source - if: ${{ github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'research/sonku-p90-') }} + if: ${{ github.event_name == 'pull_request' && (startsWith(github.event.pull_request.head.ref, 'research/sonku-p90-') || startsWith(github.event.pull_request.head.ref, 'research/sonku-p912-')) }} runs-on: windows-2022 timeout-minutes: 55 steps: @@ -708,21 +711,23 @@ jobs: -DARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT=ON ` -DARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT=ON ` -DARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT=ON ` -DBUILD_TESTING=ON if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } $cache = Get-Content build/CMakeCache.txt -Raw - if ($cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT:BOOL=ON') { + if ($cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT:BOOL=ON' -or + $cache -notmatch 'ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT:BOOL=ON') { throw 'SONKU_P90_WRONG_NATIVE_CONFIGURATION' } - name: Build real native JUCE PCM, state ACK, and Windows GUI shell: pwsh run: | - cmake --build build --config Release --parallel 2 --target ARMixSonKuP90NativeTests ARMixSonKuP90SourceTests ARMixSonKuP89NativeTests ARMixSonKuP89SourceTests ARMixConsole + cmake --build build --config Release --parallel 2 --target ARMixSonKuP92NativeTests ARMixSonKuP92SourceTests ARMixSonKuP90NativeTests ARMixSonKuP90SourceTests ARMixSonKuP89NativeTests ARMixSonKuP89SourceTests ARMixConsole if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } if (-not (Test-Path -LiteralPath 'build/ARMixConsole_artefacts/Release/AR MIX Studio.exe' -PathType Leaf)) { throw 'SONKU_P90_NATIVE_GUI_EXE_MISSING' } - ctest --test-dir build -C Release --output-on-failure -R '^NativeSonKuP(89RoomAnchoredStereoAndP88GoldenParity|89JuceV10AppliedAckAndV9Restore|90StereoExternalizationSource|90JuceV11AppliedAckAndLegacyRestore)$' + ctest --test-dir build -C Release --output-on-failure -R '^NativeSonKuP(89RoomAnchoredStereoAndP88GoldenParity|89JuceV10AppliedAckAndV9Restore|90StereoExternalizationSource|90JuceV11AppliedAckAndLegacyRestore|92MusicFidelityPhysicalBassSource|92JuceV12AppliedAckAndV11Restore)$' if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } - name: Verified portable package, no installer or release shell: pwsh @@ -734,14 +739,14 @@ jobs: & ./scripts/verify_native_windows_artifact.ps1 -OutputDir dist if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } Copy-Item docs/THIRD_PARTY_8D_SONKU_HRTF.md dist/THIRD_PARTY_8D_SONKU_HRTF.md - Copy-Item docs/SONKU_P90_TRUE_EXTERNAL_SPEAKER_FAT_20261115.md dist/SONKU_P90_FIELD_FAT.md + Copy-Item docs/SONKU_P912_MUSIC_FIDELITY_PHYSICAL_BASS_FAT_20261116.md dist/SONKU_P92_FIELD_FAT.md $provenance = Get-Content -LiteralPath dist/BUILD_PROVENANCE.json -Raw | ConvertFrom-Json if ($provenance.sourceCommit -ne (git rev-parse HEAD).Trim()) { throw 'SONKU_P90_SOURCE_COMMIT_MISMATCH' } $provenance | Add-Member -Force -NotePropertyName sonkuExperiment -NotePropertyValue @{ - mode = 'P9.0_TRUE_EXTERNAL_SPEAKER' - stateSchema = 11 + mode = 'P9.1_P9.2_MUSIC_FIDELITY_PHYSICAL_BASS' + stateSchema = 12 headphoneFat = 'PENDING' publicRelease = $false physicalAsioQualified = $false @@ -750,7 +755,7 @@ jobs: $provenance | ConvertTo-Json -Depth 20 | Set-Content dist/BUILD_PROVENANCE.json -Encoding utf8 - uses: actions/upload-artifact@v4 with: - name: ArSonMix-SonKu-P90-Windows-x64-${{ github.run_id }} + name: ArSonMix-SonKu-P92-Music-Bass-Windows-x64-${{ github.run_id }} path: dist/ if-no-files-found: error retention-days: 21 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d9ebab73..372d20891 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,6 +96,13 @@ if(ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT AND NOT ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) message(FATAL_ERROR "P9.0 requires P8.9 research branch baseline") endif() +# P9.1+P9.2 music fidelity and physical bass share the P9 measured binaural graph. +option(ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT + "Private P9.1+P9.2 calibrated music and source-coupled axial LF room modes" OFF) +if(ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT AND + NOT ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT) + message(FATAL_ERROR "P9.2 music/bass requires P9.0 measured stereo engine") +endif() set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -312,7 +319,9 @@ target_compile_definitions(ARMixConsole PRIVATE $<$:ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT=1> $<$:SONKU_P89_DEPTH_COHERENCE_RESEARCH=1> $<$:ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT=1> - $<$:SONKU_P90_TRUE_EXTERNAL_RESEARCH=1>) + $<$:SONKU_P90_TRUE_EXTERNAL_RESEARCH=1> + $<$:ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT=1> + $<$:SONKU_P92_MUSIC_BASS_FOUNDATION=1>) if(WIN32) # Windows retains its proven ASIO-first / WASAPI / static WebView2 distribution. # Never link Windows loader or sound APIs into macOS/Linux builds. @@ -826,6 +835,64 @@ if(BUILD_TESTING) SONKU_P90_TRUE_EXTERNAL_RESEARCH=1) add_test(NAME NativeSonKuP90JuceV11AppliedAckAndLegacyRestore COMMAND ARMixSonKuP90NativeTests) + if(ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT) + add_executable(ARMixSonKuP92SourceTests + tests/sonku_p92_music_bass_source_test.cpp) + target_compile_features(ARMixSonKuP92SourceTests PRIVATE cxx_std_20) + target_compile_definitions(ARMixSonKuP92SourceTests 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 + SONKU_P90_TRUE_EXTERNAL_RESEARCH=1 + SONKU_P92_MUSIC_BASS_FOUNDATION=1) + add_test(NAME NativeSonKuP92MusicFidelityPhysicalBassSource + COMMAND ARMixSonKuP92SourceTests) + juce_add_console_app(ARMixSonKuP92NativeTests + PRODUCT_NAME "ArSonMix SonKu P92 JUCE v12 State Tests") + target_sources(ARMixSonKuP92NativeTests PRIVATE + tests/sonku_p92_native_juce_v12_test.cpp) + target_compile_features(ARMixSonKuP92NativeTests PRIVATE cxx_std_20) + target_link_libraries(ARMixSonKuP92NativeTests PRIVATE + juce::juce_audio_processors juce::juce_recommended_config_flags) + target_compile_definitions(ARMixSonKuP92NativeTests 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 + ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT=1 + ARMIX_SONKU_EXPERIMENTAL_P92_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 + SONKU_P90_TRUE_EXTERNAL_RESEARCH=1 + SONKU_P92_MUSIC_BASS_FOUNDATION=1) + add_test(NAME NativeSonKuP92JuceV12AppliedAckAndV11Restore + COMMAND ARMixSonKuP92NativeTests) + endif() endif() endif() endif() diff --git a/docs/SONKU_P912_MUSIC_FIDELITY_PHYSICAL_BASS_FAT_20261116.md b/docs/SONKU_P912_MUSIC_FIDELITY_PHYSICAL_BASS_FAT_20261116.md new file mode 100644 index 000000000..37ded83bd --- /dev/null +++ b/docs/SONKU_P912_MUSIC_FIDELITY_PHYSICAL_BASS_FAT_20261116.md @@ -0,0 +1,41 @@ +# SonKu P9.1+P9.2 — Music Fidelity and Physical Bass Foundation +**Research only. Headphone field acceptance required. 2026-11-16.** + +## Reconciliation / baseline + +- `main` HEAD `37985f02caecd93b22f853183888d81e18dc6736` includes audio I/O recovery (#713) and the approved mixer GUI. No attempt to merge/revert it here. +- SonKu P9.0 #717 HEAD `cd85ffee054dad6b3b752b5351d34921ddc92717` is a draft, based on P8.9 #716, with stable dropdown and measured 2×2 stereo FIR. This P9.1+P9.2 source branch descends from that exact SHA; it must remain draft and must not be merged straight to production. +- Comparison found P9 draft **257 commits ahead and four commits behind** `main`; `src/Main.cpp`, `CMakeLists.txt`, `p1-windows.yml`, and GUI changes require manually reviewed integration with #713 on a separate merge candidate. P9.2's FAT does not prove hardware audio continuity. +- P8.2–P9.0 native renders, UI option names, and old SONK state versions remain A/B references. The P9.2 candidate is **new opt-in renderMode=10**, schema and SONK state version 12, preserving the 63-byte v9–v12 payload structure. v1–v11 remain readable; old files must not silently select mode 10. + +## Root causes found in actual P9 source + +1. Old default `outputTrim=.75` (-2.50 dB) and direct speaker sum factor `sceneBinauralLevel=.5`. P9.0's LF headphone return and HRTF spectral response make overall loudness dependent on programme and direction. Owner needed +7dB to audition. Pure output gain is not a safe automatic fix; it also drives the existing peak limiter. +2. P9.0 `transparentBass` subtracts the <220Hz measured binaural ear transfer, then adds original channel-locked low-pass left/right. This defeats world-anchored LF source movement and can make bass feel disconnected from the spatialized harmonics. +3. The six wall paths and 8-line 3-band FDN do not model source-dependent axial bass room modes. Raising wet percentages cannot manufacture physical bass or prove dearVR parity. + +## Implementation + +- **P9.1 measured music foundation:** in `SonKuP92MusicBassFoundation.h`, at `prepare()` calculate broadband magnitude of actual bundled MIT KEMAR HRIR at 250/600/1200/2500Hz and 0/30/45° over both ears (no proprietary dataset). The stable source gain is `clamp(1/(sqrt(1/2)*meanMagnitude),1,1.9)`. Source outputs still pass through the old measured two-speaker FIR and head-relative HRTF, never independent AGC. We do **not** call this loudness matching; a LUFS test on music is a separate FAT gate. +- **P9.2 directional bass, phase guard:** the initial candidate that preserved the raw measured full-band HRIR lost **70%** of mono energy and **86%** of anti-phase energy in the real native source test. Instead, mode 10 uses a WORLD-speaker/HEAD-relative two-emitter low-frequency pressure matrix below the existing complementary ~220Hz crossover; the >220Hz contribution remains the actual measured KEMAR 2×2 HRIR. The LF weights are direction dependent (bounded by 0.82×sine of source angle relative to head), smooth in 8ms, and mix both speaker sources into BOTH ears; no original L/R headphone LF injection. A common broad +1.14x shelf near 105Hz supports body without an oscillator. **This LF matrix is a psychoacoustic approximation, not measured BRIR or physically exact 40Hz ILD.** +- **Prepared axial LF room modes:** three damped bandpass modes per room, with frequencies derived from `343*n/(2*dimension)` and even harmonics to avoid listener-centre pressure nulls. Each L/R virtual source excites its modes according to **world-space** position; excitation is injected into its source FIR history before the same 2×2 measured HRIR. Three Q7.5–10 modes, per-mode excitation bounded by `0.17/3`, 45ms slewed wet parameter; dimension/coefficients precomputed. This is a physically motivated **parametric approximation**, not a measured BRIR or subwoofer cabinet model. +- **Controlled room presence:** mode 10 uses its own lower direct/early/late ratio than the old P8.9 large affine wet amplification; the original reverb FDN remains authoritative. This avoids masking the direct speakers by boosting reverb simply to recover perceived loudness. +- **Music-first audition entry:** selecting P9.2 explicitly applies STATIC front pair, 82°, 1.6m, Large room, Reflections 72%, Reverb 38%, 100% Mix and 0dB trim. The normalized measured source gain replaces the need for pre-applied +7dB trim. **Never** modify original default initializers, existing saved sessions, or another render mode without an operator edit. + +## Objective gates + +- Native PCM: 44.1k/48k, source L-only/R-only/correlated MID/anti-phase/stereo, yaw -85/+85, reference P9.0 unchanged, room ON/OFF and 64/128/256 callback invariance, finite peak under sample-peak limiter. +- Native JUCE: actual `processBlock` ACK and readback, no speculative JS success, stable 63-byte schema-12 `.smix`, v1..v11 restore, v11 P9.0 mode 9 retained, old physical P8.3 prohibited, device reprepare. +- UI: mock 40 native polling cycles with combined P9.2/P9/P8.9 capability flags, no option repaint when dropdown is open; first-entry explicit preset only. +- Release: package verified Windows GUI EXE at exact source SHA with license and this guide. No public release or main merge. +- **Missing:** actual music loudness match ±0.5 LU integrated (dry/P9/P9.2/dearVR), bass frequency/decay/distortion vs controlled reference, headphone/externalization FAT, physical ASIO/restart and speaker/HRTF-specific tonal measurements. Numeric CTest cannot establish subjective parity. + +## Headphone field evaluation + +Use the same reference stereo mix with FX rack **SonKu ONLY** (dearVR bypassed while auditioning SonKu), headphones and matched LUFS. Compare dry, P8.2, P9.0, P9.2, and a separately configured dearVR PRO 2. Headphone sound pressure must be controlled during testing, especially kick transients. Start P9.2 preset at 82° front / 1.6m with orbit OFF; test yaw -90, 0, +90, rotation and distance 1.6/3/6.7m. Compare 40–160Hz punch, resonant tail, separation, full-range timbre, center vocal, measured/output clipping, and the physical *outside-head* sensation. Avoid attributing body vibration from real subwoofers to headphone DSP. + +Reference: AES69 SOFA data interoperability https://www.sofacoustics.org/ ; externalization uses direct/reverberant cues and directional binaural room reflections, see https://www.mdpi.com/2076-3417/7/5/532 . The SonKu modal transfer here is **not** a SOFA/BRIR measurement. + +## Failsafe + +Do not change the approved mixer/routing, device recovery, GUI layout, user-owned `.smix` file or default P9/P8 programmes. Keep the branch draft if any native CTest, real Windows packaging, UI repeatability, LF tone, or headphone fatigue test fails. diff --git a/engine/builtin_fx/SonKuSpatialProcessor.h b/engine/builtin_fx/SonKuSpatialProcessor.h index 6ed46528f..077ac4b6e 100644 --- a/engine/builtin_fx/SonKuSpatialProcessor.h +++ b/engine/builtin_fx/SonKuSpatialProcessor.h @@ -18,7 +18,24 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, SonKuSpatialProcessor() : juce::AudioProcessor(BusesProperties() .withInput("Input",juce::AudioChannelSet::stereo(),true) - .withOutput("Output",juce::AudioChannelSet::stereo(),true)) {} + .withOutput("Output",juce::AudioChannelSet::stereo(),true)) { +#if defined(ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT + // First inserted FX only: a musician-friendly reference from first + // PCM sample, not an opt-in-only GUI cosmetic preset. State restore + // always replaces this with the exact existing v1-v12 .smix values. + // All public/non-P92 binaries retain their historical defaults. + accepted_.renderMode=10; + accepted_.moving=false; + accepted_.startAzimuthDegrees=0.f; + accepted_.stereoSpreadDegrees=82.f; + accepted_.spatialMix=1.f; + accepted_.outputTrim=1.f; + accepted_.spacePreset=3; + accepted_.sourceDistanceMeters=1.6f; + accepted_.roomAmount=.72f; + accepted_.ambience=.38f; +#endif + } const juce::String getName() const override {return "8D-SonKu";} bool acceptsMidi() const override {return false;} bool producesMidi() const override {return false;} @@ -164,7 +181,11 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, #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 defined(ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT + out.writeInt(12); // unchanged 63-byte state; isolated P9.2 mode 10 +#else out.writeInt(11); // unchanged 63-byte state; P9 mode 9 +#endif #else out.writeInt(10); // 63 bytes v9 layout, opt-in mode 8 #endif @@ -253,6 +274,9 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, &&version!=10 #if defined(ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT &&version!=11 +#if defined(ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT + &&version!=12 +#endif #endif #endif #endif @@ -281,6 +305,9 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, ||(version==10&&size!=63) #if defined(ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT ||(version==11&&size!=63) +#if defined(ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT + ||(version==12&&size!=63) +#endif #endif #endif #endif @@ -368,6 +395,13 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, next.renderMode!=7 && next.renderMode!=8 && next.renderMode!=9) return false; if(version==11 && next.musicCompatibleLowFrequency)return false; +#if defined(ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT + if(version==12 && next.renderMode!=0 && next.renderMode!=3 && + next.renderMode!=4 && next.renderMode!=5 && next.renderMode!=6 && + next.renderMode!=7 && next.renderMode!=8 && next.renderMode!=9 && + next.renderMode!=10)return false; + if(version==12 && 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 2820af40f..32e4ae0c6 100644 --- a/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h +++ b/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h @@ -22,6 +22,9 @@ enum class Mode : std::uint8_t { ,MusicSpatialP89=8 #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH ,MusicSpatialP90=9 +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + ,MusicSpatialP92=10 +#endif #endif #endif #endif @@ -48,6 +51,9 @@ inline bool valid(Mode m) noexcept { || m==Mode::MusicSpatialP89 #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH || m==Mode::MusicSpatialP90 +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + || m==Mode::MusicSpatialP92 +#endif #endif #endif #endif diff --git a/engine/builtin_fx/sonku/SonKuP92MusicBassFoundation.h b/engine/builtin_fx/sonku/SonKuP92MusicBassFoundation.h new file mode 100644 index 000000000..9238b3d40 --- /dev/null +++ b/engine/builtin_fx/sonku/SonKuP92MusicBassFoundation.h @@ -0,0 +1,216 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "SonKuMeasuredHrir.h" +#include +#include +#include +#include +#include + +// P9.1+P9.2: music-level foundation and gently coupled, spatialized LF room +// modes. The measured 2x2 HRIR remains the ONLY ear renderer. Room modes +// excite each WORLD-anchored source BEFORE the existing FIR; no unpositioned +// headphone sub-bus, L/R panner, fake LF oscillator or second PCM graph. +// +// This is a bounded parametric research model, NOT a measured BRIR or a +// reproduction of proprietary speaker-cabinet/room DSP. No allocation, log, +// exp, trig, IO, locks or policy decisions in process(). All fixed room-mode +// biquad coefficients and music calibration are computed at prepare(). +namespace armix::sonku::p92 { +class MusicBassFoundation final { +public: + using Bank=const std::int16_t (*)[2][hrir::taps]; + struct Sources {float left=0.f,right=0.f;}; + static constexpr int modeCount=3; + bool prepare(double rate,Bank bank) noexcept { + if(!bank||!std::isfinite(rate)|| + (std::abs(rate-44100.)>.1&&std::abs(rate-48000.)>.1))return false; + rate_=static_cast(rate); + constexpr double pi=3.1415926535897932384626433832795; + // Average the measured HRTF magnitude at representative music + // frequencies/near-front directions. One stable broadband scalar, + // not time-varying AGC that pumps with the music or head rotation. + constexpr std::array frequencies{250.,600.,1200.,2500.}; + constexpr std::array directions{0,6,9}; + double power=0.; + int count=0; + for(int d:directions)for(int ear=0;ear<2;++ear) + for(double frequency:frequencies) { + const double omega=2.*pi*frequency/rate; + double re=0.,im=0.; + for(int tap=0;tap(std::clamp( + 1./(.7071067811865476*meanMagnitude),1.0,1.90)); + bassShelfAlpha_=static_cast( + 1.-std::exp(-2.*pi*105./rate)); + roomSlew_=static_cast(1.-std::exp(-1./(rate*.045))); + weightSlew_=static_cast(1.-std::exp(-1./(rate*.008))); + // Prepared modal frequencies are actual axial eigenfrequencies of + // the three configured rooms: f=c*n/(2*dimension), with even n so + // a central listener is not on a zero-pressure node. + constexpr std::array,3> dimensions{{ + {{7.2f,7.2f,3.2f}}, + {{14.4f,14.4f,4.8f}}, + {{28.8f,28.8f,7.2f}} + }}; + constexpr std::array desiredHz{46.f,71.f,96.f}; + constexpr std::array quality{7.5f,9.f,10.f}; + for(int room=0;room<3;++room) + for(int mode=0;mode(std::lround( + desiredHz[mode]*program.dimension/343.))); + program.harmonic=harmonic; + program.frequency=343.f*harmonic/(2.f*program.dimension); + if(program.frequency>=rate*.45f)return false; + const double omega=2.*pi*program.frequency/rate; + const double sn=std::sin(omega); + const double alpha=sn/(2.*quality[mode]); + const double inv=1./(1.+alpha); + // RBJ constant-0dB-peak bandpass: no DC, no subharmonic + // synthesis, bounded output and damping Q<10. + program.b0=static_cast(alpha*inv); + program.b2=-program.b0; + program.a1=static_cast(-2.*std::cos(omega)*inv); + program.a2=static_cast((1.-alpha)*inv); + } + reset(); + return true; + } + void reset() noexcept { + for(auto& perSource:state_) + for(auto& state:perSource)state={}; + bassState_.fill(0.f); + room_=0; + roomBlend_=targetBlend_=0.f; + for(auto& perSource:coupling_)perSource.fill(0.f); + for(auto& ear:lowWeights_)ear.fill(1.f); + for(auto& ear:targetLowWeights_)ear.fill(1.f); + } + float directMakeup() const noexcept{return directMakeup_;} + void updateScene(int room,float wet,float distance,float worldCenter, + float spread,float headYaw) noexcept { + const int next=(room>=1&&room<=3)?room:0; + // A different room program cannot reuse the old resonator history. + // Only 12 float delays are cleared at most once per scene switch. + if(next!=room_) { + room_=next; + for(auto& perSource:state_) + for(auto& state:perSource)state={}; + roomBlend_=0.f; + } + targetBlend_=room_?std::clamp(wet,0.f,1.f)*.17f:0.f; + constexpr float pi=3.14159265358979323846f; + const float azimuths[2]{worldCenter-spread*.5f, + worldCenter+spread*.5f}; + // BELOW ~220Hz the measured KEMAR transfer can nearly cancel a + // deliberately anti-phase stereo programme. Preserve a physically + // oriented two-emitter LF pressure matrix instead of injecting + // unpositioned original headphone L/R bass. Small interaural + // asymmetry is a *psychoacoustic* compromise, not a measured BRIR. + for(int source=0;source<2;++source) { + const float head=(azimuths[source]-headYaw)*(pi/180.f); + const float lean=.82f*std::sin(head); + targetLowWeights_[0][source]=1.f-lean; + targetLowWeights_[1][source]=1.f+lean; + } + if(!room_)return; + const auto& programs=programs_[room_-1]; + for(int source=0;source<2;++source) { + const float r=azimuths[source]*(pi/180.f); + const float x=distance*std::sin(r); + const float y=distance*std::cos(r); + for(int mode=0;mode=1&&room<=3&&mode>=0&&mode,3> programs_{}; + std::array,2> state_{}; + std::array,2> coupling_{}; + std::array bassState_{}; + float rate_=48000.f,directMakeup_=1.f,bassShelfAlpha_=0.f; + float roomSlew_=0.f,roomBlend_=0.f,targetBlend_=0.f,weightSlew_=0.f; + std::array,2> lowWeights_{},targetLowWeights_{}; + int room_=0; +}; +} // namespace armix::sonku::p92 diff --git a/engine/builtin_fx/sonku/SonKuSpatialCore.h b/engine/builtin_fx/sonku/SonKuSpatialCore.h index 68ca3d80d..ef0e885b3 100644 --- a/engine/builtin_fx/sonku/SonKuSpatialCore.h +++ b/engine/builtin_fx/sonku/SonKuSpatialCore.h @@ -21,6 +21,9 @@ #include "SonKuP84FusedMusicHrir.h" #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH #include "SonKuP90StereoDecoder.h" +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION +#include "SonKuP92MusicBassFoundation.h" +#endif #endif #endif #if defined(SONKU_P87_MUSIC_BODY_RESEARCH) && SONKU_P87_MUSIC_BODY_RESEARCH @@ -103,7 +106,11 @@ inline bool valid(const Settings& s) noexcept { #if defined(SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH) && SONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH #if defined(SONKU_P89_DEPTH_COHERENCE_RESEARCH) && SONKU_P89_DEPTH_COHERENCE_RESEARCH #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + s.renderMode<=10 && ((s.renderMode<3 || s.renderMode>10) || !s.musicCompatibleLowFrequency) && +#else s.renderMode<=9 && ((s.renderMode<3 || s.renderMode>9) || !s.musicCompatibleLowFrequency) && +#endif #else s.renderMode<=8 && ((s.renderMode!=3 && s.renderMode!=4 && s.renderMode!=5 && s.renderMode!=6 && s.renderMode!=7 && s.renderMode!=8) || !s.musicCompatibleLowFrequency) && #endif @@ -133,6 +140,9 @@ inline bool valid(const Settings& s) noexcept { && s.renderMode!=8 #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH && s.renderMode!=9 +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + && s.renderMode!=10 +#endif #endif #endif ) || (s.directElevationDegrees+s.hrtfElevationTrimDegrees>=-40.f && @@ -202,6 +212,9 @@ class SonKuSpatialCore final { if(!p84MusicKernel_.prepare(rate))return false; #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH if(!p90Decoder_.prepare(rate))return false; +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + if(!p92Foundation_.prepare(rate,bank_))return false; +#endif #endif #endif #if defined(SONKU_P87_MUSIC_BODY_RESEARCH) && SONKU_P87_MUSIC_BODY_RESEARCH @@ -269,6 +282,9 @@ class SonKuSpatialCore final { integrity_.reset(); #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH p90Decoder_.reset(); +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + p92Foundation_.reset(); +#endif #endif #if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH p83LowFrequency_.reset(); @@ -312,6 +328,13 @@ class SonKuSpatialCore final { #if defined(SONKU_P87_MUSIC_BODY_RESEARCH) && SONKU_P87_MUSIC_BODY_RESEARCH if(s.renderMode!=settings_.renderMode || s.spacePreset!=settings_.spacePreset)p87Body_.reset(); +#endif +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + if(s.renderMode!=settings_.renderMode && + (s.renderMode==10 || settings_.renderMode==10)){ + p92Foundation_.reset(); // prevent stale bass modes after P9 A/B + p90Decoder_.reset(); // no old correlation evidence after mode fade + } #endif settings_=s; #if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH @@ -502,6 +525,9 @@ class SonKuSpatialCore final { && p83Mode_!=p83::Mode::MusicSpatialP89 #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH && p83Mode_!=p83::Mode::MusicSpatialP90 +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + && p83Mode_!=p83::Mode::MusicSpatialP92 +#endif #endif #endif #endif @@ -513,6 +539,11 @@ class SonKuSpatialCore final { const bool monoObject=positionedMode && p83Mode_==p83::Mode::MonoObject; #else constexpr bool positionedMode=false,monoObject=false; +#endif +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + const bool p92Stage=p83Mode_==p83::Mode::MusicSpatialP92; +#else + constexpr bool p92Stage=false; #endif const float distanceGain=room_.relativeDistanceGain(); const bool nativeSpace=nativeSpaceEverUsed_; @@ -547,6 +578,9 @@ class SonKuSpatialCore final { || p83Mode_==p83::Mode::MusicSpatialP89 #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH || p83Mode_==p83::Mode::MusicSpatialP90 +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + || p83Mode_==p83::Mode::MusicSpatialP92 +#endif #endif #endif #endif @@ -568,6 +602,9 @@ class SonKuSpatialCore final { || p83Mode_==p83::Mode::MusicSpatialP89 #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH || p83Mode_==p83::Mode::MusicSpatialP90 +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + || p83Mode_==p83::Mode::MusicSpatialP92 +#endif #endif #endif #endif @@ -581,6 +618,9 @@ class SonKuSpatialCore final { || p83Mode_==p83::Mode::MusicSpatialP89 #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH || p83Mode_==p83::Mode::MusicSpatialP90 +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + || p83Mode_==p83::Mode::MusicSpatialP92 +#endif #endif #endif #endif @@ -600,6 +640,9 @@ class SonKuSpatialCore final { || p83Mode_==p83::Mode::MusicSpatialP89 #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH || p83Mode_==p83::Mode::MusicSpatialP90 +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + || p83Mode_==p83::Mode::MusicSpatialP92 +#endif #endif #endif )?0.27f:0.13f)* @@ -616,6 +659,9 @@ class SonKuSpatialCore final { || p83Mode_==p83::Mode::MusicSpatialP89 #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH || p83Mode_==p83::Mode::MusicSpatialP90 +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + || p83Mode_==p83::Mode::MusicSpatialP92 +#endif #endif #endif )? @@ -627,6 +673,9 @@ class SonKuSpatialCore final { const bool p89Stage=p83Mode_==p83::Mode::MusicSpatialP89 #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH ||p83Mode_==p83::Mode::MusicSpatialP90 +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + ||p83Mode_==p83::Mode::MusicSpatialP92 +#endif #endif ; const float p89Depth=p89Stage&&roomEnabled? @@ -660,7 +709,11 @@ class SonKuSpatialCore final { const float x0=std::isfinite(left[i])?left[i]:0.f; const float x1=monoObject?0.f:(std::isfinite(right[i])?right[i]:0.f); #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH - if(p83Mode_==p83::Mode::MusicSpatialP90)p90Decoder_.observe(x0,x1); + if(p83Mode_==p83::Mode::MusicSpatialP90 +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + ||p83Mode_==p83::Mode::MusicSpatialP92 +#endif + )p90Decoder_.observe(x0,x1); #endif // Preserve strong anti-correlated music side energy without // collapsing it into the two virtual mono HRTF sources. The @@ -678,11 +731,21 @@ class SonKuSpatialCore final { float sideRescue=positionedMode?0.f:(musicSafe? smoothedMix_*smoothedTrim_*musicSideWidth*preservedSide: .65f*smoothedMix_*smoothedTrim_*preservedSide); +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + const auto bassRoom=p92Stage?p92Foundation_.process(x0,x1): + p92::MusicBassFoundation::Sources{}; +#endif float originalLowL=0.f,originalLowR=0.f; #if defined(SONKU_P80_TRANSPARENT_BASS_RESEARCH) && SONKU_P80_TRANSPARENT_BASS_RESEARCH if(transparentBass){ - originalBass_[0]+=bassCrossoverAlpha_*(x0-originalBass_[0]); - originalBass_[1]+=bassCrossoverAlpha_*(x1-originalBass_[1]); +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + const float sourceBassL=x0+(p92Stage?bassRoom.left:0.f); + const float sourceBassR=x1+(p92Stage?bassRoom.right:0.f); +#else + const float sourceBassL=x0,sourceBassR=x1; +#endif + originalBass_[0]+=bassCrossoverAlpha_*(sourceBassL-originalBass_[0]); + originalBass_[1]+=bassCrossoverAlpha_*(sourceBassR-originalBass_[1]); originalLowL=originalBass_[0]; originalLowR=originalBass_[1]; // P7.5's full-band SIDE return caused LF to be counted @@ -698,11 +761,20 @@ class SonKuSpatialCore final { // world-locked measured reflections shoulder the extra space. sideRescue*=p89SideGain; #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH - if(p83Mode_==p83::Mode::MusicSpatialP90)sideRescue=0.f; + if(p83Mode_==p83::Mode::MusicSpatialP90 +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + ||p83Mode_==p83::Mode::MusicSpatialP92 +#endif + )sideRescue=0.f; #endif #endif +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + history_[0][write_]=x0+bassRoom.left; + history_[1][write_]=x1+bassRoom.right; +#else history_[0][write_]=x0; history_[1][write_]=x1; +#endif float ears[2]{0.f,0.f}; for(int tap=0;tap(degrees_),settings_.stereoSpreadDegrees, + p83HeadYaw_); +#endif p90Decoder_.compose(centerTarget_,targets_[0],targets_[1]); + } else #endif p84MusicKernel_.merge(centerTarget_,targets_[0],targets_[1]); @@ -1202,6 +1329,9 @@ class SonKuSpatialCore final { p84::FusedMusicHrir p84MusicKernel_{}; #if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH p90::StereoDecoder p90Decoder_{}; +#if defined(SONKU_P92_MUSIC_BASS_FOUNDATION) && SONKU_P92_MUSIC_BASS_FOUNDATION + p92::MusicBassFoundation p92Foundation_{}; +#endif #endif #if defined(SONKU_P87_MUSIC_BODY_RESEARCH) && SONKU_P87_MUSIC_BODY_RESEARCH p87::MusicalAirBody p87Body_{}; diff --git a/site/preview-v2/assets/mixer-native-sonku.js b/site/preview-v2/assets/mixer-native-sonku.js index 5ad8c9597..ed0788b29 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.renderMode===8||s.renderMode===9)?(s.hrtfElevationTrimDegrees??0):0; + const spectralOffset=(s.renderMode===7||s.renderMode===8||s.renderMode===9||s.renderMode===10)?(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<=9 && + Number.isInteger(s.renderMode)&&s.renderMode>=0&&s.renderMode<=10 && typeof s.musicCompatibleLowFrequency==="boolean" && (s.hrtfElevationTrimDegrees===undefined || ( Number.isFinite(s.hrtfElevationTrimDegrees) && s.hrtfElevationTrimDegrees>=-30 && s.hrtfElevationTrimDegrees<=20 && - ((s.renderMode!==7&&s.renderMode!==8&&s.renderMode!==9) || (s.directElevationDegrees+s.hrtfElevationTrimDegrees>=-40 && + ((s.renderMode!==7&&s.renderMode!==8&&s.renderMode!==9&&s.renderMode!==10) || (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,p89Capable=false,p90Capable=false,musicSafeStereo=false,p8TransparentBass=false,p82MultibandRoom=false, + xyzCapable=false,p83Capable=false,p84Capable=false,p85Capable=false,p86Capable=false,p87Capable=false,p88Capable=false,p89Capable=false,p90Capable=false,p92Capable=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,19 @@ function render(){ const row=$("skRenderRow");row.hidden=!(p83Capable||p84Capable); if(p83Capable||p84Capable){ const picker=$("skRenderMode"); - if(p90Capable && picker.dataset.nativeModeSet!=="p90"){ + if(p92Capable && picker.dataset.nativeModeSet!=="p92"){ + picker.innerHTML=''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''; + picker.dataset.nativeModeSet="p92"; + root.querySelector(".sk-render-label").textContent="RENDER MODE · P9.1+P9.2 HEADPHONE FAT"; + }else if(!p92Capable && p90Capable && picker.dataset.nativeModeSet!=="p90"){ picker.innerHTML=''+ ''+ ''+ @@ -279,7 +291,8 @@ function render(){ picker.dataset.nativeModeSet="p83"; root.querySelector(".sk-render-label").textContent="RENDER MODE · P8.3 TEST"; } - const v=p90Capable?(s.renderMode===9?"external":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"): + const v=p92Capable?(s.renderMode===10?"foundation":s.renderMode===9?"external":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"): + p90Capable?(s.renderMode===9?"external":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"): 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"): @@ -337,7 +350,7 @@ function render(){ $("skElevationValue").textContent=s.directElevationDegrees.toFixed(1)+"°"; } const alignRow=$("skHrtfAlignRow"),align=$("skHrtfAlign"); - alignRow.hidden=!(p88Capable&&(s.renderMode===7||s.renderMode===8||s.renderMode===9)); + alignRow.hidden=!(p88Capable&&(s.renderMode===7||s.renderMode===8||s.renderMode===9||s.renderMode===10)); if(!alignRow.hidden){ const min=Math.max(-30,-40-s.directElevationDegrees); const max=Math.min(20,60-s.directElevationDegrees); @@ -345,7 +358,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=p90Capable&&s.renderMode===9? + root.querySelector(".sk-stage-caption").textContent=p92Capable&&s.renderMode===10? + "P9.2 CALIBRATED WORLD SPEAKERS + SOURCE-COUPLED LF ROOM · HEADPHONE FAT REQUIRED": + p90Capable&&s.renderMode===9? "P9.0 MEASURED TWIN-SPEAKER HRIR · WORLD-LOCKED STEREO · FAT REQUIRED": p89Capable&&s.renderMode===8? "P8.9 ROOM-ANCHORED STEREO · DIRECT MUSICAL BODY PRESERVED · FAT REQUIRED": @@ -372,7 +387,9 @@ function render(){ $("skSpread").closest("label").querySelector(".sk-param-name").textContent= (p83Capable||p84Capable)&&s.renderMode!==0?"SPEAKER ANGLE": musicSafeStereo?"SIDE WIDTH":"SPREAD"; - root.querySelector(".sk-guide").textContent=p90Capable&&s.renderMode===9 + root.querySelector(".sk-guide").textContent=p92Capable&&s.renderMode===10 + ?"World-anchored bass and music reference level · calibrated headphone FAT pending" + :p90Capable&&s.renderMode===9 ?"Two positioned measured HRIR speakers · 0° co-location cannot preserve anti-phase" :musicSafeStereo ?"Legacy music WIDTH adjusts headlocked SIDE; P9 spatializes it" @@ -390,7 +407,8 @@ function render(){ // redrawn at 60 Hz. The native audio callback remains the time authority. drawSpeakers(); $("skMode").textContent=native()?(context()? - (p90Capable&&s.renderMode===9?"NATIVE P9.0 TRUE EXTERNAL · TEST": + (p92Capable&&s.renderMode===10?"NATIVE P9.2 MUSIC + ROOM BASS · TEST": + p90Capable&&s.renderMode===9?"NATIVE P9.0 TRUE EXTERNAL · TEST": p89Capable&&s.renderMode===8?"NATIVE P8.9 STEREO + ROOM · TEST": p88Capable&&s.renderMode===7?"NATIVE P8.8 EAR ALIGN + DISTANCE · TEST": p87Capable&&s.renderMode===6?"NATIVE P8.7 MUSICAL AIR + BODY · TEST": @@ -542,7 +560,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===10 || r.schemaVersion===11) && + r.schemaVersion===5 || r.schemaVersion===6 || r.schemaVersion===7 || r.schemaVersion===8 || r.schemaVersion===9 || r.schemaVersion===10 || r.schemaVersion===11 || r.schemaVersion===12) && Number.isFinite(r.settings?.directElevationDegrees); if(r.schemaVersion!==2&&!measured)return; const incoming=normalizeSettings(r.settings); @@ -554,7 +572,9 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ Number.isInteger(incoming.renderMode) && typeof incoming.musicCompatibleLowFrequency==="boolean" && Number.isFinite(incoming.headYawDegrees); - p90Capable=r.schemaVersion===11 && r.p90TrueExternalSpeaker===true && + p92Capable=r.schemaVersion===12 && r.p92MusicBassFoundation===true && + Number.isFinite(incoming.hrtfElevationTrimDegrees); + p90Capable=(r.schemaVersion===11||p92Capable) && r.p90TrueExternalSpeaker===true && Number.isFinite(incoming.hrtfElevationTrimDegrees); p89Capable=(r.schemaVersion===10||p90Capable) && r.p89StereoRoomDepth===true && Number.isFinite(incoming.hrtfElevationTrimDegrees); @@ -571,7 +591,8 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ (p87Capable&&incoming.renderMode===6)|| (p88Capable&&incoming.renderMode===7)|| (p89Capable&&incoming.renderMode===8)|| - (p90Capable&&incoming.renderMode===9)) && + (p90Capable&&incoming.renderMode===9)|| + (p92Capable&&incoming.renderMode===10)) && typeof incoming.musicCompatibleLowFrequency==="boolean" && incoming.musicCompatibleLowFrequency===false && Number.isFinite(incoming.headYawDegrees); @@ -606,7 +627,7 @@ backend()?.addEventListener?.("arMixBuiltinSonKuSnapshot",r=>{ } render(); }); -$("skClose").addEventListener("click",()=>{root.hidden=true;current=null;xyzCapable=false;p85Capable=false;p86Capable=false;p87Capable=false;p88Capable=false;p89Capable=false;p90Capable=false;musicSafeStereo=false;p8TransparentBass=false;p82MultibandRoom=false; +$("skClose").addEventListener("click",()=>{root.hidden=true;current=null;xyzCapable=false;p85Capable=false;p86Capable=false;p87Capable=false;p88Capable=false;p89Capable=false;p90Capable=false;p92Capable=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;} @@ -614,7 +635,8 @@ $("skClose").addEventListener("click",()=>{root.hidden=true;current=null;xyzCapa $("skRenderMode").addEventListener("change",()=>{ if(!(p83Capable||p84Capable))return; const v=$("skRenderMode").value; - const mode=p90Capable?(v==="external"?9:v==="depth"?8:v==="align"?7:v==="body"?6:v==="focus"?5:v==="coherence"?4:v==="clarity"?3:0): + const mode=p92Capable?(v==="foundation"?10:v==="external"?9:v==="depth"?8:v==="align"?7:v==="body"?6:v==="focus"?5:v==="coherence"?4:v==="clarity"?3:0): + p90Capable?(v==="external"?9:v==="depth"?8:v==="align"?7:v==="body"?6:v==="focus"?5:v==="coherence"?4:v==="clarity"?3:0): 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): @@ -623,6 +645,14 @@ $("skRenderMode").addEventListener("change",()=>{ p84Capable?(v==="clarity"?3:0): v==="mono"?1:v==="physical"||v==="musiclf"?2:0; const scene={...draft,renderMode:mode,musicCompatibleLowFrequency:v==="musiclf"}; + // Apply only on deliberate P9.2 selection. Existing saved sessions and + // P8/P9 mode switches are never rewritten or migrated speculatively. + if(mode===10 && draft.renderMode!==10){ + Object.assign(scene,{moving:false,startAzimuthDegrees:0, + stereoSpreadDegrees:82,spatialMix:1,outputTrim:1,spacePreset:3, + sourceDistanceMeters:1.6,roomAmount:.72,ambience:.38, + hrtfElevationTrimDegrees:0}); + } // Mode changes in v6 must not reset the owner scene, yaw or motion. if(mode!==0 && !p85Capable){ scene.moving=false; diff --git a/src/Main.cpp b/src/Main.cpp index 3a9937b8d..55f7e7846 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -3046,7 +3046,19 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr armix::sonku::SonKuReflectionProfile::SixSurfaceKemarResearch) reply->setProperty("p8TransparentBass",true); #endif -#if defined(ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P92_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); + reply->setProperty("p90TrueExternalSpeaker",true); + reply->setProperty("p92MusicBassFoundation",true); + } +#elif defined(ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P90_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 f5e55bdda..5134b7538 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_P90_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT + return 12; +#elif defined(ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT return 11; #elif defined(ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT return 10; @@ -104,7 +106,11 @@ inline bool decodeSettings(const juce::var& values,armix::sonku::Settings& out) #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 defined(ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P92_NATIVE_RT + if(proposed.renderMode!=0 && proposed.renderMode!=3 && proposed.renderMode!=4 && proposed.renderMode!=5 && proposed.renderMode!=6 && proposed.renderMode!=7 && proposed.renderMode!=8 && proposed.renderMode!=9 && proposed.renderMode!=10)return false; +#else if(proposed.renderMode!=0 && proposed.renderMode!=3 && proposed.renderMode!=4 && proposed.renderMode!=5 && proposed.renderMode!=6 && proposed.renderMode!=7 && proposed.renderMode!=8 && proposed.renderMode!=9)return false; +#endif #else if(proposed.renderMode!=0 && proposed.renderMode!=3 && proposed.renderMode!=4 && proposed.renderMode!=5 && proposed.renderMode!=6 && proposed.renderMode!=7 && proposed.renderMode!=8)return false; #endif diff --git a/tests/sonku_p90_dropdown_stability_test.cjs b/tests/sonku_p90_dropdown_stability_test.cjs index 890d0de90..8749a9585 100644 --- a/tests/sonku_p90_dropdown_stability_test.cjs +++ b/tests/sonku_p90_dropdown_stability_test.cjs @@ -7,13 +7,13 @@ const assert=require("node:assert/strict"); const fs=require("node:fs"); const vm=require("node:vm"); const source=fs.readFileSync("site/preview-v2/assets/mixer-native-sonku.js","utf8"); -const start=source.indexOf(' if(p90Capable && picker.dataset.nativeModeSet!=="p90"){'); -const end=source.indexOf(" const v=p90Capable?",start); +const start=source.indexOf(' if(p92Capable && picker.dataset.nativeModeSet!=="p92"){'); +const end=source.indexOf(" const v=p92Capable?",start); assert(start!==-1&&end>start,"Locate actual native SonKu mode menu reconciliation"); const actualReconcile=source.slice(start,end); const renderMenu=vm.runInNewContext( '(function(picker,root,cap){ const {'+ - 'p90Capable,p89Capable,p88Capable,p87Capable,p86Capable,'+ + 'p92Capable,p90Capable,p89Capable,p88Capable,p87Capable,p86Capable,'+ 'p85Capable,p84Capable,p83Capable}=cap;\n'+ actualReconcile+'\n})',{} ); @@ -45,7 +45,7 @@ const label={textContent:""}; const root={querySelector(selector){ assert.equal(selector,".sk-render-label");return label; }}; -const full={p90Capable:true,p89Capable:true,p88Capable:true, +const full={p92Capable:false,p90Capable:true,p89Capable:true,p88Capable:true, p87Capable:true,p86Capable:true,p85Capable:true,p84Capable:true, p83Capable:false}; renderMenu(picker,root,full); diff --git a/tests/sonku_p92_dropdown_stability_test.cjs b/tests/sonku_p92_dropdown_stability_test.cjs new file mode 100644 index 000000000..d01d1dc55 --- /dev/null +++ b/tests/sonku_p92_dropdown_stability_test.cjs @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Exercise the ACTUAL SonKu render-mode DOM-update branch, not a hand-copied +// model. Regression: native schema 12 advertises P9.2, P9.0 and P8.9 capabilities; +// priority must remain P9.2 > P9.0 > P8.9 without rewriting the popup. +"use strict"; +const assert=require("node:assert/strict"); +const fs=require("node:fs"); +const vm=require("node:vm"); +const source=fs.readFileSync("site/preview-v2/assets/mixer-native-sonku.js","utf8"); +const start=source.indexOf(' if(p92Capable && picker.dataset.nativeModeSet!=="p92"){'); +const end=source.indexOf(" const v=p92Capable?",start); +assert(start!==-1&&end>start,"Locate actual native SonKu mode menu reconciliation"); +const actualReconcile=source.slice(start,end); +const renderMenu=vm.runInNewContext( + '(function(picker,root,cap){ const {'+ + 'p92Capable,p90Capable,p89Capable,p88Capable,p87Capable,p86Capable,'+ + 'p85Capable,p84Capable,p83Capable}=cap;\n'+ + actualReconcile+'\n})',{} +); +const syncMatch=source.match(/if\(picker\.value!==v\)picker\.value=v;/); +assert(syncMatch,"Native render must not reset an unchanged open popup value"); +const syncSelection=vm.runInNewContext( + '(function(picker,v){'+syncMatch[0]+'})',{} +); +const optionWrites=[]; +const picker={dataset:{},isOpen:false,_markup:"",_value:"music", + get innerHTML(){return this._markup;}, + set innerHTML(markup){ + assert.equal(this.isOpen,false, + "Render must not replace