diff --git a/.github/workflows/sonku-p74-windows-field.yml b/.github/workflows/sonku-p74-windows-field.yml index c717caa42..bae760900 100644 --- a/.github/workflows/sonku-p74-windows-field.yml +++ b/.github/workflows/sonku-p74-windows-field.yml @@ -1,18 +1,9 @@ name: SonKu P7.4 physical Windows XYZ field candidate # Isolated opt-in full JUCE app build; no public installer, tag or release. +# Historical FAT remains reproducible by explicit dispatch only. +# Never run an expensive full JUCE/Windows candidate on every newer SonKu +# source edit; current milestone dispatch is specified in AGENTS.md. on: - pull_request: - types: [opened, reopened, synchronize] - paths: - - '.github/workflows/sonku-p74-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_*' workflow_dispatch: permissions: contents: read diff --git a/.github/workflows/sonku-p75-windows-field.yml b/.github/workflows/sonku-p75-windows-field.yml index adad0dc3f..3ac872ec5 100644 --- a/.github/workflows/sonku-p75-windows-field.yml +++ b/.github/workflows/sonku-p75-windows-field.yml @@ -1,19 +1,9 @@ name: SonKu P7.5 phase-safe Windows music field candidate # Isolated opt-in full JUCE app build; no public installer, tag or release. +# Historical FAT remains reproducible by explicit dispatch only. +# Never run an expensive full JUCE/Windows candidate on every newer SonKu +# source edit; current milestone dispatch is specified in AGENTS.md. 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_*' workflow_dispatch: permissions: contents: read diff --git a/.github/workflows/sonku-p80-acoustic-windows-field.yml b/.github/workflows/sonku-p80-acoustic-windows-field.yml index 10cd27f1f..78c343aaf 100644 --- a/.github/workflows/sonku-p80-acoustic-windows-field.yml +++ b/.github/workflows/sonku-p80-acoustic-windows-field.yml @@ -1,20 +1,9 @@ name: SonKu P8.0 measurable stereo-bass and room native field candidate # Isolated opt-in full JUCE app build; no public installer, tag or release. +# Historical FAT remains reproducible by explicit dispatch only. +# Never run an expensive full JUCE/Windows candidate on every newer SonKu +# source edit; current milestone dispatch is specified in AGENTS.md. on: - pull_request: - types: [opened, reopened, synchronize] - paths: - - '.github/workflows/sonku-p80-acoustic-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_*' workflow_dispatch: permissions: contents: read diff --git a/.github/workflows/sonku-p82-acoustic-windows-field.yml b/.github/workflows/sonku-p82-acoustic-windows-field.yml index 15ff4e144..786a861ac 100644 --- a/.github/workflows/sonku-p82-acoustic-windows-field.yml +++ b/.github/workflows/sonku-p82-acoustic-windows-field.yml @@ -1,21 +1,8 @@ name: SonKu P8.2 six-wall and three-band room acoustic native field candidate # Isolated opt-in full JUCE app build; no public installer, tag or release. +# Historical P8.2 physical FAT remains manual; do not launch duplicate +# full Windows JUCE builds for native P8.3 milestone source edits. on: - pull_request: - types: [opened, reopened, synchronize] - paths: - - '.github/workflows/sonku-p82-acoustic-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_*' workflow_dispatch: permissions: contents: read diff --git a/.github/workflows/sonku-p83-native-speaker-gates.yml b/.github/workflows/sonku-p83-native-speaker-gates.yml new file mode 100644 index 000000000..ff7353ca2 --- /dev/null +++ b/.github/workflows/sonku-p83-native-speaker-gates.yml @@ -0,0 +1,190 @@ +name: SonKu P8.3 native physical speaker research PCM +on: + pull_request: + paths: + - 'engine/builtin_fx/sonku/SonKuSpatialCore.h' + - 'engine/builtin_fx/sonku/SonKuEarlyReflections.h' + - 'engine/builtin_fx/sonku/SonKuP83SpeakerScene.h' + - 'engine/builtin_fx/sonku/SonKuP83LowFrequencyTransfer.h' + - 'tests/sonku_p83_*' + - 'engine/builtin_fx/SonKuSpatialProcessor.h' + - 'src/SonKuNativeBridgeContract.h' + - 'site/preview-v2/assets/mixer-native-sonku.js' + - 'CMakeLists.txt' + - 'tools/sonku_p83_offline_ab.cpp' + - '.github/workflows/sonku-p83-native-speaker-gates.yml' + workflow_dispatch: +permissions: + contents: read +concurrency: + group: sonku-p83-physical-${{ github.ref }} + cancel-in-progress: true +jobs: + native-source: + name: Native C++ P8.3 source, PCM/stems/no-null and Music Bed invariants + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - name: Build and run original SonKu native source + shell: bash + run: | + set -euo pipefail + FLAGS=(-std=c++20 -O2 -Wall -Wextra -Werror -pedantic + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 + -DSONKU_P72_NATIVE_XYZ_RT=1 + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1) + g++ "${FLAGS[@]}" -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 \ + tests/sonku_p83_physical_speaker_source_test.cpp -o /tmp/p83-native + /tmp/p83-native --wavdir sonku-p83-native-pcm | tee /tmp/p83-native.log + grep -q '^PASS P8.3 SOURCE GATES:' /tmp/p83-native.log + g++ "${FLAGS[@]}" tests/sonku_p83_externalization_gap_diagnostic.cpp \ + -o /tmp/p82-gap + /tmp/p82-gap | tee /tmp/p82-gap.log + grep -q '^PASS P8.3 DIAGNOSTIC:' /tmp/p82-gap.log + + - name: Realtime mode source gate and P8.3 GUI syntax/capability + shell: bash + 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 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 \ + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 \ + -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 \ + tests/sonku_p83_live_scene_edit_test.cpp -o /tmp/p83-live + /tmp/p83-live + node --check site/preview-v2/assets/mixer-native-sonku.js + node tests/sonku_p73_gui_contract_test.js + - name: Cross-build exact Music Bed P8.2 raw PCM unchanged by opt-in P8.3 compilation + shell: bash + run: | + set -euo pipefail + FLAGS=(-std=c++20 -O2 -Wall -Wextra -Werror -pedantic + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 + -DSONKU_P72_NATIVE_XYZ_RT=1 + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1) + g++ "${FLAGS[@]}" tests/sonku_p83_music_bed_byte_parity.cpp -o /tmp/p82-golden + g++ "${FLAGS[@]}" -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 \ + tests/sonku_p83_music_bed_byte_parity.cpp -o /tmp/p83-default + /tmp/p82-golden /tmp/p82-golden.raw + /tmp/p83-default /tmp/p83-default.raw + cmp /tmp/p82-golden.raw /tmp/p83-default.raw + sha256sum /tmp/p82-golden.raw /tmp/p83-default.raw + - name: Hosted CPU evidence 44.1/48k 64/128/256 1/2/4 inserts (NOT ASIO) + shell: bash + 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 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 \ + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 \ + -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 \ + tests/sonku_p83_hosted_cpu_benchmark.cpp -o /tmp/p83-bench + /tmp/p83-bench | tee /tmp/p83-bench.log + grep -q '^P83_HOSTED_CPU,mode=P83' /tmp/p83-bench.log + - name: Strict music fidelity FAT veto - P8.2 reference is mandatory + shell: bash + run: | + set -euo pipefail + awk -F, ' + /^P83_SPECTRAL,MUSIC_LF_ANTIPHASE,48000,frequency=83Hz/ {split($5,a,"="); bass=a[2]} + /^P83_SPECTRAL,MUSIC_LF_ANTIPHASE,48000,frequency=1703Hz/ {split($5,a,"="); mid=a[2]} + END { + if (bass=="" || mid=="") {print "FAIL P83 MUSIC: missing source spectra"; exit 2} + diff=bass-mid + printf "P83_MUSIC_GATE,48000,83Hz_minus_1703Hz_relative_to_P82=%.3f dB,minimum=-6 dB\n",diff + if(diff < -6) {print "FAIL P83 MUSIC: opt-in LF safeguard still loses bass"; exit 1} + print "PASS P83 MUSIC: all-source spectral and broadband gate; headphone listening still pending" + } + ' /tmp/p83-native.log + grep -q '^PASS P8.3 SOURCE FIDELITY:' /tmp/p83-native.log + - name: Build exact SonKu P8.3 offline music A/B utility and smoke real WAV + shell: bash + 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 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 \ + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 \ + -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 \ + tools/sonku_p83_offline_ab.cpp -o /tmp/sonku-p83-ab + python3 - <<'PY' + import math,struct,wave + with wave.open('/tmp/sonku-p83-input.wav','wb') as f: + f.setnchannels(2); f.setsampwidth(2); f.setframerate(48000) + data=bytearray() + for i in range(96000): + t=i/48000 + x=.13*math.sin(2*math.pi*83*t)+.08*math.sin(2*math.pi*461*t) + y=.07*math.sin(2*math.pi*1703*t)+.05*math.sin(2*math.pi*5387*t) + data+=struct.pack('96000*8 + assert struct.unpack_from(' sonku-integrity-evidence/KEMAR-SPECTRAL-AUDIT.csv - test "$(($(wc -l < sonku-integrity-evidence/KEMAR-SPECTRAL-AUDIT.csv)-1))" -eq 380 - - name: Same-runner informational SonKu native realtime CPU check - run: | - g++ -std=c++20 -O2 -Wall -Wextra -pedantic tools/sonku_rt_benchmark.cpp -o /tmp/sonku-integrity-cpu - /tmp/sonku-integrity-cpu - - name: Upload original lossless music-integrity proof - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - name: ArSonMix-SonKu-Phase-Integrity-${{ github.run_id }} - path: | - sonku-integrity-evidence/* - sonku-integrity-baseline/* - if-no-files-found: ignore - retention-days: 14 - vocal-throw-preview: name: Vocal Delay native editor desktop/mobile Chromium FAT needs: quick diff --git a/AGENTS.md b/AGENTS.md index 1bca12415..f2d6d2777 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,6 +12,12 @@ **2026-11-13 implementation starting point:** at that checkpoint [#604](https://github.com/masarray/arsonmix/pull/604) was a browser reference UI draft and [#606](https://github.com/masarray/arsonmix/pull/606) was the more advanced in-scope integration draft **including #604** and SonKu. Refresh live main and PR heads first; reconcile the most advanced source without reimplementing it, losing plugin/editor work, or double-merging. **Naming across the repository and CI:** ArSonMix is the mixer. Harmonice is its built-in vocal harmony plugin. Use mixer terminology for shared controls, including MUTE/SOLO/PFL and SOF, and name the actual subsystem in test labels (plugin DSP, mixer PCM, ASIO). Do not schedule Windows builds for specification-only changes. +### Accepted GAIN GUI checkpoint / cross-thread preservation — 2026-11-14 + +**When working on GAIN, GUI integration, Pages, SonKu, LMS, FX or native controls, consult [cross-thread safety ledger #699](https://github.com/masarray/arsonmix/issues/699) and re-audit LIVE `main` plus relevant PR files.** The accepted operator GAIN baseline was shipped via #690 → #694 → #696 → #698 (`a01fe350` at that moment): static steel PNG knob with shadow, 58px default cap / 84×25px recessed green-on-black LCD and 30-segment LED arc, no click-to-seek, 6px intentional drag arm, 0dB capture ±1.6dB / release ±3.2dB, and native ACK/readback. Use the current approved `/preview/` and targeted visual/gesture tests; *do not replay these historical PR commits*. + +**High-risk old integration branches:** draft #661 and #649 carry pre-checkpoint GAIN HTML/CSS/bridge; draft #635 changes Pages assembler/CI, while SonKu P7–P8 is a stacked, physically unqualified research/field chain. Reconcile only relevant, source-owned hunks onto the latest `main`; do not copy whole old GUI files, merge the stacked drafts en masse, force-push or overwrite other threads. This ledger is a collision warning, **not a new coordination/owner gate**. Continue independent work normally and treat any physical audio FAT separately from Chromium/UI success. + ## Long-term maintainability execution — 2026-11-11 For real source ownership and future feature-extension work, read [Current Architecture](docs/architecture/README.md), [Maintainability Execution Blueprint](docs/architecture/MAINTAINABILITY_EXECUTION_V1_20261111.md), and [Fast Feature Playbook](docs/architecture/FEATURE_EXTENSION_PLAYBOOK.md). A [ready-to-copy next-thread implementation prompt](docs/architecture/NEXT_THREAD_EXECUTION_PROMPT.md) begins coding M1 instead of repeating architecture research. [Issue #527](https://github.com/masarray/arsonmix/issues/527) tracks progress. These are implementation aids, NOT an extra coordination gate or an override of the approved /preview/, single native PCM callback, hard RT/audio safety, owner-authorized smart CI, or physical FAT rules. Keep the plan updated after proven source changes; do not create a new high-level plan instead of shipping a testable milestone. diff --git a/CMakeLists.txt b/CMakeLists.txt index ba32b706b..50dbac9ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,15 @@ if(ARMIX_SONKU_EXPERIMENTAL_P82_ROOM AND NOT ARMIX_SONKU_EXPERIMENTAL_P8_TRANSPARENT_BASS) message(FATAL_ERROR "P8.2 room requires P8.1 transparent-bass experiment") endif() +# Isolated P8.3 physical speakers + music-LF A/B, public binaries OFF. +# Requires the already opt-in P8.2 native measured room/XYZ stack. +option(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + "Enable P8.3 v4 native render mode and real-time speaker audition (unreleased)" + OFF) +if(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT AND + NOT ARMIX_SONKU_EXPERIMENTAL_P82_ROOM) + message(FATAL_ERROR "P8.3 native speaker research requires P8.2 room ON") +endif() set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -237,7 +246,9 @@ target_compile_definitions(ARMixConsole PRIVATE $<$: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_P82_MULTIBAND_ROOM_RESEARCH=1> + $<$:ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT=1> + $<$:SONKU_P83_PHYSICAL_SPEAKER_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. @@ -403,6 +414,40 @@ if(BUILD_TESTING) SONKU_P82_MULTIBAND_ROOM_RESEARCH=1) add_test(NAME NativeSonKuP82SixWallThreeBandRoomTimingDecayAndParity COMMAND ARMixSonKuP82RoomTests) + if(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) + add_executable(ARMixSonKuP83LiveSourceTests + tests/sonku_p83_live_scene_edit_test.cpp) + target_compile_features(ARMixSonKuP83LiveSourceTests PRIVATE cxx_std_20) + target_compile_definitions(ARMixSonKuP83LiveSourceTests 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) + add_test(NAME NativeSonKuP83RealtimeModeSourceAndMusicIntegrity + COMMAND ARMixSonKuP83LiveSourceTests) + juce_add_console_app(ARMixSonKuP83NativeTests + PRODUCT_NAME "ArSonMix SonKu P83 Native JUCE v4 Tests") + target_sources(ARMixSonKuP83NativeTests PRIVATE + tests/sonku_p83_native_juce_v4_test.cpp) + target_compile_features(ARMixSonKuP83NativeTests PRIVATE cxx_std_20) + target_link_libraries(ARMixSonKuP83NativeTests PRIVATE + juce::juce_audio_processors juce::juce_recommended_config_flags) + target_compile_definitions(ARMixSonKuP83NativeTests PRIVATE + ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT=1 + ARMIX_SONKU_EXPERIMENTAL_P83_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) + add_test(NAME NativeSonKuP83JuceV4AudioAckLegacyRestoreAndHeadYaw + COMMAND ARMixSonKuP83NativeTests) + endif() endif() endif() endif() diff --git a/docs/SONKU_P83_NATIVE_MIXER_FIELD_FAT_20261115.md b/docs/SONKU_P83_NATIVE_MIXER_FIELD_FAT_20261115.md new file mode 100644 index 000000000..b590a44f1 --- /dev/null +++ b/docs/SONKU_P83_NATIVE_MIXER_FIELD_FAT_20261115.md @@ -0,0 +1,142 @@ +# SonKu P8.3 — Native Windows Mixer Headphone FAT (research only) + +**Candidate**: exact full native JUCE AR MIX Studio.exe from the +\`ArSonMix-SonKu-P83-Native-Mixer-Windows-x64-*\` GitHub Actions artifact. +The artifact is a portable research mixer, not a public release or +installer. The build must say P8.3 in \`BUILD_PROVENANCE.json\`, use +\`stateSchema=4\` and cite the source SHA. No dearVR parity claim. + +## Run the REAL native mixer, not the offline WAV renderer + +1. Extract the whole artifact to its own directory, never overwrite + your existing P8.2-approved test mixer or public Harmonice install. + Open the packaged native mixer .exe. Keep the P8.2 golden portable + for controlled A/B. No ASIO 4–8-channel device is required: + a working headphone stereo output is sufficient. +2. In **Audio Setup**, select your actual interface ASIO/WASAPI and + headphone playback L/R; verify audio device channel routing and + Master Mono is OFF. Use **48k, buffer 128** initially, with a + safe monitor volume. The existing native JUCE PCM authority remains + the only audio graph; avoid multiple independently monitoring paths. +3. Route your own stereo music source through a native mixer channel, + insert **8D-SonKu** in that channel's FX rack. Use the normal + approved GUI /preview/ and mixer routing, not a second WebAudio tab. +4. Open SonKu. A real P8.3 research binary shows a small **RENDER MODE** + dropdown after the native v4 snapshot. If no selector appears, + the running executable is NOT a functioning P8.3 host candidate. + Do not treat the browser preview as audio. +5. Switch between: + - **MUSIC BED · P8.2**: last-approved tonal/bass baseline; + - **SPEAKER MONITOR · PHYSICAL**: exact measured KEMAR two-speaker + transfer. Opposite-phase bass may cancel physically; + - **SPEAKER MONITOR · MUSIC LF**: 480Hz explicit compromise, + not a physically measured low-band BRIR; + - **MONO OBJECT · LEFT INPUT**: LEFT input only drives a single + virtual source, useful with one mono test channel. + A mode edit should first queue, then report audio **APPLIED** + and return the accepted settings in readback. No fake switch. +6. Set STATIC, position=0° and SPREAD=60° for stereo front + speakers at -30/+30°, elevation 0°, distance 1.6m. Compare ROOM OFF + first; then SQUARE with reflections 55%, reverb 30%. + Head yaw slider simulates head rotation with world-fixed sources. + It is NOT camera/head-tracking hardware. +7. Listen at matched loudness on the exact same headphone, interface, + source and mix settings. Test directional RIGHT/LEFT, FRONT/REAR, + overhead false elevation, real distance and vocals/bass at equal + levels, first at low monitor volume. Avoid accidentally listening + to double-played signal routed directly to MAIN and through SonKu. + +## Simple report: the hearing verdict matters + +Record under each of the three modes: perceived source location, +externalization (inside/outside head), overhead illusion, distance, +vocal timbre, bass/kick fullness, artifacts/clicks, and CPU/XRUN +if the device reports them. For moving sources test 0°, ±30°, ±90°, +±150° and 180°. Perform blind trials at 4 and 8 directions with a +confusion matrix; target ≥80% cardinal correctness before comparison +against dearVR PRO 2 on the same headphones. + +**Acceptance guard:** no merge/public release or declaration of +dearVR equivalence until human listening signs off. Generic KEMAR +HRTFs, 480Hz LF directional compromise, limited non-individual +pinna cues and absent automatic head tracking remain limitations. +Computer CI cannot establish real-world externalization or ASIO +hardware p95/p99/XRUN. Retain P8.2 as an always-available fallback. + +## CI trust boundary + +Only count the zip as the P8.3 native candidate when the pipeline +compiled **ARMixConsole** with +\`ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT=ON\`, +ran \`NativeSonKuP83JuceV4AudioAckLegacyRestoreAndHeadYaw\`, +passed source/legacy regression tests, verified executable PE/GUI +resources, and generated an exact source-commit-provenanced portable +artifact. Unrelated P7.x/P8.0 Windows outputs do not contain P8.3. + +## Real Windows candidate gate correction — strict native state bytes + +The first full Windows build successfully compiled the actual +`ARMixConsole` plus P8.3 JUCE test executable, and 7/8 focused tests +passed. The 8th revealed a real bug: JUCE `readByte()` can return +signed -1 for corrupt `0xFF`, so a `>1` boolean check accidentally +accepted it. The v4 and inherited v1-v3 boolean admissions now +require **exactly 0 or 1**. A dedicated logical/unpublished editor +test also prevents queued mode edits from awaiting a nonexistent audio +callback, while published realtime edits require the full 12 ms +fade-and-audio ACK transaction. State snapshots are now blocked by an +atomic pending-mode fence during the transition. This corrected +candidate must pass all 8 Windows CTests before packaging. + +## CRITICAL: USER HEADPHONE FAT REJECTED, 2026-11-15 WIB + +The owner tested the full native mixer P8.3 portable candidate from run +43635510105 and found the sound **compressed/boxed-in, quiet and lacking +body**, far worse than the approved P8.2. Treat the physical headphone +result as a HARD FAILURE, not a request for additive gain or more reverb. +The P8.3 portable artifact is preserved for forensic reproduction +ONLY. **Do not recommend it as an accepted listening candidate**. + +Source-level root causes supported by current code: +1. `transparentBass` is disabled whenever `positionedMode` is true. + That removes P8.2's original L/R LF pressure restoration. +2. `musicSafe` and `sideRescue` are disabled for positioned mode. + That removes P8.2 stereo SIDE musical preservation and centered + anti-comb filtering. +3. `roomEnabled&&!positionedMode` excludes P8.3 from P8.2 scene + presence calibration, despite still using the scene's FIR, ER/FDN, + and output gain/smoothing paths. +4. Two measured HRIRs at +/-30 degrees are valid directional research + sources but do NOT alone guarantee consistent full-spectrum music; + their MID/SIDE transfer can have low-energy and cancellation valleys. +5. The "LF480" substitute only conditions the direct 480-Hz low band, + uses an intentionally non-measured 2x2 matrix, and does not guarantee + stereo music above its crossover. Prior 4-bin +/-6dB acceptance is + inadequate for real music. + +Existing exact native 48k PCM evidence: anti-phase P8.2 energy +8.967784318, physical speaker 1.520875549 (-7.71dB), opt-in LF480 +5.489325122 (-2.13dB). LF480 at 461Hz is -5.801dB and correlated +mono at 1703Hz -3.887dB relative to P8.2. These do not by themselves +prove the exact frequency profile of the user's song/headphones, but +they INVALIDATE the previous "music fidelity PASS" conclusion. + +FAT gate is now deliberately strict: LF480 must preserve five +program-material fixtures within +/-3dB full-band level and both mono +and anti-phase spectral probes at 83/461/1703/5387Hz within +/-2.5dB +at both 44.1/48k. Any violation MUST FAIL the CI, preventing another +"green" portable candidate that is materially quieter or hollow. +Additional continuous-spectrum FFT, transient, binaural IACC, +loudness-matched headphone and human sound-location tests remain +mandatory. Do not game these gates with auto-gain. + +## CI release freeze + +The Windows research FAT workflow is now `workflow_dispatch` only. +Even manual dispatch starts with an actual P8.3 C++ acoustic regression +gate and refuses a Windows runner unless this source gate passes. +This prevents repeated, costly full JUCE builds of the rejected DSP. +The older artifact from 43635510105 remains downloadable as forensic +evidence but is **NOT approved for monitoring or public release**. +The CI source-fidelity veto must not be bypassed by modifying a +threshold simply to make the build green. Subjective owner FAT still +controls final approval after measurable musical integrity has passed. diff --git a/docs/SONKU_P83_NATIVE_PHYSICAL_SPEAKER_CHECKPOINT_20261114.md b/docs/SONKU_P83_NATIVE_PHYSICAL_SPEAKER_CHECKPOINT_20261114.md new file mode 100644 index 000000000..9bb2873e3 --- /dev/null +++ b/docs/SONKU_P83_NATIVE_PHYSICAL_SPEAKER_CHECKPOINT_20261114.md @@ -0,0 +1,221 @@ +# SonKu P8.3 — Native physical speaker research checkpoint + +**Status:** experimental source-mode DSP; do NOT merge into public main. +Base: PR #697 above P8.2 PR #695. Existing P8.2 portable artifact +`14118867259` is the golden headphone reference. + +## Code, not merely an ARD + +`SonKuP83SpeakerScene.h` defines explicit `MusicBedP82`, +`MonoObject` and `SpeakerMonitor` semantics. The default remains +the former P8.2 Music Bed with its approved bass and SIDE behavior. +Research-only quiescent methods on `SonKuSpatialCore` select a mode, +head yaw and read-only isolated acoustic stems. They **cannot** be invoked +after PCM starts; no native SPSC/ACK, presets or session version is changed. + +- **MonoObject** consumes INPUT LEFT only; one world-positioned emitter + produces both ears. INPUT RIGHT is deliberately ignored. Never infer + mono from correlations. +- **SpeakerMonitor** uses independent L and R physical sources, default + positions -30/+30 degrees around the FRONT, preserving two measured + time-domain HRTF transfers to both ears. The two sources are never + collapsed into MID nor augmented by a head-locked headphone SIDE bed. + No direct LF headphone bed is mixed into this mode. +- **World yaw** is a separate control. Direct angle subtracts head yaw; + room images remain located in the world and their measured ear arrival + angles subtract yaw. This covers both horizontal and vertical ER. + It is *deterministic offline yaw*, NOT live tracking or a sensor pipeline. +- The approved P8.1 tonal calibration is retained for P8.3 research + direct sound; low frequency/musical quality remains an open listening gate. +- P8.2 materials, measured KEMAR, six walls, and 3-band FDN are shared, + not reimplemented. P8.2 speaker behavior is not rewritten. +- `Stem` Direct/Early/Late plus six-bit wall mask gives exact native + direct, horizontal, floor, ceiling, late and combined captures. It is + diagnostic output gating, not arbitrary room gain or elevation hacks. + +## Fast reproducible evidence + +GitHub Actions `sonku-p83-native-speaker-gates.yml` builds the actual +`SonKuSpatialCore` at 44.1/48 kHz, runs source-direction, yaw, +/-180, +independent two-speaker L/R, correlated, antiphase, partial-coherence, +Music Bed chunk-parity and masked room-path probes. It checks finite +PCM, interaural sign, non-null side-only music, first-arrival ordering, +and native diagnostic stems. A separate unmodified P8.2 defect +reproduction runs alongside to avoid declaring the old failure a PASS. +The artifact offers deterministic 48k float32 stereo WAV stems; **these +WAVs are diagnostic impulses/tones, not natural musical or ASIO FAT**. + +Run locally: + +```bash +g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH=1 \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH=1 -DSONKU_P72_NATIVE_XYZ_RT=1 \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH=1 \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH=1 \ + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH=1 \ + -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH=1 \ + tests/sonku_p83_physical_speaker_source_test.cpp -o /tmp/p83-speaker +/tmp/p83-speaker --wavdir /tmp/p83-research-pcm +``` + +## Gates NOT passed by this source milestone + +1. This is NOT yet user-switchable in the full native JUCE host. Next + vertical integration adds versioned `.smix` render mode, native + SPSC/ACK, live speaker audition, portable Windows research candidate + and a minimal mode selector WITHOUT changing approved visual skins. +2. True head yaw updating *during* callback needs bounded native + command/queue and smooth kernel transitions. Current quiescent yaw + validates world-frame geometry, not tracking latency or drift. +3. Linear HRIR interpolation preserves tap timing numerically but phase + behavior between measured grid points still needs objective ITD/ + spectrum testing and listening for front/back/elevation. Additional + SOFA banks need explicit licensing. +4. No per-device ASIO p95/p99/XRUN or 1/2/4 insert live profiling here. +5. Speaker mode anti-phase non-null is necessary but insufficient: + measure LF, narrow-band comb depth, vocals and stereo against P8.2. + Do not approve without level-matched music and blind headphone + directional/externalization evidence (including overhead errors). +6. Acoustic source and head yaw are world-separated; actual BRIR/headphone + calibration and floor/ceiling contribution require human comparison. +7. Never claim dearVR PRO 2 parity without matched hardware and listener A/B. + +## Further source evidence + +The P8.2 default is now compared bytewise across two independent native +compilations, with P8.3 macro disabled and enabled but unselected; both +ROOM ON/OFF and correlated/antiphase inputs at 44.1/48 kHz. Research +impulse measurements include full-window IACC/ITD, +/-20 degrees direct +elevation, spectral level and ear phase at 83, 461, 1703 and 5387 Hz, +and reconstruction of isolated native wall/late stems. **IACC is not +perceptual externalization**. CPU p50/p95/p99 and ASIO measurements +remain a distinct performance milestone, not proven by this source test. + +## P8.3 experimental music-integrity rejection (14 November 2026) + +48k measured native speaker anti-phase drops 83 Hz by -25.112 dB +relative to P8.2, but 1703 Hz by only -1.374 dB. The resulting +LF-versus-mid difference is -23.738 dB; a global trim cannot restore +this ratio. At 44.1k the similar values are -26.095/-2.113 dB. +A real symmetric pair of speakers playing opposing polarity can cancel +bass near a central listener. However, this is still a music-fidelity +**failure** against the owner's SonKu contract, NOT a successful candidate. +Keep Music Bed default and do not ship a compensating headphone stereo +bed as a disguised physical speaker. The CI includes an intentional +**red LF quality veto** until a physical and musically acceptable solution +passes. This gate is independent of the native directional source PASS. +A 44.1/48k, 64/128/256, 1/2/4-insert Linux hosted CPU benchmark is +also added; neither this benchmark nor a source PASS proves ASIO XRUNs. + +## Opt-in music-compatible LF research mode, not a physical BRIR + +The measured physical stereo 2x2 KEMAR transfer remains default and +separately reported. Real symmetric loudspeakers can cancel anti-phase +LF at a central listener. A 150-Hz complementary crossover can +instead substitute ONLY the direct low-frequency transfer with a +source-position/head-yaw-aware 2x2 ear matrix. Both sources feed both +ears, but this low-band compensation intentionally introduces +non-physical ILD and is NOT the measured response of two speakers. +It is research-only and explicit through quiescent +`setResearchSpeakerMusicLowFrequency(true)`; the full measured +upper-frequency HRTF, six directional walls, room materials and FDN +remain intact. MonoObject and P8.2 Music Bed are unchanged. +This is not a hidden headphone SIDE return, but it is a monitored +physical-fidelity tradeoff; user listening must assess whether that +tradeoff is acceptable. + +The source gate compares physical versus music LF anti-phase, correlated, +hard-L/R, head-yaw and block parity, and records reproducible WAVs. +The relative -6 dB threshold now checks the opt-in monitoring variant. +A PASS is only a *tonal source gate*, not proof of externalization. + +## Narrow-band regression audit + +An initial opt-in 150-Hz direct LF crossover improved 48-kHz anti-phase +83 Hz from -25.112 dB to -2.849 dB vs P8.2, but 461 Hz remained +-11.520 dB, and mono 1703 Hz remained -7.207 dB. **Do not claim +music fidelity PASS from the original 83-Hz-only quality gate.** +The native source now tests crossover frequencies 150/220/350/480/650 Hz +on *the same* original input, printing 83/461/1703/5387-Hz +anti-phase and correlated-mono spectral differences for engineering +selection. A larger LF substitution harms physical low-mid ITD/ILD; +select only after reviewing these cross-band measurements. + +## Chosen P8.3 opt-in crossover, based on same-source 44.1/48k sweep + +The smallest measured crossover in the sweep that avoided a >6dB +reduction across *both* 83 Hz and 461 Hz was **480 Hz**: +- 48k anti-phase: 83 -1.693dB, 461 -5.801dB, 1703 -0.173dB + and 5387 +0.917dB relative to P8.2. +- 48k correlated mono: 83 +1.053dB, 461 +1.096dB, 1703 + -3.887dB and 5387 -2.781dB. +- 44.1k anti-phase: 83 -1.713dB, 461 -5.665dB, + 1703 -0.792dB, 5387 +0.120dB. +- 44.1k correlated mono: 83 +1.016dB, 461 +1.295dB, + 1703 -3.395dB and 5387 -2.795dB. + +650Hz would improve the 461Hz differential further but destroys +more measured low-mid physical cues. 480Hz is only a tradeoff candidate, +NOT a psychoacoustically verified optimum. Source gates now reject +relative dips *or boosts* outside +/-6dB at all four frequencies and +both rates for BOTH correlated and anti-phase tests, while the +unaltered physical mode remains separately measurable. Any unsampled +spectral cancellations, room coloration or headphone externalization +failures still veto product approval. + +## Offline headphone A/B with your OWN music, exact native DSP + +`tools/sonku_p83_offline_ab.cpp` reads a user-owned uncompressed +stereo WAV (PCM16/24 or IEEE float32, 44.1/48k) and writes +`P82_MusicBed.wav`, `P83_SpeakerPhysical.wav` and +`P83_SpeakerMusicLF480.wav`, with matching input, trim (.75), +speaker angle (-30/+30), head yaw (0), distance (1.6m), timebase and +optional `--room=on` (actual P8.2 three-band FDN +and six-wall early room). It uses the EXACT native SonKuSpatialCore, +not simulated Javascript/WebAudio. Default `--room=off` isolates +direct sound first. No tracker, live host routing or VST3 integration. + +Windows MSVC build command (developer toolchain; not a packaged app): +`cl /std:c++20 /O2 /EHsc /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 + tools\\sonku_p83_offline_ab.cpp /Fe:sonku-p83-ab.exe` + +Run `sonku-p83-ab.exe "D:\\Music\\my-song.wav" "D:\\SonKuAB" --room=off`. +For room comparison repeat with separate output folder and `--room=on`. + +The utility records **raw**, NOT matched-loudness output PCM and +`sonku_p83_ab_metrics.csv` (whole-file RMS/peak). Listening FAT +must loudness-match on the same headphones/audio interface and use +one song excerpt; normalize with an external trusted tool, not by +arbitrary output makeup in this renderer. No stream/ASIO/GUI changes, +no public release. Do not use this CLI to claim latency or real +speaker externalization. Only user listening can approve that. + +The fast Linux CI compiles and smoke-renders an original test WAV, +uploads three original-source A/B listening files and metrics. +The sample is deliberately original synthesized material, not +proprietary music. + +Input support also includes common WAVEFORMATEXTENSIBLE PCM/IEEE float +WAVs from DAWs. WAV PCM32 signed integer is supported; unsupported +sample rates, compressed WAV and mismatched valid-bits fields fail +closed. Output is standard IEEE 32-bit float WAV with a `fact` chunk. +A separate CI smoke exercises extensible float32 input with ROOM OFF. + +## Smart CI cost regression corrected + +In the active P8.3 PR, three historical P7.4/P7.5/P8.0 Windows FAT +workflows still had `pull_request` path filters on all `sonku/**`. +They each launched a full JUCE Windows portable build on ordinary +P8.3 source/diagnostic pushes, despite the repository's selective FAT +policy. This workstream disables their automatic PR trigger, retaining +explicit `workflow_dispatch` on each historical workflow. The +path-scoped C++ P8.3 Linux source, audio, A/B and CPU gates continue +automatically. New P8.3 JUCE/ASIO FAT must use a deliberate exact-SHA +qualification after native host render-mode/ACK integration and musical +source gates, NOT the old P7 Windows binaries. diff --git a/engine/builtin_fx/SonKuSpatialProcessor.h b/engine/builtin_fx/SonKuSpatialProcessor.h index f2e083793..eb4b16913 100644 --- a/engine/builtin_fx/SonKuSpatialProcessor.h +++ b/engine/builtin_fx/SonKuSpatialProcessor.h @@ -51,6 +51,13 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, ready_=core_.prepare(rate,profile); observedAzimuthDegrees_.store(accepted_.startAzimuthDegrees,std::memory_order_relaxed); if(ready_)ready_=core_.setSettings(accepted_); +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + audioSettings_=accepted_; + modeFade_=1.f; + modePhase_=ModePhase::Stable; + modeTransitionPending_.store(false,std::memory_order_release); + modeStep_=static_cast(1./(rate*.012)); +#endif } void releaseResources() override {ready_=false;} void processBlock(juce::AudioBuffer& pcm,juce::MidiBuffer&) override { @@ -58,14 +65,63 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, if(!ready_||pcm.getNumChannels()<2||pcm.getNumSamples()<=0)return; consumeRealtimeEdits(); core_.process(pcm.getWritePointer(0),pcm.getWritePointer(1),pcm.getNumSamples()); +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + // No extra PCM graph: click-safe fade OUT before changing the + // authoritative FIR speaker transfer, then IN on subsequent blocks. + // An APPLIED completion is published only AFTER core.setSettings(). + if(modePhase_!=ModePhase::Stable){ + auto* l=pcm.getWritePointer(0); + auto* r=pcm.getWritePointer(1); + for(int i=0;i(core_.azimuthDegrees()), std::memory_order_relaxed); } void processBlock(juce::AudioBuffer&,juce::MidiBuffer&) override {} void consumeRealtimeEdits() noexcept override { Edit next; - if(!ready_||!complete_.canPush()||!queue_.pop(next))return; + if(!ready_||!complete_.canPush())return; +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + if(modePhase_!=ModePhase::Stable)return; +#endif + if(!queue_.pop(next))return; +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + // Logical/unpublished FX has NO callback: apply directly so + // an offline .smix edit can be saved instead of hanging in fade. + if(published_ && + (next.settings.renderMode!=audioSettings_.renderMode || + next.settings.musicCompatibleLowFrequency!= + audioSettings_.musicCompatibleLowFrequency || + next.settings.headYawDegrees!=audioSettings_.headYawDegrees)){ + stagedModeEdit_=next; + modeTransitionPending_.store(true,std::memory_order_release); + modePhase_=ModePhase::FadingOut; + return; // ACK only after the actual audio-side mode switch + } +#endif const bool ok=core_.setSettings(next.settings); +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + if(ok)audioSettings_=next.settings; +#endif complete_.push({next.requestId,next.settings,ok}); } // Control thread: returns QUEUED, not accepted/applied. Host native ACK @@ -89,14 +145,22 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, } void sealForRealtime() noexcept override {published_=true;} bool stateSnapshotQuiescent() const noexcept override { - return queue_.empty()&&complete_.empty(); + return queue_.empty()&&complete_.empty() +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + && !modeTransitionPending_.load(std::memory_order_acquire) +#endif + ; } // CONTROL only; state is accepted, not speculative or PCM-owned. void getStateInformation(juce::MemoryBlock& dest) override { juce::MemoryOutputStream out(dest,false); out.writeInt(0x534F4E4B); // SONK #if defined(ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT) && ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + out.writeInt(4); +#else out.writeInt(3); +#endif #else out.writeInt(2); #endif @@ -113,12 +177,21 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, out.writeFloat(accepted_.ambience); #if defined(ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT) && ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT out.writeFloat(accepted_.directElevationDegrees); +#endif +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + out.writeInt(accepted_.renderMode); + out.writeByte(accepted_.musicCompatibleLowFrequency?1:0); + out.writeFloat(accepted_.headYawDegrees); #endif } bool restoreUnpublishedState(const void* data,int size) { if(published_||!data|| #if defined(ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT) && ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + (size!=30&&size!=46&&size!=50&&size!=59)|| +#else (size!=30&&size!=46&&size!=50)|| +#endif #else (size!=30&&size!=46)|| #endif @@ -129,10 +202,16 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, if((version!=1&&version!=2 #if defined(ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT) && ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT &&version!=3 +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + &&version!=4 +#endif #endif ) || (version==1&&size!=30)||(version==2&&size!=46) #if defined(ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT) && ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT ||(version==3&&size!=50) +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + ||(version==4&&size!=59) +#endif #endif )return false; armix::sonku::Settings next{}; @@ -142,7 +221,10 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, next.spatialMix=in.readFloat(); next.outputTrim=in.readFloat(); const int moving=in.readByte(),clockwise=in.readByte(); - if(moving>1||clockwise>1)return false; + // JUCE readByte() may return a SIGNED char. Reject -1/0xFF, + // not just values above 1, for every v1/v2/v3/v4 restoration. + if((moving!=0&&moving!=1)||(clockwise!=0&&clockwise!=1)) + return false; next.moving=moving!=0; next.clockwise=clockwise!=0; if(version>=2) { @@ -152,7 +234,16 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, next.ambience=in.readFloat(); } #if defined(ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT) && ARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT - if(version==3)next.directElevationDegrees=in.readFloat(); + if(version>=3)next.directElevationDegrees=in.readFloat(); +#endif +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + if(version==4){ + next.renderMode=in.readInt(); + const int music=in.readByte(); + if(music!=0&&music!=1)return false; + next.musicCompatibleLowFrequency=music!=0; + next.headYawDegrees=in.readFloat(); + } #endif // v1 OFF, v2 original scene; experimental v3 includes direct // elevation, and is rejected by ordinary public v2 builds. @@ -173,6 +264,14 @@ class SonKuSpatialProcessor final : public juce::AudioProcessor, FxSpsc complete_{}; armix::sonku::Settings accepted_{}; std::atomic observedAzimuthDegrees_{0.f}; +#if defined(ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT) && ARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT + enum class ModePhase : std::uint8_t { Stable, FadingOut, FadingIn }; + Edit stagedModeEdit_{}; + armix::sonku::Settings audioSettings_{}; + ModePhase modePhase_=ModePhase::Stable; + std::atomic modeTransitionPending_{false}; + float modeFade_=1.f,modeStep_=0.f; +#endif bool ready_=false; bool published_=false; }; diff --git a/engine/builtin_fx/sonku/SonKuEarlyReflections.h b/engine/builtin_fx/sonku/SonKuEarlyReflections.h index 745c0910b..a14fb45b9 100644 --- a/engine/builtin_fx/sonku/SonKuEarlyReflections.h +++ b/engine/builtin_fx/sonku/SonKuEarlyReflections.h @@ -6,6 +6,9 @@ #include #include #include "SonKuMeasuredHrir.h" +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH +#include "SonKuP83SpeakerScene.h" +#endif #if defined(SONKU_P82_MULTIBAND_ROOM_RESEARCH) && SONKU_P82_MULTIBAND_ROOM_RESEARCH #include "SonKuRoomMaterials.h" #endif @@ -215,6 +218,13 @@ class SonKuEarlyReflections final { untilGeometry_=0; return true; } +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + bool setResearchWallMask(std::uint8_t mask) noexcept { + if(validFrames_!=0 || (mask & ~0x3fu)!=0u)return false; + p83WallMask_=mask; + return true; + } +#endif float relativeDistanceGain() const noexcept { return custom_?1.6f/geometry_.distanceMeters:1.f; } @@ -229,10 +239,11 @@ class SonKuEarlyReflections final { return wallCount; // original shipping source optimizes to 4 #endif } - Ears process(float left,float right,double azimuth,float spread) noexcept { + Ears process(float left,float right,double azimuth,float spread, + float headYawDegrees=0.f) noexcept { if(!active())return {}; if(untilGeometry_==0){ - updateGeometry(azimuth,spread); + updateGeometry(azimuth,spread,headYawDegrees); untilGeometry_=geometryInterval; } const float x[2]{std::isfinite(left)?left:0.f, @@ -384,8 +395,14 @@ class SonKuEarlyReflections final { r=bandpass(r,p.bandLowR,p.bandWideR); } #endif - output.left+=p.gainL*l; - output.right+=p.gainR*r; +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + if((p83WallMask_ & (1u<(ringFrames-hrir::taps-3)); p.targetDelayL=p.targetDelayR=delay; p.targetGainL=p.targetGainR=arrival.gain; - hrir3d::interpolate(arrival.azimuth,arrival.elevation, + hrir3d::interpolate(arrival.azimuth-headYawDegrees,arrival.elevation, std::abs(rate_-44100.f)<.1f, p.targetKernel); if(!primed_){ @@ -592,6 +618,9 @@ class SonKuEarlyReflections final { bool directionalHrir_=false; bool fastZeroSpread_=false,fuseEligible_=true; bool fastContiguousHrir_=false; +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + std::uint8_t p83WallMask_=0x3f; +#endif SonKuReflectionProfile profile_=SonKuReflectionProfile::Lightweight; }; } // namespace armix::sonku diff --git a/engine/builtin_fx/sonku/SonKuP83LowFrequencyTransfer.h b/engine/builtin_fx/sonku/SonKuP83LowFrequencyTransfer.h new file mode 100644 index 000000000..670fd9cef --- /dev/null +++ b/engine/builtin_fx/sonku/SonKuP83LowFrequencyTransfer.h @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include +#include +#include + +// Experimental, explicitly NON-PHYSICAL LF music monitoring compromise. +// True KEMAR stereo speaker transfer remains the P8.3 physical default. +// Symmetric real loudspeakers cancel opposite-polarity low-frequency pressure +// at a centered listener; output gain cannot repair this acoustic null. +// A 480-Hz complementary crossover conditions the DIRECT two-source +// to two-ear matrix. Both speakers feed BOTH ears, with gains that follow +// source directions relative to head orientation. It is NOT a direct +// headphone-only SIDE return; but the low-frequency ILD is not measured BRIR. +// Above crossover the original measured HRTF and all room DSP remain. +// No detector, heap, IO, mutex, lookahead or new PCM routing authority. +namespace armix::sonku::p83 { +class LowFrequencySpeakerTransfer final { +public: + bool prepare(double rate) noexcept { + if(!std::isfinite(rate) || rate<44000. || rate>48100.)return false; + rate_=rate; + return setCutoff(cutoff_); + } + // Called ONLY on prepared, quiescent research cores, not audio callback. + bool setCutoff(float hz) noexcept { + if(!std::isfinite(hz)||hz<100.f||hz>750.f||rate_<=0.)return false; + cutoff_=hz; + alpha_=static_cast(1.-std::exp( + -2.*3.14159265358979323846*hz/rate_)); + reset(); + return true; + } + float cutoffHz() const noexcept {return cutoff_;} + void reset() noexcept { + lowSource_.fill(0.f); + lowHrtf_.fill(0.f); + } + // Coefficients only recalc at 16-frame HRTF target updates. + void updateDirections(float leftHead,float rightHead) noexcept { + updateSource(0,leftHead); + updateSource(1,rightHead); + } + void process(float xL,float xR,float& earL,float& earR) noexcept { + lowSource_[0]+=alpha_*(xL-lowSource_[0]); + lowSource_[1]+=alpha_*(xR-lowSource_[1]); + lowHrtf_[0]+=alpha_*(earL-lowHrtf_[0]); + lowHrtf_[1]+=alpha_*(earR-lowHrtf_[1]); + // Existing SonKu scene direct gain = 0.5: restore LF pressure + // through the existing ear path, NOT by another additive dry bus. + const float lowL=2.f*(weights_[0][0]*lowSource_[0]+ + weights_[1][0]*lowSource_[1]); + const float lowR=2.f*(weights_[0][1]*lowSource_[0]+ + weights_[1][1]*lowSource_[1]); + earL=earL-lowHrtf_[0]+lowL; + earR=earR-lowHrtf_[1]+lowR; + } +private: + void updateSource(int index,float headAngle) noexcept { + constexpr float radians=.017453292519943295769f; + // 30-degree speaker: 0.92 near, 0.08 far. Center: 0.5/0.5. + // Intentional directional LF compromise, not physical shadowing. + const float lean=std::clamp(1.68f*std::sin(headAngle*radians), + -.84f,.84f); + weights_[index][0]=.5f*(1.f-lean); + weights_[index][1]=.5f*(1.f+lean); + } + float alpha_=0.f,cutoff_=480.f; + double rate_=0.; + std::array lowSource_{},lowHrtf_{}; + std::array,2> weights_{{{{.92f,.08f}}, + {{.08f,.92f}}}}; +}; +} // namespace armix::sonku::p83 diff --git a/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h b/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h new file mode 100644 index 000000000..e5a02c844 --- /dev/null +++ b/engine/builtin_fx/sonku/SonKuP83SpeakerScene.h @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include +#include + +// Research-only speaker positions are fixed in WORLD, head yaw is separate. +// No IO, tracker, threads, heap or additional PCM authority. +namespace armix::sonku::p83 { +enum class Mode : std::uint8_t { MusicBedP82=0, MonoObject=1, SpeakerMonitor=2 }; +enum class Stem : std::uint8_t { Combined=0, Direct=1, Early=2, Late=3 }; +inline bool valid(Mode m) noexcept { + return m==Mode::MusicBedP82 || m==Mode::MonoObject || + m==Mode::SpeakerMonitor; +} +inline bool valid(Stem s) noexcept { + return s==Stem::Combined || s==Stem::Direct || + s==Stem::Early || s==Stem::Late; +} +inline bool validYaw(float yaw) noexcept { + return std::isfinite(yaw) && yaw>=-360.f && yaw<=360.f; +} +// Positive azimuth RIGHT; head turn +90 places world FRONT at head LEFT -90. +inline float toHead(float worldAzimuth,float headYaw) noexcept { + // Bounded angle arithmetic avoids libm fmod in native PCM geometry. + float a=worldAzimuth-headYaw; + if(a>=540.f)a-=720.f; + else if(a< -540.f)a+=720.f; + if(a>=180.f)a-=360.f; + else if(a< -180.f)a+=360.f; + if(a>=180.f)a-=360.f; + else if(a< -180.f)a+=360.f; + return a; +} +struct Stereo { + float leftWorld=0.f,rightWorld=0.f; + float leftHead=0.f,rightHead=0.f; +}; +inline Stereo stereo(float worldCenter,float spread,float yaw) noexcept { + const float half=spread*.5f; + return {worldCenter-half,worldCenter+half, + toHead(worldCenter-half,yaw),toHead(worldCenter+half,yaw)}; +} +} // namespace armix::sonku::p83 diff --git a/engine/builtin_fx/sonku/SonKuSpatialCore.h b/engine/builtin_fx/sonku/SonKuSpatialCore.h index be007328b..d3c0a17c6 100644 --- a/engine/builtin_fx/sonku/SonKuSpatialCore.h +++ b/engine/builtin_fx/sonku/SonKuSpatialCore.h @@ -4,6 +4,14 @@ #include "SonKuEarlyReflections.h" #include "SonKuMusicalReverb.h" #include "SonKuStereoIntegrity.h" +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH +#if !defined(SONKU_P82_MULTIBAND_ROOM_RESEARCH) || !SONKU_P82_MULTIBAND_ROOM_RESEARCH || \ + !defined(SONKU_P71_DIRECT_XYZ_RESEARCH) || !SONKU_P71_DIRECT_XYZ_RESEARCH +#error P8.3 speaker research requires the P8.2 baseline and P7.1 XYZ engine +#endif +#include "SonKuP83SpeakerScene.h" +#include "SonKuP83LowFrequencyTransfer.h" +#endif #if defined(SONKU_P80_TRANSPARENT_BASS_RESEARCH) && SONKU_P80_TRANSPARENT_BASS_RESEARCH #include "SonKuHrtfTonalCalibration.h" #endif @@ -47,6 +55,13 @@ struct Settings { // existing native SPSC edit, never a second FX graph or audio worker. float directElevationDegrees = 0.f; #endif +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + // Experimental FX-state v4 only; no public v2/v3 ABI changes. + // 0=P8.2 Music Bed, 1=MonoObject LEFT input, 2=two world speakers. + int renderMode = 0; + bool musicCompatibleLowFrequency = false; + float headYawDegrees = 0.f; // deterministic world/head separation +#endif }; inline bool valid(const Settings& s) noexcept { return std::isfinite(s.startAzimuthDegrees) && @@ -62,6 +77,12 @@ inline bool valid(const Settings& s) noexcept { s.sourceDistanceMeters<=10.f && std::isfinite(s.roomAmount) && s.roomAmount>=0.f && s.roomAmount<=1.f && std::isfinite(s.ambience) && s.ambience>=0.f && s.ambience<=1.f && +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + s.renderMode>=0 && s.renderMode<=2 && + p83::validYaw(s.headYawDegrees) && + (s.renderMode!=2 || (s.stereoSpreadDegrees>=20.f && + s.stereoSpreadDegrees<=120.f)) && +#endif #if defined(SONKU_P72_NATIVE_XYZ_RT) && SONKU_P72_NATIVE_XYZ_RT // Pure control-thread admission; validate even when ROOM is OFF so // a later enable cannot silently admit an impossible placement. @@ -115,6 +136,9 @@ class SonKuSpatialCore final { 1.-std::exp(-2.*3.14159265358979323846*220./rate)); #endif limiterRelease_=static_cast(1./(rate*0.080)); +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + if(!p83LowFrequency_.prepare(rate))return false; +#endif #if defined(SONKU_P71_DIRECT_XYZ_RESEARCH) && SONKU_P71_DIRECT_XYZ_RESEARCH // The special elevation control is not serialized or published to // a public host. Downgrading the prepared profile clears it. @@ -169,9 +193,17 @@ class SonKuSpatialCore final { room_.reset(); reverb_.reset(); integrity_.reset(); +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + p83LowFrequency_.reset(); +#endif } bool setSettings(const Settings& s) noexcept { if(!valid(s))return false; +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + if(s.renderMode!=0 && + room_.preparedProfile()!=SonKuReflectionProfile::SixSurfaceKemarResearch) + return false; // Only real measured prepared native research instance +#endif #if defined(SONKU_P72_NATIVE_XYZ_RT) && SONKU_P72_NATIVE_XYZ_RT const auto activeProfile=room_.preparedProfile(); if(activeProfile!=SonKuReflectionProfile::SixSurfaceKemarResearch && @@ -201,6 +233,19 @@ class SonKuSpatialCore final { s.startAzimuthDegrees!=settings_.startAzimuthDegrees) degrees_=wrapDegrees(s.startAzimuthDegrees); settings_=s; +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + // Apply typed real-time SPSC state, not quiescent-only test setters. + // The JUCE adapter fades out to zero BEFORE applying a mode edit. + // No heavy DSP reset or heap work on the audio thread. + if(p83Mode_!=static_cast(s.renderMode) || + p83MusicCompatibleLf_!=s.musicCompatibleLowFrequency || + p83HeadYaw_!=s.headYawDegrees) { + p83LowFrequency_.reset(); // four small scalar filter memories + } + p83Mode_=static_cast(s.renderMode); + p83MusicCompatibleLf_=s.musicCompatibleLowFrequency; + p83HeadYaw_=s.headYawDegrees; +#endif // Once native ROOM has been enabled, retain the smoothed transition // when it is turned OFF. Standalone experimental V2/V3 OFF fixtures // continue to use their exact original 1/r distance law. @@ -209,6 +254,59 @@ class SonKuSpatialCore final { return true; } Settings settings() const noexcept {return settings_;} +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + // OFFLINE ONLY: quiescent, before PCM. Native session/GUI/SPSC untouched. + bool setResearchRenderMode(p83::Mode mode) noexcept { + if(!ready_ || researchPcmStarted_ || !p83::valid(mode) || + room_.preparedProfile()!=SonKuReflectionProfile::SixSurfaceKemarResearch || + (mode==p83::Mode::SpeakerMonitor && + (settings_.stereoSpreadDegrees<20.f || + settings_.stereoSpreadDegrees>120.f)))return false; + p83Mode_=mode; + settings_.renderMode=static_cast(mode); + reset(); + return true; + } + // Pre-PCM-only A/B: physical KEMAR transfer remains the default. + // This changes ONLY SpeakerMonitor LF, not MonoObject or P8.2. + bool setResearchSpeakerMusicLowFrequency(bool enabled) noexcept { + if(!ready_ || researchPcmStarted_ || + room_.preparedProfile()!=SonKuReflectionProfile::SixSurfaceKemarResearch) + return false; + p83MusicCompatibleLf_=enabled; + settings_.musicCompatibleLowFrequency=enabled; + reset(); + return true; + } + bool setResearchSpeakerMusicLowFrequencyCutoff(float hz) noexcept { + if(!ready_||researchPcmStarted_ || + room_.preparedProfile()!=SonKuReflectionProfile::SixSurfaceKemarResearch) + return false; + return p83LowFrequency_.setCutoff(hz); + } + bool researchSpeakerMusicLowFrequency() const noexcept { + return p83MusicCompatibleLf_; + } + bool setResearchHeadYaw(float yaw) noexcept { + if(!ready_ || researchPcmStarted_ || !p83::validYaw(yaw) || + room_.preparedProfile()!=SonKuReflectionProfile::SixSurfaceKemarResearch) + return false; + p83HeadYaw_=yaw; + settings_.headYawDegrees=yaw; + reset(); + return true; + } + // Native PCM evidence: wall bits left,right,front,back,floor,ceiling. + bool setResearchEvidence(p83::Stem stem,std::uint8_t wallMask=0x3f) noexcept { + if(!ready_ || researchPcmStarted_ || !p83::valid(stem) || + room_.preparedProfile()!=SonKuReflectionProfile::SixSurfaceKemarResearch || + !room_.setResearchWallMask(wallMask))return false; + p83Stem_=stem; + return true; + } + p83::Mode researchMode() const noexcept {return p83Mode_;} + float researchHeadYaw() const noexcept {return p83HeadYaw_;} +#endif #if defined(SONKU_P71_DIRECT_XYZ_RESEARCH) && SONKU_P71_DIRECT_XYZ_RESEARCH // Only quiescent, unpublished *research* cores may change source XYZ. // This is intentionally NOT a new FX/state/UI/ACK field. No race with @@ -289,12 +387,20 @@ class SonKuSpatialCore final { #endif const double step=(settings_.moving ? (settings_.clockwise?1.:-1.)*360./(sampleRate_*settings_.revolutionSeconds) : 0.); +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + const bool positionedMode= + room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch && + p83Mode_!=p83::Mode::MusicBedP82; + const bool monoObject=positionedMode && p83Mode_==p83::Mode::MonoObject; +#else + constexpr bool positionedMode=false,monoObject=false; +#endif const float distanceGain=room_.relativeDistanceGain(); const bool nativeSpace=nativeSpaceEverUsed_; const bool roomEnabled=settings_.spacePreset!=0; #if defined(SONKU_P80_TRANSPARENT_BASS_RESEARCH) && SONKU_P80_TRANSPARENT_BASS_RESEARCH const bool transparentBass= - room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch; + room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch && !positionedMode; #else constexpr bool transparentBass=false; #endif @@ -303,7 +409,7 @@ class SonKuSpatialCore final { // through one real measured center HRTF, keep stereo SIDE separated. // The original two-emitter renderer is never modified in public builds. const bool musicSafe= - room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch; + room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch && !positionedMode; #else constexpr bool musicSafe=false; #endif @@ -333,13 +439,13 @@ class SonKuSpatialCore final { remaining_=updateInterval; } const float x0=std::isfinite(left[i])?left[i]:0.f; - const float x1=std::isfinite(right[i])?right[i]:0.f; + const float x1=monoObject?0.f:(std::isfinite(right[i])?right[i]:0.f); // Preserve strong anti-correlated music side energy without // collapsing it into the two virtual mono HRTF sources. The // independent guard has no hidden UI state or new audio bus. const float inputMid=.5f*(x0+x1); - const float preservedSide=musicSafe?.5f*(x0-x1): - integrity_.preservedSide(x0,x1); + const float preservedSide=positionedMode?0.f: + (musicSafe?.5f*(x0-x1):integrity_.preservedSide(x0,x1)); // P7.5 research: an unconditional, orthogonal L/R side return // rather than correlation-gated, time-varying rescue. A centered // HRTF cannot annihilate anti-phase stereo. WIDTH changes level @@ -347,9 +453,9 @@ class SonKuSpatialCore final { // 0° => 0.5x; 60° => 1x; >=90° => 1.25x (bounded). const float musicSideWidth=musicSafe? std::min(1.25f,.5f+settings_.stereoSpreadDegrees/120.f):1.f; - float sideRescue=musicSafe? + float sideRescue=positionedMode?0.f:(musicSafe? smoothedMix_*smoothedTrim_*musicSideWidth*preservedSide: - .65f*smoothedMix_*smoothedTrim_*preservedSide; + .65f*smoothedMix_*smoothedTrim_*preservedSide); float originalLowL=0.f,originalLowR=0.f; #if defined(SONKU_P80_TRANSPARENT_BASS_RESEARCH) && SONKU_P80_TRANSPARENT_BASS_RESEARCH if(transparentBass){ @@ -396,19 +502,34 @@ class SonKuSpatialCore final { } } #if defined(SONKU_P80_TRANSPARENT_BASS_RESEARCH) && SONKU_P80_TRANSPARENT_BASS_RESEARCH - if(transparentBass) + if(transparentBass || positionedMode) tonalCalibration_.process(ears[0],ears[1]); #endif - const auto reflection=room_.active() +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + if(positionedMode && !monoObject && p83MusicCompatibleLf_) + p83LowFrequency_.process(x0,x1,ears[0],ears[1]); +#endif + auto reflection=room_.active() ?room_.process(transparentBass?x0:(musicSafe?inputMid:x0), transparentBass?x1:(musicSafe?inputMid:x1), degrees_,transparentBass?settings_.stereoSpreadDegrees: - (musicSafe?0.f:settings_.stereoSpreadDegrees)) + ((musicSafe||monoObject)?0.f:settings_.stereoSpreadDegrees) +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + ,positionedMode?p83HeadYaw_:0.f +#endif + ) :SonKuEarlyReflections::Ears{}; - const auto late=reverb_.active() + auto late=reverb_.active() ?reverb_.process(transparentBass?x0:(musicSafe?inputMid:x0), transparentBass?x1:(musicSafe?inputMid:x1)) :SonKuMusicalReverb::Ears{}; +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + if(positionedMode && p83Stem_!=p83::Stem::Combined) { + if(p83Stem_!=p83::Stem::Direct)ears[0]=ears[1]=0.f; + if(p83Stem_!=p83::Stem::Early)reflection={}; + if(p83Stem_!=p83::Stem::Late)late={}; + } +#endif if(!transparentBass && !nativeSpace && settings_.outputTrim<=1.f && smoothedTrim_<=1.f) { // Preserve byte-for-byte original HRTF/old .smix output for @@ -429,9 +550,9 @@ class SonKuSpatialCore final { smoothedDistanceGain_+=distanceSlew_* (targetDistance-smoothedDistanceGain_); smoothedRoomLevel_+=distanceSlew_* - ((roomEnabled?1.12f:1.f)-smoothedRoomLevel_); + (((roomEnabled&&!positionedMode)?1.12f:1.f)-smoothedRoomLevel_); smoothedBassShelf_+=distanceSlew_* - ((roomEnabled?0.82f:0.f)-smoothedBassShelf_); + (((roomEnabled&&!positionedMode)?0.82f:0.f)-smoothedBassShelf_); // The original experimental return levels were intentionally // near-silent: ER base 0.28 * wall 0.70 * 1/r and diffuse FDN // output 0.23 * amount, followed by another 0.5 * trim. @@ -440,9 +561,9 @@ class SonKuSpatialCore final { // echoes and the later diffuse field identify the room. // Gain laws are bounded affine maps, zero wet stays EXACT // zero, no exp/pow/alloc on the audio callback. - const float targetErPresence=roomEnabled? + const float targetErPresence=roomEnabled&&!positionedMode? 1.45f+2.0f*settings_.roomAmount:1.f; - const float targetTailPresence=roomEnabled? + const float targetTailPresence=roomEnabled&&!positionedMode? 2.2f+4.0f*settings_.ambience:1.f; smoothedErPresence_+=distanceSlew_* (targetErPresence-smoothedErPresence_); @@ -576,6 +697,28 @@ class SonKuSpatialCore final { } } void updateKernels() noexcept { +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + if(p83Mode_!=p83::Mode::MusicBedP82 && + room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch) { + // 2x2 measured source-to-ear transfer. No MID center + // projection, no headphone SIDE, no coherence-dependent mode. + const auto positions=p83::stereo(static_cast(degrees_), + settings_.stereoSpreadDegrees,p83HeadYaw_); + interpolate(targets_[0],p83Mode_==p83::Mode::MonoObject? + p83::toHead(static_cast(degrees_),p83HeadYaw_): + positions.leftHead); + if(p83Mode_==p83::Mode::SpeakerMonitor) + interpolate(targets_[1],positions.rightHead); + else + for(auto& ear:targets_[1])ear.fill(0.f); + if(p83MusicCompatibleLf_ && p83Mode_==p83::Mode::SpeakerMonitor) + p83LowFrequency_.updateDirections(positions.leftHead, + positions.rightHead); + if(!haveKernel_)kernels_=targets_; + haveKernel_=true; + return; + } +#endif #if defined(SONKU_P75_MUSIC_SAFE_RESEARCH) && SONKU_P75_MUSIC_SAFE_RESEARCH if(room_.preparedProfile()==SonKuReflectionProfile::SixSurfaceKemarResearch) { // Control evidence no longer gates musical MID coefficients: @@ -652,6 +795,13 @@ class SonKuSpatialCore final { bool ready_=false; bool haveKernel_=false; bool nativeSpaceEverUsed_=false; +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + p83::Mode p83Mode_=p83::Mode::MusicBedP82; + p83::Stem p83Stem_=p83::Stem::Combined; + p83::LowFrequencySpeakerTransfer p83LowFrequency_{}; + bool p83MusicCompatibleLf_=false; + float p83HeadYaw_=0.f; +#endif #if defined(SONKU_P71_DIRECT_XYZ_RESEARCH) && SONKU_P71_DIRECT_XYZ_RESEARCH float researchElevationDegrees_=0.f; bool researchPcmStarted_=false; diff --git a/site/preview-v2/assets/mixer-fx-rack.css b/site/preview-v2/assets/mixer-fx-rack.css index 8d4ba687d..77d732b4b 100644 --- a/site/preview-v2/assets/mixer-fx-rack.css +++ b/site/preview-v2/assets/mixer-fx-rack.css @@ -1371,3 +1371,14 @@ /* Rear-camera perspective: two real source nodes, two SVG painter planes. */ .mx-sonku #skFarSources .sk-src{filter:drop-shadow(0 1px 2px rgba(0,0,0,.3))} .mx-sonku #skNearSources .sk-src{filter:drop-shadow(0 3px 6px rgba(0,0,0,.72))} + +/* SonKu v4 research controls share the existing lightweight FX skin. + Hidden unless the real native processor reports P8.3 capability. */ +.mx-sonku .sk-render-row[hidden]{display:none!important} +.mx-sonku .sk-render-row{display:grid;gap:5px;margin:0 0 8px;padding:6px 7px; + background:linear-gradient(180deg,#213948,#162b39);border:1px solid #345766; + border-radius:6px} +.mx-sonku .sk-render-label{font-size:9px;letter-spacing:.7px;color:#9ebbc8} +.mx-sonku #skRenderMode{width:100%;background:#132732;color:#e0eff5; + border:1px solid #577888;border-radius:4px;padding:4px 6px;font:inherit;font-size:10px} +.mx-sonku .sk-yaw{margin-top:2px} diff --git a/site/preview-v2/assets/mixer-gain-knob-brushed-steel.png b/site/preview-v2/assets/mixer-gain-knob-brushed-steel.png new file mode 100644 index 000000000..7bae3ba39 Binary files /dev/null and b/site/preview-v2/assets/mixer-gain-knob-brushed-steel.png differ diff --git a/site/preview-v2/assets/mixer-native-sonku.js b/site/preview-v2/assets/mixer-native-sonku.js index d2721f16d..fb3ed5394 100644 --- a/site/preview-v2/assets/mixer-native-sonku.js +++ b/site/preview-v2/assets/mixer-native-sonku.js @@ -51,7 +51,12 @@ const valid=s=>s && Number.isFinite(s.startAzimuthDegrees) && s.sourceDistanceMeters*Math.cos(s.directElevationDegrees*Math.PI/180)>=.7 && 1.45+s.sourceDistanceMeters*Math.sin(s.directElevationDegrees*Math.PI/180)>=.5 && 1.45+s.sourceDistanceMeters*Math.sin(s.directElevationDegrees*Math.PI/180)<= - roomHeights[s.spacePreset]-.5)); + roomHeights[s.spacePreset]-.5)) && + (s.renderMode===undefined || ( + Number.isInteger(s.renderMode)&&s.renderMode>=0&&s.renderMode<=2 && + typeof s.musicCompatibleLowFrequency==="boolean" && + Number.isFinite(s.headYawDegrees)&&Math.abs(s.headYawDegrees)<=360 && + (s.renderMode!==2 || (s.stereoSpreadDegrees>=20&&s.stereoSpreadDegrees<=120)))); const backend=()=>window.__JUCE__?.backend; const native=()=>typeof backend()?.emitEvent==="function"; const snapshot=()=>window.__ARMIX_NATIVE_M2__?.fxEditorState?.()|| @@ -139,6 +144,15 @@ root.innerHTML=[ 'R', '
HEADPHONES · HRIR 0° ELEVATION · 44.1 / 48 kHz
', '