diff --git a/.github/workflows/alpha-preview-publish.yml b/.github/workflows/alpha-preview-publish.yml index c60aad931..dfb070322 100644 --- a/.github/workflows/alpha-preview-publish.yml +++ b/.github/workflows/alpha-preview-publish.yml @@ -111,8 +111,14 @@ jobs: - name: Configure release application shell: pwsh run: | - cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DJUCE_ROOT="$env:GITHUB_WORKSPACE/third_party/JUCE" -DBUILD_TESTING=OFF -DJUCE_WEBVIEW2_PACKAGE_LOCATION="$env:GITHUB_WORKSPACE/.deps" -DARMIX_RELEASE_TAG="$env:ARMIX_RELEASE_TAG" + cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DJUCE_ROOT="$env:GITHUB_WORKSPACE/third_party/JUCE" -DBUILD_TESTING=OFF -DJUCE_WEBVIEW2_PACKAGE_LOCATION="$env:GITHUB_WORKSPACE/.deps" -DARMIX_RELEASE_TAG="$env:ARMIX_RELEASE_TAG" -DARMIX_IMMERSIB_RELEASE_CANDIDATE=ON -DARMIX_SONKU_APPROVED_P99_MAIN=ON if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + # The official Windows prerelease MUST contain both public FX. + $cache = @(Get-Content -LiteralPath build/CMakeCache.txt -Encoding UTF8) + foreach ($entry in @('ARMIX_IMMERSIB_RELEASE_CANDIDATE:BOOL=ON', + 'ARMIX_SONKU_APPROVED_P99_MAIN:BOOL=ON')) { + if ($entry -notin $cache) { throw "PUBLIC_SPATIAL_FX_RELEASE_FLAG_MISSING: $entry" } + } node scripts/check_approved_native_gui_release.mjs --source-only --bundle build/approved_gui if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } diff --git a/.github/workflows/imersip-p92-single-engine.yml b/.github/workflows/imersip-p92-single-engine.yml new file mode 100644 index 000000000..db569d122 --- /dev/null +++ b/.github/workflows/imersip-p92-single-engine.yml @@ -0,0 +1,280 @@ +name: ImerSip P9.2 same native SonKu engine — isolated Windows FAT +on: + pull_request: + types: [opened, reopened, synchronize] + paths: + - '.github/workflows/imersip-p92-single-engine.yml' + - 'CMakeLists.txt' + - 'engine/builtin_fx/ImerSipP92*.h' + - 'assets/imersip/**' + - 'tests/imersip_scene_assets_contract_test.py' + - 'engine/builtin_fx/SonKuSpatialProcessor.h' + - 'engine/builtin_fx/sonku/**' + - 'src/Main.cpp' + - 'src/NativeBuiltInFx.h' + # Native/engine edits only. Documentation and immutable-checkpoint + # ledger changes have a separate fast contract job, not full JUCE. + - 'tests/imersip_p92_native_test.cpp' + - 'tests/imersip_p92_catalog_contract_test.py' + workflow_dispatch: +permissions: + contents: read +concurrency: + group: imersip-p92-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + source: + name: Fast P9 PCM + ImerSip registration guard + runs-on: ubuntu-latest + timeout-minutes: 12 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + persist-credentials: false + - name: Gate accepted six real venue PNGs; forbid rejected asset pack + run: python -m unittest discover -s tests -p 'imersip_scene_assets_contract_test.py' -v + - name: Source contract and no accidental shadow DSP + run: | + set -euo pipefail + python -m unittest discover -s tests -p 'imersip_p92_*contract_test.py' -v + - name: Exact P9.1+P9.2 native PCM foundation 44.1/48k + run: | + set -euo pipefail + c++ -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 \ + tests/sonku_p91_p92_music_bass_foundation_test.cpp -o /tmp/p92-source + /tmp/p92-source + - name: Test ImerSip concert preset audibility, anti-phase and wet room + run: | + set -euo pipefail + c++ -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 \ + tests/imersip_p92_factory_music_test.cpp -o /tmp/imersip-p92-presets + /tmp/imersip-p92-presets + - name: ImmerSIB P9.7 Venue golden and P9.8 scene native PCM + run: | + set -euo pipefail + c++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic \ + -DSONKU_P7_MEASURED_ELEVATION_RESEARCH \ + -DSONKU_P71_DIRECT_XYZ_RESEARCH \ + -DSONKU_P72_NATIVE_XYZ_RT \ + -DSONKU_P75_MUSIC_SAFE_RESEARCH \ + -DSONKU_P80_TRANSPARENT_BASS_RESEARCH \ + -DSONKU_P82_MULTIBAND_ROOM_RESEARCH \ + -DSONKU_P83_PHYSICAL_SPEAKER_RESEARCH \ + -DSONKU_P84_SINGLE_CORE_FUSION_RESEARCH \ + -DSONKU_P85_WORLD_COHERENCE_RESEARCH \ + -DSONKU_P86_HORIZONTAL_FOCUS_RESEARCH \ + -DSONKU_P87_MUSIC_BODY_RESEARCH \ + -DSONKU_P88_PERCEPTUAL_ALIGNMENT_RESEARCH \ + -DSONKU_P89_DEPTH_COHERENCE_RESEARCH \ + -DSONKU_P90_TRUE_EXTERNAL_RESEARCH \ + -DSONKU_P94_FRONT_BACK_DEPTH_RESEARCH \ + -DSONKU_P95_MUSICAL_PRESENCE_RESEARCH \ + -DSONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH \ + -DSONKU_P97_STAGE_IMPACT_RESEARCH \ + -DSONKU_P98_SCENE_VOICING_RESEARCH \ + -DSONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH=1 \ + -DSONKU_IMMERSIB_PCM_DIAGNOSTICS=1 \ + tests/immersib_p98_native_sonic_gate.cpp -o /tmp/immersib-p98 + /tmp/immersib-p98 + windows: + name: Actual JUCE ImerSip P9.2 insert + Windows GUI + needs: source + runs-on: windows-2022 + timeout-minutes: 50 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + persist-credentials: false + - name: Verify immutable source commit + shell: pwsh + env: + EXPECTED_SHA: ${{ github.event.pull_request.head.sha || github.sha }} + run: | + if ((& git rev-parse HEAD).Trim() -ne $env:EXPECTED_SHA) { + throw 'IMERSIP_P92_WRONG_SOURCE_SHA' + } + - uses: actions/checkout@v4 + with: + repository: juce-framework/JUCE + ref: 8.0.15 + path: third_party/JUCE + persist-credentials: false + - name: Obtain pinned WebView2 headers + shell: pwsh + run: | + nuget install Microsoft.Web.WebView2 -Version 1.0.3485.44 -OutputDirectory .deps -NonInteractive + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + - name: Configure exact P9 native FX graph and focused CTest + shell: pwsh + run: | + cmake -S . -B build -G "Visual Studio 17 2022" -A x64 ` + -DJUCE_ROOT="$env:GITHUB_WORKSPACE/third_party/JUCE" ` + -DJUCE_WEBVIEW2_PACKAGE_LOCATION="$env:GITHUB_WORKSPACE/.deps" ` + -DARMIX_SONKU_EXPERIMENTAL_NATIVE_XYZ_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_MUSIC_SAFE=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P8_TRANSPARENT_BASS=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P82_ROOM=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P83_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P84_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P85_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P86_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P87_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P88_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P89_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P97_STAGE_IMPACT=ON ` + -DARMIX_SONKU_EXPERIMENTAL_P98_SCENE_VOICING=ON ` + -DARMIX_IMMERSIB_RELEASE_CANDIDATE=ON ` + -DARMIX_SONKU_APPROVED_P99_MAIN=ON ` + -DBUILD_TESTING=ON + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + $tests = (& ctest --test-dir build -C Release --show-only=json-v1 | Out-String | ConvertFrom-Json) + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + if ('NativeImmerSIBJucePresetACKStateAndBypass' -notin + @($tests.tests | ForEach-Object {$_.name})) { + throw 'IMERSIP_P92_NATIVE_TEST_NOT_COMPILED' + } + - name: Compile focused real JUCE audio editor and state first + shell: pwsh + run: | + cmake --build build --config Release --parallel 2 --target ARMixImerSipP92NativeTests + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + ctest --test-dir build -C Release --output-on-failure ` + -R '^NativeImmerSIBJucePresetACKStateAndBypass$' + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + - name: Upload actual JUCE native 100, 125, 150 and 200 percent captures + uses: actions/upload-artifact@v4 + with: + name: ImerSip-P92-Native-JUCE-DPI-Captures-${{ github.run_id }} + path: | + build/ImerSip_P92_JUCE_*.png + build/ImerSip_P92_SCENE_*.png + if-no-files-found: error + retention-days: 14 + - name: Compile authentic production-shaped native GUI research candidate + shell: pwsh + run: | + cmake --build build --config Release --parallel 2 --target ARMixConsole + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + $exe = 'build/ARMixConsole_artefacts/Release/AR MIX Studio.exe' + if (-not (Test-Path -LiteralPath $exe -PathType Leaf)) { + throw 'IMERSIP_P92_GUI_MISSING' + } + - name: Package and verify portable Windows application + shell: pwsh + run: | + & ./scripts/package_native_windows.ps1 -BuildDir build -OutputDir dist + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + python scripts/factoryfx_release_bundle.py stage --lock config/factoryfx-approved-releases.json --output dist --best-effort + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + & ./scripts/verify_native_windows_artifact.ps1 -OutputDir dist + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + # The release verifier uses a strict dist/ allowlist. Attach the + # acoustic FAT and MIT KEMAR attribution OUTSIDE verified dist/, + # not by making unverified changes to the portable application. + New-Item -ItemType Directory -Path field_candidate -Force | Out-Null + Copy-Item -LiteralPath dist -Destination field_candidate/ArSonMix-Portable -Recurse + Copy-Item -LiteralPath docs/IMERSIP_P92_SINGLE_NATIVE_ENGINE_FAT_20261116.md -Destination field_candidate/IMERSIP_P92_FIELD_FAT.md + Copy-Item -LiteralPath docs/THIRD_PARTY_8D_SONKU_HRTF.md -Destination field_candidate/THIRD_PARTY_8D_SONKU_HRTF.md + - uses: actions/upload-artifact@v4 + with: + name: ImerSip-P92-Shared-Core-Windows-x64-${{ github.run_id }} + path: field_candidate/ + if-no-files-found: error + retention-days: 14 + compression-level: 0 + + - name: Recompile default public SonKu P9.9 profile with ImmerSIB RC OFF + shell: pwsh + run: | + # Reuse the same Windows checkout and build tree AFTER RC artifact + # upload. This proves default/public build compatibility without + # allocating a second Windows runner or changing the RC package. + $sourceSha = (& git rev-parse HEAD).Trim() + $candidate = Get-Content -LiteralPath dist/BUILD_PROVENANCE.json -Raw -Encoding UTF8 | ConvertFrom-Json + if ($candidate.sourceCommit -ne $sourceSha) { + throw 'PUBLIC_PROFILE_CANDIDATE_SOURCE_MISMATCH' + } + $cmakeText = Get-Content -LiteralPath CMakeLists.txt -Raw -Encoding UTF8 + $flags = @([regex]::Matches($cmakeText, '(?m)^\s*option\((ARMIX_SONKU_EXPERIMENTAL_[A-Z0-9_]+)') | + ForEach-Object { $_.Groups[1].Value } | Sort-Object -Unique) + if ($flags.Count -lt 10) { throw 'PUBLIC_PROFILE_RESEARCH_OPTION_AUDIT_INCOMPLETE' } + $args = @('-S','.','-B','build','-DARMIX_IMMERSIB_RELEASE_CANDIDATE=OFF') + foreach ($flag in $flags) { $args += "-D${flag}=OFF" } + & cmake @args + if ($LASTEXITCODE -ne 0) { throw 'PUBLIC_PROFILE_CMAKE_CONFIGURE_FAILED' } + # Get-Content without -Raw yields exact logical lines on Windows + # (CMakeCache.txt uses CRLF). Regex end-of-line checks on raw CRLF + # incorrectly rejected valid OFF/ON cache entries. + $cacheLines = @(Get-Content -LiteralPath build/CMakeCache.txt -Encoding UTF8) + $expected = @('ARMIX_IMMERSIB_RELEASE_CANDIDATE:BOOL=OFF', + 'ARMIX_SONKU_APPROVED_P99_MAIN:BOOL=ON') + foreach ($entry in $expected) { + if ($entry -notin $cacheLines) { + $key = ($entry -split ':')[0] + $actual = @($cacheLines | Where-Object { $_.StartsWith("${key}:") }) + throw "PUBLIC_PROFILE_OPTION_MISMATCH: expected=$entry actual=$($actual -join ',')" + } + } + foreach ($flag in $flags) { + if ("${flag}:BOOL=OFF" -notin $cacheLines) { + $actual = @($cacheLines | Where-Object { $_.StartsWith("${flag}:") }) + throw "PUBLIC_PROFILE_RESEARCH_FLAG_ENABLED: $flag actual=$($actual -join ',')" + } + } + $catalog = (& ctest --test-dir build -C Release --show-only=json-v1 | Out-String | ConvertFrom-Json) + if ($LASTEXITCODE -ne 0) { throw 'PUBLIC_PROFILE_CTEST_CATALOG_FAILED' } + $tests = @($catalog.tests | ForEach-Object { $_.name }) + if ('NativeImmerSIBJucePresetACKStateAndBypass' -in $tests) { + throw 'PUBLIC_PROFILE_IMMERSIB_TEST_STILL_REGISTERED' + } + if ('NativeSonKuSessionV1V2AndAudioAppliedAck' -notin $tests) { + throw 'PUBLIC_PROFILE_SONKU_REGRESSION_MISSING' + } + & cmake --build build --config Release --parallel 2 --target ARMixConsole ARMixSonKuNativeStateTests + if ($LASTEXITCODE -ne 0) { throw 'PUBLIC_PROFILE_WINDOWS_BUILD_FAILED' } + & ctest --test-dir build -C Release --output-on-failure -R '^NativeSonKuSessionV1V2AndAudioAppliedAck$' + if ($LASTEXITCODE -ne 0) { throw 'PUBLIC_PROFILE_SONKU_STATE_REGRESSION' } + $exe = 'build/ARMixConsole_artefacts/Release/AR MIX Studio.exe' + if (-not (Test-Path -LiteralPath $exe -PathType Leaf)) { + throw 'PUBLIC_PROFILE_WINDOWS_GUI_MISSING' + } + $publicSha = (Get-FileHash -LiteralPath $exe -Algorithm SHA256).Hash.ToLowerInvariant() + if ($publicSha -eq $candidate.exeSha256) { + throw 'PUBLIC_PROFILE_SAME_BINARY_AS_IMMERSIB_RC' + } + Write-Host "PUBLIC_PROFILE_RC_OFF_BUILD_ACCEPTED: source=$sourceSha exeSha256=$publicSha" + Write-Host 'RC PACKAGE UNCHANGED: verified artifact uploaded before public-profile recompile' diff --git a/.github/workflows/native-fx-owned-editor.yml b/.github/workflows/native-fx-owned-editor.yml new file mode 100644 index 000000000..81b871a83 --- /dev/null +++ b/.github/workflows/native-fx-owned-editor.yml @@ -0,0 +1,41 @@ +name: Native FX owned editor + reopen FAT (focused Windows) +on: + pull_request: + paths: + - 'src/Main.cpp' + - 'src/NativeOwnedFloatingWindow.h' + - 'src/NativeFxWin32Owner.h' + - 'tests/native_fx_win32_owner_test.cpp' + - 'tests/native_fx_window_lifecycle_contract_test.py' + - 'tests/native_fx_window_owner/**' + - '.github/workflows/native-fx-owned-editor.yml' + workflow_dispatch: +permissions: + contents: read +concurrency: + group: owned-fx-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true +jobs: + windows-owned-fx: + runs-on: windows-2022 + timeout-minutes: 9 + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} + persist-credentials: false + - name: Fail closed on all three native editor lifetime paths + shell: pwsh + run: python -m unittest discover -s tests -p native_fx_window_lifecycle_contract_test.py -v + - name: Configure and compile only Win32 HWND host test (no JUCE or ASIO) + shell: pwsh + run: | + cmake -S tests/native_fx_window_owner -B build-owned-fx -G "Visual Studio 17 2022" -A x64 + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + cmake --build build-owned-fx --config Release --parallel 2 + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + - name: Verify owned z-order, hide and reopen without global TOPMOST + shell: pwsh + run: | + ctest --test-dir build-owned-fx -C Release --output-on-failure + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } diff --git a/CMakeLists.txt b/CMakeLists.txt index b074e3964..5f58974e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.22) project(ARMixConsole VERSION 0.5.0 LANGUAGES C CXX) +# ImmerSIB is code-integrated but not publicly shipped before headphone FAT. +# The RC flag is explicit, per-product and leaves accepted SonKu P9.9 intact. +option(ARMIX_IMMERSIB_RELEASE_CANDIDATE + "Build the integrated ImmerSIB P9.9 audio + JUCE venue UI RC" OFF) # Experimental P6 native profile: OFF by default in production/installer. option(ARMIX_SONKU_EXPERIMENTAL_DIRECTIONAL_RT "Enable unqualified SonKu full KEMAR directional reflections on the native JUCE callback" @@ -273,10 +277,23 @@ endif() file(GLOB ARMIX_GUITAR_SKIN_PNGS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/design-references/guitar-fx/assets/gfx-*.png") list(SORT ARMIX_GUITAR_SKIN_PNGS) +set(ARMIX_IMERSIB_SCENE_PNG_SOURCES) +if(ARMIX_IMMERSIB_RELEASE_CANDIDATE) + foreach(name IN ITEMS scene_live_concert scene_royal_concert_hall + scene_arena_thunder scene_front_row_power scene_symphonic_palace + scene_velvet_cinema) + set(scene "${CMAKE_CURRENT_SOURCE_DIR}/assets/imersip/scenes/${name}.png") + if(NOT EXISTS "${scene}") + message(FATAL_ERROR "Missing ImmerSIB venue image: ${scene}") + endif() + list(APPEND ARMIX_IMERSIB_SCENE_PNG_SOURCES "${scene}") + endforeach() +endif() juce_add_binary_data(ARMixAssets SOURCES "${ARMIX_APPROVED_GUI_DIR}/index.html" ${ARMIX_APPROVED_GUI_BINARIES} ${ARMIX_GUITAR_SKIN_PNGS} - "${ARMIX_BRAND_DIR}/arsonmix-256.png") + "${ARMIX_BRAND_DIR}/arsonmix-256.png" + ${ARMIX_IMERSIB_SCENE_PNG_SOURCES}) target_include_directories(ARMixConsole PRIVATE "${ARMIX_APPROVED_GUI_DIR}") target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h engine/builtin_fx/HarmonyDsp.h engine/builtin_fx/HarmonyMusicKey.h engine/builtin_fx/ChannelHarmonyProcessor.h engine/builtin_fx/SonKuSpatialProcessor.h engine/builtin_fx/sonku/SonKuSpatialCore.h engine/builtin_fx/sonku/SonKuMeasuredHrir.h src/VstOrbitController.h engine/core/MixerRoutingPlan.h engine/core/ChannelRoutingContract.h engine/core/ChannelSendPlan.h engine/core/AuxBusPlan.h engine/core/PreparedMixerBlock.h engine/core/MasterOutputMonoPolicy.h engine/core/LiveChannelFxGraph.h engine/core/PreparedNativeMixerSession.h engine/core/NativeDryRouteCommand.h engine/core/RealtimeRoutePublisher.h engine/device/LiveInputPortRegistry.h src/LiveDryRoutingLab.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h engine/core/OrbitDistanceMapping.h engine/core/DearVrPolarPolicy.h src/PluginCatalog.h src/NativeFxParameterHotkey.h src/FactoryFxRegistry.h src/PluginVault.h src/PortableWorkspace.h src/StudioBackup.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/NativeShowSchema.h src/NativeDryShowRecall.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/LiveSecondaryOutputDevice.h engine/core/LiveOutputRouteGate.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/JuceActivePortSnapshot.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h) @@ -411,6 +428,14 @@ if(ARMIX_SONKU_APPROVED_P99_MAIN) SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH=1 ARMIX_SONKU_EXPERIMENTAL_P99_VOCAL_DEPTH=1) endif() +if(ARMIX_IMMERSIB_RELEASE_CANDIDATE) + if(NOT ARMIX_SONKU_APPROVED_P99_MAIN) + message(FATAL_ERROR "ImmerSIB RC requires the approved SonKu P9.9 foundation") + endif() + target_compile_definitions(ARMixConsole PRIVATE + ARMIX_IMMERSIB_RELEASE_CANDIDATE=1 + SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH=1) +endif() if(WIN32) # Windows retains its proven ASIO-first / WASAPI / static WebView2 distribution. @@ -422,7 +447,7 @@ if(WIN32) # Dedicated INITGUID TU supplies PKEY_AudioEndpoint_FormFactor and # PKEY_AudioEngine_DeviceFormat to the Windows MMDevice discovery path. target_sources(ARMixConsole PRIVATE engine/device/WindowsAudioPropertyKeys.cpp) - target_link_libraries(ARMixConsole PRIVATE ole32 uuid advapi32) + target_link_libraries(ARMixConsole PRIVATE ole32 uuid advapi32 dwmapi) endif() target_link_libraries(ARMixConsole PRIVATE @@ -480,6 +505,37 @@ if(BUILD_TESTING) add_test(NAME BuiltInFxUserPresetFourRealJuceAdaptersAndColdReopen COMMAND ARMixBuiltInFxAcceptedSnapshotTests) + if(ARMIX_IMMERSIB_RELEASE_CANDIDATE) + # Real brand-specific JUCE FX, ACK, UI DPI, state and full PCM gates. + juce_add_console_app(ARMixImerSipP92NativeTests + PRODUCT_NAME "ImmerSIB Native Editor/State Tests") + target_sources(ARMixImerSipP92NativeTests PRIVATE + tests/imersip_p92_native_test.cpp) + target_compile_features(ARMixImerSipP92NativeTests PRIVATE cxx_std_20) + target_link_libraries(ARMixImerSipP92NativeTests PRIVATE + ARMixAssets juce::juce_audio_processors + juce::juce_recommended_config_flags) + get_target_property(IMMERSIB_RC_DEFINES ARMixConsole COMPILE_DEFINITIONS) + # Native editor/state FAT has no WebView2 browser. Propagating the + # app's GUI browser defines would compile juce_gui_extra WebView2.cpp + # without its app-only SDK include path. Preserve exact PCM flags while + # keeping browser integration in the separately built ARMixConsole. + list(FILTER IMMERSIB_RC_DEFINES EXCLUDE REGEX + "^JUCE_(WEB_BROWSER|USE_WIN_WEBVIEW2|USE_WIN_WEBVIEW2_WITH_STATIC_LINKING)(=|$)") + target_compile_definitions(ARMixImerSipP92NativeTests + PRIVATE ${IMMERSIB_RC_DEFINES}) + add_test(NAME NativeImmerSIBJucePresetACKStateAndBypass + COMMAND ARMixImerSipP92NativeTests) + add_executable(ARMixImmerSIBP99NativeSonicGate + tests/immersib_p98_native_sonic_gate.cpp) + target_compile_features(ARMixImmerSIBP99NativeSonicGate PRIVATE cxx_std_20) + target_compile_definitions(ARMixImmerSIBP99NativeSonicGate + PRIVATE ${IMMERSIB_RC_DEFINES} + SONKU_IMMERSIB_PCM_DIAGNOSTICS=1) + add_test(NAME NativeImmerSIBP99VocalRoomAndVenueGolden + COMMAND ARMixImmerSIBP99NativeSonicGate) + endif() + # Native 8D-SonKu non-JUCE measured-HRIR PCM and deterministic orbit fixture. add_executable(ARMixSonKuCoreTests tests/sonku_spatial_core_test.cpp) target_compile_features(ARMixSonKuCoreTests PRIVATE cxx_std_20) diff --git a/assets/imersip/scenes/scene_arena_thunder.png b/assets/imersip/scenes/scene_arena_thunder.png new file mode 100644 index 000000000..42b083054 Binary files /dev/null and b/assets/imersip/scenes/scene_arena_thunder.png differ diff --git a/assets/imersip/scenes/scene_front_row_power.png b/assets/imersip/scenes/scene_front_row_power.png new file mode 100644 index 000000000..a1e59793c Binary files /dev/null and b/assets/imersip/scenes/scene_front_row_power.png differ diff --git a/assets/imersip/scenes/scene_live_concert.png b/assets/imersip/scenes/scene_live_concert.png new file mode 100644 index 000000000..87cb8eccf Binary files /dev/null and b/assets/imersip/scenes/scene_live_concert.png differ diff --git a/assets/imersip/scenes/scene_royal_concert_hall.png b/assets/imersip/scenes/scene_royal_concert_hall.png new file mode 100644 index 000000000..434e1a7f8 Binary files /dev/null and b/assets/imersip/scenes/scene_royal_concert_hall.png differ diff --git a/assets/imersip/scenes/scene_symphonic_palace.png b/assets/imersip/scenes/scene_symphonic_palace.png new file mode 100644 index 000000000..28112e610 Binary files /dev/null and b/assets/imersip/scenes/scene_symphonic_palace.png differ diff --git a/assets/imersip/scenes/scene_velvet_cinema.png b/assets/imersip/scenes/scene_velvet_cinema.png new file mode 100644 index 000000000..0b1669936 Binary files /dev/null and b/assets/imersip/scenes/scene_velvet_cinema.png differ diff --git a/config/spatial_audio_authority.json b/config/spatial_audio_authority.json new file mode 100644 index 000000000..03f5e1407 --- /dev/null +++ b/config/spatial_audio_authority.json @@ -0,0 +1,274 @@ +{ + "schemaVersion": 1, + "purpose": "Research ownership/acceptance ledger. NOT audio runtime config, session state, or release approval.", + "selectedSonKuBaseline": { + "pr": 719, + "issue": 720, + "immutableCheckpointBranch": "checkpoint/sonku-p91-p92-operator-confirmed-20261116", + "immutableCheckpointSha": "763706a15a2617a10d23b5e2e43eb5689e454ccb", + "nativeRenderer": "SonKuSpatialCore", + "researchRenderMode": 9, + "modeNameInCode": "MusicSpatialP90", + "actualAudioFeatures": "P9.1 + P9.2: world-positioned stereo sources, P9 complementary LF world bass and bounded axial room modes", + "releaseQualified": false, + "acousticSourceBlobSha1": { + "engine/builtin_fx/sonku/SonKuSpatialCore.h": "5b8e26eaf4673fe2235d0b87d60b4ddc619e9602", + "engine/builtin_fx/sonku/SonKuP91P92WorldBassFoundation.h": "938cb96a5b7181d37f5c290c13fd39370ab18826", + "engine/builtin_fx/sonku/SonKuP90StereoDecoder.h": "f760c673dec8031f4dfcc76d6f1fee36beffa043", + "engine/builtin_fx/sonku/SonKuEarlyReflections.h": "46209c6b841bb8eb03bbd2dc65b3ac080586a826", + "engine/builtin_fx/sonku/SonKuMusicalReverb.h": "c2f273ef7c1ee26c5566b05568416e5cedaef6c4", + "engine/builtin_fx/sonku/SonKuMeasuredHrir3D.h": "816e7255939f0bb262374a5b4c0240438ec1e3a0", + "engine/builtin_fx/sonku/SonKuHrtfTonalCalibration.h": "233e2b26caf51e88df4ed82babc442f2b341c2d7" + } + }, + "imersip": { + "activeIntegrationPr": 734, + "sourceResearchPrs": [722, 732, 731], + "approvedSonKuMainPr": 733, + "basePr": 719, + "catalogIdentity": "armix.builtin.imersip.v1", + "processor": "ImerSipP92Processor", + "nativeRenderer": "SonKuSpatialCore", + "settingsFormat": "IMRS", + "settingsVersion": 7, + "nestedSonKuVersion": 12, + "researchOnly": true, + "independentSpatialDsp": false, + "releaseQualified": false, + "displayName": "ImmerSIB", + "previousDisplayName": "ImerSip", + "renamePolicy": "Display-only rebrand. Preserve catalogIdentity, native API, IMRS wire state and saved .smix.", + "mainIntegrationMode": "flagged-by-ARMIX_IMMERSIB_RELEASE_CANDIDATE" + }, + "audioScenes": { + "operatorCheckpointObservation": { + "speakerSpreadDeg": 82, + "distanceMeters": 1.6, + "spacePreset": 3, + "earlyRoom": 1, + "lateRoom": 0.62, + "spatialMix": 1, + "outputGainDb": 7, + "revolutionSeconds": 8.5, + "notFactoryDefault": true, + "referenceIssue": 720 + }, + "p92NeutralABReference": { + "speakerSpreadDeg": 82, + "distanceMeters": 1.6, + "spacePreset": 3, + "earlyRoom": 0.78, + "lateRoom": 0.33, + "spatialMix": 1, + "outputTrimLinear": 1, + "moving": false, + "internalRegressionOnly": true, + "userVisiblePreset": false + }, + "imersipNewInsertDefault": { + "presetId": 2, + "name": "Live Concert — nearfield vocal clarity candidate", + "speakerSpreadDeg": 112, + "distanceMeters": 2, + "spacePreset": 3, + "earlyRoom": 1.36, + "lateRoom": 0.84, + "spatialMix": 1, + "outputTrimLinear": 1.8, + "sceneVoicing": 4, + "releaseQualified": false, + "outputGainDb": 5.10545 + }, + "imersipAuditionPresetIds": { + "2": "Live Concert — 2.0m, 112°, Early136%, Late84%, vocal-detail4, trim1.8", + "3": "Royal Concert Hall — 2.2m, 106°, Early155%, Late78%, detail4", + "4": "Arena Thunder — 2.5m, 124°, Early145%, Late86%, impact5", + "5": "Front Row Power — 1.3m, 104°, Early126%, Late70%, detail4", + "6": "Symphonic Palace — 1.9m, 118°, Early160%, Late80%, detail4", + "7": "Velvet Cinema — 1.8m, 108°, Early142%, Late82%, Cinema3", + "8": "Concert Front Row XL — 1.5m, 134°, Early170%, Late94%, detail4, +4.4dB" + }, + "ownerScreenshotObservation": { + "speakerSpreadDeg": 150, + "distanceMeters": 1.6, + "spacePreset": 3, + "earlyRoom": 1, + "lateRoom": 0.91, + "spatialMix": 1, + "outputGainDb": 4.1, + "notFactoryDefault": true, + "separateFromIssue720": true + } + }, + "nonAuthoritativeCandidates": [ + { + "pr": 706, + "role": "Superseded ImerSip P8 DSP; archived for comparison and IMRS v1-v5 migration" + }, + { + "pr": 718, + "role": "Divergent P9.1/P9.2 acoustic alternative; retained for scientific A/B, not selected renderer" + }, + { + "pr": 717, + "role": "P9.0 ancestor; dependency of selected P9.1/P9.2 #719, not current owner-accepted version" + } + ], + "historicalP83": { + "workflow": ".github/workflows/sonku-p83-native-speaker-gates.yml", + "qualification": "REJECTED_LEGACY_NEGATIVE_ACOUSTIC_EVIDENCE", + "automaticExecution": "only pull request head refs containing p83", + "manualExecution": "workflow_dispatch", + "notP9OrImerSipReleaseGate": true, + "strictOriginalFidelityVetoRetained": true + }, + "production": { + "mainMustRemainUnchanged": false, + "noAutomaticMerge": true, + "physicalHeadphoneAbStillRequired": true, + "releaseCandidateIntegratedOnMain": false, + "publicReleaseAllowed": false, + "releaseRequiresOperatorHeadphoneApproval": true + }, + "immersibP98Integration": { + "product": "ImmerSIB", + "reason": "Operator explicitly requested forward-port P9.7 approved Venue and P9.8 voicing without changing production main or the frozen P9.2 checkpoint.", + "venueOperatorCheckpointBranch": "checkpoint/sonku-p97-venue-mega-space-owner-approved-20261116", + "sourceBranch": "feat/sonku-p98-signature-cinema-studio-voicing-20261116", + "venueGolden": { + "stageDegrees": 106, + "distanceMeters": 10, + "spacePreset": 3, + "earlyRoom": 1, + "lateRoom": 1, + "outputTrimLinear": 1.8, + "sceneVoicing": 0 + }, + "nativeRenderMode": 9, + "featureFlag": "ARMIX_IMMERSIB_RELEASE_CANDIDATE", + "releaseQualified": false, + "immersibP99VocalRoom": { + "product": "ImmerSIB", + "featureFlag": "ARMIX_IMMERSIB_RELEASE_CANDIDATE", + "perInstanceOptIn": "ImerSipP92Processor only, never generic SonKu/IMRS", + "donorApprovedMainCommit": "cdee12c6f71b35b75ddb9ba3da9a98999b60d119", + "donorExactBlob": "d8542d7aa333d689eea9637fc9f5f122c468277a", + "adapterBlob": "0aee9e1154f6052db02a8e8dfdb696ef4462aa10", + "scope": "sceneVoicing4/5 only, room ON, MIX>0, explicit product opt-in, 42% Detail / 34% Impact of already approved P9.9 Profile1", + "routing": "P9.8 source delta captured BEFORE P9.9 and applied to original 32%/12% feeds; P9.9 center 330Hz feeds separately enter existing six-wall/late engines once", + "safety": "no new FX ID/session bytes/HRIR/dry stem/second engine/heap/FFT, neutral Venue and non-opted SonKu bit-exact", + "status": "Main-based RC, synthetic PCM plus real Windows/owner listening gates required" + }, + "acousticSourceBlobSha1": { + "engine/builtin_fx/sonku/SonKuSpatialCore.h": "f9fdcdec933bc62710bdb84fa44c0830bdc16868", + "engine/builtin_fx/sonku/SonKuP91P92WorldBassFoundation.h": "63551d22e8dff672fe136131c32d28b568bb3170", + "engine/builtin_fx/sonku/SonKuP94FrontBackDepthCue.h": "f0f88088c68ef6865d64c240c4c87accaf136070", + "engine/builtin_fx/sonku/SonKuP95MusicalPresence.h": "f458d520c9ca6c75b1b961d220e15abd64b07497", + "engine/builtin_fx/sonku/SonKuP96DistanceReinforcement.h": "a32fb6e6fdd431901323d4278c51991607c02d84", + "engine/builtin_fx/sonku/SonKuP97StageImpact.h": "5384fd3cc67c31f0a8038b315856d20933249b5b", + "engine/builtin_fx/sonku/SonKuP98SceneVoicing.h": "5ec8d135d54e846c3f8d86d80202c29de67b724f", + "engine/builtin_fx/sonku/SonKuEarlyReflections.h": "5a6a9b48cfdc60729f130c61110c8d8590b20f35", + "engine/builtin_fx/sonku/SonKuSourcePlacement3D.h": "9afb959bed292626c3097c2a382208ce8798e90c" + }, + "ownerFrontRowXLCohesionCandidate": { + "status": "development_only_requires_headphone_AB", + "screenshotPresetId": 8, + "screenshotPresetName": "Concert Front Row XL", + "revisedListeningPresetDistanceMeters": 1.5, + "revision": "owner_2026_11_17_front_row_grandeur_and_exact_preset_identity", + "revisedListeningRangeMeters": [ + 1.1, + 2.5 + ], + "note": "Historical screenshot observed 1.0m; new owner request changes candidate to 1.1m. visibleControls remains original evidence.", + "visibleControls": { + "room": 3, + "stageDegrees": 147, + "distanceMeters": 1, + "earlyPercent": 180, + "latePercent": 60, + "spatialMixPercent": 100, + "earAlignDegrees": 0, + "headYawDegrees": 0, + "outputGainDb": 2.5 + }, + "unobservableScreenshotState": "sceneVoicing is hidden in Custom; candidate explicitly selects Detail Warm id4, verify vs actual saved IMRS state for exact listening parity", + "hypothesesUnderTest": [ + "original dry-side spectrum in room differs from warm direct HRIR feed", + "upward P9.5 makeup plus linked peak guard may modulate mastered music" + ], + "candidateChanges": "warm voicings 4/5 only: 32 percent already-processed source delta fed to existing early reflections; 12 percent to existing late reverb; adaptive makeup ceiling 1.10 rather than 1.65 while warm/room on", + "diagnostics": "offline-only native test captures P9.5 makeup and linked limiter reduction; changes do not prove subjective vocal segregation or absence of pumping", + "goldenConstraint": "Venue P9.7 profile0 and SonKu voicings 0..3 remain PCM-identical and immutable", + "lateralHighAir": "P9.8 voicings 4/5 only: first-image KEMAR early lateral >5.2kHz gains 0.18/0.14; no extra dry upper-mid, delays or second DSP", + "newFrontRowXLAudition": { + "presetId": 8, + "stageDegrees": 134, + "distanceMeters": 1.5, + "earlyRoom": 1.7, + "lateRoom": 0.94, + "outputGainDb": 4.4, + "voicing": 4, + "goal": "larger diffuse envelopment than original 60 percent late scene while keeping source in the nearfield", + "historicalScreenshotUnmodified": true, + "operatorHeadphoneABRequired": true + }, + "presetIdentityCorrection": "JUCE sends exact factory Settings when selecting named scene; subsequent edits mutate only changed axis of message-thread scene intent; names reconcile on native ACK, Custom only after genuine control edit; IMRS wire format unchanged", + "released": false + }, + "productTuning": { + "status": "nearfield_vocal_masking_candidate_owner_not_auditioned", + "archivedP97VenueGolden": "10m / 106° / ER100% / late100% / trim1.8 / voicing0, PRIVATE test-only", + "newFactoryRangeMeters": [ + 1.1, + 2.5 + ], + "newEarlyRoomRangePercent": [ + 0, + 180 + ], + "reason": "Owner hears farfield presets as vague and 100% early room too weak; M/S masking relief is source-domain frequency-selective, not stem separation", + "newDSPBlobSha1": { + "engine/builtin_fx/sonku/SonKuSpatialCore.h": "adb44388544cf2378a282afb14cc4c4a48f2a149", + "engine/builtin_fx/sonku/SonKuEarlyReflections.h": "5a6a9b48cfdc60729f130c61110c8d8590b20f35", + "engine/builtin_fx/sonku/SonKuP98SceneVoicing.h": "5ec8d135d54e846c3f8d86d80202c29de67b724f", + "engine/builtin_fx/sonku/SonKuSourcePlacement3D.h": "9afb959bed292626c3097c2a382208ce8798e90c" + }, + "legacyIMRS": "Old 1.0m/4-10m saved scenes migrate to 1.1-2.5m preserving room/voicing/gain; no codec or FX ID change", + "physicalHeadphoneABRequired": true, + "sceneBalance": "Historical Symphonic 3.6m and Cinema 2.8m sounded vague; current nearfield uses Symphonic 1.9m / Cinema 1.8m without gain-only inflation.", + "vocalBodyCorrection": { + "status": "audition_candidate_not_owner_approved", + "userEvidence": "Dua Lipa live concert playback: center vocal sounds thin, sharp, and unpleasant after previous 2.05kHz/5.2kHz voicing, despite PCM and Windows builds passing", + "diagnosis": "Stacked 1.9k/2.05k source+ear presence, high-air on side and early reflection, no independent center 285Hz body in ImmerSIB profiles 4/5", + "correctsProfiles": [ + 4, + 5 + ], + "chosenDSP": "pre-KEMAR world-center broad 285Hz body; suppress SIDE upper-mid 2.05k+3.45k; gentle linked-ear 3.45k fatigue notch after render; remove stacked >5.2k boost in profiles 4/5", + "constraints": "No actual vocal stem/AI extraction, no extra HRTF, no output loudness chase, no added latency, no tail/room change, no changes in frozen P9.7 Venue or SONK profiles 0..3", + "beforeVoicingGitBlob": "cc769dade5a752e0f84f02348e07332bce7c268b", + "afterVoicingGitBlob": "90bab191a62601021c4a7a77d64e0e4d408d3011", + "requiredChecks": "Native source & finished stereo tone spectral balance, 44.1/48k exact Venue PCM hash, antiphase, mono, IMRS7/SONK12 state roundtrip, JUCE Windows and portable EXE build, physical loudness-matched Dua Lipa concert FAT", + "qualityGateRevision": { + "reason": "Legacy 85% venue-total-electric-energy gate excluded the vocal chest/body band and rewarded shrillness; replace with whole native scene tonal transfer plus finite peak, anti-phase, PCM hash and 70% minimum electric safety floor", + "wholePcmConditions": [ + "center 285Hz body ratio >1.08 to neutral voicing, same scene", + "SIDE 3.45kHz energy ratio <1.05", + "SIDE 7.4kHz retained >0.65", + "legacy P9.7 44.1/48k PCM hash must remain exact" + ], + "notEvidenceOf": "audible vocal source isolation, mastered-song loudness, subjective preference or universal de-essing" + } + } + }, + "mainIntegration": { + "baseMain": "7b0c2fc1dea359dc98b8807ccd6806ad761ffbd6", + "strategy": "forward port ImmerSIB-only code over approved SonKu P9.9 main without history replay", + "flagDefault": false, + "operatorHeadphoneFAT": "pending", + "windowsRC": "pending", + "mainP99Preserved": true + } + } +} diff --git a/docs/IMERSIP_P92_SINGLE_NATIVE_ENGINE_FAT_20261116.md b/docs/IMERSIP_P92_SINGLE_NATIVE_ENGINE_FAT_20261116.md new file mode 100644 index 000000000..d2a114ee9 --- /dev/null +++ b/docs/IMERSIP_P92_SINGLE_NATIVE_ENGINE_FAT_20261116.md @@ -0,0 +1,27 @@ +# ImerSip P9.1/P9.2 — single-engine adoption (16 November 2026) + +**User reference:** 8D-SonKu P9.1–P9.2 is reported to sound external and alive on the user's real headphones. Do not replace its acoustic renderer with the older ImerSip P8.2/P8.4 bespoke dry-MID/room-enhancer path. + +**New insert audition default** (after owner headphone feedback): `Live Concert`, 150°/2.2 m/Large/Early 100%/Late 91%/+4.8 dB. The original 82°/1.6 m/78%/33%/0 dB reference remains ONLY as an internal PCM regression reference, not in the preset picker. Owner-visible presets now include Live Concert, Royal Concert Hall, Arena Thunder, Front Row Power, Symphonic Palace, and Velvet Cinema. The original screenshot 150°/1.6 m/100%/91%/+4.1 dB remains documented; Front Row Power develops it into a richer audition scene. This is preset-only product tuning; **not** a change to the P9.2 DSP, and neither enhanced gain nor acoustic realism is guaranteed for full-scale mastered material. + +**Canonical ownership and CI classification:** [SPATIAL_AUDIO_AUTHORITY.md](SPATIAL_AUDIO_AUTHORITY.md) and [machine-readable ledger](../config/spatial_audio_authority.json). The ImerSip factory scene is **not** the operator's louder/roomier #720 headphone-test scene. + +**Baseline:** PR #719 commit `763706a15a2617a10d23b5e2e43eb5689e454ccb`. This integration is a new research branch based on that exact PR, not a merge of divergent #706. Production `main` and both older PRs remain untouched. + +## Design + +- **One PCM authority:** `ImerSipP92Processor` inherits the existing native `SonKuSpatialProcessor`, whose single callback invokes the exact P9.1/P9.2 `SonKuSpatialCore` renderer in mode 9. This is inheritance of transport/control, not another sound engine. No P8-only `ImerSipDsp`, HRTF staging, secondary limiter, headphone SIDE widening, EQ, early-reflection boost, or LF shelf. +- **Product identity:** same ImerSip native catalog ID `armix.builtin.imersip.v1`, its own native editor and IMRS state, existing host FX slot routing/bypass. P9 CMake flag is private/opt-in, so public builds are unaffected. +- **Factory vs reference:** the first ImerSip insert now starts in `Live Concert` and the **P9.2 neutral A/B reference** remains separately selectable. Original SonKu product defaults and restored user sessions remain unchanged. This separation is enforced by source and native JUCE tests. +- **Real controls only:** speaker angle, source distance (bounded by real room geometry), EARLY ROOM, LATE ROOM, spatial mix, output gain, manual yaw, KEMAR ear alignment, preset and native per-slot power/close. UI edits go through existing audio ACK; no optimistic DSP success. +- **Session:** new `IMRS` v6 embeds the accepted native 63-byte `SONK` v11 state. Old IMRS v1–v5 are parsed and deliberately migrated into P9 **without** re-enabling P8-only Bass Impact/Detail/Stereo Keep DSP. These old three controls have no bit-perfect P9 analogue and cannot be claimed lossless. Existing room/distance maps are validated and clamped to physical geometry rather than rejected or rendering stale filters. +- **Research limits:** P9 bass modes are parametric, not a measured commercial BRIR. A byte-level native PCM comparison proves no new audio processing; headphone perception remains a user-listening qualification. + +## Mandatory quality gates + +1. Native JUCE P9 core parity: same PCM sample-for-sample as ImerSip insert at 44.1 and 48 kHz with actual stereo music fixture and late tail. +2. Real native FX catalog registration / editor and native host power after stable insert lease; source-only JS or false WebView2 render is not sufficient. +3. Audio queue ACK after processing, IMRS v6 round-trip, old v1–v5 fail-closed migration, corrupted state rejection and no per-callback dynamic allocation. +4. Full Windows JUCE EXE + isolated artifact. No release/merge until exact Windows gates and real headphone A/B pass. + +**Listening:** Compare 8D-SonKu P9.1–P9.2 and ImerSip at identical *native settings* with no other FX. PCM should match; externalization and bass must not change just because the plugin name changed. Then separately audition ImerSip's scene presets. diff --git a/docs/IMMERSIB_FRONT_ROW_XL_COHESION_20261116.md b/docs/IMMERSIB_FRONT_ROW_XL_COHESION_20261116.md new file mode 100644 index 000000000..cb1069eea --- /dev/null +++ b/docs/IMMERSIB_FRONT_ROW_XL_COHESION_20261116.md @@ -0,0 +1,151 @@ +# ImmerSIB Concert Front Row XL + vocal/room cohesion candidate (2026-11-16) + +## Source of truth and UX + +Owner's native JUCE screenshot shows a **Custom** scene with: LARGE 28.8 M, Stage Width **147°**, Source Distance **1.0 m**, Early Room **180%**, Late Room **60%**, Spatial Mix **100%**, Ear Align **0°**, Head Yaw **0°**, Master Gain **+2.5 dB**. + +These visible controls are added as typed preset **ID 8, Concert Front Row XL** (scene voicing **4 / Detail Warm**). An important limitation: the screenshot *does not display the hidden serialized scene voicing*. Choosing ID4 is a documented assumption, not proof of bit-identical sound to the actual saved Custom session. The original .smix / IMRS settings remain authoritative; no session format change and no migration of UI preset IDs. All six prior presets retain their values. + +No new GUI image was synthesized. ID8 reuses the existing Live Concert background because the screenshot visually shows the live venue. GUI artwork, layout and dimensions remain owned by the GUI thread. + +## Root-cause hypotheses, not promises + +1. P9.8 center-source body/presence is processed before the world-positioned KEMAR HRIRs, but the six-surface early reflections and diffuse late-room processors previously consumed unchanged stereo input. At high Early Room this can make direct spectral body and room spectral body perceptually inconsistent. +2. P9.5's upward-only adaptive makeup has a 1.65 maximum, followed by P9.7/P9.8 spectral makeup and an existing zero-lookahead 0.98 peak limiter with 80ms release. A strong mastered source can therefore modulate the entire output, even when the tone changes alone sound promising. +3. An independent true-vocal stem is unavailable: L+R center is NOT exclusively the singer, and L-R SIDE is not only instruments. Static spectral notches are not stem separation. + +Research motivating the experimental candidates: Arweiler & Buchholz, JASA 2011, DOI 10.1121/1.3609258 (spectral characteristics of early reflections); Bradley et al., JASA 2003, DOI 10.1121/1.1570439 (early reflection contribution to intelligibility); Prodi et al., JASA 2022, DOI 10.1121/10.0011403 (spatial perception and early/late balance). None of these papers validates arbitrary numerical mix coefficients for Dua Lipa concert material. + +## Narrow candidate changes + +- **Only mode 9, room enabled, and sceneVoicing 4/5**: reuse a modest fraction of the existing, pre-HRTF warm source delta in the genuine six-wall early-reflection feed (32%) and original late-reverb feed (12%). The room maintains its original direction/tap/geometry/late decay; no extra HRTF, delay, crossfeed, AI or vocal stem. +- **Only same warm scenes**: P9.5 upward makeup maximum **1.10× (~+0.83 dB)**, rather than 1.65×. The 280ms detector / 450ms slew is preserved and smooths switches. Previously accepted voicing 0–3 and golden P9.7 remain on the unchanged 1.65 path. +- **Existing linked peak guard retained**. An exact preset with +2.5dB does not guarantee no limiting on mastered peak-heavy music. Do not promise no pumping until real PCM gain-reduction and matched-loudness user FAT are done. +- **Offline diagnostics compile flag**: `SONKU_IMMERSIB_PCM_DIAGNOSTICS=1` for the ImmerSIB native acoustic gate only. Counts limiter-hit frames and sums makeup/gain reduction; not available in production callbacks. Do not read counters concurrently with live audio. + +## Required qualification + +- Native C++ at 44.1/48 kHz including all seven scenes, owner screenshot exact controls, original P9.7 Venue PCM hash, mono/anti-phase/finite/peak, adaptive makeup bound, original legacy voicing parity. +- Actual native JUCE parameter dispatch/readback, IMRS7/SONK12 session restore, preset dropdown and Windows build/portable artifact. +- A/B at **matched LUFS** on the exact permitted concert tracks: new ID8, prior custom IMRS, unchanged reference, and previous warm candidate. Track voice body/articulation, phase/coherence, ER high-frequency coloration and kick-triggered pumping. A green CI is not listener approval. + +## Status + +Development candidate on a branch stacked over draft PR #722. This document deliberately does not claim subjective listening approval, proof of isolated voice detection, calibrated true-peak, or physical-speaker parity. No production merge or release. + +## User revision 16 Nov: frontstage distance and reflected high-air + +The owner revised the desired distance to **1.1–2.5m**. This overrides +the previous 1.0m screenshot *only for the new listening candidate*; +that earlier screenshot remains recorded above as historical provenance. + +- P9.8 product GUI, typed presets, scene validation and IMRS v6/v7 + + older legacy migration share one 1.1–2.5m envelope, preserving room, + gain and voicing. Distances now: Live 2.0m, Royal 2.2m, Arena 2.5m, + Front Row 1.3m, Symphonic 1.9m, Cinema 1.8m, Front Row XL 1.1m. + Existing 1.0m/10m files load at the closest accepted bound; + session bytes, catalog IDs and the private P9.7 10m Venue fixture + remain unchanged. +- Only voicings 4 and 5 add a **small linear (>5.2kHz) lateral term** + to the existing, already directional KEMAR EARLY-reflection output: + gains 0.18 (Detail Warm) and 0.14 (Impact Warm) multiply the ear + difference of the highpassed early component. The early MID, direct + HRTF, late reverb, reflection wall geometry and delay are unchanged. + No artificial Haas delay, extra HRTF, singer stem, compressor, FFT, + parameter ID, or realtime memory allocation is introduced. +- This is **not a blanket HF increase**. Directional early image + energy can improve stage width and envelope fusion, but overly + bright/loud reflections increase metallic sibilance or mask vocals. + Inspect native PCM 7.4kHz lateral/1.5kHz impact and matched-volume + concert audition before approval. High-frequency side gain is a + deliberately small *candidate*, not a calibrated room model. + +Reference for broadband lateral early reflections and preserved envelope: +Lokki et al., JASA 129 EL223 (2011), doi:10.1121/1.3579145. +No research source proves any single numerical gain optimal for this +mastered concert recording. + +**Gate:** both 44.1/48k native tests, old Venue PCM hash, mono symmetry, +native JUCE state migration and source-only/ROOM OFF integrity. Keep +PR Draft, and reject/retune if the owner's headphone FAT hears harshness +or unchanged pumping. + +## 2026-11-17 listening follow-up: preserve named preset + Grand Front Row + +Owner A/B: **Live Concert already feels majestic**, but Concert Front Row +XL lacks the same hall envelopment. Screenshot: Live parameters display +112deg / 2.0m / ER136 / late84 / +5.1dB while combo incorrectly shows +`Custom` without a manual edit. Diagnosis: factory Live trim is exactly +`1.8f`, i.e. ~5.10545dB, but JUCE slider step `0.1dB` rounds to +5.1dB. The prior `sync(factory); submit(readControls());` loses +precision before the native ACK, and strict factory matching on restore +incorrectly displays Custom. + +**Fix in the existing native JUCE editor, no format change:** + +- Selecting a named preset enqueues its **exact typed factory scene**. + There is no readback through the rounded JUCE sliders during preset + selection. Native P9 PCM and ACK authority are unchanged. +- The editor keeps one control-thread `uiScene_` with exact values. A + slider updates **only its own typed axis**, preserving e.g. unedited + 1.8 gain when STAGE changes. A deliberate slider/ROOM edit sets Custom, + but programmatic `dontSendNotification` sync never does. +- After ACK, the selected name is retained; canonical recognition from + saved IMRS settings still works at editor creation. Existing binary + wire layout and preset IDs stay the same. Test all preset selections + after real native callback and JUCE 25Hz timer, plus one genuine manual + control edit and untouched-gain exactness. +- New **Concert Front Row XL** factory 8 is an audition candidate: + Large28.8, **134deg/1.5m/ER170%/Late94%/Mix100%/+4.4dB**, + Ear0/Yaw0, Warm Detail voicing 4. More diffuse hall return while + keeping a near-stage front image; the old screenshot 147deg/1.0m + (prior product candidate 1.1m)/ER180%/Late60%/+2.5dB stays archival. +- **Live Concert is unchanged**. P9.7 private Venue 10m golden PCM + remains immutable. No new HRIR, stereo delay, DSP path, runtime heap, + preset identity serialization, or louder-than-Live target. + +Acoustics rationale: early lateral energy informs apparent source width, +while late/reverberant energy informs listener envelopment. A roomier +front-row scene is preferable to uniformly increasing treble or direct +gain, but listening taste remains subjective. The test compares the +old and new Front Row PCM at 44.1/48k, anti-phase and limiter guards, +rather than claiming the numerical presets are perceptually proven. + +**Remaining acceptance:** real headphone, matched-loudness owner A/B +with the same live recording, check vocal presence, clarity, spacious +tails, cymbal harshness and compression pumping. Continue Draft until +audition and fully green Windows JUCE FAT. + +## 2026-11-17 — Isolated Vocal Room Enhancement from SonKu P9.9 + +**Donor:** byte-identical `SonKuP99MusicalVocalDepth.h` from the +listening-approved 8D-SonKu PR #733 (blob +`d8542d7aa333d689eea9637fc9f5f122c468277a`). +Do NOT copy full SonKu research branches or its Orbit Stage factory. + +**Candidate:** P9.8 ImmerSIB Warm IDs 4/5 only, private compile +option `ARMIX_IMMERSIB_EXPERIMENTAL_P99_VOCAL_ROOM` default OFF and +explicit per-instance ImerSipP92Processor opt-in. Use the donor's +center-attention algorithm, 210–880Hz musical body, carefully limited +presence, 330Hz Q1.4 vocal room coupling, directional early widening +and late masking relief. The adapter adds only 42% to Detail / 34% to +Impact, with 35ms strength slew, to avoid full P9.9 on top of existing +P9.8 body shaping. The 32%/12% P9.8 source/room coherence uses a +*pre-P9.9* source snapshot, preventing double feeding. P9.9 sends enter +the SAME real KEMAR/six-wall/late-room graph only once. No separate +reverb/feedback, artificial stereo delay, dry center overlay, FFT, +new GUI control, or allocation on the PCM callback. + +**Preserved:** accepted Live Concert room geometry/parameters, Front Row +XL tuning and display, native power/ACK and preset identity, 1.1–2.5m +slider, IMRS v7 and SONK v12 bytes, P9.5 makeup cap 1.10 and linked +.98 peak guard. SonKu P9.9 is still exclusively opt-in for its own +product; unopted SonKu, neutral Venue, ROOM OFF and MIX0 are bit-exact. +44.1/48k native PCM regression must verify warmer center 330Hz without +bass 86Hz or treble 7600Hz overboost, bounded overall power, anti-phase +integrity, true bypass, and both Windows JUCE and portable artifacts. + +**Audio acceptance:** real mastered concert listening with gain-matched +P9.8 comparison: coherent warm singer, preserved bass punch, no +piercing 2–4kHz, natural early/late room interaction, no audible pumping. +These hypotheses cannot be proved by synthetic PCM; keep PR Draft. diff --git a/docs/IMMERSIB_MAIN_RC_RELEASE_GATE_20261117.md b/docs/IMMERSIB_MAIN_RC_RELEASE_GATE_20261117.md new file mode 100644 index 000000000..53a2ebb4d --- /dev/null +++ b/docs/IMMERSIB_MAIN_RC_RELEASE_GATE_20261117.md @@ -0,0 +1,107 @@ +# ImmerSIB — main-based release-candidate integration gate (17 November 2026) + +## Ownership / exact provenance + +This is a **selective code forward-port**, not a merge of 400+ experimental +SonKu ancestry commits. The approved **8D-SonKu P9.9 `main` engine** remains +the source of truth. ImmerSIB Engine PR #732 and JUCE GUI/UX PR #722 are +integrated as a **separate product, sharing the one native SonKu PCM core**. + +- Baseline `main`: `7b0c2fc1dea359dc98b8807ccd6806ad761ffbd6`. +- GUI source: PR #722, `715b21b882907ba30bc072c26e46fbdf89d003da`. +- Audio source: PR #732, `6a3fe115008329ccc456e15f1448c66ac8b471e8`. +- Donor P9.9 approved 8D-SonKu: `SonKuP99MusicalVocalDepth.h` + blob `d8542d7aa333d689eea9637fc9f5f122c468277a`. +- No new second HRTF, convolution engine, automatic FFT stem separation, + per-block heap allocation, binary session ID or graph. Production SonKu + remains the default owner of its accepted P9.9 orbit/voicing. + +## Release-candidate flag and architecture + +`-DARMIX_IMMERSIB_RELEASE_CANDIDATE=ON` enables the branded insert and +P9.9 warm vocal/room opt-in only for ImmerSIB, using +`ARMIX_SONKU_APPROVED_P99_MAIN=ON`. The flag defaults **OFF** in normal +builds. This deliberately prevents public binaries from silently shipping +an unapproved headphone voicing. + +- Product name: **ImmerSIB**; catalog ID `armix.builtin.imersip.v1`; + persisted IMRS v6/v7, nested SONK v11/v12 preserved. +- Seven concert presets, Source Distance **1.1–2.5 m**, Early Room + up to **180%**, Windows-owned floating editor with native photos and + host-authoritative FX bypass/slot/rack/global power. +- Named presets preserve the full factory floating-point values through + callback ACK. Only genuine control changes demote to Custom. +- P9.8 Detail/Impact warms body / suppresses intrusive upper mids; P9.9 + room coupling uses **42%/34%** of the approved P9.9 donor profile, + continuous strength slew, 330 Hz narrow room-band and existing six-wall + / late-room feeds. ROOM OFF, MIX0, voicing0, private 10 m Venue + reference and unrelated 8D-SonKu instance must be unaffected. +- GUI work is additive: six 2200×922 venue PNGs; no retired sprite pack, + fake native power or new independent bypass state. + +## Mandatory green release gates + +1. Python authority/preset/photo and native bridge source tests. +2. Non-JUCE PCM tests at 44.1 and 48 kHz: Venue P9.7 hash, SonKu P9.9 + donor invariance, non-opted ImmerSIB comparison, 330 Hz body, 86 Hz + bass, 7.6 kHz air, no NaN, no catastrophic anti-phase and bounded + linked limiter. Test material is **not** a subjective listening verdict. +3. Authentic Windows JUCE editor/processor state and ACK, all presets + retaining their label after ACK, edit→Custom, IMRS restoration and + power readback from slot/rack/global gates. +4. Build executable on Windows from **the same exact integration commit** + with RC flag ON; package and hash-check portable ZIP and verify + DPI images at 100/125/150/200%. +5. Default public build with RC flag OFF still passes existing 8D-SonKu + P9.9 and mixer native regression suites, and does not expose ImmerSIB. +6. Owner headphone listening FAT: level-match Live Concert, Concert Front + Row XL and SonKu P9.9 on actual mastered concert. Veto thin/cempreng + vocals, late-room smearing, artificial detached voice, pumping or LF + impact loss. No substitute for owner acceptance. +7. Release control must create **one** intentional release run from + a pinned approved `main` SHA, avoid duplicate concurrent release + jobs, and publish user-facing downloads only after all gates above. + This integration PR does **not** trigger or enable a public release. + +## Exact-commit release-candidate progress + +- Commit `15ec57da680ac58ce1ce2cf343d5a69716c5e126` completed + six matching GitHub workflows: focused Windows native JUCE GUI/PCM + + field portable, Win32 editor reopen, Chromium UI smoke, preset tests, + player contracts and AUTO PR0. The portable archive and native DPI + captures are **FAT artifacts, not an approved public installer**. +- The Windows EXE SHA-256 verified by the focused job was + `4db578828a974427d1d7550c3e7e0a0a87e8bd503bdf170f83613dc7c21202cb`. + This is exact `15ec57da` evidence, NOT the checksum of a later commit. +- A further RC-only UX change explicitly distinguishes a retired host + processor lease from both bypass and ON; the new native screenshot + probe runs alongside accepted slot/rack/global bypass and native + audio ACK tests. +- For every subsequent RC commit, the focused Windows FAT will upload + the verified RC first, then **reconfigure the same Windows tree** + with all isolated SonKu experimental options OFF and + `ARMIX_IMMERSIB_RELEASE_CANDIDATE=OFF`, preserving the accepted + `ARMIX_SONKU_APPROVED_P99_MAIN=ON`. It must build the actual public + `ARMixConsole` and pass the original SonKu state/ACK test. + This never packages the default-OFF binary as the ON candidate. +- The current alpha release publisher uses standard default CMake + flags. It would therefore omit ImmerSIB even if the integration + branch were merged, until an explicit reviewed release promotion + changes that build configuration. **Do not claim ImmerSIB publicly + shipped based on a green prerelease from the default-off workflow**. +- Required operator approvals remain physical Windows/ASIO/Rack/Global + persistence and matched-loudness headphone A/B of vocal, kick/bass, + lateral treble, room distance and Concert Front Row XL versus the + user-approved SonKu P9.9. Synthetic DSP numbers cannot replace that. + The 1.1–2.5m versus historical 1–4m user target and migration + clamping policy are intentionally unchanged pending compatibility + acceptance; neither should be silently altered in a public binary. + +## Rollback + +If any gate regresses, disable `ARMIX_IMMERSIB_RELEASE_CANDIDATE` +or revert the isolated integration commit. Neither action must alter the +existing approved 8D-SonKu P9.9 output, DSP state or session format. + +**Release status:** CODE INTEGRATION CANDIDATE; NOT PUBLICLY QUALIFIED; +operator headphone FAT and exact release artifact/installer approval pending. diff --git a/docs/IMMERSIB_P98_CONCERT_FORWARDPORT_20261116.md b/docs/IMMERSIB_P98_CONCERT_FORWARDPORT_20261116.md new file mode 100644 index 000000000..270876a0b --- /dev/null +++ b/docs/IMMERSIB_P98_CONCERT_FORWARDPORT_20261116.md @@ -0,0 +1,26 @@ +# ImmerSIB private P9.7 Venue + P9.8 native engine port (16 Nov 2026) + +**Scope:** experimental ImmerSIB PR #722 only; production main stays unchanged, old IMRS sessions, stable `armix.builtin.imersip.v1`, and saved .smix identities remain. Preset labels displayed as **ImmerSIB**. GUI art work is independent and not declared visually accepted. + +## Sonic reference +The **owner-approved 8D-SonKu P9.7 Venue Mega Space** is the golden reference, branch `checkpoint/sonku-p97-venue-mega-space-owner-approved-20261116`. P9.8 branch `feat/sonku-p98-signature-cinema-studio-voicing-20261116` includes every P9.4–P9.7 stage contribution, and original P9.8 ear/world-source voicings. The actual renderer remains **one native SonKuSpatialCore, mode 9** via `SonKuSpatialProcessor` and existing SPSC/ACK, not a parallel ImmerSIB DSP. + +**Exact Live Concert Venue world scene:** `moving=false, startAzimuth=0deg, stage=106deg, Large 28.8m, distance=10.0m, Early=100%, Late=100%, MIX=100%, outputTrim=1.8 linear, sceneVoicing=0`. This is the same `VENUE` scene defined by `tests/sonku_p98_integrated_scene_test.cpp`. Using voicing=0 deliberately turns OFF P9.8 extra source/early/ear bands so Venue stays the unaltered P9.7 golden. Tests compare full PCM output hash at 44.1/48k to the explicitly recreated reference. + +Other operator-facing scenes: Royal Concert Hall, Arena Thunder, Front Row Power, Symphonic Palace (P9.8 Signature voicing 1 with differing physical stage/room distances), Velvet Cinema (P9.8 Cinema voicing 3). Those are **audition candidates**, not perceptually approved. There is no actual music stem extraction, content-aware separator, or source classifier. P9.8 center band is a modest bilateral source emphasis fed into measured world HRIR before ears; a realistic subjective claim of independent instrument stems would be false. Premium quality requires matched-loudness user A/B. + +## Engineering +- P9.8 source forwards acoustic modules P9.4 front/back, P9.5 music presence, P9.6 reinforcement, P9.7 stage impact, and P9.8 typed voicing, together with P9.8 core and exact P9.2 foundation. Each imported file is fingerprinted in `config/spatial_audio_authority.json`. +- Native SonKu transport is P9.8 v12 but retains ImmerSIB's restricted derived scene admission, the existing virtual methods, and legacy product ID. The SonKu **default standalone constructor retains its original neutral initial scene** in this branch, avoiding unrelated automatic preset changes. +- The user-approved Venue is not modified by P9.8 voicing: `sceneVoicing=0`. Scene changes use existing native SPSC command/ACK. GUI maintains typed voicing with a single accepted scene. +- An enabled P9.8 private build writes append-only **IMRS v7 = 8-byte IMRS header + 67-byte native SONK v12 = 75 bytes**; strict preflight protects against partial state mutation. Previous **IMRS v6 + SONK v11 (71 bytes)** and older IMRS v1–v5 formats restore with neutral voicing. Existing .smix audio slots use the same identity. +- Private `ARMIX_SONKU_EXPERIMENTAL_P94_...`, `P95`, `P96`, `P97`, `P98` CMake flags stay OFF by default. The dedicated ImmerSIB CI config explicitly enables the full five-stage stack; the standalone PCM check compiles exact equivalent flags to prevent a false-green different renderer. +- The editor supports 10m Venue instead of clipping the value to the previous 7.4m UI limit; scene renderer retains safe speaker geometry. + +## Acceptance boundary +1. Fast source test: exact Venue golden PCM hash, all scene profiles have actual distinct non-NaN output, anti-phase stereo doesn't catastrophically null, linked guard sample peaks <= 0.9805 at 44.1/48k. +2. Windows native JUCE: exact per-slot FX behavior, typed scene presets, native ACK/readback, IMRS v7/v6 and v1-v5 compatibility, editor actual layout and package verifier. +3. Real user headphone acceptance: kick/tom attack, warm/controlled LF resonance, centered vocal intelligibility, preserved cymbal/treble brightness, instrument clarity, front/rear depth and immersive stage. Loudness-match carefully; stronger gain alone is not proof of detail or premium quality. The owner-approved Venue must remain selectable and bit-exact. +4. PR remains Draft; no release/merge until owner validates. + +**Notes:** old `tests/imersip_p92_factory_music_test.cpp` remains the historical P9.2 data fixture built without P9.8 flags. New `tests/immersib_p98_native_sonic_gate.cpp` tests the actual P9.8 world engine. Neither silently re-qualifies P8.3 historical rejected mode. diff --git a/engine/builtin_fx/ImerSipP92Editor.h b/engine/builtin_fx/ImerSipP92Editor.h new file mode 100644 index 000000000..43c1373d0 --- /dev/null +++ b/engine/builtin_fx/ImerSipP92Editor.h @@ -0,0 +1,392 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +// Compact ImmerSIB concert scene + native JUCE control panel. +// Scene photography is image-backed; all control surfaces and icons are JUCE. +// Audio uses the existing SonKu PCM, host bypass, ACK, and IMRS state paths. +#include +#include +#include +#include +#include +#include +#include +#include "ImerSipP92VisualSkin.h" + +namespace armix::builtin_fx { + +class ImerSipP92Editor final : public juce::AudioProcessorEditor, + private juce::Timer { +public: + // Snapshot of actual host PCM control gates, never a GUI-local power flag. + // Slot preference is independent of the additive rack/global gates. + struct HostBypassState final { + bool valid=false; + bool slotBypassed=false; + bool rackBypassed=false; + bool globalBypassed=false; + bool effectiveBypassed() const noexcept { + return valid && (slotBypassed || rackBypassed || globalBypassed); + } + }; + explicit ImerSipP92Editor(ImerSipP92Processor& processor) + :juce::AudioProcessorEditor(processor),fx_(processor) { + // Compact 85% presentation of the audited 1100x680 master canvas. + // The host sees an actual 935x578 editor rather than an oversized FX. + setSize(935,578); + setResizable(false,false); + preset_.setComponentID("imersip.preset"); + preset_.addItem("Custom",1); + for(const auto& scene:imersipP92Presets) + preset_.addItem(juce::String(scene.label),scene.id); + preset_.setLookAndFeel(&skin_); + preset_.onChange=[this]{ + const int id=preset_.getSelectedId(); + if(!imersipP92PresetById(id))return; + // A named preset queues its exact factory scene, never a + // rounded slider snapshot (e.g. 1.8 linear -> displayed +5.1dB). + const auto factory=imersipP92Factory(id); + isCustomIntent_=false; + visualSceneId_=id; + sync(factory); + preset_.setSelectedId(id,juce::dontSendNotification); + submit(factory); + }; + addAndMakeVisible(preset_); + room_.setComponentID("imersip.room"); + room_.addItem("ROOM OFF",1); + room_.addItem("STUDIO 7.2 M",2); + room_.addItem("CHAMBER 14.4 M",3); + room_.addItem("LARGE 28.8 M",4); + room_.setLookAndFeel(&skin_); + room_.onChange=[this]{ + uiScene_.spacePreset=std::clamp(room_.getSelectedId()-1,0,3); + isCustomIntent_=true; + preset_.setSelectedId(1,juce::dontSendNotification); + submit(uiScene_); + }; + addAndMakeVisible(room_); + + const char* ids[]={"stage","distance","early","late", + "mix","gain","align","yaw"}; + const char* names[]={"STAGE WIDTH","DISTANCE","EARLY ROOM", + "LATE ROOM","SPATIAL MIX","MASTER GAIN", + "EAR ALIGN","HEAD YAW"}; + const double lower[]={30.,imersipP92MinDistance(),0.,0.,0.,-12.,-30.,-90.}; + #if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + const double upper[]={180.,2.5,180.,100.,100.,6.,20.,90.}; +#else + const double upper[]={180.,7.4,100.,100.,100.,6.,20.,90.}; +#endif + const double step[]={1.,.1,1.,1.,1.,.1,1.,1.}; + for(int i=0;i<8;++i){ + auto& slider=knobs_[static_cast(i)]; + slider.setComponentID(juce::String("imersip.")+ids[i]); + slider.setSliderStyle(i==5? + juce::Slider::RotaryHorizontalVerticalDrag: + juce::Slider::LinearHorizontal); + slider.setTextBoxStyle(juce::Slider::NoTextBox,false,0,0); + slider.setRange(lower[i],upper[i],step[i]); + slider.setLookAndFeel(&skin_); + slider.onValueChange=[this,i]{ + applySliderEdit(i); + isCustomIntent_=true; + preset_.setSelectedId(1,juce::dontSendNotification); + submit(uiScene_); + repaint(); + }; + addAndMakeVisible(slider); + auto& label=labels_[static_cast(i)]; + label.setComponentID(juce::String("imersip.label.")+ids[i]); + label.setText(names[i],juce::dontSendNotification); + label.setJustificationType(juce::Justification::centredLeft); + label.setColour(juce::Label::textColourId,juce::Colour(0xffcbd7dc)); + label.setFont(juce::FontOptions(14.0f)); + addAndMakeVisible(label); + } + power_.setComponentID("imersip.power"); + power_.setButtonText({}); // Icon is drawn by the JUCE LookAndFeel. + power_.setClickingTogglesState(false); // Host readback is authoritative. + power_.setTooltip("FX state unavailable"); + power_.setLookAndFeel(&skin_); + power_.setEnabled(false); // no fake bypass authority + power_.onClick=[this] { + if(!requestBypass_ || !readHostPower_)return; + const auto before=readHostPower_(); + if(!before.valid || before.globalBypassed || + before.rackBypassed) { + status_=before.globalBypassed?"GLOBAL FX BYPASSED - USE MIXER POWER": + before.rackBypassed?"FX RACK BYPASSED - USE RACK POWER": + "FX INSTANCE NO LONGER ACTIVE"; + refreshHostPower(); + repaint(); + return; + } + const bool wanted=!before.slotBypassed; + const bool accepted=requestBypass_(wanted); + const auto after=readHostPower_(); + status_=!accepted?"HOST FX POWER REJECTED - REFRESH FX RACK": + !after.valid?"FX INSTANCE CHANGED - REOPEN EDITOR": + after.slotBypassed!=wanted?"HOST FX POWER NOT CONFIRMED": + wanted?"FX BYPASS ACCEPTED":"FX ENABLE ACCEPTED"; + refreshHostPower(); + repaint(); + }; + addAndMakeVisible(power_); + sync(fx_.acceptedSettings()); + startTimerHz(25); + } + ~ImerSipP92Editor() override { + stopTimer(); + for(auto& slider:knobs_)slider.setLookAndFeel(nullptr); + preset_.setLookAndFeel(nullptr); + room_.setLookAndFeel(nullptr); + power_.setLookAndFeel(nullptr); + } + bool areVisualAssetsReady() const noexcept {return skin_.ready();} + void bindHostPower(std::function request, + std::function readback) { + requestBypass_=std::move(request); + readHostPower_=std::move(readback); + refreshHostPower(); + } + // Called by mixer dispatch after accepted Rack/Global FX ACK on JUCE's + // message thread. Timer polling remains a fallback for external changes. + void synchronizeHostPower() { refreshHostPower(); } + static constexpr float compactScale=0.85f; + // Master canvas and all native hitboxes share exactly one conversion. + void paint(juce::Graphics& g) override { + g.fillAll(juce::Colour(0xff11181d)); + juce::Graphics::ScopedSaveState save(g); + g.addTransform(juce::AffineTransform::scale(compactScale)); + // One authentic photo venue per scene, never the abandoned + // holographic room or stacked artificial speaker sprites. + // Only approved concert photography; rejected procedural art is removed. + skin_.drawScene(g,visualSceneId_); + if(hostBypassed_.value_or(false)) + skin_.drawBypassedVenueOverlay(g); + else if(hostLeaseWasValid_ && !hostBypassed_.has_value()) + skin_.drawUnavailableVenueOverlay(g); + + // No second header: the native plugin window already owns its title. + // Preserve the venue art's full 1100x461 scene viewport. + + // Flat JUCE-painted panel: no bitmap, bevels, screws, or partitions. + skin_.drawPanel(g); + g.setColour(juce::Colour(0xff33424b)); + g.fillRect(0,461,1100,1); + g.setColour(juce::Colour(0xffbacbd0)); + g.setFont(juce::FontOptions(13.8f)); + g.drawText("PRESET",24,485,208,19,juce::Justification::centredLeft); + g.drawText("ROOM",24,564,208,19,juce::Justification::centredLeft); + + // Seven precise native controls in two relaxed 308px lanes. + // One row owns one label, one drag rail, and one right-aligned + // readback. Avoid four 106px rails squeezed under long labels. + constexpr int ids[]={0,1,2,3,4,6,7}; + for(int j=0;j<7;++j){ + const int idx=ids[j],col=j%2,row=j/2; + const int x=252+317*col,y=485+43*row; + const double v=knobs_[static_cast(idx)].getValue(); + const juce::String value=idx==0?juce::String(v,0)+"°": + idx==1?juce::String(v,1)+" m": + idx==6||idx==7?juce::String(v,0)+"°": + juce::String(v,0)+"%"; + g.setColour(juce::Colour(0xffd6efea)); + g.setFont(juce::FontOptions(13.2f)); + g.drawText(value,x+254,y+3,49,22, + juce::Justification::centredRight); + } + const auto gain=knobs_[5].getValue(); + g.setColour(juce::Colour(0xfff0eafa)); + g.setFont(juce::FontOptions(16.f)); + g.drawText((gain>=0?"+":"")+juce::String(gain,1)+" dB", + 886,611,138,23,juce::Justification::centred); + g.setColour(juce::Colour(0xffb4c3c9)); + g.setFont(juce::FontOptions(12.2f)); + g.drawText("AUDIO / "+status_,24,648,838,23, + juce::Justification::centredLeft); + } + void paintOverChildren(juce::Graphics& g) override { + // Parent paint() cannot dim child Components: JUCE draws their + // labels, sliders and popup controls AFTER parent paint(). + // A distinct ~44% muted charcoal pass makes all inactive + // controls visibly recede, without losing label legibility. + // Exclude FX Power so the host-authoritative toggle remains + // crisp, keyboard/mouse accessible and visually actionable. + if(!hostBypassed_.value_or(false) && + !(hostLeaseWasValid_ && !hostBypassed_.has_value()))return; + juce::Graphics::ScopedSaveState saved(g); + const auto panelTop=juce::roundToInt(461.f*compactScale); + const auto panel=juce::Rectangle( + 0,panelTop,getWidth(),getHeight()-panelTop); + g.reduceClipRegion(panel); + g.excludeClipRegion(power_.getBounds()); + g.setColour(juce::Colour(0x7603060a)); // 46% muted neutral charcoal + g.fillRect(panel); + } + void resized() override { + const auto place=[](juce::Component& child,int x,int y,int w,int h){ + child.setBounds(juce::roundToInt(x*compactScale), + juce::roundToInt(y*compactScale), + juce::roundToInt(w*compactScale), + juce::roundToInt(h*compactScale)); + }; + place(preset_,24,507,206,36); + place(room_,24,586,206,36); + constexpr int ids[]={0,1,2,3,4,6,7}; + for(int j=0;j<7;++j){ + const int col=j%2,row=j/2; + const int x=252+317*col,y=485+43*row; + auto& slider=knobs_[static_cast(ids[j])]; + auto& label=labels_[static_cast(ids[j])]; + place(label,x,y,132,24); + place(slider,x+134,y,114,25); + } + // Control order: two slider lanes -> master gain -> host FX Power. + // Right-side power cell is independent of the master rotary hitbox. + place(labels_[5],884,484,139,22); + place(knobs_[5],908,510,98,94); + place(power_,1032,483,44,44); + } +private: + void applySliderEdit(int axis) { + const float v=static_cast( + knobs_[static_cast(axis)].getValue()); + switch(axis) { + case 0: uiScene_.stereoSpreadDegrees=v;break; + case 1: uiScene_.sourceDistanceMeters=std::clamp(v, + imersipP92MinDistance(), + imersipP92MaxDistance(uiScene_.spacePreset));break; + case 2: uiScene_.roomAmount=v*.01f;break; + case 3: uiScene_.ambience=v*.01f;break; + case 4: uiScene_.spatialMix=v*.01f;break; + case 5: uiScene_.outputTrim=std::pow(10.f,v/20.f);break; + case 6: uiScene_.hrtfElevationTrimDegrees=v;break; + case 7: uiScene_.headYawDegrees=v;break; + default: jassertfalse;break; + } + } + void sync(const armix::sonku::Settings& s){ + uiScene_=s; + room_.setSelectedId(s.spacePreset+1,juce::dontSendNotification); + const double vals[]={s.stereoSpreadDegrees,s.sourceDistanceMeters, + 100.*s.roomAmount,100.*s.ambience,100.*s.spatialMix, + 20.*std::log10(s.outputTrim),s.hrtfElevationTrimDegrees, + s.headYawDegrees}; + for(int i=0;i<8;++i)knobs_[static_cast(i)].setValue( + vals[i],juce::dontSendNotification); + int preset=1; + if(!isCustomIntent_)for(const auto& factory:imersipP92Presets){ + const int id=factory.id; + const auto candidate=imersipP92Factory(id); + if(s.spacePreset==candidate.spacePreset && + std::abs(s.stereoSpreadDegrees-candidate.stereoSpreadDegrees)<.01f && + std::abs(s.sourceDistanceMeters-candidate.sourceDistanceMeters)<.01f && + std::abs(s.roomAmount-candidate.roomAmount)<.001f && + std::abs(s.ambience-candidate.ambience)<.001f && + std::abs(s.spatialMix-candidate.spatialMix)<.001f && + std::abs(s.outputTrim-candidate.outputTrim)<.001f && +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + s.sceneVoicing==candidate.sceneVoicing && +#endif + std::abs(s.headYawDegrees)<.001f && + std::abs(s.hrtfElevationTrimDegrees)<.001f) {preset=id;break;} + } + if(preset!=1)visualSceneId_=preset; + // Adjusting a slider marks "Custom" but deliberately keeps the + // chosen venue image until the operator picks another scene. + preset_.setSelectedId(preset,juce::dontSendNotification); + repaint(); + } + void submit(const armix::sonku::Settings& wanted) { + if(!validImerSipP92Scene(wanted)){ + status_="INVALID ROOM / SOURCE GEOMETRY";repaint();return; + } + if(pending_!=0){ + deferred_=wanted;hasDeferred_=true; + status_="LATEST EDIT QUEUED";repaint();return; + } + const auto id=fx_.nextEditorRequestId(); + if(!fx_.queueSettings(wanted,id)){ + deferred_=wanted;hasDeferred_=true; + status_="WAITING FOR AUDIO CALLBACK";repaint();return; + } + pending_=id; + status_="PENDING NATIVE AUDIO ACK"; + repaint(); + } + void refreshHostPower() { + // One effective state = individual slot OR rack gate OR global A/B. + // Never flatten these independent remembered bypass preferences. + const auto state=readHostPower_?readHostPower_():HostBypassState{}; + const bool valid=state.valid; + const bool bypassed=state.effectiveBypassed(); + const bool enabled=valid && static_cast(requestBypass_) && + !state.rackBypassed && !state.globalBypassed; + // An unbound/offline editor stays inert; avoid a full-scene repaint + // 25 times/second when no physical lease exists. + const bool changed=(valid!=hostBypassed_.has_value()) || + (valid && *hostBypassed_!=bypassed); + if(valid) { + hostLeaseWasValid_=true; + hostBypassed_=bypassed; + } else hostBypassed_.reset(); + power_.setEnabled(enabled); + power_.setToggleState(valid && !bypassed,juce::dontSendNotification); + power_.setTooltip(!valid?"FX instance unavailable - reopen from rack": + state.globalBypassed?"GLOBAL FX BYPASSED - enable mixer FX": + state.rackBypassed?"FX RACK BYPASSED - enable rack power": + state.slotBypassed?"FX BYPASSED - click to enable": + "FX ON - click to bypass"); + // Host changes can arrive from another window while this editor is + // open. 25 Hz control-thread polling updates visual status on change. + if(changed)repaint(); + } + void timerCallback() override { + SonKuSpatialProcessor::Completion done{}; + while(fx_.pollCompletion(done)){} + if(pending_!=0 && fx_.lastCompletedRequestId()==pending_){ + const bool ok=fx_.lastCompletionApplied(); + pending_=0; + status_=ok?"APPLIED TO P9 PCM":"REJECTED BY P9 PCM"; + if(!ok || !hasDeferred_)sync(fx_.acceptedSettings()); + } + if(pending_==0 && hasDeferred_){ + const auto next=deferred_; + hasDeferred_=false; + if(validImerSipP92Scene(next)){ + const auto id=fx_.nextEditorRequestId(); + if(fx_.queueSettings(next,id)){ + pending_=id;status_="APPLYING LATEST EDIT"; + }else{ + deferred_=next;hasDeferred_=true; + } + } + } + refreshHostPower(); + repaint(juce::Rectangle(0,juce::roundToInt(646*compactScale), + getWidth(),juce::roundToInt(34*compactScale))); + } + int visualSceneId_=2; // UI-only scene selection; not IMRS / PCM state. + bool isCustomIntent_=false; + armix::sonku::Settings uiScene_{}; // Unquantized intent owned by GUI thread. + ImerSipP92Processor& fx_; + ImerSipP92VisualSkin skin_; + juce::ComboBox preset_{},room_{}; + juce::TextButton power_{}; + std::array knobs_{}; + std::array labels_{}; + std::function requestBypass_; + std::function readHostPower_; + std::optional hostBypassed_{}; // UI cache of actual host readback only + bool hostLeaseWasValid_=false; // stale-lease UI only; never audio authority + + armix::sonku::Settings deferred_{}; + std::uint64_t pending_=0; + bool hasDeferred_=false; + juce::String status_="P9.2 CONCERT ENGINE READY"; +}; +inline juce::AudioProcessorEditor* ImerSipP92Processor::createEditor() { + return new ImerSipP92Editor(*this); +} +} // namespace armix::builtin_fx diff --git a/engine/builtin_fx/ImerSipP92Processor.h b/engine/builtin_fx/ImerSipP92Processor.h new file mode 100644 index 000000000..bb57cdd18 --- /dev/null +++ b/engine/builtin_fx/ImerSipP92Processor.h @@ -0,0 +1,183 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "ImerSipP92Scene.h" +#include "SonKuSpatialProcessor.h" +#include +#include +#include +#include + +// ImerSip identity/state/UI are independent. Audio uses the SAME +// SonKuSpatialProcessor -> SonKuSpatialCore (mode 9) and same audio ACK. +// No P8 ImerSipDsp, second HRTF, stereo widening or enhancer is instantiated. +namespace armix::builtin_fx { +class ImerSipP92Processor final : public SonKuSpatialProcessor { +public: + // Public name may change; persisted .smix FX ID must not. + static constexpr const char* catalogIdentity="armix.builtin.imersip.v1"; + static constexpr const char* productDisplayName="ImmerSIB"; + ImerSipP92Processor() + : SonKuSpatialProcessor(imersipP92Factory(2)) { +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + // Distinct from 8D-SonKu P9.9 opt-in; original session ABI unchanged. + optInImmerSIBVocalRoom(); +#endif + } + const juce::String getName() const override {return productDisplayName;} + bool hasEditor() const override {return true;} + juce::AudioProcessorEditor* createEditor() override; + + // Editor gesture serials survive closing/reopening this processor's UI. + std::uint64_t nextEditorRequestId() noexcept { + if(++issued_==0)++issued_; + return issued_; + } + bool queueSettings(const armix::sonku::Settings& scene, + std::uint64_t requestId) noexcept { + if(!validImerSipP92Scene(scene) || requestId==0)return false; + if(requestId>issued_)issued_=requestId; + return SonKuSpatialProcessor::queueSettings(scene,requestId); + } + bool pollCompletion(SonKuSpatialProcessor::Completion& completed) noexcept { + if(!SonKuSpatialProcessor::pollCompletion(completed))return false; + lastCompletedRequest_=completed.requestId; + lastCompletionApplied_=completed.applied; + return true; + } + std::uint64_t lastCompletedRequestId() const noexcept { + return lastCompletedRequest_; + } + bool lastCompletionApplied() const noexcept { + return lastCompletionApplied_; + } + + void getStateInformation(juce::MemoryBlock& destination) override { + // Persist the new IMRS v6 identity, but embed the AUTHORITATIVE + // native SONK v11 settings verbatim, so no shadow state is invented. + // Session capture must use accepted audio settings, not UI drafts. + SonKuSpatialProcessor::Completion done{}; + while(pollCompletion(done)){} + juce::MemoryBlock native; + SonKuSpatialProcessor::getStateInformation(native); + juce::MemoryOutputStream out(destination,false); + out.writeInt(0x494D5253); // IMRS +#if defined(ARMIX_SONKU_EXPERIMENTAL_P98_SCENE_VOICING) && ARMIX_SONKU_EXPERIMENTAL_P98_SCENE_VOICING + out.writeInt(7); // IMRS v7: SONK v12 + typed scene, 75 bytes +#else + out.writeInt(6); // IMRS v6: SONK v11, 71 bytes +#endif + out.write(native.getData(),native.getSize()); + } + + bool restoreUnpublishedState(const void* data,int bytes) { + if(!data || bytes<8)return false; + juce::MemoryInputStream in(data,static_cast(bytes),false); + if(in.readInt()!=0x494D5253)return false; + const int version=in.readInt(); + if(version==6 +#if defined(ARMIX_SONKU_EXPERIMENTAL_P98_SCENE_VOICING) && ARMIX_SONKU_EXPERIMENTAL_P98_SCENE_VOICING + || version==7 +#endif + ) { + // Accept historical 71-byte IMRS v6/SONK v11 (voicing=0) + // and new 75-byte IMRS v7/SONK v12 atomically. + const int nativeBytes=version==7?67:63; + if(bytes!=nativeBytes+8)return false; + const auto* raw=static_cast(data)+8; + juce::MemoryInputStream check(raw,static_cast(nativeBytes),false); + if(check.readInt()!=0x534F4E4B || + check.readInt()!=(version==7?12:11))return false; + // Preflight the exact SONK v11 wire schema in a local POD. + // Parent restoration may change its accepted scene/core; doing + // that before validating ImerSip would let an invalid v6 + // session silently replace approved world-speaker P9 mode 9. + auto next=imersipP92ReferenceScene(); + next.startAzimuthDegrees=check.readFloat(); + next.revolutionSeconds=check.readFloat(); + next.stereoSpreadDegrees=check.readFloat(); + next.spatialMix=check.readFloat(); + next.outputTrim=check.readFloat(); + const int moving=check.readByte(); + const int clockwise=check.readByte(); + next.moving=moving!=0; + next.clockwise=clockwise!=0; + next.spacePreset=check.readInt(); + next.sourceDistanceMeters=check.readFloat(); + next.roomAmount=check.readFloat(); + next.ambience=check.readFloat(); + next.directElevationDegrees=check.readFloat(); + next.renderMode=check.readInt(); + const int incompatibleLf=check.readByte(); + next.musicCompatibleLowFrequency=incompatibleLf!=0; + next.headYawDegrees=check.readFloat(); + next.hrtfElevationTrimDegrees=check.readFloat(); +#if defined(ARMIX_SONKU_EXPERIMENTAL_P98_SCENE_VOICING) && ARMIX_SONKU_EXPERIMENTAL_P98_SCENE_VOICING + if(version==7)next.sceneVoicing=check.readInt(); +#endif + if(!check.isExhausted() || (moving!=0&&moving!=1) || + (clockwise!=0&&clockwise!=1) || + (incompatibleLf!=0&&incompatibleLf!=1) || + !armix::sonku::valid(next) || next.renderMode!=9 || + next.moving || next.musicCompatibleLowFrequency || + next.startAzimuthDegrees!=0.f)return false; + // Legacy 1.0m / 4-10m sessions migrate to the new listening + // envelope. Keep voicing, room, gain, IMRS bytes and FX ID. + next.sourceDistanceMeters=std::clamp(next.sourceDistanceMeters, + imersipP92MinDistance(),imersipP92MaxDistance(next.spacePreset)); + return validImerSipP92Scene(next) && adoptUnpublishedScene(next); + } + // Original IMRS v1-v5: read the actual previous format, fail closed + // on corrupt bytes and map only parameters with a real P9 counterpart. + if(version<1||version>5 || + bytes!=(version==1?32:version==2?36: + version==3?44:version==4?48:52))return false; + const int venue=in.readInt(); + const float immersion=in.readFloat(); + const float space=in.readFloat(); + const float width=in.readFloat(); + const float bassImpact=in.readFloat(); + const float trim=in.readFloat(); + const float detail=version>=2?in.readFloat():0.f; + const float stereoKeep=version>=3?in.readFloat():1.f; + const float late=version>=3?in.readFloat():.33f; + const float depth=version>=4?in.readFloat():0.f; + const float earAlign=version>=5?in.readFloat():0.f; + const auto unit=[](float x){return std::isfinite(x)&&x>=0.f&&x<=1.f;}; + if(!in.isExhausted() || venue<0 || venue>2 || + !unit(immersion)||!unit(space)||!unit(width)|| + !unit(bassImpact)||!unit(detail)||!unit(stereoKeep)|| + !unit(late)||!unit(depth)||!std::isfinite(trim)|| + trim<.25f||trim>1.5f||!std::isfinite(earAlign)|| + earAlign< -30.f||earAlign>20.f)return false; + auto next=imersipP92ReferenceScene(); + next.spacePreset=venue==0?3:venue==1?2:1; + next.spatialMix=immersion; + next.roomAmount=space; + next.stereoSpreadDegrees=30.f+150.f*width; + next.ambience=late; + next.sourceDistanceMeters=std::clamp(1.6f+5.8f*depth, + imersipP92MinDistance(),imersipP92MaxDistance(next.spacePreset)); + next.outputTrim=trim; + next.hrtfElevationTrimDegrees=earAlign; + // Bass Impact, AIR, Stereo Keep were P8-only enhancer axes. + // Deliberately DO NOT recreate P8 dry SIDE/headphone bass, which + // would destroy the owner-approved external P9 scene. + return validImerSipP92Scene(next) && adoptUnpublishedScene(next); + } + // JUCE's public AudioProcessor restore entrypoint is virtual. Without + // this override it would call the inherited SONK parser, silently + // rejecting an IMRS show even though the native FX registry restores it. + void setStateInformation(const void* data,int bytes) override { + (void)restoreUnpublishedState(data,bytes); + } +protected: + bool admitQueuedScene( + const armix::sonku::Settings& next) const noexcept override { + return validImerSipP92Scene(next); + } +private: + std::uint64_t issued_=0,lastCompletedRequest_=0; + bool lastCompletionApplied_=false; +}; +} // namespace armix::builtin_fx +#include "ImerSipP92Editor.h" diff --git a/engine/builtin_fx/ImerSipP92Scene.h b/engine/builtin_fx/ImerSipP92Scene.h new file mode 100644 index 000000000..15256e277 --- /dev/null +++ b/engine/builtin_fx/ImerSipP92Scene.h @@ -0,0 +1,126 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "sonku/SonKuSpatialCore.h" +#include +#include +#include + +// Thin ImerSip *product* scene, NOT another binaural DSP. Every PCM sample +// is rendered by the same owner-approved SonKu P9.1/P9.2 core (mode 9). +namespace armix::builtin_fx { +inline armix::sonku::Settings imersipP92ReferenceScene() noexcept { + armix::sonku::Settings s{}; + s.renderMode=9; // P9.1/P9.2 ONE native PCM authority + s.musicCompatibleLowFrequency=false; + s.moving=false; s.clockwise=true; + s.startAzimuthDegrees=0.f; // static world-front speakers + s.headYawDegrees=0.f; + s.directElevationDegrees=0.f; + s.hrtfElevationTrimDegrees=0.f; + s.stereoSpreadDegrees=82.f; + s.sourceDistanceMeters=1.6f; + s.spacePreset=3; // Large 28.8 m, P9 listening reference + s.roomAmount=.78f; // P9 direct/wall architecture untouched + s.ambience=.33f; + s.spatialMix=1.f; + s.outputTrim=1.f; // 0 dB, no P8 ImerSip shelf/limiter + return s; +} +inline float imersipP92MinDistance() noexcept { +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + return 1.1f; // bounded owner listening profile; no public P9.2 ABI change +#else + return 1.f; +#endif +} +inline float imersipP92MaxDistance(int room) noexcept { + // Six-wall geometry requires 2*(distance+.5)<=room width. +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + (void)room; + return 2.5f; // owner listening profile, all three valid venue geometries +#else + return room==1?3.05f:room==2?6.65f:7.4f; +#endif +} +inline bool validImerSipP92Scene(const armix::sonku::Settings& s) noexcept { + return armix::sonku::valid(s) && s.renderMode==9 && + !s.moving && !s.musicCompatibleLowFrequency && + s.startAzimuthDegrees==0.f && + s.sourceDistanceMeters>=imersipP92MinDistance() && + s.sourceDistanceMeters<=imersipP92MaxDistance(s.spacePreset); +} +// A single typed preset catalog drives the native UI, state recognition and +// actual SonKu P9 PCM. IDs are UI-only (IMRS persists real accepted settings), +// so removing Neutral from the picker does NOT invalidate old saved sessions. +// Keep Live Concert unchanged: the owner has auditioned and liked it. +// Don't mistake a wide stage/distant source for a guarantee of envelopment. +struct ImerSipP92Preset { + int id; + const char* label; + int spacePreset; + float stageDegrees, distanceMeters; + float earlyAmount, lateAmount, outputDb; + int voicing=0; // P9.8 typed profile; 0 preserves P9.7 Venue PCM +}; +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH +// Archival P9.7 10m Venue remains a golden *private* PCM fixture, not a +// public preset. Current owner listening envelope is 1.1..2.5m. +inline armix::sonku::Settings imersipP97VenueGoldenScene() noexcept { + auto s=imersipP92ReferenceScene(); + s.stereoSpreadDegrees=106.f;s.sourceDistanceMeters=10.f; + s.roomAmount=1.f;s.ambience=1.f;s.outputTrim=1.8f; + return s; +} +// Nearfield factory retains the same P9 world renderer, adds P9.8 +// vocal masking relief, not stem extraction or extra Haas delays. +inline constexpr std::array imersipP92Presets{{ + {2,"Live Concert", 3,112.f,2.0f,1.36f,.84f,5.10545f,4}, + {3,"Royal Concert Hall", 3,106.f,2.2f,1.55f,.78f,5.57507f,4}, + {4,"Arena Thunder", 3,124.f,2.5f,1.45f,.86f,5.45f,5}, + {5,"Front Row Power", 3,104.f,1.3f,1.26f,.70f,5.60f,4}, + {6,"Symphonic Palace", 3,118.f,1.9f,1.60f,.80f,5.25f,4}, + {7,"Velvet Cinema", 3,108.f,1.8f,1.42f,.82f,4.60898f,3}, + // Original owner screenshot: 147deg/1.0m/ER180/Late60/+2.5dB. + // Retain it as historical provenance, not as the immutable P9.7 golden. + // XL's stage-front revision balances the DIRECT front vocal with a + // longer, stronger diffuse hall envelope (late94 vs old60), bounded + // early energy and a matched-gain A/B against accepted Live Concert. + // No algorithmic changes to Venue, room IR, HRIR or scene voicing. + {8,"Concert Front Row XL",3,134.f,1.5f,1.70f,.94f,4.40f,4} +}}; +#else +// Historical P9.2 candidate stays reproducible when private P9.8 OFF. +inline constexpr std::array imersipP92Presets{{ + {2,"Live Concert", 3,150.f,2.2f,1.f,.91f,4.8f}, + {3,"Royal Concert Hall", 3,155.f,1.8f,1.f,.98f,5.4f}, + {4,"Arena Thunder", 3,164.f,1.7f,1.f,1.00f,5.7f}, + {5,"Front Row Power", 3,150.f,1.6f,1.f,.97f,5.2f}, + {6,"Symphonic Palace", 3,146.f,1.9f,1.f,.99f,5.4f}, + {7,"Velvet Cinema", 2,155.f,1.6f,1.f,1.00f,5.7f} +}}; +#endif +inline const ImerSipP92Preset* imersipP92PresetById(int id) noexcept { + for(const auto& p:imersipP92Presets)if(id==p.id)return &p; + return nullptr; +} +inline float imersipP92DbToLinear(float db) noexcept { + return std::pow(10.f,db/20.f); // editor/control thread, never PCM callback +} +inline armix::sonku::Settings imersipP92Factory(int id) noexcept { + auto s=imersipP92ReferenceScene(); // internal neutral test, not UI entry + if(const auto* p=imersipP92PresetById(id)) { + s.spacePreset=p->spacePreset; + s.stereoSpreadDegrees=p->stageDegrees; + s.sourceDistanceMeters=p->distanceMeters; + s.roomAmount=p->earlyAmount; + s.ambience=p->lateAmount; + s.outputTrim=imersipP92DbToLinear(p->outputDb); +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + s.sceneVoicing=p->voicing; + // Do not let dB conversion alter the exact approved Venue trim hash. + if(id==2)s.outputTrim=1.8f; // preserve level, move to listener nearfield +#endif + } + return s; +} +} // namespace armix::builtin_fx diff --git a/engine/builtin_fx/ImerSipP92VisualSkin.h b/engine/builtin_fx/ImerSipP92VisualSkin.h new file mode 100644 index 000000000..445c346b7 --- /dev/null +++ b/engine/builtin_fx/ImerSipP92VisualSkin.h @@ -0,0 +1,240 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +// Only six approved concert venue photographs; all controls rendered by JUCE. +// The rejected speaker/button/knob PNG kit must never return. +#include +#include +#include +#include + +namespace armix::builtin_fx { + +class ImerSipP92VisualSkin final : public juce::LookAndFeel_V4 { +public: + // Fixed pixel master matches the 1100x461 logical stage exactly (2x). + static constexpr int photoWidth=2200; + static constexpr int photoHeight=922; + ImerSipP92VisualSkin() + : sceneLive_(load(BinaryData::scene_live_concert_png,BinaryData::scene_live_concert_pngSize)), + sceneRoyal_(load(BinaryData::scene_royal_concert_hall_png,BinaryData::scene_royal_concert_hall_pngSize)), + sceneArena_(load(BinaryData::scene_arena_thunder_png,BinaryData::scene_arena_thunder_pngSize)), + sceneFront_(load(BinaryData::scene_front_row_power_png,BinaryData::scene_front_row_power_pngSize)), + sceneSymphony_(load(BinaryData::scene_symphonic_palace_png,BinaryData::scene_symphonic_palace_pngSize)), + sceneCinema_(load(BinaryData::scene_velvet_cinema_png,BinaryData::scene_velvet_cinema_pngSize)) { + setColour(juce::ComboBox::textColourId,juce::Colour(0xffdce8e9)); + setColour(juce::ComboBox::outlineColourId,juce::Colours::transparentBlack); + setColour(juce::ComboBox::arrowColourId,juce::Colour(0xff55dad0)); + setColour(juce::PopupMenu::backgroundColourId,juce::Colour(0xff17242a)); + setColour(juce::PopupMenu::textColourId,juce::Colour(0xffe0edee)); + setColour(juce::PopupMenu::highlightedBackgroundColourId,juce::Colour(0xff225d65)); + setColour(juce::TextButton::textColourOffId,juce::Colour(0xffeef3f3)); + setColour(juce::TextButton::textColourOnId,juce::Colour(0xffefffff)); + } + bool ready() const noexcept { + return allValid({&sceneLive_,&sceneRoyal_,&sceneArena_, + &sceneFront_,&sceneSymphony_,&sceneCinema_}); + } + bool hasScenes() const noexcept { return ready(); } + void drawScene(juce::Graphics& g,int presetId) const { + const juce::Image* art=&sceneLive_; + switch(presetId){ + case 3: art=&sceneRoyal_; break; + case 4: art=&sceneArena_; break; + case 5: art=&sceneFront_; break; + case 6: art=&sceneSymphony_; break; + case 7: art=&sceneCinema_; break; + case 8: art=&sceneLive_; break; // Front Row XL reuses approved Live Concert venue + default: break; // Custom keeps its last selected venue. + } + // Fail closed on an absent/mismatched scene rather than allowing + // centered 2:1 art to create black matte on either side. + if(art->isNull() || art->getWidth()!=photoWidth || + art->getHeight()!=photoHeight) { + jassertfalse; + return; + } + // The approved 2x PNG has the exact logical viewport ratio. + // Centred placement now fills edge-to-edge, without distortion. + juce::Graphics::ScopedSaveState state(g); + g.setImageResamplingQuality(juce::Graphics::highResamplingQuality); + g.reduceClipRegion(0,0,1100,461); + g.setColour(juce::Colour(0xff0e161c)); + g.fillRect(0,0,1100,461); + g.drawImageWithin(*art,0,0,1100,461, + juce::RectanglePlacement::centred); + } + void drawBypassedVenueOverlay(juce::Graphics& g) const { + // A strong but restrained mute treatment: the six approved concert + // photos remain visible, but stage lights and colours recede into + // charcoal. No new PNGs, image processing, bloom or animation. + g.setColour(juce::Colour(0xb803060a)); // ~72% near-black charcoal veil + g.fillRect(0,0,1100,461); + + // One dominant, unmistakable state label. This deliberately has + // more hierarchy than the original tiny 40px regular typography. + // Keep the entire word inside the scene safe area on every DPI. + const auto label=juce::Rectangle(110,153,880,150); + auto font=juce::Font(juce::FontOptions(76.f,juce::Font::bold)); + font.setExtraKerningFactor(0.055f); + g.setFont(font); + g.setColour(juce::Colour(0xb8000307)); + g.drawText("BYPASSED",label.translated(0,4), + juce::Justification::centred,false); + g.setColour(juce::Colour(0xeeffa53c)); // vivid translucent amber + g.drawText("BYPASSED",label,juce::Justification::centred,false); + } + void drawUnavailableVenueOverlay(juce::Graphics& g) const { + // A retired processor lease is neither FX ON nor an accepted + // BYPASSED state. Its last concert scene remains a recognisable + // photograph, but the host readback is explicitly unavailable. + g.setColour(juce::Colour(0xc003060a)); + g.fillRect(0,0,1100,461); + auto headline=juce::Font(juce::FontOptions(49.f)); + headline.setExtraKerningFactor(0.035f); + g.setFont(headline); + g.setColour(juce::Colour(0xffd0dce1)); + g.drawText("FX UNAVAILABLE",110,166,880,100, + juce::Justification::centred,false); + g.setFont(juce::FontOptions(20.f)); + g.setColour(juce::Colour(0xff87b8bc)); + g.drawText("REOPEN FROM FX RACK",110,267,880,45, + juce::Justification::centred,false); + } + void drawPanel(juce::Graphics& g) const { + // Premium restraint: one exact flat matte charcoal surface, + // no image texture, gloss, neon edges, bolts, segment borders, + // or geometric noise. DPI-independent and low-cost to render. + g.setColour(juce::Colour(0xff151a20)); + g.fillRect(0,461,1100,219); + } + void drawLinearSlider(juce::Graphics& g,int x,int y,int width,int height, + float sliderPos,float minSliderPos,float maxSliderPos, + const juce::Slider::SliderStyle style, + juce::Slider& slider) override { + if(style!=juce::Slider::LinearHorizontal){ + juce::LookAndFeel_V4::drawLinearSlider(g,x,y,width,height, + sliderPos,minSliderPos,maxSliderPos,style,slider); + return; + } + const float left=float(x+6),right=float(x+width-6); + const float cy=float(y)+float(height)*.5f; + const float thumb=std::clamp(sliderPos,left,right); + // Precise native vector rails avoid scaled PNG artefacts on HiDPI. + g.setColour(juce::Colour(0xff394a54)); + g.fillRoundedRectangle(left,cy-2.f,right-left,4.f,2.f); + if(thumb>left){ + g.setColour(juce::Colour(0xff4ac5bd)); + g.fillRoundedRectangle(left,cy-2.f,thumb-left,4.f,2.f); + } + g.setColour(juce::Colour(0xff0b2229)); + g.fillEllipse(thumb-7.5f,cy-7.5f,15.f,15.f); + g.setColour(juce::Colour(0xff86dbd4)); + g.drawEllipse(thumb-7.f,cy-7.f,14.f,14.f,1.5f); + g.setColour(juce::Colour(0xff9ddfd8)); + g.fillEllipse(thumb-2.f,cy-2.f,4.f,4.f); + } + void drawRotarySlider(juce::Graphics& g,int x,int y,int width,int height, + float proportion,float start,float end, + juce::Slider&) override { + // Native JUCE satin-metal control. No rejected knob PNG. + const float size=std::max(8.f,std::min(float(width),float(height))-5.f); + const float cx=float(x)+float(width)*.5f; + const float cy=float(y)+float(height)*.5f; + const float radius=size*.405f; + g.setColour(juce::Colour(0x5500050b)); + g.fillEllipse(cx-radius-2.f,cy-radius+2.f,2.f*radius+4.f,2.f*radius+4.f); + g.setColour(juce::Colour(0xff536775)); + g.fillEllipse(cx-radius,cy-radius,2.f*radius,2.f*radius); + g.setColour(juce::Colour(0xff0e181f)); + g.fillEllipse(cx-radius+2.f,cy-radius+2.f,2.f*radius-4.f,2.f*radius-4.f); + const float inner=radius*.76f; + g.setGradientFill(juce::ColourGradient( + juce::Colour(0xff344550),cx,cy-inner, + juce::Colour(0xff152129),cx,cy+inner,false)); + g.fillEllipse(cx-inner,cy-inner,2.f*inner,2.f*inner); + const float angle=start+std::clamp(proportion,0.f,1.f)*(end-start); + juce::Path arc; + arc.addCentredArc(cx,cy,radius+7.f,radius+7.f,0.f,start,angle,true); + g.setColour(juce::Colour(0xffbc8de4)); + g.strokePath(arc,juce::PathStrokeType(2.f)); + const float pointer=radius*.59f; + g.setColour(juce::Colour(0xfff0f7f8)); + g.drawLine(cx+std::sin(angle)*pointer*.49f, + cy-std::cos(angle)*pointer*.49f, + cx+std::sin(angle)*pointer, + cy-std::cos(angle)*pointer,2.4f); + } + void drawComboBox(juce::Graphics& g,int width,int height,bool, + int,int,int,int,juce::ComboBox&) override { + const auto bounds=juce::Rectangle(.5f,.5f, + float(width)-1.f,float(height)-1.f); + g.setColour(juce::Colour(0xff1c2c33)); + g.fillRoundedRectangle(bounds,5.f); + g.setColour(juce::Colour(0xff405c64)); + g.drawRoundedRectangle(bounds,5.f,1.f); + juce::Path arrow; + const float cx=float(width)-16.f,cy=float(height)*.52f; + arrow.startNewSubPath(cx-4.f,cy-2.f); + arrow.lineTo(cx,cy+2.f); + arrow.lineTo(cx+4.f,cy-2.f); + g.setColour(juce::Colour(0xff73c5c1)); + g.strokePath(arrow,juce::PathStrokeType(1.4f)); + } + void drawButtonBackground(juce::Graphics& g,juce::Button& button, + const juce::Colour&,bool hover,bool down) override { + if(button.getComponentID()=="imersip.power") { + // Same simple IEC power-ring language as built-in Compressor/EQ. + // Body and glyph are native JUCE; no image, font glyph, LED, + // faux switch, label, or GUI-side invented bypass state. + const auto bounds=juce::Rectangle(.5f,.5f, + float(button.getWidth()-1),float(button.getHeight()-1)); + const bool enabled=button.isEnabled(); + const bool on=enabled && button.getToggleState(); + const auto colour=!enabled?juce::Colour(0xff6b7981): + on?juce::Colour(0xff73d9d0):juce::Colour(0xffa6b6bd); + g.setColour(down?juce::Colour(0xff263941): + hover&&enabled?juce::Colour(0xff21323a): + juce::Colour(0xff1c262d)); + g.fillRoundedRectangle(bounds,6.f); + g.setColour(juce::Colour(hover&&enabled?0xff4c6870:0xff34464e)); + g.drawRoundedRectangle(bounds,6.f,1.f); + const float cx=float(button.getWidth())*.5f; + const float cy=float(button.getHeight())*.52f; + const float radius=std::min(float(button.getWidth()), + float(button.getHeight()))*.244f; + juce::Path powerRing; + powerRing.addCentredArc(cx,cy,radius,radius,0.f, + .63f,juce::MathConstants::twoPi-.63f,true); + g.setColour(colour); + g.strokePath(powerRing,juce::PathStrokeType( + 2.5f,juce::PathStrokeType::curved, + juce::PathStrokeType::rounded)); + g.drawLine(cx,cy-radius-3.f,cx,cy-1.f,2.5f); + return; + } + const auto r=juce::Rectangle(.5f,.5f, + float(button.getWidth()-1),float(button.getHeight()-1)); + const auto background=!button.isEnabled()?juce::Colour(0xff18252b): + down?juce::Colour(0xff28505a): + hover?juce::Colour(0xff29404b):juce::Colour(0xff203039); + g.setColour(background); + g.fillRoundedRectangle(r,5.f); + g.setColour(button.isEnabled() + ?juce::Colour(hover?0xff6fa6aa:0xff455963) + :juce::Colour(0xff34454b)); + g.drawRoundedRectangle(r,5.f,1.f); + } +private: + static bool allValid(std::initializer_list images) noexcept { + for(const auto* image:images) + if(image->isNull() || image->getWidth()!=photoWidth || + image->getHeight()!=photoHeight) return false; + return true; + } + static juce::Image load(const void* bytes,int size) { + return juce::ImageCache::getFromMemory(bytes,size); + } + const juce::Image sceneLive_,sceneRoyal_,sceneArena_, + sceneFront_,sceneSymphony_,sceneCinema_; +}; +} // namespace armix::builtin_fx diff --git a/engine/builtin_fx/SonKuSpatialProcessor.h b/engine/builtin_fx/SonKuSpatialProcessor.h index e1b3b20e3..6f0bfc3cf 100644 --- a/engine/builtin_fx/SonKuSpatialProcessor.h +++ b/engine/builtin_fx/SonKuSpatialProcessor.h @@ -1,6 +1,7 @@ // SPDX-License-Identifier: AGPL-3.0-only #pragma once #include "sonku/SonKuSpatialCore.h" +#include "sonku/SonKuProductAdmission.h" #if defined(ARMIX_SONKU_EXPERIMENTAL_P99_VOCAL_DEPTH) && ARMIX_SONKU_EXPERIMENTAL_P99_VOCAL_DEPTH #include "sonku/SonKuP99DefaultOrbitStage.h" #endif @@ -446,7 +447,7 @@ class SonKuSpatialProcessor : public juce::AudioProcessor, // elevation, and is rejected by ordinary public v2 builds. // Never accept a partial or malformed native FX state. if(!in.isExhausted())return false; - if(!armix::sonku::valid(next))return false; + if(!armix::sonku::valid(next)||!admitQueuedScene(next))return false; if(ready_&&!core_.setSettings(next))return false; accepted_=next; return true; @@ -455,10 +456,18 @@ class SonKuSpatialProcessor : public juce::AudioProcessor, (void)restoreUnpublishedState(data,size); } protected: +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + // Distinct from approved 8D-SonKu P9.9; only ImmerSIB constructor opts in. + void optInImmerSIBVocalRoom() noexcept { + core_.optInImmerSIBVocalRoom(); + } +#endif // Product-specific admission is a CONTROL-thread operation; the audio // callback still owns the same core, edit queue and applied ACK. virtual bool admitQueuedScene( - const armix::sonku::Settings&) const noexcept {return true;} + const armix::sonku::Settings& next) const noexcept { + return armix::sonku::valid8DSonKuInsertSettings(next); + } // Branded insert constructor never borrows SonKu's newly approved // ORBIT STAGE default or P9.9 sonic character. A derived product diff --git a/engine/builtin_fx/sonku/SonKuEarlyReflections.h b/engine/builtin_fx/sonku/SonKuEarlyReflections.h index 46209c6b8..5a6a9b48c 100644 --- a/engine/builtin_fx/sonku/SonKuEarlyReflections.h +++ b/engine/builtin_fx/sonku/SonKuEarlyReflections.h @@ -161,7 +161,7 @@ class SonKuEarlyReflections final { !std::isfinite(g.distanceMeters))return false; if(g.widthMeters<5.f||g.depthMeters<5.f|| g.widthMeters>40.f||g.depthMeters>40.f|| - g.distanceMeters<1.6f||g.distanceMeters>10.f|| + g.distanceMeters<1.f||g.distanceMeters>10.f|| 2.f*(g.distanceMeters+.5f)>std::min(g.widthMeters,g.depthMeters)) return false; const float longest=std::max(g.widthMeters,g.depthMeters)+g.distanceMeters; diff --git a/engine/builtin_fx/sonku/SonKuImmerSIBVocalRoom.h b/engine/builtin_fx/sonku/SonKuImmerSIBVocalRoom.h new file mode 100644 index 000000000..0aee9e115 --- /dev/null +++ b/engine/builtin_fx/sonku/SonKuImmerSIBVocalRoom.h @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "SonKuP99MusicalVocalDepth.h" +#include +#include + +// ImmerSIB-only conservative adapter over the SAME approved P9.9 math. +// No second PCM/HRTF graph, no spectral duplicate, no stem inference. +// P9.8 warm ID4/5 map to donor's Signature P9.9 center/room logic, +// but blend a bounded fraction so existing P9.8 body is not doubled. +// A hard disengage (ROOM OFF/MIX0) returns original floats exactly. +namespace armix::sonku::p99 { +class ImmerSIBVocalRoom final { +public: + using Stereo=MusicalVocalDepth::Stereo; + bool prepare(double rate) noexcept { + if(!donor_.prepare(rate))return false; + // ~35ms smooth transition between warm profiles, not per-phoneme AGC. + strengthSlew_=static_cast(1.-std::exp(-1./(rate*.035))); + reset(); + return true; + } + void reset() noexcept {donor_.reset();strength_=0.f;} + Stereo source(float left,float right,int scene,bool enabled) noexcept { + const float goal=enabled?(scene==4?.42f:(scene==5?.34f:0.f)):0.f; + strength_+=strengthSlew_*(goal-strength_); + if(!enabled || goal==0.f) { + (void)donor_.source(0.f,0.f,0,false); + return {left,right}; + } + // Use donor Signature's accepted center attention, 210-880Hz + // warmth and 330Hz room coupling, but at ImmerSIB-safe weight. + const auto shaped=donor_.source(left,right,1,true); + return {left+strength_*(shaped.left-left), + right+strength_*(shaped.right-right)}; + } + Stereo roomEarlyFeed(float left,float right) const noexcept { + const auto r=donor_.roomEarlyFeed(left,right); + return {left+strength_*(r.left-left),right+strength_*(r.right-right)}; + } + Stereo roomLateFeed(float left,float right) const noexcept { + const auto r=donor_.roomLateFeed(left,right); + return {left+strength_*(r.left-left),right+strength_*(r.right-right)}; + } + Stereo early(float left,float right) noexcept { + const auto r=donor_.early(left,right); + return {left+strength_*(r.left-left),right+strength_*(r.right-right)}; + } + Stereo late(float left,float right) noexcept { + const auto r=donor_.late(left,right); + return {left+strength_*(r.left-left),right+strength_*(r.right-right)}; + } +private: + MusicalVocalDepth donor_{}; // exact main/P9.9 source, no forked EQ + float strengthSlew_=0.f,strength_=0.f; +}; +} // namespace armix::sonku::p99 diff --git a/engine/builtin_fx/sonku/SonKuP95MusicalPresence.h b/engine/builtin_fx/sonku/SonKuP95MusicalPresence.h index ece40572b..f458d520c 100644 --- a/engine/builtin_fx/sonku/SonKuP95MusicalPresence.h +++ b/engine/builtin_fx/sonku/SonKuP95MusicalPresence.h @@ -19,7 +19,11 @@ class MusicalPresence final { reset();return true; } void reset() noexcept {inPower_=outPower_=0.f;target_=makeup_=1.f;counter_=0;} - float process(float inL,float inR,float wetL,float wetR) noexcept { + // Optional bounded ceiling lets ImmerSIB reject high automatic makeup on + // deliberately wet, already-positive-trim scenes. 1.65 is the exact legacy + // path; the existing 450ms slew also smooths scene transitions. + float process(float inL,float inR,float wetL,float wetR, + float maxMakeup=1.65f) noexcept { const float a=.5f*(inL*inL+inR*inR); const float b=.5f*(wetL*wetL+wetR*wetR); inPower_+=detector_*(a-inPower_); @@ -31,7 +35,7 @@ class MusicalPresence final { const float ratio=std::sqrt(inPower_/outPower_); // 1.12× = +0.98dB *electrical* minimum when possible. // Never auto-reduce the deliberate user outputTrim boost. - target_=std::clamp(1.12f*ratio,1.f,1.65f); + target_=std::clamp(1.12f*ratio,1.f,maxMakeup); }else target_=1.f; } makeup_+=slew_*(target_-makeup_); diff --git a/engine/builtin_fx/sonku/SonKuP98SceneVoicing.h b/engine/builtin_fx/sonku/SonKuP98SceneVoicing.h index 78d8ff28a..5ec8d135d 100644 --- a/engine/builtin_fx/sonku/SonKuP98SceneVoicing.h +++ b/engine/builtin_fx/sonku/SonKuP98SceneVoicing.h @@ -14,7 +14,10 @@ class SceneVoicing final { public: struct Stereo {float left=0.f,right=0.f;}; // These IDs are stable native-serialized values, NOT native ROOM sizes. - enum : int { Neutral=0, Signature=1, LiveStudio=2, Cinema=3 }; + // 4/5 are opt-in ImmerSIB-only profile IDs. Existing SONK v12 IDs + // 0..3 retain byte-for-byte matching coefficients and meaning. + enum : int { Neutral=0, Signature=1, LiveStudio=2, Cinema=3, + ImmerSIBDetail=4, ImmerSIBImpact=5 }; bool prepare(double sampleRate) noexcept { if (!std::isfinite(sampleRate) || (std::abs(sampleRate-44100.)>.1 && std::abs(sampleRate-48000.)>.1)) @@ -22,6 +25,10 @@ class SceneVoicing final { constexpr double pi=3.1415926535897932384626433832795; punchCoeff_=bandpass(sampleRate,86.,.85); voiceCoeff_=bandpass(sampleRate,2050.,.92); + // Product-only voicing 4/5: broad mid-vocal chest/body anchor, + // and upper-mid masking relief. All coefficients prepared OFF RT. + bodyCoeff_=bandpass(sampleRate,285.,.72); + edgeCoeff_=bandpass(sampleRate,3450.,.78); bassAlpha_=static_cast(1.-std::exp(-2.*pi*130./sampleRate)); airAlpha_=static_cast(1.-std::exp(-2.*pi*5200./sampleRate)); slew_=static_cast(1.-std::exp(-1./(sampleRate*.055))); @@ -30,10 +37,12 @@ class SceneVoicing final { } void reset() noexcept { gains_={};center1_={};center2_={};punch_={};voice_={}; - bass_={};air_={};earlyAir_={}; + bass_={};air_={};earlyAir_={};sidePresence1_={}; + sidePresence2_={};sideAirLow_=0.f; + bodyCenter_={};sideEdge_={};earEdge_={}; } static constexpr bool valid(int scene) noexcept { - return scene>=Neutral && scene<=Cinema; + return scene>=Neutral && scene<=ImmerSIBImpact; } // Only explicit preset changes set an ID. 55ms interpolates changes in // gains, with no per-sample coefficient recompute, memory allocation or @@ -46,9 +55,29 @@ class SceneVoicing final { } const float center=.5f*(left+right); const float band=center2_.run(voiceCoeff_,center1_.run(voiceCoeff_,center)); - if(gains_[0]==0.f)return {left,right}; - const float delta=gains_[0]*band; - return {left+delta,right+delta}; + // ImmerSIB selective M/S masking relief BEFORE measured HRIR: + // suppress only competing SIDE presence (not stems or vocals), + // and retain/enlarge lateral high-air image >5.2kHz. The two + // original KEMAR speaker paths remain the sole binaural renderer. + // Legacy voicing 0..3 has zero extra gains: same PCM arithmetic. + const float side=.5f*(left-right); + const float sideBand=sidePresence2_.run(voiceCoeff_, + sidePresence1_.run(voiceCoeff_,side)); + sideAirLow_+=airAlpha_*(side-sideAirLow_); + // Center-dominant material (often lead vocal, NOT a detected + // vocal stem) receives broad 285Hz body before virtual speakers. + // Instruments in the stereo difference are softly notched around + // 3.45kHz, where guitars/cymbals can mask a center vocal. + const float body=bodyCenter_.run(bodyCoeff_,center); + const float edge=sideEdge_.run(edgeCoeff_,side); + if(gains_[0]==0.f&&gains_[6]==0.f&&gains_[7]==0.f&& + gains_[8]==0.f&&gains_[9]==0.f) + return {left,right}; // profiles 0..3: source stays identical + const float centerBoost=gains_[0]*band+gains_[8]*body; + const float lateralAir=gains_[7]*(side-sideAirLow_); + const float maskedSide=gains_[6]*sideBand+gains_[9]*edge; + return {left+centerBoost-maskedSide+lateralAir, + right+centerBoost+maskedSide-lateralAir}; } Stereo early(float left,float right) noexcept { const std::array x{left,right}; @@ -58,6 +87,16 @@ class SceneVoicing final { out[c]=gains_[4]==0.f?x[c]: x[c]+gains_[4]*(x[c]-earlyAir_[c]); } + // Slightly enrich only the ALREADY directional KEMAR early-image + // interaural high-air field (>5.2kHz). The original center (often + // vocal) remains unchanged. No separate HRTF, delay or stem guess. + if(gains_[11]!=0.f) { + const float lateralAir=.5f*((x[0]-earlyAir_[0])- + (x[1]-earlyAir_[1])); + const float spread=gains_[11]*lateralAir; + out[0]+=spread; + out[1]-=spread; + } return {out[0],out[1]}; } Stereo finish(float left,float right) noexcept { @@ -69,27 +108,41 @@ class SceneVoicing final { voice_[c][0].run(voiceCoeff_,x[c])); bass_[c]+=bassAlpha_*(x[c]-bass_[c]); air_[c]+=airAlpha_*(x[c]-air_[c]); + const float harsh=earEdge_[c].run(edgeCoeff_,x[c]); if(gains_[1]==0.f&&gains_[2]==0.f&&gains_[3]==0.f&& - gains_[5]==0.f){ + gains_[5]==0.f&&gains_[10]==0.f){ out[c]=x[c]; }else{ + // Avoid the old cumulative 2-5kHz presence/air lifts. + // A small broad EAR cut after the original measured HRIR + // helps reduce fatigue, keeping no extra crossfeed/delay. out[c]=x[c]+gains_[1]*bass_[c]+gains_[2]*kick+ - gains_[3]*vocal+gains_[5]*(x[c]-air_[c]); + gains_[3]*vocal+gains_[5]*(x[c]-air_[c])- + gains_[10]*harsh; } } return {out[0],out[1]}; } private: // channels: center-source, bass body, bass kick, vocal presence, - // real first-image air, already-binaural direct/final air. + // first-image air, final-ear air, SIDE presence masking relief, + // SIDE high-air field, MID chest body, SIDE harsh relief, EAR + // de-harsh and lateral EARLY-reflection air. Prepared filters only; still no FFT, lookahead or stems. // Signature is designed for high clarity AND physical music body. // Studio adjustment deliberately gentler than Cinema. Venue profile // is ALL ZEROS: its approved P9.7 acoustic graph is immutable. - static constexpr std::array,4> curves_{{ - {{0.f,0.f,0.f,0.f,0.f,0.f}}, // Venue / Custom: EXACT - {{.22f,.15f,.17f,.15f,.16f,.070f}}, // Signature flagship - {{.035f,.045f,.055f,.045f,.04f,.020f}}, // Live Studio subtle - {{.075f,.15f,.15f,.060f,.065f,.035f}} // Cinema LF weight + static constexpr std::array,6> curves_{{ + // Columns: upper-mid source; LF; kick; ear-presence; early air; + // ear air; SIDE 2.05k; SIDE HF; center 285Hz body; + // SIDE 3.45k masking; EAR 3.45k fatigue; EARLY lateral air. + {{0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f}}, // Venue EXACT + {{.22f,.15f,.17f,.15f,.16f,.070f,0.f,0.f,0.f,0.f,0.f,0.f}}, // Signature + {{.035f,.045f,.055f,.045f,.04f,.020f,0.f,0.f,0.f,0.f,0.f,0.f}}, // Live Studio + {{.075f,.15f,.15f,.060f,.065f,.035f,0.f,0.f,0.f,0.f,0.f,0.f}}, // Cinema + // ImmerSIB-only: warmer front-center body and controlled upper + // mids, not another 2k/5k treble boost. LF concert impact kept. + {{.09f,.11f,.11f,.035f,.025f,.000f,.19f,.015f,.36f,.23f,.13f,.18f}}, // Detail Warm + {{.08f,.22f,.20f,.030f,.025f,.000f,.16f,.015f,.29f,.20f,.12f,.14f}} // Impact Warm }}; struct Coeff {float b0=0,b1=0,b2=0,a1=0,a2=0;}; struct Filter { @@ -110,12 +163,15 @@ class SceneVoicing final { static_cast(-2.*std::cos(w)*inv), static_cast((1.-a)*inv)}; } - Coeff punchCoeff_{},voiceCoeff_{}; + Coeff punchCoeff_{},voiceCoeff_{},bodyCoeff_{},edgeCoeff_{}; Filter center1_{},center2_{}; std::array punch_{}; std::array,2> voice_{}; std::array bass_{},air_{},earlyAir_{}; - std::array gains_{}; + Filter sidePresence1_{},sidePresence2_{},bodyCenter_{},sideEdge_{}; + std::array earEdge_{}; + float sideAirLow_=0.f; + std::array gains_{}; float bassAlpha_=0.f,airAlpha_=0.f,slew_=0.f; }; } // namespace armix::sonku::p98 diff --git a/engine/builtin_fx/sonku/SonKuProductAdmission.h b/engine/builtin_fx/sonku/SonKuProductAdmission.h new file mode 100644 index 000000000..8401e7598 --- /dev/null +++ b/engine/builtin_fx/sonku/SonKuProductAdmission.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include "SonKuSpatialCore.h" + +// The measured binaural DSP core accepts settings needed by both products. +// This is the control-plane contract for the original 8D-SonKu product, +// NOT another DSP, scene serializer or callback-time check. The original +// SonKu P9.9 room/distance ranges and scene IDs 0..3 remain unchanged. +// ImmerSIB has its separate, explicitly opted-in product admission rule. +namespace armix::sonku { +inline bool valid8DSonKuInsertSettings(const Settings& next) noexcept { + if(!valid(next) || next.sourceDistanceMeters<1.6f || + next.roomAmount>1.f)return false; +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + if(next.sceneVoicing>p98::SceneVoicing::Cinema)return false; +#endif + return true; +} +} // namespace armix::sonku diff --git a/engine/builtin_fx/sonku/SonKuSourcePlacement3D.h b/engine/builtin_fx/sonku/SonKuSourcePlacement3D.h index 74f87f4ba..9afb959be 100644 --- a/engine/builtin_fx/sonku/SonKuSourcePlacement3D.h +++ b/engine/builtin_fx/sonku/SonKuSourcePlacement3D.h @@ -16,7 +16,7 @@ inline bool project(float radialMeters,float elevationDegrees, Placement& result) noexcept { if(!std::isfinite(radialMeters)||!std::isfinite(elevationDegrees)|| !std::isfinite(listenerHeight)||!std::isfinite(roomHeight)|| - radialMeters<1.6f||radialMeters>10.f|| + radialMeters<1.f||radialMeters>10.f|| elevationDegrees< -40.f||elevationDegrees>60.f|| roomHeight<2.4f||roomHeight>12.f|| listenerHeight<.5f||listenerHeight>roomHeight-.5f)return false; diff --git a/engine/builtin_fx/sonku/SonKuSpatialCore.h b/engine/builtin_fx/sonku/SonKuSpatialCore.h index fcb3524e0..f9fdcdec9 100644 --- a/engine/builtin_fx/sonku/SonKuSpatialCore.h +++ b/engine/builtin_fx/sonku/SonKuSpatialCore.h @@ -33,6 +33,9 @@ #endif #if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH #include "SonKuP98SceneVoicing.h" +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH +#include "SonKuImmerSIBVocalRoom.h" +#endif #endif #if defined(SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH) && SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH #if !defined(SONKU_P98_SCENE_VOICING_RESEARCH) || !SONKU_P98_SCENE_VOICING_RESEARCH @@ -115,9 +118,14 @@ inline bool valid(const Settings& s) noexcept { std::isfinite(s.spatialMix) && s.spatialMix>=0.f && s.spatialMix<=1.f && std::isfinite(s.outputTrim) && s.outputTrim>=0.f && s.outputTrim<=4.f && s.spacePreset>=0 && s.spacePreset<=3 && - std::isfinite(s.sourceDistanceMeters) && s.sourceDistanceMeters>=1.6f && + std::isfinite(s.sourceDistanceMeters) && s.sourceDistanceMeters>=1.f && s.sourceDistanceMeters<=10.f && - std::isfinite(s.roomAmount) && s.roomAmount>=0.f && s.roomAmount<=1.f && + std::isfinite(s.roomAmount) && s.roomAmount>=0.f && +#if defined(SONKU_P83_PHYSICAL_SPEAKER_RESEARCH) && SONKU_P83_PHYSICAL_SPEAKER_RESEARCH + s.roomAmount<=(s.renderMode==9?1.8f:1.f) && +#else + s.roomAmount<=1.f && +#endif std::isfinite(s.ambience) && s.ambience>=0.f && s.ambience<=1.f && #if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH p98::SceneVoicing::valid(s.sceneVoicing) && @@ -202,12 +210,23 @@ class SonKuSpatialCore final { public: static constexpr int taps=hrir::taps; static constexpr int updateInterval=16; +#if defined(SONKU_IMMERSIB_PCM_DIAGNOSTICS) && SONKU_IMMERSIB_PCM_DIAGNOSTICS + struct DynamicsTrace { + std::uint64_t samples=0,limitedSamples=0; + double limiterReductionSum=0.,makeupGainSum=0.; + float minimumLimiterGain=1.f,currentMakeup=1.f; + }; + DynamicsTrace dynamicsTrace() const noexcept {return dynamicsTrace_;} +#endif #if defined(SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH) && SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH // Control thread, before prepare: explicitly authorize P9.9 on THIS // SonKu insert, not all products sharing this exact native core. // Separate branded processors (e.g. ImmerSIB) remain P9.8 until they // independently adopt its P9.9 voicing. No extra PCM graph or state ABI. void optInP99ForSonKuInsert() noexcept { p99ForSonKuInsert_=true; } +#endif +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + void optInImmerSIBVocalRoom() noexcept {immersibP99Enabled_=true;} #endif bool prepare(double rate, SonKuReflectionProfile profile= SonKuReflectionProfile::Lightweight) noexcept { @@ -257,6 +276,9 @@ class SonKuSpatialCore final { #if defined(SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH) && SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH if(!p99VocalDepth_.prepare(rate))return false; #endif +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + if(!immersibP99VocalRoom_.prepare(rate))return false; +#endif #if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH if(!p95Presence_.prepare(rate))return false; #endif @@ -321,6 +343,9 @@ class SonKuSpatialCore final { sideBass_=0.f; #endif limiterGain_=1.f; +#if defined(SONKU_IMMERSIB_PCM_DIAGNOSTICS) && SONKU_IMMERSIB_PCM_DIAGNOSTICS + dynamicsTrace_={}; +#endif write_=0; remaining_=0; degrees_=wrapDegrees(settings_.startAzimuthDegrees); @@ -343,6 +368,9 @@ class SonKuSpatialCore final { #if defined(SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH) && SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH p99VocalDepth_.reset(); #endif +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + immersibP99VocalRoom_.reset(); +#endif #if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH p95Presence_.reset(); #endif @@ -412,6 +440,9 @@ class SonKuSpatialCore final { #if defined(SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH) && SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH p99VocalDepth_.reset(); #endif +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + immersibP99VocalRoom_.reset(); +#endif #if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH p95Presence_.reset(); #endif @@ -704,6 +735,12 @@ class SonKuSpatialCore final { const bool p90World=p83Mode_==p83::Mode::MusicSpatialP90; #else constexpr bool p90World=false; +#endif +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + const bool immersiveWarm=p90World && roomEnabled && + settings_.spatialMix>0.f && + (settings_.sceneVoicing==p98::SceneVoicing::ImmerSIBDetail || + settings_.sceneVoicing==p98::SceneVoicing::ImmerSIBImpact); #endif // Deliberate music-monitor compensation: real distance perception // still comes from direct/reflected ratio and high-frequency cues, @@ -848,6 +885,20 @@ class SonKuSpatialCore final { (void)p98Voicing_.source(0.f,0.f,0,false); } #endif +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + const float p98RoomSourceL=history_[0][write_]; + const float p98RoomSourceR=history_[1][write_]; + const bool vocalRoomOn=immersibP99Enabled_ && p90World && + roomEnabled && settings_.spatialMix>0.f && + (settings_.sceneVoicing==4 || settings_.sceneVoicing==5); + if(immersibP99Enabled_) { + const auto vocal=immersibP99VocalRoom_.source( + history_[0][write_],history_[1][write_], + settings_.sceneVoicing,vocalRoomOn); + history_[0][write_]=vocal.left; + history_[1][write_]=vocal.right; + } +#endif #if defined(SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH) && SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH if(p99ForSonKuInsert_ && p90World && settings_.spatialMix>0.f){ // Source-depth control happens BEFORE measured two-speaker @@ -920,6 +971,19 @@ class SonKuSpatialCore final { // the original stereo SIDE and respecting their geometry/delay. float earlyFeedL=x0,earlyFeedR=x1; float lateFeedL=x0,lateFeedR=x1; +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + if(immersiveWarm) { +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + const float deltaL=p98RoomSourceL-x0; + const float deltaR=p98RoomSourceR-x1; +#else + const float deltaL=history_[0][write_]-x0; + const float deltaR=history_[1][write_]-x1; +#endif + earlyFeedL+=.32f*deltaL;earlyFeedR+=.32f*deltaR; + lateFeedL+=.12f*deltaL;lateFeedR+=.12f*deltaR; + } +#endif #if defined(SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH) && SONKU_P99_MUSICAL_VOCAL_DEPTH_RESEARCH if(p99ForSonKuInsert_ && p90World && settings_.spatialMix>0.f && roomEnabled){ const auto earlyFeed=p99VocalDepth_.roomEarlyFeed(x0,x1); @@ -929,6 +993,14 @@ class SonKuSpatialCore final { lateFeedL=lateFeed.left; lateFeedR=lateFeed.right; } +#endif +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + if(vocalRoomOn){ + const auto e=immersibP99VocalRoom_.roomEarlyFeed(x0,x1); + const auto l=immersibP99VocalRoom_.roomLateFeed(x0,x1); + earlyFeedL+=e.left-x0;earlyFeedR+=e.right-x1; + lateFeedL+=l.left-x0;lateFeedR+=l.right-x1; + } #endif auto reflection=room_.active() ?room_.process((p90World||transparentBass)?earlyFeedL:(musicSafe?inputMid:x0), @@ -1083,6 +1155,14 @@ class SonKuSpatialCore final { late.left=background.left; late.right=background.right; } +#endif +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + if(vocalRoomOn) { + const auto e=immersibP99VocalRoom_.early(reflection.left,reflection.right); + const auto l=immersibP99VocalRoom_.late(late.left,late.right); + reflection.left=e.left;reflection.right=e.right; + late.left=l.left;late.right=l.right; + } #endif float spatialL=directL+ smoothedErPresence_*calibratedEarly*reflection.left+ @@ -1159,7 +1239,12 @@ class SonKuSpatialCore final { // Single native PCM graph, no WebAudio or dynamic makeup // at 0% spatial MIX. Explicit user GAIN still applies. if(settings_.spatialMix>0.f){ +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + const float makeup=p95Presence_.process(x0,x1,outL,outR, + immersiveWarm?1.10f:1.65f); +#else const float makeup=p95Presence_.process(x0,x1,outL,outR); +#endif outL*=makeup;outR*=makeup; } } @@ -1188,6 +1273,17 @@ class SonKuSpatialCore final { const float immediate=peak>0.98f?0.98f/peak:1.f; limiterGain_=std::min(immediate, std::min(1.f,limiterGain_+limiterRelease_)); +#if defined(SONKU_IMMERSIB_PCM_DIAGNOSTICS) && SONKU_IMMERSIB_PCM_DIAGNOSTICS + ++dynamicsTrace_.samples; + if(limiterGain_<.999f)++dynamicsTrace_.limitedSamples; + dynamicsTrace_.minimumLimiterGain=std::min( + dynamicsTrace_.minimumLimiterGain,limiterGain_); + dynamicsTrace_.limiterReductionSum+=1.-limiterGain_; +#if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH + dynamicsTrace_.currentMakeup=p95Presence_.gain(); + dynamicsTrace_.makeupGainSum+=dynamicsTrace_.currentMakeup; +#endif +#endif left[i]=outL*limiterGain_; right[i]=outR*limiterGain_; } @@ -1223,7 +1319,7 @@ class SonKuSpatialCore final { const auto preset=s.spacePreset==3?SonKuReverbPreset::LargeRoom: s.spacePreset==2?SonKuReverbPreset::AiryChamber: SonKuReverbPreset::StudioGlue; - return room_.setRealtimeRoom(geometry,s.roomAmount,s.spacePreset!=0) && + return room_.setRealtimeRoom(geometry,std::min(s.roomAmount,1.f),s.spacePreset!=0) && reverb_.setRealtimeProgram(preset, s.spacePreset!=0?s.ambience:0.f); } @@ -1463,6 +1559,9 @@ class SonKuSpatialCore final { #endif float smoothedDistanceGain_=1.f,smoothedRoomLevel_=1.f; float smoothedBassShelf_=0.f,limiterGain_=1.f; +#if defined(SONKU_IMMERSIB_PCM_DIAGNOSTICS) && SONKU_IMMERSIB_PCM_DIAGNOSTICS + DynamicsTrace dynamicsTrace_{}; +#endif float smoothedErPresence_=1.f,smoothedTailPresence_=1.f; std::array earBass_{}; #if defined(SONKU_P80_TRANSPARENT_BASS_RESEARCH) && SONKU_P80_TRANSPARENT_BASS_RESEARCH @@ -1506,6 +1605,10 @@ class SonKuSpatialCore final { p99::MusicalVocalDepth p99VocalDepth_{}; bool p99ForSonKuInsert_=false; // per-instance, never serialized #endif +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + p99::ImmerSIBVocalRoom immersibP99VocalRoom_{}; + bool immersibP99Enabled_=false; +#endif #if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH p95::MusicalPresence p95Presence_{}; #endif diff --git a/installer/ArSonMix.iss b/installer/ArSonMix.iss index e63d94dd6..d0159b32b 100644 --- a/installer/ArSonMix.iss +++ b/installer/ArSonMix.iss @@ -58,6 +58,7 @@ Source: "ArSonMixAutoUpdate.ps1"; DestDir: "{app}"; Flags: ignoreversion Source: "{#SourceRoot}\verified-gui.exe"; DestDir: "{app}"; DestName: "ArSonMix.exe"; Flags: ignoreversion Source: "{#SourceRoot}\BUILD_PROVENANCE.json"; DestDir: "{app}"; Flags: ignoreversion Source: "{#SourceRoot}\README.md"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#SourceRoot}\THIRD_PARTY_8D_SONKU_HRTF.md"; DestDir: "{app}"; Flags: ignoreversion Source: "{#SourceRoot}\FactoryFX\*"; DestDir: "{app}\FactoryFX"; Flags: ignoreversion recursesubdirs createallsubdirs skipifsourcedoesntexist [Icons] Name: "{autoprograms}\ArSonMix"; Filename: "{app}\ArSonMix.exe"; WorkingDir: "{app}" diff --git a/scripts/build_verify_windows_installer.ps1 b/scripts/build_verify_windows_installer.ps1 index c4b415404..e551c6333 100644 --- a/scripts/build_verify_windows_installer.ps1 +++ b/scripts/build_verify_windows_installer.ps1 @@ -38,7 +38,8 @@ $fixtureProcess=$null try { New-Item -ItemType Directory -Force -Path $stage | Out-Null Copy-Item -LiteralPath $exe -Destination (Join-Path $stage "verified-gui.exe") - foreach($item in @("BUILD_PROVENANCE.json","README.md")){ + foreach($item in @("BUILD_PROVENANCE.json","README.md", + "THIRD_PARTY_8D_SONKU_HRTF.md")){ Copy-Item -LiteralPath (Join-Path $dist $item) -Destination (Join-Path $stage $item) } Copy-Item -LiteralPath "assets/icon/arsonmix-app.ico" -Destination (Join-Path $stage "arsonmix-app.ico") @@ -66,6 +67,12 @@ try { } $installedManifest=Get-Content -LiteralPath (Join-Path $install "BUILD_PROVENANCE.json") -Raw -Encoding UTF8 | ConvertFrom-Json if($installedManifest.sourceCommit -ne $sha){throw "Wrong installed provenance"} + $installedNotice = Join-Path $install "THIRD_PARTY_8D_SONKU_HRTF.md" + if(-not (Test-Path -LiteralPath $installedNotice -PathType Leaf) -or + (Get-FileHash -LiteralPath $installedNotice -Algorithm SHA256).Hash.ToLowerInvariant() -ne + $manifest.hrirNoticeSha256) { + throw "Installed third-party KEMAR/MIT notice missing or altered" + } # REAL Windows in-place UPDATE test: replace the *test-installed* PE # with a harmless WinForms window. Installer must ask it to WM_CLOSE, # observe the graceful close marker, replace its running .exe with the diff --git a/scripts/package_native_windows.ps1 b/scripts/package_native_windows.ps1 index 3ed1cda9a..d335c6d06 100644 --- a/scripts/package_native_windows.ps1 +++ b/scripts/package_native_windows.ps1 @@ -87,6 +87,12 @@ if (-not (Test-Path -LiteralPath $fatGuide -PathType Leaf)) { } Copy-Item -LiteralPath $readme -Destination (Join-Path $OutputDir "README.md") Copy-Item -LiteralPath $fatGuide -Destination (Join-Path $OutputDir "HARDWARE_FAT_GUIDE.md") +# Ship MIT KEMAR/HRIR attribution with the actual portable executable. +$hrirNotice = "docs/THIRD_PARTY_8D_SONKU_HRTF.md" +if (-not (Test-Path -LiteralPath $hrirNotice -PathType Leaf)) { + throw "Mandatory MIT KEMAR/HRIR attribution missing" +} +Copy-Item -LiteralPath $hrirNotice -Destination (Join-Path $OutputDir "THIRD_PARTY_8D_SONKU_HRTF.md") # Selective FAT-only extraction from parked #270, no PCM or GUI production code. $fatBundleFiles = @("collect_hardware_fat_windows.ps1", "m3e_fat_evidence_gate.mjs") foreach ($file in $fatBundleFiles) { @@ -122,6 +128,7 @@ $manifest = [ordered]@{ exeSha256 = (Get-FileHash -LiteralPath $destination -Algorithm SHA256).Hash.ToLowerInvariant() fatCollectorSha256 = (Get-FileHash -LiteralPath (Join-Path $OutputDir "collect_hardware_fat_windows.ps1") -Algorithm SHA256).Hash.ToLowerInvariant() fatGateSha256 = (Get-FileHash -LiteralPath (Join-Path $OutputDir "m3e_fat_evidence_gate.mjs") -Algorithm SHA256).Hash.ToLowerInvariant() + hrirNoticeSha256 = (Get-FileHash -LiteralPath (Join-Path $OutputDir "THIRD_PARTY_8D_SONKU_HRTF.md") -Algorithm SHA256).Hash.ToLowerInvariant() approvedGuiRoute = $approvedGui.authoritativePagesRoute approvedGuiOutput = $approvedGui.authoritativePagesOutput approvedGuiCanonicalSource = $approvedGui.canonicalSource diff --git a/scripts/test_inno_graceful_update_windows.ps1 b/scripts/test_inno_graceful_update_windows.ps1 index c14f8b6fe..215abf1f2 100644 --- a/scripts/test_inno_graceful_update_windows.ps1 +++ b/scripts/test_inno_graceful_update_windows.ps1 @@ -49,6 +49,9 @@ try { Assert-Condition ($LASTEXITCODE -eq 0) "Test-only WinForms fixture failed to compile" Copy-Item -LiteralPath (Join-Path $root "assets/icon/arsonmix-app.ico") -Destination (Join-Path $stage "arsonmix-app.ico") "Test-only installer mechanics fixture" | Set-Content -LiteralPath (Join-Path $stage "README.md") + # Match the real Inno source manifest: full third-party legal notices + # are required for test fixtures as well as public native bundles. + Copy-Item -LiteralPath (Join-Path $root "docs/THIRD_PARTY_8D_SONKU_HRTF.md") -Destination (Join-Path $stage "THIRD_PARTY_8D_SONKU_HRTF.md") '{"sourceCommit":"TEST_FIXTURE_ONLY","fatStatus":"NOT_A_PRODUCT"}' | Set-Content -LiteralPath (Join-Path $stage "BUILD_PROVENANCE.json") # Contract fixture, NEVER vendor bytes: /VERYSILENT has the optional # vendor step skipped in silent mode. This proves ordinary repair/upgrade can @@ -69,6 +72,10 @@ try { Assert-Condition ($first.ExitCode -eq 0) ("First test install exit="+$first.ExitCode) $installedExe=Join-Path $install "ArSonMix.exe" Assert-Condition (Test-Path -LiteralPath $installedExe -PathType Leaf) "Installed fixture missing" + $mitSourceHash=(Get-FileHash -LiteralPath (Join-Path $root "docs/THIRD_PARTY_8D_SONKU_HRTF.md") -Algorithm SHA256).Hash + $installedMit=Join-Path $install "THIRD_PARTY_8D_SONKU_HRTF.md" + Assert-Condition ((Test-Path -LiteralPath $installedMit -PathType Leaf) -and + (Get-FileHash -LiteralPath $installedMit -Algorithm SHA256).Hash -eq $mitSourceHash) "Inno fixture did not install exact MIT KEMAR notice" $fixtureHash=(Get-FileHash -LiteralPath (Join-Path $stage "verified-gui.exe") -Algorithm SHA256).Hash Assert-Condition ((Get-FileHash -LiteralPath $installedExe -Algorithm SHA256).Hash -eq $fixtureHash) "First install changed test executable bytes" $userFile=Join-Path $install "user-file.keep" diff --git a/scripts/verify_native_windows_artifact.ps1 b/scripts/verify_native_windows_artifact.ps1 index d0e02feb2..8ba72a267 100644 --- a/scripts/verify_native_windows_artifact.ps1 +++ b/scripts/verify_native_windows_artifact.ps1 @@ -11,6 +11,7 @@ $expected = @( "BUILD_PROVENANCE.json", "HARDWARE_FAT_GUIDE.md", "README.md", + "THIRD_PARTY_8D_SONKU_HRTF.md", "portable_mode.txt", "collect_hardware_fat_windows.ps1", "m3e_fat_evidence_gate.mjs", @@ -36,6 +37,23 @@ if (@(Compare-Object -ReferenceObject $expected -DifferenceObject $actual).Count } $manifest = Get-Content -LiteralPath (Join-Path $OutputDir "BUILD_PROVENANCE.json") -Raw -Encoding UTF8 | ConvertFrom-Json +$notice = "THIRD_PARTY_8D_SONKU_HRTF.md" +$sourceNotice = Join-Path "docs" $notice +$distNotice = Join-Path $OutputDir $notice +if (-not (Test-Path -LiteralPath $sourceNotice -PathType Leaf) -or + -not (Test-Path -LiteralPath $distNotice -PathType Leaf)) { + throw "MIT/HRIR attribution absent from source or distribution" +} +$noticeHash = (Get-FileHash -LiteralPath $sourceNotice -Algorithm SHA256).Hash.ToLowerInvariant() +$distNoticeHash = (Get-FileHash -LiteralPath $distNotice -Algorithm SHA256).Hash.ToLowerInvariant() +if ($manifest.hrirNoticeSha256 -ne $noticeHash -or $noticeHash -ne $distNoticeHash) { + throw "Third-party HRIR notice differs from exact source/manifest" +} +$noticeText = Get-Content -LiteralPath $distNotice -Raw -Encoding UTF8 +foreach ($marker in @("Bill Gardner", "Keith Martin", "Aristotel Digenis", + "Permission is hereby granted", "THE SOFTWARE IS PROVIDED")) { + if (-not $noticeText.Contains($marker)) { throw "Incomplete HRIR notice: $marker" } +} # FAT tools match source bytes, distributed bytes AND the current SHA manifest. $fatTools = @{ "collect_hardware_fat_windows.ps1" = [string]$manifest.fatCollectorSha256 diff --git a/site/preview-v2/index.html b/site/preview-v2/index.html index ed6a565b9..4eeb19998 100644 --- a/site/preview-v2/index.html +++ b/site/preview-v2/index.html @@ -2826,8 +2826,13 @@ bypass state; the native bridge calls this only with published FX status. */ window.__ARMIX_SET_GLOBAL_FX_VIEW__=(enabled)=>{ if(typeof enabled!=='boolean')return false; - if(globalFxOn===enabled){syncGlobalFxButton();return true;} - globalFxOn=enabled;render();return true; + // The bridge has already painted each installed FX row using the SAME + // authoritative PCM snapshot. Only the global button and overall muted + // styling change here; render() would unnecessarily replace faders, rack + // buttons and open editor focus on every global bypass click. + globalFxOn=enabled; + syncGlobalFxButton(); + return true; }; document.querySelector('.section-rail').addEventListener('click',e=>{ const button=e.target.closest('[data-section]');if(!button)return; diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index f7bee36fa..42951518e 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -2258,6 +2258,45 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback const armix::mixer::LiveChannelFxGraph::InstanceLease& owner) const noexcept { return dryRoutingLab_.retainsFxEditor(epoch,owner); } + using RetainedFxPowerState=LiveDryRoutingLab::RetainedFxPowerState; + // Same verified control authority as FX Rack, but the native editor + // resolves the CURRENT graph revision for its retained exact instance. + RetainedFxPowerState retainedNativeFxPower( + const armix::mixer::LiveChannelFxGraph::InstanceLease& held, + armix::mixer::ChannelId id,std::size_t slot, + const juce::String& token) const noexcept { + if(routeReconfiguring_.load(std::memory_order_acquire)|| + independent_.active())return {}; + return dryRoutingLab_.retainedNativeFxPower(held,id,slot,token); + } + bool bypassRetainedNativeFx( + const armix::mixer::LiveChannelFxGraph::InstanceLease& held, + armix::mixer::ChannelId id,std::size_t slot, + const juce::String& token,bool bypass) noexcept { + if(routeReconfiguring_.load(std::memory_order_acquire)|| + independent_.active()|| + diagnosticRoute_.load(std::memory_order_acquire)!= + armix::diagnostics::Route::normal)return false; + return dryRoutingLab_.bypassRetainedNativeFx( + held,id,slot,token,bypass); + } + RetainedFxPowerState retainedRoutedFxPower( + const armix::mixer::LiveChannelFxGraph::InstanceLease& held, + int lane,int slot,const juce::String& token) const noexcept { + if(routeReconfiguring_.load(std::memory_order_acquire)|| + independent_.active())return {}; + return dryRoutingLab_.retainedRoutedFxPower(held,lane,slot,token); + } + bool bypassRetainedRoutedFx( + const armix::mixer::LiveChannelFxGraph::InstanceLease& held, + int lane,int slot,const juce::String& token,bool bypass) noexcept { + if(routeReconfiguring_.load(std::memory_order_acquire)|| + independent_.active()|| + diagnosticRoute_.load(std::memory_order_acquire)!= + armix::diagnostics::Route::normal)return false; + return dryRoutingLab_.bypassRetainedRoutedFx( + held,lane,slot,token,bypass); + } bool bypassNativeVst3(std::uint64_t epoch,std::uint64_t revision, armix::mixer::ChannelId id,std::size_t slot, const juce::String& token,bool bypass) noexcept { diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index 02292934a..418465e7b 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -66,6 +66,14 @@ class LiveDryRoutingLab final { const juce::MemoryBlock* binary=nullptr; }; using FxRestores=std::array,fxSlots>; + // CONTROL/UI-thread snapshot of the three independent audio bypass gates. + // Do not overwrite saved slot/rack flags when global A/B changes. + struct RetainedFxPowerState final { + bool valid=false,slotBypassed=false,rackBypassed=false,globalBypassed=false; + bool effectiveBypassed() const noexcept { + return valid && (slotBypassed || rackBypassed || globalBypassed); + } + }; struct ChannelEdit { float linear=1.f, pan=0.f; bool mute=false, solo=false, mono=false; @@ -1404,6 +1412,56 @@ class LiveDryRoutingLab final { if(prepared->insertInstanceId(lane,slot)==owner->instanceId)return true; return false; } + // The editor may outlive an FX rack MOVE/revision. Resolve the actual + // CURRENT accepted owner, rather than using epoch/revision frozen when + // its window opened. A replaced/retired processor is NEVER controlled. + RetainedFxPowerState retainedNativeFxPower( + const FxGraph::InstanceLease& held,armix::mixer::ChannelId id, + std::size_t slot,const juce::String& token) const noexcept { + RetainedFxPowerState out{}; + if(!held || !id.value || token.isEmpty() || + !channelIdPhysicalPcmActive() || !nativeAccepted_.fxOwners || + nativeAccepted_.deviceEpoch!=epoch() || !ready())return out; + const auto* live=nativeAccepted_.fxOwners->ownerForControl(id,slot); + if(!live || !*live || live->get()!=held.get() || + (*live)->instanceId!=token || !(*live)->processor)return out; + out.valid=true; + out.slotBypassed=held->bypassRequested.load(std::memory_order_acquire); + out.rackBypassed=nativeAccepted_.fxOwners->rackBypassed(id); + out.globalBypassed=globalFxBypassed(); + return out; + } + bool bypassRetainedNativeFx( + const FxGraph::InstanceLease& held,armix::mixer::ChannelId id, + std::size_t slot,const juce::String& token,bool bypass) noexcept { + if(!retainedNativeFxPower(held,id,slot,token).valid)return false; + return nativeAccepted_.setFxBypass(nativePublisher_,epoch(), + nativeAccepted_.pcmRevision,id,slot,token,bypass); + } + RetainedFxPowerState retainedRoutedFxPower( + const FxGraph::InstanceLease& held,int lane,int slot, + const juce::String& token) const noexcept { + RetainedFxPowerState out{}; + if(!held || token.isEmpty() || !ready() || + channelIdPhysicalPcmActive() || !hasExplicitRoute() || + lane<0 || lane>=fxSlots || slot<0 || slot>=maxFxPerLane) + return out; + const auto ep=epoch(),rev=revision(); + const auto* current=publisher_.controlPrepared(ep,rev); + if(!current || current->leaseInsert(lane,slot,token)!=held) + return out; + out.valid=true; + out.slotBypassed=held->bypassRequested.load(std::memory_order_acquire); + out.rackBypassed=current->rackBypassed(lane); + out.globalBypassed=globalFxBypassed(); + return out; + } + bool bypassRetainedRoutedFx( + const FxGraph::InstanceLease& held,int lane,int slot, + const juce::String& token,bool bypass) noexcept { + if(!retainedRoutedFxPower(held,lane,slot,token).valid)return false; + return setFxBypass(lane,slot,epoch(),revision(),token,bypass); + } bool bypassNativeInsert(std::uint64_t epochAtEdit,std::uint64_t pcmRevision, armix::mixer::ChannelId target,std::size_t slot, const juce::String& token,bool bypass) noexcept { diff --git a/src/Main.cpp b/src/Main.cpp index f3b51774d..487662c1d 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -12,6 +12,7 @@ #include "NativeSessionToken.h" #include "ArSonMixStartupSplash.h" #include "ArSonWindowChrome.h" +#include "NativeOwnedFloatingWindow.h" #include "VstOrbitController.h" #include "../engine/core/OrbitDistanceMapping.h" #include "../engine/core/DearVrPolarPolicy.h" @@ -179,15 +180,28 @@ class Browser final : public juce::WebBrowserComponent class PluginEditorWindow final : public juce::DocumentWindow { public: - PluginEditorWindow (const juce::String& title, juce::AudioProcessorEditor* editor) + PluginEditorWindow (const juce::String& title, juce::AudioProcessorEditor* editor, + juce::Component& mixer) : DocumentWindow (title, juce::Colour (0xff14212a), allButtons) { setUsingNativeTitleBar (true); setIcon (approvedAppIcon()); setContentOwned (editor, true); - setResizable (true, true); + // Do not offer false host resizing for fixed-geometry built-in FX. + setResizable (editor->isResizable(), false); centreWithSize (juce::jmax (380, editor->getWidth()), juce::jmax (300, editor->getHeight())); + // A Win32-owned floating editor stays above THIS mixer, not every app. + // Attach after bounds are set (JUCE 8 native owned-popup coordinates). + (void) armix::ui::attachOwnedFloatingWindow (*this, mixer); setVisible (true); + (void) armix::ui::attachOwnedFloatingWindow (*this, mixer); + present(); + } + void present() + { + if (!isVisible()) setVisible (true); + if (isMinimised()) setMinimised (false); + toFront (true); } void closeButtonPressed() override { setVisible (false); } }; @@ -196,7 +210,8 @@ class AudioSetupWindow final : public juce::DocumentWindow { public: explicit AudioSetupWindow (juce::AudioDeviceManager& manager, - std::function onClosed) + std::function onClosed, + juce::Component& mixer) : juce::DocumentWindow ("AR MIX — ASIO / WASAPI Setup", juce::Colour (0xff14212a), allButtons), onClosed_ (std::move (onClosed)) @@ -217,6 +232,7 @@ class AudioSetupWindow final : public juce::DocumentWindow selector->setSize (720, 550); setContentOwned (selector, false); centreWithSize (740, 590); + (void) armix::ui::attachOwnedFloatingWindow (*this, mixer); } void closeButtonPressed() override { setVisible (false); } void visibilityChanged() override @@ -586,6 +602,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr juce::String lastNativeThrowEpoch_,lastNativeThrowRevision_; armix::mixer::NativeMusicTempoMonitor::State lastMusicTempo_{}; std::unique_ptr editorWindow_; + juce::AudioProcessor* editorProcessor_=nullptr; // identity only, never owns PCM std::unique_ptr audioSetupWindow_; // Persistent modal lease: blocks an Apply/ASIO restart while JUCE's // device selector is open, not merely during the initial show() call. @@ -1028,9 +1045,21 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr browser_.emitEventIfBrowserIsVisible ("arMixPresets", presets_.list()); } + void synchronizeOpenImmerSIBPower() { +#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE + // The editor must reflect accepted global/rack/slot PCM state even + // when the gesture originated in the WebView header or FX Rack. + // All these dispatches run on JUCE's UI/message thread. + if(editorWindow_) + if(auto* ui=dynamic_cast( + editorWindow_->getContentComponent())) + ui->synchronizeHostPower(); +#endif + } void closePluginEditor() noexcept { - // JUCE destroys the editor before releasing the owner's processor. + // Dispose the native UI BEFORE dropping the graph/processor lease. editorWindow_.reset(); + editorProcessor_=nullptr; routedEditorOwner_.reset(); routedEditorEpoch_=0; } @@ -1304,23 +1333,32 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr } void openLogicalVendorEditor(const juce::var& request) { - if(logicalVendorEditor_ || mixerSessionWorker_.busy() || logicalMixer_.readOnly()) { - emitNotice("Close the current FX editor or wait for the mixer to finish saving",true); - return; - } std::uint64_t channel=0; std::size_t slot=0; if(!logicalFxTarget(request,channel,slot)) { emitNotice("The selected FX slot changed",true); return; } + if(logicalVendorEditor_) { + auto& existing=*logicalVendorEditor_; + if(existing.window)existing.window->present(); + if(existing.workspaceToken==logicalMixer_.workspace().workspaceToken() && + existing.insert.channel==armix::mixer::ChannelId{channel} && existing.insert.slot==slot) + return; // Exact same logical FX: refocus without losing state. + emitNotice("Finish the currently open FX editor first",true); + return; + } + if(mixerSessionWorker_.busy() || logicalMixer_.readOnly()) { + emitNotice("Finish the current mixer save before opening FX",true); + return; + } LogicalVendorEditor prepared; auto error=prepareLogicalFx(logicalMixer_.workspace(),{channel},slot,prepared.insert,prepared.processor); if(error.isEmpty()) { try { if(auto* editor=prepared.processor->createEditorIfNeeded()) { prepared.window=std::make_unique( - prepared.processor->getName(),editor); + prepared.processor->getName(),editor,*this); prepared.workspaceToken=logicalMixer_.workspace().workspaceToken(); logicalVendorEditor_=std::move(prepared); return; @@ -2684,8 +2722,10 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr : "Choose a working stereo output in Audio I/O. Input hardware is optional.", true); safe->emitApprovedNativeSnapshot(); } - }); + }, *safe); safe->audioSetupWindow_->setVisible (true); + (void) armix::ui::attachOwnedFloatingWindow ( + *safe->audioSetupWindow_, *safe); safe->audioSetupWindow_->toFront (true); // The peer now exists: perform one initial JUCE layout on the // message thread, rather than relying on a manual window drag. @@ -5351,6 +5391,12 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr armix::mixer::LiveChannelFxGraph::InstanceLease{}; auto* p=dynamic_cast( unbound?offline.get():owner?owner->processor.get():nullptr); +#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE + // Branded ImmerSIB never responds to another 8D-SonKu editor's + // stale WebView control requests, while retaining shared DSP. + if(p && dynamic_cast(p)) + p=nullptr; +#endif if(action=="nativeSonKuSnapshot") { emitNativeSonKuSnapshot(request,rawChannel.toString(), rawEpoch.toString(),rawRevision.toString(),rawInstance.toString(),p); @@ -5570,6 +5616,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr lane,static_cast(static_cast(ep)), static_cast(static_cast(rv)), static_cast(value)); + if(applied)synchronizeOpenImmerSIBPower(); auto ack=std::make_unique(); ack->setProperty("requestId",requestId); ack->setProperty("ok",applied); @@ -5938,6 +5985,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr if(browser_.loaded)browser_.emitEventIfBrowserIsVisible( "arMixGlobalFxAck",juce::var(ack.release())); if(applied) { + synchronizeOpenImmerSIBPower(); diagnostics_.record("GLOBAL_FX_AB", engine_.globalFxBypassed()?"BYPASS_ALL":"ENABLE_RESTORED"); emitApprovedNativeSnapshot(); @@ -5997,6 +6045,13 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr "Native FX power rejected: stale device/revision, Show busy or instance mismatch"); if(browser_.loaded)browser_.emitEventIfBrowserIsVisible( "arMixNativeFxPowerAck",juce::var(ack.release())); + if(applied) { + synchronizeOpenImmerSIBPower(); + // A native slot/rack ACK is not enough to repaint the + // other authority (WebView FX Rack). Publish the accepted + // producer state once per successful gesture, never on hover. + emitApprovedNativeSnapshot(); + } if(applied)diagnostics_.record("NATIVE_FX_POWER", rawId.toString()+(action=="routingNativeFxRackBypass"?" rack":" insert")+ (static_cast(value)?" BYPASS":" ENABLE")); @@ -6469,6 +6524,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr static_cast(args.getProperty("revision",juce::var(0)))); const bool ok=value.isBool()&&engine_.setDryRoutingLabFxBypass( lane,slot,epoch,revision,token,static_cast(value)); + if(ok)synchronizeOpenImmerSIBPower(); auto ack=std::make_unique(); ack->setProperty("ok",ok); ack->setProperty("requestId",args.getProperty("requestId",juce::var())); @@ -6498,6 +6554,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr if(!nativeShowBusy_&&!studioBackupBusy_&&!engine_.isGraphSwitchPending()) { armix::mixer::LiveChannelFxGraph::InstanceLease owner; std::uint64_t retainedEpoch=epoch; + std::uint64_t retainedRevision=revision,nativeChannel=0; + bool nativeTarget=false; const auto nativeId=args.getProperty("channelId",{}); if(!nativeId.isVoid()) { std::uint64_t id=0,ep=0,rev=0; @@ -6508,16 +6566,71 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr owner=engine_.leaseNativeVst3Editor(ep,rev, armix::mixer::ChannelId{id},static_cast(slot),token); retainedEpoch=ep; + retainedRevision=rev; + nativeChannel=id; + nativeTarget=static_cast(owner); } } else owner=engine_.leaseRoutedFxForEditor(lane,slot,epoch,revision,token); if(owner && owner->processor) { - try { + // A second click must raise an already open OR hidden + // editor for exactly this accepted instance. Do not + // destroy/recreate JUCE's active editor on every click. + if(editorWindow_ && routedEditorOwner_==owner && + routedEditorEpoch_==retainedEpoch && + editorProcessor_==owner->processor.get()) { + editorWindow_->present(); + opened=true; + error.clear(); + } else try { closePluginEditor(); if(auto* editor=owner->processor->createEditorIfNeeded()) { +#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE + if(auto* imer=dynamic_cast< + armix::builtin_fx::ImerSipP92Editor*>(editor)) { + // Exact retained processor identity is + // authoritative. Resolve CURRENT published + // PCM revision at each click, not the revision + // cached when the floating editor opened. + // Read all three independent bypass gates so + // global mixer A/B also mutes this editor. + auto held=owner; + const auto readPower=[this,held,nativeTarget, + nativeChannel,lane,slot,token] { + const auto current=nativeTarget? + engine_.retainedNativeFxPower( + held,armix::mixer::ChannelId{nativeChannel}, + static_cast(slot),token): + engine_.retainedRoutedFxPower( + held,lane,slot,token); + armix::builtin_fx::ImerSipP92Editor::HostBypassState state; + state.valid=current.valid; + state.slotBypassed=current.slotBypassed; + state.rackBypassed=current.rackBypassed; + state.globalBypassed=current.globalBypassed; + return state; + }; + imer->bindHostPower( + [this,held,nativeTarget,nativeChannel, + lane,slot,token](bool bypass) { + const bool applied=nativeTarget? + engine_.bypassRetainedNativeFx( + held,armix::mixer::ChannelId{nativeChannel}, + static_cast(slot), + token,bypass): + engine_.bypassRetainedRoutedFx( + held,lane,slot,token,bypass); + if(applied)emitApprovedNativeSnapshot(); + else emitNotice( + "FX Power rejected: accepted graph or instance changed",true); + return applied; + },readPower); + } +#endif routedEditorOwner_=owner; routedEditorEpoch_=retainedEpoch; editorWindow_=std::make_unique( - owner->processor->getName(),editor); + owner->processor->getName(),editor,*this); + editorProcessor_=owner->processor.get(); opened=true; error.clear(); } else error="This VST3 has no native editor"; @@ -7378,14 +7491,31 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr // Never open an editor for an old graph waiting to be destroyed. if (engine_.isGraphSwitchPending()) return emitNotice ("FX recall is transitioning; open the editor after recall completes.", true); - closePluginEditor(); if (auto* processor = engine_.pluginAt (slot)) { - if (auto* editor = processor->createEditorIfNeeded()) - editorWindow_ = std::make_unique ( - processor->getName(), editor); + if (editorWindow_ && !routedEditorOwner_ && + editorProcessor_ == processor) + { + editorWindow_->present(); // repeated FX Rack click + } else - emitNotice ("This VST3 does not expose a graphical editor.", true); + { + closePluginEditor(); + if (auto* editor = processor->createEditorIfNeeded()) + { + editorWindow_ = std::make_unique ( + processor->getName(), editor, *this); + editorProcessor_=processor; + } + else + emitNotice ("This VST3 does not expose a graphical editor.", true); + } + } + else + { + // The requested slot no longer owns a processor. Never + // leave a floating editor bound to a retired plugin. + closePluginEditor(); } } else if (action == "monitor" && value.isBool()) diff --git a/src/NativeBuiltInFx.h b/src/NativeBuiltInFx.h index 1e98f0a51..b03a5ac4b 100644 --- a/src/NativeBuiltInFx.h +++ b/src/NativeBuiltInFx.h @@ -7,6 +7,9 @@ #include "../engine/builtin_fx/VocalThrowProcessor.h" #include "../engine/builtin_fx/GuitarRigEditor.h" #include "../engine/builtin_fx/SonKuSpatialProcessor.h" +#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE +#include "../engine/builtin_fx/ImerSipP92Processor.h" +#endif #include "../engine/core/PreparedMixerBlock.h" #include #include @@ -83,6 +86,15 @@ inline constexpr std::array nativeBuiltInFx{ "NATIVE_SONKU_UNSUPPORTED_AUDIO_FORMAT","NATIVE_SONKU_PREPARE_REJECTED", "NATIVE_SONKU_PREPARE_EXCEPTION","Saved 8D-SonKu state rejected; graph unchanged", prepareNativeBuiltInFx}, +#if defined(ARMIX_IMMERSIB_RELEASE_CANDIDATE) && ARMIX_IMMERSIB_RELEASE_CANDIDATE + NativeBuiltInFx{ImerSipP92Processor::catalogIdentity, + ImerSipP92Processor::productDisplayName,"Spatial",true,44100.,48000., + "NATIVE_IMERSIP_HOST_UNAVAILABLE","NATIVE_IMERSIP_DEVICE_CHANGED", + "NATIVE_IMERSIP_UNSUPPORTED_AUDIO_FORMAT","NATIVE_IMERSIP_PREPARE_REJECTED", + "NATIVE_IMERSIP_PREPARE_EXCEPTION", + "Saved ImmerSIB IMRS state rejected; graph unchanged", + prepareNativeBuiltInFx}, +#endif NativeBuiltInFx{GuitarRigProcessor::catalogIdentity,"Guitar FX Rig","Guitar",true,32000.,192000., "NATIVE_GFX_HOST_UNAVAILABLE","NATIVE_GFX_DEVICE_CHANGED", "NATIVE_GFX_UNSUPPORTED_AUDIO_FORMAT","NATIVE_GFX_PREPARE_REJECTED", diff --git a/src/NativeFxWin32Owner.h b/src/NativeFxWin32Owner.h new file mode 100644 index 000000000..acd4bd2a3 --- /dev/null +++ b/src/NativeFxWin32Owner.h @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#if defined(_WIN32) +#include +#include + +namespace armix::ui::win32 { +// Native Windows caption colour is OS-owned. Prefer its supported dark +// presentation to match the mixer; unsupported Windows versions are benign. +// The plugin remains an ordinary non-topmost document window. +inline void preferDarkTitleBar(HWND hwnd) noexcept { + if(!hwnd || !::IsWindow(hwnd))return; + const BOOL dark=TRUE; + constexpr DWORD modernAttribute=20; // DWMWA_USE_IMMERSIVE_DARK_MODE + const auto hr=::DwmSetWindowAttribute(hwnd,modernAttribute,&dark,sizeof(dark)); + if(FAILED(hr)) { + constexpr DWORD olderAttribute=19; // Earlier Windows 10 preview API + (void)::DwmSetWindowAttribute(hwnd,olderAttribute,&dark,sizeof(dark)); + } +} +// UI thread only. GWLP_HWNDPARENT means owner for top-level WS_POPUP/ +// WS_OVERLAPPED windows. Do NOT SetParent(), create WS_CHILD, or set TOPMOST. +inline bool attachOwnedPopup(HWND popup, HWND owner) noexcept { + if (popup == nullptr || owner == nullptr || popup == owner || + !::IsWindow(popup) || !::IsWindow(owner) || + (::GetWindowLongPtrW(popup,GWL_STYLE) & WS_CHILD) != 0) + return false; + if (::GetWindow(popup,GW_OWNER)==owner) return true; + ::SetLastError(0); + const auto previous=::SetWindowLongPtrW( + popup,GWLP_HWNDPARENT,reinterpret_cast(owner)); + if (previous==0 && ::GetLastError()!=0) return false; + return ::GetWindow(popup,GW_OWNER)==owner; +} +} // namespace armix::ui::win32 +#endif diff --git a/src/NativeOwnedFloatingWindow.h b/src/NativeOwnedFloatingWindow.h new file mode 100644 index 000000000..b6d89eaa2 --- /dev/null +++ b/src/NativeOwnedFloatingWindow.h @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include +#include "NativeFxWin32Owner.h" + +namespace armix::ui { +// UI/message-thread only. An HWND owner keeps plugin windows above the mixer +// without making them system-wide topmost or child components of WebView2. +inline bool attachOwnedFloatingWindow(juce::Component& floating, + juce::Component& mixer) noexcept { +#if defined(_WIN32) + const auto* popupPeer=floating.getPeer(); + const auto* mixerPeer=mixer.getPeer(); + if(popupPeer==nullptr || mixerPeer==nullptr)return false; + const auto child=static_cast(popupPeer->getNativeHandle()); + const auto owner=static_cast(mixerPeer->getNativeHandle()); + const bool attached=win32::attachOwnedPopup(child,owner); + win32::preferDarkTitleBar(child); + return attached; +#else + (void)floating; + (void)mixer; + return true; // Native non-Windows foreground policy remains JUCE-owned. +#endif +} +} // namespace armix::ui diff --git a/src/SonKuNativeBridgeContract.h b/src/SonKuNativeBridgeContract.h index bce0fb491..28792e589 100644 --- a/src/SonKuNativeBridgeContract.h +++ b/src/SonKuNativeBridgeContract.h @@ -3,6 +3,7 @@ // One typed CONTROL-plane schema for the existing SonKu JUCE/JS bridge. // No renderer, callback, allocation or additional FX authority lives here. #include "../engine/builtin_fx/sonku/SonKuSpatialCore.h" +#include "../engine/builtin_fx/sonku/SonKuProductAdmission.h" #include #include #include @@ -138,7 +139,7 @@ inline bool decodeSettings(const juce::var& values,armix::sonku::Settings& out) if(proposed.musicCompatibleLowFrequency) return false; // P8.3 LF480 is forbidden throughout native v5. #endif - if(!armix::sonku::valid(proposed))return false; + if(!armix::sonku::valid8DSonKuInsertSettings(proposed))return false; out=proposed; return true; } diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 5a87e39dd..764f0be92 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -1475,6 +1475,8 @@ test("P0 native FX rack and per-slot readback update mounted strip without repla vm.runInNewContext(read("web/approved-native-bridge.js"), {window:win,document:doc,performance:{now:()=>0},console},{timeout:1500}); const base=acceptedFixture(); + // Production approvedNativeSnapshot publishes this PCM scalar, not CSS. + base.globalFxBypassed=false; base.graph.channels[0].fxRackBypassed=false; base.graph.channels[0].inserts=[ {id:"vst-live-1",catalogId:"eq-a",name:"EQ",bypassed:false}, @@ -1528,7 +1530,21 @@ test("P0 native FX rack and per-slot readback update mounted strip without repla assert.equal(track.fxOn,true); assert.deepEqual(rows.map(r=>r.power.getAttribute("aria-pressed")),["true","false"]); assert.deepEqual(rows.map(r=>r.dataset.fxEffective),["true","false"]); - const individual=clone(restored); + // One PCM global A/B overrides every displayed FX power without + // changing either remembered individual bypass preference or DOM nodes. + const allBypassed=clone(restored); + allBypassed.globalFxBypassed=true; + listeners.get("arMixConsoleSnapshot")(allBypassed); + assert.equal(paints,1,"global FX is a scalar, not a graph rebuild"); + assert.deepEqual(rows.map(r=>r.dataset.fxEffective),["false","false"]); + assert.deepEqual(rows.map(r=>r.power.getAttribute("aria-pressed")),["false","false"]); + assert.deepEqual(Array.from(track.slotBypass.slice(0,2)),[false,true]); + const restoredGlobal=clone(allBypassed); + restoredGlobal.globalFxBypassed=false; + listeners.get("arMixConsoleSnapshot")(restoredGlobal); + assert.equal(paints,1); + assert.deepEqual(rows.map(r=>r.dataset.fxEffective),["true","false"]); + const individual=clone(restoredGlobal); individual.graph.channels[0].inserts[0].bypassed=true; listeners.get("arMixConsoleSnapshot")(individual); assert.equal(paints,1,"slot power is a realtime scalar, not a topology edit"); @@ -1897,8 +1913,17 @@ test("native vendor editor retention follows current PCM ownership, not inactive assert.match(main,/routedEditorEpoch_=retainedEpoch/); assert.match(main,/retainedEpoch=ep/); assert.match(lab,/nativeAccepted_\.fxOwners->retainsEditor\(owner\)/); - const editor=main.slice(main.indexOf('if(owner && owner->processor)'),main.indexOf('if(owner && owner->processor)')+700); - assert.ok(editor.indexOf('closePluginEditor();')processor)'); + assert.ok(start>=0,'routed FX editor source must exist'); + const editor=main.slice(start,main.indexOf('catch(const std::exception& ex)',start)); + assert.ok(editor.includes('routedEditorOwner_==owner'), + 'reopen only exact current accepted PCM owner'); + assert.ok(editor.includes('editorWindow_->present()'), + 'same FX instance must be focused instead of recreated'); + const fresh=editor.slice(editor.indexOf('} else try {')); + assert.ok(fresh.includes('closePluginEditor();') && + fresh.indexOf('closePluginEditor();')1.f",gate) + self.assertIn("next.sceneVoicing>p98::SceneVoicing::Cinema",gate) + self.assertIn("valid8DSonKuInsertSettings(next)",processor) + self.assertIn("!admitQueuedScene(next)",processor) + self.assertIn("valid8DSonKuInsertSettings(proposed)",bridge) + self.assertIn("sonkuProductIsolation(44100)",read( + "tests/imersip_p92_native_test.cpp")) + + def test_operator_scene_is_not_factory_default(self): + scene=read("engine/builtin_fx/ImerSipP92Scene.h") + factory=self.record["audioScenes"]["p92NeutralABReference"] + candidate=self.record["audioScenes"]["imersipNewInsertDefault"] + screenshot=self.record["audioScenes"]["ownerScreenshotObservation"] + user=self.record["audioScenes"]["operatorCheckpointObservation"] + self.assertTrue(user["notFactoryDefault"]) + self.assertEqual(factory["earlyRoom"],.78) + self.assertEqual(factory["lateRoom"],.33) + self.assertEqual(user["earlyRoom"],1) + self.assertEqual(user["lateRoom"],.62) + self.assertEqual(user["outputGainDb"],7) + self.assertEqual(screenshot["speakerSpreadDeg"],150) + self.assertEqual(screenshot["distanceMeters"],1.6) + self.assertEqual(screenshot["lateRoom"],.91) + self.assertEqual(candidate["presetId"],2) + self.assertGreater(candidate["distanceMeters"],1.6) + self.assertGreater(candidate["outputGainDb"],screenshot["outputGainDb"]) + self.assertIn("s.stereoSpreadDegrees=106.f;s.sourceDistanceMeters=10.f",scene) + self.assertIn("112.f,2.0f,1.36f,.84f,5.10545f,4",scene) + self.assertIn("180.,2.5,180.,100.",read("engine/builtin_fx/ImerSipP92Editor.h")) + self.assertIn("150.f,2.2f,1.f,.91f,4.8f",scene) + self.assertIn('"Royal Concert Hall"',scene) + self.assertNotIn("P9.2 Neutral A/B",read( + "engine/builtin_fx/ImerSipP92Editor.h")) + self.assertIn("s.roomAmount=.78f",scene) + self.assertIn("s.ambience=.33f",scene) + self.assertIn("s.outputTrim=1.f",scene) + + def test_immersib_p97_golden_and_p98_native_wire(self): + self.assertEqual(self.record["immersibP98Integration"]["venueGolden"]["distanceMeters"],10) + self.assertEqual(self.record["immersibP98Integration"]["venueGolden"]["sceneVoicing"],0) + self.assertIn("SONKU_P98_SCENE_VOICING_RESEARCH",read( + "engine/builtin_fx/sonku/SonKuSpatialCore.h")) + self.assertIn("out.writeInt(12)",read( + "engine/builtin_fx/SonKuSpatialProcessor.h")) + self.assertIn("IMRS v7",read( + "engine/builtin_fx/ImerSipP92Processor.h")) + + def test_rc_is_flagged_without_importing_rejected_research_workflows(self): + historical=self.record["historicalP83"] + self.assertTrue(historical["notP9OrImerSipReleaseGate"]) + self.assertTrue(historical["strictOriginalFidelityVetoRetained"]) + cmake=read("CMakeLists.txt") + self.assertIn("ARMIX_IMMERSIB_RELEASE_CANDIDATE",cmake) + self.assertIn("NativeImmerSIBP99VocalRoomAndVenueGolden",cmake) + self.assertIn("NativeImmerSIBJucePresetACKStateAndBypass",cmake) + self.assertIn("ARMIX_SONKU_APPROVED_P99_MAIN",cmake) + self.assertIn('"mainP99Preserved": true', + read("config/spatial_audio_authority.json")) + self.assertTrue(self.record["production"]["releaseRequiresOperatorHeadphoneApproval"]) + self.assertFalse(self.record["imersip"]["releaseQualified"]) + +if __name__=="__main__": unittest.main() diff --git a/tests/imersip_p92_catalog_contract_test.py b/tests/imersip_p92_catalog_contract_test.py new file mode 100644 index 000000000..da1c89728 --- /dev/null +++ b/tests/imersip_p92_catalog_contract_test.py @@ -0,0 +1,196 @@ +# SPDX-License-Identifier: AGPL-3.0-only +"""Guard a real P9.2 ImerSip insert, never a GUI-only catalog item.""" +from pathlib import Path +import unittest + +ROOT=Path(__file__).resolve().parents[1] +def source(path): return (ROOT/path).read_text(encoding="utf-8") + +class ImerSipP92Contract(unittest.TestCase): + def test_single_pcm_authority_and_stable_catalog(self): + p=source("engine/builtin_fx/ImerSipP92Processor.h") + scene=source("engine/builtin_fx/ImerSipP92Scene.h") + catalog=source("src/NativeBuiltInFx.h") + self.assertIn("class ImerSipP92Processor final : public SonKuSpatialProcessor",p) + self.assertNotIn("ImerSipDsp",p.split("#include",1)[0]) + self.assertIn('armix.builtin.imersip.v1',p) + self.assertIn('productDisplayName="ImmerSIB"',p) + self.assertIn('return productDisplayName;',p) + self.assertIn("s.renderMode=9",scene) + for value in ("s.stereoSpreadDegrees=82.f","s.sourceDistanceMeters=1.6f", + "s.spacePreset=3","s.roomAmount=.78f","s.ambience=.33f", + "s.outputTrim=1.f"): + self.assertIn(value,scene) + self.assertIn("SonKuSpatialProcessor(imersipP92Factory(2))",p) + self.assertIn("imersipP97VenueGoldenScene()",scene) + self.assertIn("next.sourceDistanceMeters=std::clamp(",p) + self.assertIn("const double upper[]={180.,2.5,180.",source( + "engine/builtin_fx/ImerSipP92Editor.h")) + self.assertIn("sidePresence2_.run",source( + "engine/builtin_fx/sonku/SonKuP98SceneVoicing.h")) + self.assertIn("inline constexpr std::array",scene) # legacy + self.assertIn("inline constexpr std::array",scene) # P9.8 + self.assertIn("imersipP92MinDistance()",scene) + self.assertIn("134.f,1.5f,1.70f,.94f,4.40f,4",scene) + self.assertIn('"Concert Front Row XL"',scene) + # Named scenes bypass quantized JUCE slider roundtrip. + ui=source("engine/builtin_fx/ImerSipP92Editor.h") + self.assertIn("submit(factory);",ui) + self.assertIn("uiScene_=s;",ui) + self.assertIn("submit(uiScene_);",ui) + self.assertIn("isCustomIntent_=true;",ui) + # Brand opt-in only; factory IDs, GUI, IMRS and SonKu P9.9 + # approved instance must never be renamed or silently retuned. + processor=source("engine/builtin_fx/ImerSipP92Processor.h") + native=source("engine/builtin_fx/SonKuSpatialProcessor.h") + core=source("engine/builtin_fx/sonku/SonKuSpatialCore.h") + wrapper=source("engine/builtin_fx/sonku/SonKuImmerSIBVocalRoom.h") + cmake=source("CMakeLists.txt") + self.assertIn("optInImmerSIBVocalRoom();",processor) + self.assertIn("core_.optInImmerSIBVocalRoom();",native) + self.assertIn("immersibP99Enabled_ && p90World",core) + self.assertIn("const float p98RoomSourceL",core) + self.assertIn("p98RoomSourceL-x0",core) + self.assertIn("p99::ImmerSIBVocalRoom",core) + self.assertIn("MusicalVocalDepth donor_",wrapper) + self.assertIn("ARMIX_IMMERSIB_RELEASE_CANDIDATE",cmake) + self.assertIn("publicly shipped before headphone FAT",cmake) + self.assertNotIn("readControls()",ui) + self.assertIn('"Royal Concert Hall"',scene) + self.assertIn('"Arena Thunder"',scene) + self.assertIn('"Front Row Power"',scene) + self.assertIn('"Symphonic Palace"',scene) + self.assertIn('"Velvet Cinema"',scene) + ui=source("engine/builtin_fx/ImerSipP92Editor.h") + self.assertIn("ImerSipP92VisualSkin",ui) + self.assertNotIn("imersipP92ConcertBoxes(",ui) + self.assertNotIn("skin_.drawRoom(g)",ui) + self.assertIn("skin_.drawPanel(g)",ui) + self.assertIn("skin_.drawScene(g,visualSceneId_)",ui) + self.assertIn("if(preset!=1)visualSceneId_=preset",ui) + self.assertIn("visualSceneId_=id",ui) + self.assertNotIn("L / WORLD PA",ui) + self.assertNotIn("LIVE CONCERT WORLD",ui) + self.assertNotIn("skin_.drawHeader(g)",ui) + for label in ("PRESET","ROOM","DISTANCE","MASTER GAIN"): + self.assertIn(label,ui) + # Header/footer close chrome is owned by the native plugin window. + self.assertNotIn("SPATIAL CONCERT MONITOR",ui) + self.assertNotIn('g.fillRect(0,0,1100,68)',ui) + self.assertNotIn('close_.setButtonText',ui) + self.assertNotIn("close_",ui) + # Host state is the only authority for the native power glyph. + self.assertIn('power_.setButtonText({})',ui) + self.assertIn('power_.setToggleState(valid && !bypassed',ui) + # The bypass UI is strictly host-readback derived, never click + # optimistic. JUCE paints the veil *after* child controls and + # cuts a hole around the native power icon, leaving it actionable. + self.assertIn("std::optional hostBypassed_",ui) + self.assertIn("hostBypassed_=bypassed",ui) + self.assertIn("if(changed)repaint()",ui) + self.assertIn("paintOverChildren(juce::Graphics& g) override",ui) + self.assertIn("g.excludeClipRegion(power_.getBounds())",ui) + self.assertIn("skin_.drawBypassedVenueOverlay(g)",ui) + self.assertIn("skin_.drawUnavailableVenueOverlay(g)",ui) + self.assertIn("hostLeaseWasValid_",ui) + self.assertIn("drawUnavailableVenueOverlay",source( + "engine/builtin_fx/ImerSipP92VisualSkin.h")) + self.assertIn('g.drawText("FX UNAVAILABLE"',source( + "engine/builtin_fx/ImerSipP92VisualSkin.h")) + self.assertIn('savePowerFrame("LEASE_UNAVAILABLE")',source( + "tests/imersip_p92_native_test.cpp")) + skin=source("engine/builtin_fx/ImerSipP92VisualSkin.h") + native=source("tests/imersip_p92_native_test.cpp") + self.assertIn('g.drawText("BYPASSED"',skin) + self.assertIn("juce::FontOptions(76.f,juce::Font::bold)",skin) + self.assertIn("font.setExtraKerningFactor(0.055f)",skin) + self.assertIn("juce::Colour(0xb803060a)",skin) + self.assertIn("juce::Colour(0x7603060a)",ui) + self.assertIn("sceneMutedEnergy*100=15)",native) + self.assertIn("assert(stageDarker>=24)",native) + self.assertIn("assert(amberLetters>=380 && amberRows>=36)",native) + self.assertIn("assert(panelMutedEnergy*100",catalog) + self.assertIn("ARMIX_IMMERSIB_RELEASE_CANDIDATE",catalog) + def test_legacy_and_host_power_are_realtime_owned(self): + p=source("engine/builtin_fx/ImerSipP92Processor.h") + ui=source("engine/builtin_fx/ImerSipP92Editor.h") + host=source("src/Main.cpp") + self.assertIn("restoreUnpublishedState",p) + self.assertIn("out.writeInt(6)",p) + self.assertIn("SonKuSpatialProcessor::getStateInformation",p) + self.assertIn("SonKuSpatialProcessor::queueSettings",p) + self.assertIn("ImerSipP92Editor*>(editor)",host) + self.assertIn("ImerSipP92Processor*>(p)",host) + self.assertIn("admitQueuedScene",source( + "engine/builtin_fx/SonKuSpatialProcessor.h")) + self.assertIn("engine_.bypassNativeVst3(",host) + self.assertIn("engine_.setDryRoutingLabFxBypass(",host) + self.assertIn("power_.setEnabled(false)",ui) + self.assertIn("fx_.lastCompletedRequestId()",ui) + def test_no_shadow_fx_in_public_build(self): + cmake=source("CMakeLists.txt") + self.assertIn("ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT",cmake) + self.assertIn("ARMixImerSipP92NativeTests",cmake) + +if __name__=="__main__": unittest.main() diff --git a/tests/imersip_p92_factory_music_test.cpp b/tests/imersip_p92_factory_music_test.cpp new file mode 100644 index 000000000..1be0607e8 --- /dev/null +++ b/tests/imersip_p92_factory_music_test.cpp @@ -0,0 +1,156 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Product preset audition probes using the *unchanged* P9.1/P9.2 PCM core. +// Tests evidence; neither synthetic signals nor sample RMS proves luxury. +#if defined(NDEBUG) +#undef NDEBUG +#endif +#if !defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) || !SONKU_P90_TRUE_EXTERNAL_RESEARCH +#error ImerSip P9.2 audition needs the real P9 DSP switch +#endif +#include "../engine/builtin_fx/ImerSipP92Scene.h" +#include +#include +#include +#include +#include +#include +#include + +using namespace armix::sonku; +using armix::builtin_fx::imersipP92Factory; +using armix::builtin_fx::imersipP92ReferenceScene; +using armix::builtin_fx::validImerSipP92Scene; +using Stereo=std::array,2>; +constexpr double pi=3.1415926535897932384626433832795; +constexpr int frames=32768; +constexpr int skip=8192; +enum class Material { Musical, AntiPhase }; + +static Stereo source(int rate,Material material){ + Stereo p{std::vector(frames),std::vector(frames)}; + for(int i=0;i( + .14*std::sin(2*pi*83*t)+.055*std::sin(2*pi*1703*t)); + p[0][i]=s;p[1][i]=-s; + } else { + const float mid=static_cast( + .092*std::sin(2*pi*83*t)+ + .073*std::sin(2*pi*116*t)+ + .065*std::sin(2*pi*371*t)+ + .035*std::sin(2*pi*1900*t)+ + .026*std::sin(2*pi*8500*t)); + const float side=static_cast( + .048*std::sin(2*pi*520*t)+ + .025*std::sin(2*pi*3120*t)); + p[0][i]=mid+side; + p[1][i]=mid-side; + } + } + return p; +} +static Stereo render(int rate,const Settings& scene,Stereo data){ + auto dsp=std::make_unique(); + assert(dsp->prepare(rate,SonKuReflectionProfile::SixSurfaceKemarResearch)); + assert(validImerSipP92Scene(scene)); + assert(dsp->setSettings(scene)); + for(int i=0;iprocess(data[0].data()+i,data[1].data()+i,128); + for(int ear=0;ear<2;++ear) + for(const float s:data[ear])assert(std::isfinite(s)&&std::abs(s)<.981f); + return data; +} +static double energy(const Stereo& p,bool side=false){ + double total=0.; + for(int i=skip;i=1 && s.spacePreset<=3); + const auto heard=render(rate,s,raw); + const double ratio=std::sqrt(energy(heard)/original); + const double side=energy(heard,true); + auto silenceRoom=s; + silenceRoom.roomAmount=0.f; + silenceRoom.ambience=0.f; + const auto withoutRoom=render(rate,silenceRoom,raw); + const double roomDelta=std::sqrt( + nullDelta(heard,withoutRoom)/energy(heard)); + const auto antiWet=render(rate,s,anti); + const double antiRatio=std::sqrt(energy(antiWet)/energy(anti)); + const double antiSide=std::sqrt(energy(antiWet,true)/ + energy(anti,true)); + std::printf("IMERSIP_FACTORY_METRIC,rate=%d,id=%d," + "rmsVsSource=%.4f,rmsVsNeutral=%.4f," + "roomDelta=%.4f,stereoSideEnergy=%.5f," + "antiphaseRms=%.4f,antiphaseSide=%.4f\n", + rate,id,ratio,ratio/neutralRms,roomDelta,side, + antiRatio,antiSide); + assert(std::isfinite(ratio)&&std::isfinite(roomDelta)); + assert(side>1.e-5); + assert(antiRatio>.08 && antiSide>.08); // catastrophic null veto + if(id>=2 && id<=7){ + assert(s.sourceDistanceMeters>=1.6f); // front row is intentionally near + assert(s.outputTrim>1.f); + // A richer room must produce an actual, measurable wet PCM + // difference, not just turn up a headphone-locked dry signal. + assert(roomDelta>.045); + // Factory candidates must not be quieter than selected P9 + // neutral. Mastered material is handled by the linked guard. + assert(ratio>neutralRms*1.05); + } + if(id!=2){ + // New named scenes may not collapse into identical DSP + // settings or a weaker version of the owner's Live Concert. + assert(nullDelta(heard,liveRendered)>.001); + assert(ratio>liveRms*.90); // reject another weak renamed preset + } + if(id==5){ + assert(std::abs(s.stereoSpreadDegrees-150.f)<1.e-4f); + assert(std::abs(s.sourceDistanceMeters-1.6f)<1.e-4f); + assert(std::abs(s.ambience-.97f)<1.e-4f); + } + if(id==7)assert(s.spacePreset==2); + assert(s.outputTrim<=armix::builtin_fx::imersipP92DbToLinear(6.f)); + } +} +int main(){ + verify(44100); + verify(48000); + std::puts("PASS IMERSIP RICH SCENES: six live/room presets, phase, wet/dry, internal neutral-only guard"); +} diff --git a/tests/imersip_p92_native_test.cpp b/tests/imersip_p92_native_test.cpp new file mode 100644 index 000000000..93051037a --- /dev/null +++ b/tests/imersip_p92_native_test.cpp @@ -0,0 +1,858 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#if defined(NDEBUG) +#undef NDEBUG +#endif +#if !defined(ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT) || !ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT +#error ImerSip P9.2 native test requires explicit P9 experimental research +#endif +#include "../engine/builtin_fx/ImerSipP92Processor.h" +#include "../src/SonKuNativeBridgeContract.h" +#include +#include +#include +#include +#include +#include +#include +#include + +using armix::builtin_fx::ImerSipP92Processor; +using armix::builtin_fx::imersipP92ReferenceScene; +using armix::builtin_fx::imersipP92Factory; +using armix::sonku::SonKuSpatialCore; +constexpr double pi=3.14159265358979323846; + +static juce::MemoryBlock oldImrsV5() { + juce::MemoryBlock bytes; + { + juce::MemoryOutputStream out(bytes,false); + out.writeInt(0x494D5253);out.writeInt(5); + out.writeInt(0); // original concert + out.writeFloat(.88f);out.writeFloat(.78f); + out.writeFloat(.67f);out.writeFloat(.70f); + out.writeFloat(1.f);out.writeFloat(.60f); + out.writeFloat(1.f);out.writeFloat(.25f); + out.writeFloat(.78f);out.writeFloat(0.f); + } + assert(bytes.getSize()==52); + return bytes; +} + +static void sonkuProductIsolation(int rate) { + using armix::builtin_fx::SonKuSpatialProcessor; + auto sonku=std::make_unique(); + sonku->prepareToPlay(static_cast(rate),128); + assert(sonku->isReady()); + const auto original=sonku->acceptedSettings(); + assert(armix::sonku::valid8DSonKuInsertSettings(original)); + // These controls are deliberately valid for the shared ImmerSIB + // DSP, but must NEVER be admitted to the ordinary SonKu product. + auto near=original; + near.sourceDistanceMeters=1.1f; + assert(armix::sonku::valid(near)); + assert(!sonku->queueSettings(near,5101)); + auto excessiveEarly=original; + excessiveEarly.roomAmount=1.7f; + assert(armix::sonku::valid(excessiveEarly)); + assert(!sonku->queueSettings(excessiveEarly,5102)); +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + auto foreignVoicing=original; + foreignVoicing.sceneVoicing=4; + assert(armix::sonku::valid(foreignVoicing)); + assert(!sonku->queueSettings(foreignVoicing,5103)); + armix::sonku::Settings parsed{}; + const auto foreignJson= + armix::builtin_fx::sonku_bridge::acceptedSettings(foreignVoicing); + assert(!armix::builtin_fx::sonku_bridge::decodeSettings( + foreignJson,parsed)); +#endif + assert(sonku->stateSnapshotQuiescent()); + assert(sonku->acceptedSettings().sourceDistanceMeters== + original.sourceDistanceMeters); + // Approved P9.9/Signature SonKu still queues, applies and round-trips. + assert(sonku->queueSettings(original,5104)); + juce::AudioBuffer buffer(2,128); + juce::MidiBuffer midi; + buffer.clear(); + sonku->processBlock(buffer,midi); + SonKuSpatialProcessor::Completion ack{}; + assert(sonku->pollCompletion(ack) && ack.applied && + ack.requestId==5104); + juce::MemoryBlock saved; + sonku->getStateInformation(saved); +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + assert(saved.getSize()==67); + auto forgedVoicing=saved; + const int imersibOnly=4; + std::memcpy(static_cast(forgedVoicing.getData())+63, + &imersibOnly,sizeof(imersibOnly)); + SonKuSpatialProcessor restored; + restored.prepareToPlay(static_cast(rate),128); + assert(!restored.restoreUnpublishedState( + forgedVoicing.getData(),static_cast(forgedVoicing.getSize()))); + assert(restored.acceptedSettings().sceneVoicing==original.sceneVoicing); + auto forgedEarly=saved; + const float imersibEarly=1.7f; + std::memcpy(static_cast(forgedEarly.getData())+38, + &imersibEarly,sizeof(imersibEarly)); + assert(!restored.restoreUnpublishedState( + forgedEarly.getData(),static_cast(forgedEarly.getSize()))); + assert(restored.restoreUnpublishedState( + saved.getData(),static_cast(saved.getSize()))); + assert(restored.acceptedSettings().sceneVoicing==original.sceneVoicing); + restored.releaseResources(); +#endif + sonku->releaseResources(); +} + +static void nativeParity(int rate) { + auto fx=std::make_unique(); + assert(fx->getName()=="ImmerSIB"); + assert(juce::String(ImerSipP92Processor::catalogIdentity)== + "armix.builtin.imersip.v1"); + fx->prepareToPlay(static_cast(rate),128); + assert(fx->isReady()); + const auto reference=imersipP92Factory(2); + // Reference has NO selectable preset ID. ID 6 is now Symphonic Palace. + const auto neutral=imersipP92ReferenceScene(); + assert(armix::builtin_fx::validImerSipP92Scene(reference)); + assert(armix::builtin_fx::validImerSipP92Scene(neutral)); + const auto actual=fx->acceptedSettings(); + assert(actual.renderMode==9&&!actual.moving); + assert(actual.spacePreset==3); +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + assert(std::abs(actual.stereoSpreadDegrees-112.f)<.001f); + assert(std::abs(actual.sourceDistanceMeters-2.f)<.001f); + assert(actual.roomAmount==1.36f && actual.ambience==.84f); + assert(actual.outputTrim==1.8f && actual.sceneVoicing==4); +#else + assert(std::abs(actual.stereoSpreadDegrees-150.f)<.001f); + assert(std::abs(actual.sourceDistanceMeters-2.2f)<.001f); + assert(std::abs(actual.roomAmount-1.f)<.001f); + assert(std::abs(actual.ambience-.91f)<.001f); + assert(std::abs(actual.outputTrim- + armix::builtin_fx::imersipP92DbToLinear(4.8f))<.001f); +#endif + assert(std::abs(neutral.stereoSpreadDegrees-82.f)<.001f); + assert(std::abs(neutral.ambience-.33f)<.001f); + assert(std::abs(neutral.outputTrim-1.f)<.001f); + assert(!actual.musicCompatibleLowFrequency); + + auto native=std::make_unique(); +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + // Sample parity compares two identically opted-in instances of the + // SAME core. Generic SonKu stays unopted and byte-identical separately. + native->optInImmerSIBVocalRoom(); +#endif + assert(native->prepare(rate, + armix::sonku::SonKuReflectionProfile::SixSurfaceKemarResearch)); + assert(native->setSettings(reference)); + + juce::MidiBuffer midi; + juce::AudioBuffer pcm(2,128); + float left[128]{},right[128]{}; + double dryEnergy=0.,changeEnergy=0.,stereoEnergy=0.; + for(int block=0;block<256;++block){ + for(int i=0;i<128;++i) { + const double t=(block*128+i)/static_cast(rate); + const float mid=static_cast( + .15*std::sin(2*pi*311*t)+ + .060*std::sin(2*pi*1130*t)+ + .045*std::sin(2*pi*8250*t)); + const float side=static_cast( + .075*std::sin(2*pi*633*t)+.04*std::sin(2*pi*3200*t)); + left[i]=mid+side;right[i]=mid-side; + pcm.setSample(0,i,left[i]);pcm.setSample(1,i,right[i]); + } + native->process(left,right,128); + fx->processBlock(pcm,midi); + for(int i=0;i<128;++i){ + const float l=pcm.getSample(0,i),r=pcm.getSample(1,i); + assert(std::isfinite(l)&&std::isfinite(r)); + // EXACT native callback with matching ImmerSIB product opt-in; no second DSP. + assert(std::abs(l-left[i])<2.e-6f); + assert(std::abs(r-right[i])<2.e-6f); + if(block<32)continue; // settle measured KEMAR/room histories + const double t=(block*128+i)/static_cast(rate); + const double m=.15*std::sin(2*pi*311*t)+ + .060*std::sin(2*pi*1130*t)+ + .045*std::sin(2*pi*8250*t); + const double s=.075*std::sin(2*pi*633*t)+ + .04*std::sin(2*pi*3200*t); + const double dryL=m+s,dryR=m-s; + dryEnergy+=dryL*dryL+dryR*dryR; + changeEnergy+=(l-dryL)*(l-dryL)+(r-dryR)*(r-dryR); + stereoEnergy+=(l-r)*(l-r); + } + } + const double delta=std::sqrt(changeEnergy/(dryEnergy+1.e-15)); + std::fprintf(stderr, + "IMERSIP_P92_NATIVE_PARITY rate=%d delta=%.6f stereo=%.4f\n", + rate,delta,stereoEnergy); + assert(delta>.05 && stereoEnergy>.01); + + // v6 IMRS wraps native SONK v11, not an invented shadow DSP schema. + juce::MemoryBlock state; + fx->getStateInformation(state); +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + assert(state.getSize()==75); +#else + assert(state.getSize()==71); +#endif + auto restored=std::make_unique(); + restored->prepareToPlay(rate,128); + assert(restored->restoreUnpublishedState(state.getData(), + static_cast(state.getSize()))); + assert(restored->acceptedSettings().renderMode==9); + assert(restored->acceptedSettings().stereoSpreadDegrees== + reference.stereoSpreadDegrees); +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + assert(restored->acceptedSettings().sceneVoicing==4); + // Existing IMRS v7 shows saved at 10m are admitted with a nearfield + // distance migration, but preserve voicing, early room, and gain. + auto farState=state; + const float farDistance=10.f; + std::memcpy(static_cast(farState.getData())+42, + &farDistance,sizeof(farDistance)); // SONK v12 distance + auto migratedFar=std::make_unique(); + migratedFar->prepareToPlay(rate,128); + assert(migratedFar->restoreUnpublishedState( + farState.getData(),static_cast(farState.getSize()))); + assert(migratedFar->acceptedSettings().sourceDistanceMeters==2.5f); + assert(migratedFar->acceptedSettings().sceneVoicing==4); + assert(migratedFar->acceptedSettings().roomAmount==1.36f); + migratedFar->releaseResources(); + // Earlier Custom sessions may be 1.0m; migrate UP to 1.1m. + auto nearState=state; + const float near1m=1.f; + std::memcpy(static_cast(nearState.getData())+42, + &near1m,sizeof(near1m)); + auto migratedNear=std::make_unique(); + migratedNear->prepareToPlay(rate,128); + assert(migratedNear->restoreUnpublishedState( + nearState.getData(),static_cast(nearState.getSize()))); + assert(migratedNear->acceptedSettings().sourceDistanceMeters==1.1f); + assert(migratedNear->acceptedSettings().roomAmount==reference.roomAmount); + assert(migratedNear->acceptedSettings().outputTrim==reference.outputTrim); + migratedNear->releaseResources(); + // Compatibility proof: an old IMRS v6 carries SONK v11 exactly + // (63 bytes, no sceneVoicing). Restore it in the P9.8 engine as 0. + juce::MemoryBlock oldV6; + { + juce::MemoryOutputStream wire(oldV6,false); + wire.writeInt(0x494D5253);wire.writeInt(6); + wire.writeInt(0x534F4E4B);wire.writeInt(11); + wire.write(static_cast(state.getData())+16,55); + } + assert(oldV6.getSize()==71); + auto migratedV6=std::make_unique(); + migratedV6->prepareToPlay(rate,128); + assert(migratedV6->restoreUnpublishedState( + oldV6.getData(),static_cast(oldV6.getSize()))); + assert(migratedV6->acceptedSettings().sceneVoicing==0); + assert(migratedV6->acceptedSettings().sourceDistanceMeters<=2.5f); + assert(migratedV6->acceptedSettings().stereoSpreadDegrees== + reference.stereoSpreadDegrees); + migratedV6->releaseResources(); +#endif + + // The embedded v11 SONK mode field is at byte 50 of its 63-byte + // record (after the 8-byte IMRS header). Corrupting P9 -> P8.2 mode + // must fail BEFORE modifying a prepared FX's accepted PCM scene. + auto wrongMode=state; + auto* wrongBytes=static_cast(wrongMode.getData()); + assert(wrongBytes[8+50]==9); + wrongBytes[8+50]=0; + assert(!restored->restoreUnpublishedState( + wrongMode.getData(),static_cast(wrongMode.getSize()))); + assert(restored->acceptedSettings().renderMode==9); + auto movingWorld=state; + auto* movingBytes=static_cast(movingWorld.getData()); + movingBytes[8+28]=1; // dynamic orbit not allowed by ImerSip's scene + assert(!restored->restoreUnpublishedState( + movingWorld.getData(),static_cast(movingWorld.getSize()))); + assert(restored->acceptedSettings().renderMode==9); + + // Original IMRS 52-byte v5 restores without silently launching P8 DSP. + auto old=oldImrsV5(); + auto legacy=std::make_unique(); + legacy->prepareToPlay(rate,128); + assert(legacy->restoreUnpublishedState(old.getData(), + static_cast(old.getSize()))); + const auto migrated=legacy->acceptedSettings(); + assert(migrated.renderMode==9 && !migrated.moving); + assert(std::abs(migrated.stereoSpreadDegrees-130.5f)<.01f); + assert(migrated.spacePreset==3); + // Exercise the *virtual JUCE* restoration path as well as registry + // restore. A base-class SONK parser must not swallow ImerSip IMRS. + auto viaJuce=std::make_unique(); + viaJuce->prepareToPlay(rate,128); + juce::AudioProcessor& conventionalHost=*viaJuce; + conventionalHost.setStateInformation( + old.getData(),static_cast(old.getSize())); + assert(std::abs(viaJuce->acceptedSettings().stereoSpreadDegrees- + 130.5f)<.01f); + auto corrupt=old; + corrupt.getData(); // corrupted byte count must reject before mutation + auto invalid=std::make_unique(); + invalid->prepareToPlay(rate,128); + assert(!invalid->restoreUnpublishedState(corrupt.getData(),51)); + + // Edits travel through the SAME native callback and audio ACK. + auto changed=fx->acceptedSettings(); + changed.stereoSpreadDegrees=100.f; + assert(fx->queueSettings(changed,72)); + assert(fx->acceptedSettings().stereoSpreadDegrees== + reference.stereoSpreadDegrees); + pcm.clear(); + fx->processBlock(pcm,midi); + armix::builtin_fx::SonKuSpatialProcessor::Completion ack{}; + assert(fx->pollCompletion(ack)); + assert(ack.requestId==72 && ack.applied); + assert(std::abs(fx->acceptedSettings().stereoSpreadDegrees-100.f)<.01f); + assert(fx->stateSnapshotQuiescent()); + + // Even when the caller holds the SonKu BASE pointer, its public + // settings queue must not admit an old MusicBed or orbit mode into + // an ImerSip world-speaker insert. + armix::builtin_fx::SonKuSpatialProcessor& baseControl=*fx; + auto wrongP8=fx->acceptedSettings(); + wrongP8.renderMode=0; + assert(!baseControl.queueSettings(wrongP8,73)); + auto wrongOrbit=fx->acceptedSettings(); + wrongOrbit.moving=true; + assert(!baseControl.queueSettings(wrongOrbit,74)); + assert(fx->stateSnapshotQuiescent()); + + fx->releaseResources(); + restored->releaseResources(); + legacy->releaseResources(); + viaJuce->releaseResources(); + invalid->releaseResources(); +} +int main() { + juce::ScopedJuceInitialiser_GUI gui; + auto editorFx=std::make_unique(); + editorFx->prepareToPlay(48000.,128); + std::unique_ptr editor(editorFx->createEditor()); + assert(editor && editor->findChildWithID("imersip.preset")); + assert(editor->getWidth()==935 && editor->getHeight()==578); + auto* visualEditor=dynamic_cast(editor.get()); + assert(visualEditor && visualEditor->areVisualAssetsReady()); + + // Actual compact native JUCE hit bounds: no overlapping controls, + // labels/text remain independent from the background PNG scene. + const char* controlIds[]={"imersip.preset","imersip.room", + "imersip.stage","imersip.distance","imersip.early", + "imersip.late","imersip.mix","imersip.gain", + "imersip.align","imersip.yaw","imersip.power"}; + std::array controls{}; + for(std::size_t i=0;ifindChildWithID(controlIds[i]); + assert(controls[i]); + const auto r=controls[i]->getBounds(); + assert(!r.isEmpty()); + assert(editor->getLocalBounds().contains(r)); + for(std::size_t j=0;jgetBounds())); + } + // The native OS close control replaces the redundant in-editor CLOSE. + assert(editor->findChildWithID("imersip.close")==nullptr); + const auto powerBounds=controls[10]->getBounds(); + const auto gainBounds=controls[7]->getBounds(); + assert(powerBounds.getY()>=juce::roundToInt(461.f*.85f)); + assert(powerBounds.getRight()>gainBounds.getRight()); + assert(powerBounds.getX()>gainBounds.getRight()); + assert(powerBounds.getY()( + editor->findChildWithID("imersip.label.distance")); + assert(distanceLabel && distanceLabel->getText()=="DISTANCE"); + auto* masterLabel=dynamic_cast( + editor->findChildWithID("imersip.label.gain")); + assert(masterLabel && masterLabel->getText()=="MASTER GAIN"); + assert(masterLabel->getX()getBounds(); + const auto b=controls[3]->getBounds(); + const auto c=controls[4]->getBounds(); + assert(a.getY()==b.getY() && c.getY()>a.getY()); + assert(a.getX()=200); + + // The rejected synthetic-speaker positioning engine was deleted. + // Test the CURRENT rendering contract instead: full-range UI values + // must keep the actual photo venue and controls inside the editor. + // No audio edit is enqueued by these display-only extreme probes. + auto* stageProbe=dynamic_cast( + editor->findChildWithID("imersip.stage")); + auto* distanceProbe=dynamic_cast( + editor->findChildWithID("imersip.distance")); + assert(stageProbe && distanceProbe); + const auto priorStage=stageProbe->getValue(); + const auto priorDistance=distanceProbe->getValue(); + for(const double angle:{stageProbe->getMinimum(),stageProbe->getMaximum()}){ + for(const double metres:{distanceProbe->getMinimum(), + distanceProbe->getMaximum()}){ + stageProbe->setValue(angle,juce::dontSendNotification); + distanceProbe->setValue(metres,juce::dontSendNotification); + const auto extreme=editor->createComponentSnapshot( + editor->getLocalBounds()); + assert(extreme.isValid() && extreme.getWidth()==935 && + extreme.getHeight()==578); + for(auto* child:controls) + assert(editor->getLocalBounds().contains(child->getBounds())); + } + } + stageProbe->setValue(priorStage,juce::dontSendNotification); + distanceProbe->setValue(priorDistance,juce::dontSendNotification); + auto visual=editor->createComponentSnapshot(editor->getLocalBounds()); + assert(visual.isValid() && visual.getWidth()==935 && + visual.getHeight()==578); + assert(visual.getPixelAt(480,120)!=visual.getPixelAt(480,484)); + // Genuine native JUCE component snapshots, not an HTML or design mock. + // Render all requested Windows framebuffer density ratios while retaining + // the original 1100x680 logical hit-testing and parameter geometry. + for(const auto dpi : {100,125,150,200}) { + const float scale=static_cast(dpi)/100.f; + // JUCE 8.0.15 provides a first-class scale-aware snapshot API. + // paintEntireComponent() into a manually transformed offscreen + // Graphics can produce blank/incorrect images on Windows headless + // runners even when createComponentSnapshot() passes above. + // Keep the strict non-blank/opaque assertions below. + auto frame=editor->createComponentSnapshot( + editor->getLocalBounds(),true,scale); + assert(frame.isValid() && + frame.getWidth()==juce::roundToInt(935.f*scale) && + frame.getHeight()==juce::roundToInt(578.f*scale)); + // A single pixel comparison can falsely fail when two dark metal + // points happen to have the same RGBA. Validate a distributed sample + // of the REAL native pixel buffer instead, and still reject blank art. + const auto first=frame.getPixelAt(frame.getWidth()/10, + frame.getHeight()/10); + int distinct=0,opaque=0; + for(int yy=1;yy<10;++yy) + for(int xx=1;xx<10;++xx){ + const auto sample=frame.getPixelAt( + xx*frame.getWidth()/10, yy*frame.getHeight()/10); + if(sample!=first)++distinct; + if(sample.getAlpha()>0)++opaque; + } + assert(distinct>=8 && opaque>=40); + const auto file=juce::File::getCurrentWorkingDirectory() + .getChildFile("ImerSip_P92_JUCE_"+juce::String(dpi)+".png"); + juce::FileOutputStream output(file); + assert(output.openedOk()); + juce::PNGImageFormat encoder; + assert(encoder.writeImageToStream(frame,output)); + output.flush(); + assert(file.existsAsFile() && file.getSize()>10000); + } + auto* stage=dynamic_cast( + editor->findChildWithID("imersip.stage")); + auto* master=dynamic_cast( + editor->findChildWithID("imersip.gain")); + assert(stage && stage->getSliderStyle()==juce::Slider::LinearHorizontal); + assert(master && master->getSliderStyle()== + juce::Slider::RotaryHorizontalVerticalDrag); + auto* power=dynamic_cast( + editor->findChildWithID("imersip.power")); + assert(power && !power->isEnabled()); + assert(power->getButtonText().isEmpty()); + assert(!power->getToggleState()); + auto* selector=dynamic_cast( + editor->findChildWithID("imersip.preset")); +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + assert(selector&&selector->getNumItems()==8); // Custom + seven scenes +#else + assert(selector&&selector->getNumItems()==7); // Historical P9.2 +#endif + assert(selector->getSelectedId()==2); + for(int i=0;igetNumItems();++i){ + const auto name=selector->getItemText(i); + assert(!name.containsIgnoreCase("neutral")); + assert(!name.containsIgnoreCase("a/b")); + } + assert(armix::builtin_fx::imersipP92PresetById(6)!=nullptr); + auto* distanceSlider=dynamic_cast( + editor->findChildWithID("imersip.distance")); + auto* earlySlider=dynamic_cast( + editor->findChildWithID("imersip.early")); + assert(distanceSlider && earlySlider); +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + assert(std::abs(distanceSlider->getMinimum()-1.1)<1.e-4); + assert(distanceSlider->getMaximum()==2.5); + assert(earlySlider->getMaximum()==180.0); +#endif +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + assert(armix::builtin_fx::imersipP92PresetById(8)!=nullptr); +#else + assert(armix::builtin_fx::imersipP92PresetById(8)==nullptr); +#endif + // Front Row Power must be a real applied audio edit, not UI illusion. + selector->setSelectedId(5,juce::sendNotificationSync); + juce::MidiBuffer editMidi; + juce::AudioBuffer editPcm(2,128); + editPcm.clear(); + editorFx->processBlock(editPcm,editMidi); + armix::builtin_fx::SonKuSpatialProcessor::Completion selected{}; + assert(editorFx->pollCompletion(selected)&&selected.applied); +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + assert(std::abs(editorFx->acceptedSettings().stereoSpreadDegrees-104.f)<.001f); + assert(std::abs(editorFx->acceptedSettings().sourceDistanceMeters-1.3f)<.001f); + assert(std::abs(editorFx->acceptedSettings().ambience-.70f)<.001f); + assert(std::abs(editorFx->acceptedSettings().roomAmount-1.26f)<.001f); + assert(editorFx->acceptedSettings().sceneVoicing==4); + juce::MemoryBlock detailState; + editorFx->getStateInformation(detailState); + assert(detailState.getSize()==75); + auto detailRestored=std::make_unique(); + detailRestored->prepareToPlay(48000.,128); + assert(detailRestored->restoreUnpublishedState( + detailState.getData(),static_cast(detailState.getSize()))); + assert(detailRestored->acceptedSettings().sceneVoicing==4); + assert(detailRestored->acceptedSettings().sourceDistanceMeters<=2.5f); + assert(detailRestored->acceptedSettings().roomAmount>1.f); + detailRestored->releaseResources(); + assert(std::abs(editorFx->acceptedSettings().outputTrim- + armix::builtin_fx::imersipP92DbToLinear(5.60f))<.001f); +#else + assert(std::abs(editorFx->acceptedSettings().stereoSpreadDegrees-150.f)<.001f); + assert(std::abs(editorFx->acceptedSettings().sourceDistanceMeters-1.6f)<.001f); + assert(std::abs(editorFx->acceptedSettings().ambience-.97f)<.001f); + assert(std::abs(editorFx->acceptedSettings().outputTrim- + armix::builtin_fx::imersipP92DbToLinear(5.2f))<.001f); +#endif +#if defined(SONKU_P98_SCENE_VOICING_RESEARCH) && SONKU_P98_SCENE_VOICING_RESEARCH + // The first editor's ACK has been consumed explicitly by the test, + // while its Timer normally retires pending_ on the message thread. + // Use a fresh real editor/processor for an independent owner-preset + // transaction instead of inventing a second ACK for a deferred edit. + auto ownerFx=std::make_unique(); + ownerFx->prepareToPlay(48000.,128); + assert(ownerFx->isReady()); + std::unique_ptr ownerEditor(ownerFx->createEditor()); + assert(ownerEditor); + auto* ownerSelector=dynamic_cast( + ownerEditor->findChildWithID("imersip.preset")); + assert(ownerSelector && ownerSelector->getSelectedId()==2); + ownerSelector->setSelectedId(8,juce::sendNotificationSync); + juce::AudioBuffer ownerPcm(2,128); + juce::MidiBuffer ownerMidi; + ownerPcm.clear(); + ownerFx->processBlock(ownerPcm,ownerMidi); + armix::builtin_fx::SonKuSpatialProcessor::Completion userScene{}; + assert(ownerFx->pollCompletion(userScene) && userScene.applied && + userScene.requestId!=0); + const auto screenshot=ownerFx->acceptedSettings(); + assert(userScene.settings.stereoSpreadDegrees==134.f); + assert(screenshot.spacePreset==3); + assert(screenshot.stereoSpreadDegrees==134.f); + assert(screenshot.sourceDistanceMeters==1.5f); + assert(screenshot.roomAmount==1.70f); + assert(screenshot.ambience==.94f && screenshot.spatialMix==1.f); + assert(screenshot.hrtfElevationTrimDegrees==0.f && screenshot.headYawDegrees==0.f); + assert(screenshot.sceneVoicing==4); + assert(std::abs(screenshot.outputTrim- + armix::builtin_fx::imersipP92DbToLinear(4.4f))<.001f); + juce::MemoryBlock ownerState; + ownerFx->getStateInformation(ownerState); + auto ownerRestored=std::make_unique(); + ownerRestored->prepareToPlay(48000.,128); + assert(ownerRestored->restoreUnpublishedState( + ownerState.getData(),static_cast(ownerState.getSize()))); + assert(ownerRestored->acceptedSettings().stereoSpreadDegrees==134.f); + assert(ownerRestored->acceptedSettings().roomAmount==1.70f); + ownerRestored->releaseResources(); + ownerEditor.reset(); // Destroy editor before its processor. + ownerFx->releaseResources(); + + // Regression: the user's exact screenshot showed Live Concert controls + // 112deg / 2m / ER136 / Late84 / +5.1dB, but the preset showed Custom. + // Factory outputTrim=1.8f is NOT equal to the rounded slider's 5.1dB + // conversion. An untouched preset must submit exact factory Settings, + // retain its NAME after the real AUDIO ACK, and serialize unchanged. + auto sceneFx=std::make_unique(); + sceneFx->prepareToPlay(48000.,128); + assert(sceneFx->isReady()); + std::unique_ptr sceneEditor(sceneFx->createEditor()); + assert(sceneEditor); + auto* sceneSelector=dynamic_cast( + sceneEditor->findChildWithID("imersip.preset")); + auto* sceneStage=dynamic_cast( + sceneEditor->findChildWithID("imersip.stage")); + assert(sceneSelector && sceneStage && sceneSelector->getSelectedId()==2); + juce::AudioBuffer scenePcm(2,128); + juce::MidiBuffer sceneMidi; + const auto settleGui=[&]{ + // Native JUCE 25Hz editor timer must consume ACK and reconcile + // the selected label, not leave this assertion at pre-ACK state. + // The pinned headless JUCE build excludes the optional + // MessageManager modal loop API. Wait for the 25Hz timer to + // become due and pump the real JUCE timer callback synchronously. + juce::Thread::sleep(65); + juce::Timer::callPendingTimersSynchronously(); + }; + for(const auto& p:armix::builtin_fx::imersipP92Presets){ + sceneSelector->setSelectedId(p.id,juce::sendNotificationSync); + assert(sceneSelector->getSelectedId()==p.id); + scenePcm.clear(); + sceneFx->processBlock(scenePcm,sceneMidi); + settleGui(); + assert(sceneSelector->getSelectedId()==p.id); + const auto expected=imersipP92Factory(p.id); + const auto accepted=sceneFx->acceptedSettings(); + assert(std::abs(accepted.outputTrim-expected.outputTrim)<1.e-7f); + assert(std::abs(accepted.sourceDistanceMeters- + expected.sourceDistanceMeters)<1.e-6f); + assert(std::abs(accepted.roomAmount-expected.roomAmount)<1.e-6f); + assert(std::abs(accepted.ambience-expected.ambience)<1.e-6f); + assert(accepted.sceneVoicing==expected.sceneVoicing); + } + sceneSelector->setSelectedId(2,juce::sendNotificationSync); + scenePcm.clear(); + sceneFx->processBlock(scenePcm,sceneMidi); + settleGui(); + assert(sceneSelector->getSelectedId()==2); + assert(sceneFx->acceptedSettings().outputTrim==1.8f); + const auto originalStage=sceneStage->getValue(); + sceneStage->setValue(originalStage+1.,juce::sendNotificationSync); + assert(sceneSelector->getSelectedId()==1); // true parameter edit only + scenePcm.clear(); + sceneFx->processBlock(scenePcm,sceneMidi); + settleGui(); + assert(sceneSelector->getSelectedId()==1); // remains Custom after ACK + // Changing STAGE must not round and silently shift MASTER GAIN. + assert(sceneFx->acceptedSettings().outputTrim==1.8f); + assert(sceneFx->acceptedSettings().stereoSpreadDegrees==113.f); + sceneEditor.reset(); + sceneFx->releaseResources(); +#endif + auto* actualEditor=dynamic_cast( + editor.get()); + assert(actualEditor); + bool bypassed=false,rackBypassed=false,globalBypassed=false; + bool hostAvailable=true,acceptPower=true; + int acceptedLocalPower=0; + const auto hostState=[&] { + armix::builtin_fx::ImerSipP92Editor::HostBypassState state{}; + state.valid=hostAvailable; + state.slotBypassed=bypassed; + state.rackBypassed=rackBypassed; + state.globalBypassed=globalBypassed; + return state; + }; + actualEditor->bindHostPower( + [&](bool desired) { + if(!acceptPower)return false; + bypassed=desired; + ++acceptedLocalPower; + return true; + },hostState); + assert(power->isEnabled() && power->getToggleState()); + // Host-connected native screenshots prove the two actual power glyph + // states. The earlier DPI snapshots deliberately test disabled/fail-safe + // before host binding; these frames additionally verify the real bypass + // response without faking a DSP power state in the editor. + const auto savePowerFrame=[&](const char* mode) { + auto frame=editor->createComponentSnapshot(editor->getLocalBounds()); + assert(frame.isValid() && frame.getWidth()==935 && + frame.getHeight()==578); + const auto file=juce::File::getCurrentWorkingDirectory() + .getChildFile("ImerSip_P92_JUCE_POWER_"+juce::String(mode)+".png"); + juce::FileOutputStream output(file); + assert(output.openedOk()); + juce::PNGImageFormat encoder; + assert(encoder.writeImageToStream(frame,output)); + output.flush(); + assert(file.existsAsFile() && file.getSize()>10000); + return frame; + }; + const auto activeFrame=savePowerFrame("ON"); + power->onClick(); + assert(bypassed && !power->getToggleState()); + const auto bypassFrame=savePowerFrame("BYPASSED"); + + // Validate the *real JUCE framebuffer*, not just an ON/OFF flag. + // The stage must darken independently of the amber label, the label + // must be legible near scene centre, and the lower controls must dim + // while the power icon itself remains interactive and visible. + const auto rgbEnergy=[](juce::Colour px){ + return 3*int(px.getRed())+6*int(px.getGreen())+int(px.getBlue()); + }; + int stageDarker=0; + for(const int y:{75,110,150,285,320,350}) + for(const int x:{80,145,210,720,790,845}) + if(rgbEnergy(activeFrame.getPixelAt(x,y))- + rgbEnergy(bypassFrame.getPixelAt(x,y))>=15) + ++stageDarker; + assert(stageDarker>=24); // No washed-out "barely bypassed" venue + // Check relative scene luminance, not just binary "some pixel changed". + // Keep a trace of the venue rather than turning the stage completely black. + std::int64_t sceneOnEnergy=0,sceneMutedEnergy=0; + for(const int y:{75,110,150,285,320,350}) + for(const int x:{80,145,210,720,790,845}) { + sceneOnEnergy+=rgbEnergy(activeFrame.getPixelAt(x,y)); + sceneMutedEnergy+=rgbEnergy(bypassFrame.getPixelAt(x,y)); + } + assert(sceneMutedEnergy*100sceneOnEnergy*18); + + // Enforce actual glyph prominence: broad amber letter coverage across + // at least 36 vertical framebuffer rows; a small thin 40px regular + // caption would not pass this native pixel-level requirement. + int amberLetters=0,amberRows=0; + for(int y=115;y<285;++y) { + int inThisRow=0; + for(int x=200;x<740;x+=2) { + const auto px=bypassFrame.getPixelAt(x,y); + if(px.getRed()>170 && px.getGreen()>85 && + int(px.getRed())>int(px.getGreen())+55 && + int(px.getGreen())>int(px.getBlue())+35) { + ++amberLetters; + ++inThisRow; + } + } + if(inThisRow>=8) ++amberRows; + } + assert(amberLetters>=380 && amberRows>=36); + + std::int64_t panelOnEnergy=0,panelMutedEnergy=0; + for(const int y:{410,435,475,520,552}) + for(const int x:{45,120,225,305,415,550,675,775}) { + panelOnEnergy+=rgbEnergy(activeFrame.getPixelAt(x,y)); + panelMutedEnergy+=rgbEnergy(bypassFrame.getPixelAt(x,y)); + } + // A true UI mute is visually distinct, but labels remain decipherable. + assert(panelMutedEnergy*100panelOnEnergy*35); + + // Power is intentionally excluded from the panel veil. It must remain + // conspicuous and actionable when bypassed, not darkened with the rack. + int powerHighlightPixels=0; + const auto activePowerBounds=power->getBounds(); + for(int y=activePowerBounds.getY()+3;y112 && px.getGreen()>120 && px.getBlue()>125) + ++powerHighlightPixels; + } + assert(powerHighlightPixels>=15); + + int changedPowerPixels=0; + const auto powerRegion=power->getBounds(); + for(int y=powerRegion.getY()+3;y=10); // Visible true host ON/OFF indication + power->onClick(); + assert(!bypassed && power->getToggleState()); + assert(acceptedLocalPower==2); + + // Rejected host commands do not optimistic-toggle the actual PCM state. + acceptPower=false; + power->onClick(); + assert(!bypassed && power->getToggleState()); + assert(acceptedLocalPower==2); + acceptPower=true; + + // Mixer-header FX Power is a GLOBAL override, not a rewrite of + // any slot's remembered bypass preference. With editor still open + // it must immediately show BYPASSED and block misleading local power. + globalBypassed=true; + actualEditor->synchronizeHostPower(); + assert(!bypassed && !power->isEnabled() && !power->getToggleState()); + const auto globalFrame=savePowerFrame("GLOBAL_BYPASSED"); + assert(globalFrame.getPixelAt(450,195)!=activeFrame.getPixelAt(450,195)); + globalBypassed=false; + actualEditor->synchronizeHostPower(); + assert(!bypassed && power->isEnabled() && power->getToggleState()); + + // Rack Power is another independent additive gate; it must dim even + // though this individual slot's preference is still enabled. + rackBypassed=true; + actualEditor->synchronizeHostPower(); + assert(!bypassed && !power->isEnabled() && !power->getToggleState()); + const auto rackFrame=savePowerFrame("RACK_BYPASSED"); + assert(rackFrame.getPixelAt(450,195)!=activeFrame.getPixelAt(450,195)); + rackBypassed=false; + actualEditor->synchronizeHostPower(); + assert(!bypassed && power->isEnabled() && power->getToggleState()); + + // An invalidated processor lease can neither change another slot nor + // pretend that its UI owns an admitted host effect. + hostAvailable=false; + actualEditor->synchronizeHostPower(); + assert(!power->isEnabled() && !power->getToggleState()); + assert(power->getTooltip().contains("unavailable")); + const auto unavailableFrame=savePowerFrame("LEASE_UNAVAILABLE"); + // A lost native processor lease must never look like an active + // concert scene or an intentionally bypassed FX. It must remain + // visually distinct from both, with no stale clickable Power. + assert(unavailableFrame.getPixelAt(85,92)!=activeFrame.getPixelAt(85,92)); + assert(unavailableFrame.getPixelAt(450,195)!=bypassFrame.getPixelAt(450,195)); + const auto offlineCaption=unavailableFrame.getPixelAt(460,253); + (void)offlineCaption; + hostAvailable=true; + actualEditor->synchronizeHostPower(); + assert(power->isEnabled() && power->getToggleState()); + + // Original per-insert bypass must survive a global A/B roundtrip. + power->onClick(); + assert(bypassed); + globalBypassed=true; + actualEditor->synchronizeHostPower(); + globalBypassed=false; + actualEditor->synchronizeHostPower(); + assert(bypassed && !power->getToggleState() && power->isEnabled()); + power->onClick(); + assert(!bypassed && power->getToggleState()); + + // Actual JUCE scene renders: exact same embedded venue images as shipped + // with the native app. These captures are NOT HTML concept mockups. + // Each of the six preset IDs must produce a distinct visual composition. + std::uint64_t previousSceneSignature=0; + for(int sceneId=2;sceneId<=7;++sceneId) { + selector->setSelectedId(sceneId,juce::sendNotificationSync); + auto photo=editor->createComponentSnapshot(editor->getLocalBounds()); + assert(photo.isValid() && photo.getWidth()==935 && photo.getHeight()==578); + std::uint64_t signature=14695981039346656037ull; + for(int y=100;y<385;y+=37) + for(int x=65;x<860;x+=53) { + const auto px=photo.getPixelAt(x,y).getARGB(); + signature=(signature ^ static_cast(px)) + *1099511628211ull; + } + assert(sceneId==2 || signature!=previousSceneSignature); + previousSceneSignature=signature; + // The exact same six embedded PNGs must reach BOTH left/right + // viewport edges. Prior centred 2:1 images left uniform matte bands. + for(const int edgeX:{8,photo.getWidth()-9}) { + const auto first=photo.getPixelAt(edgeX,45); + int matteCount=0; + int varied=0; + for(int y=52;y<385;y+=19) { + const auto pixel=photo.getPixelAt(edgeX,y); + if(pixel==juce::Colour(0xff0e161c))++matteCount; + if(pixel!=first)++varied; + } + assert(matteCount<3 && varied>=7); + } + const auto sceneFile=juce::File::getCurrentWorkingDirectory() + .getChildFile("ImerSip_P92_SCENE_"+juce::String(sceneId)+".png"); + juce::FileOutputStream stream(sceneFile); + assert(stream.openedOk()); + juce::PNGImageFormat format; + assert(format.writeImageToStream(photo,stream)); + stream.flush(); + assert(sceneFile.existsAsFile() && sceneFile.getSize()>10000); + } + editor.reset(); + editorFx->releaseResources(); + sonkuProductIsolation(44100); + sonkuProductIsolation(48000); + nativeParity(44100); + nativeParity(48000); + std::puts("PASS IMERSIP P92 JUCE: exact P9 PCM, 44.1/48k, native state, legacy IMRS, editor, audio ACK"); +} diff --git a/tests/imersip_scene_assets_contract_test.py b/tests/imersip_scene_assets_contract_test.py new file mode 100644 index 000000000..d5ca5b45d --- /dev/null +++ b/tests/imersip_scene_assets_contract_test.py @@ -0,0 +1,73 @@ +# SPDX-License-Identifier: AGPL-3.0-only +"""ImmerSIB scene asset FAT: accept six venues only; reject retired sprite pack.""" +import pathlib +import struct +import unittest + +ROOT=pathlib.Path(__file__).resolve().parents[1] +SCENES=("live_concert","royal_concert_hall","arena_thunder", + "front_row_power","symphonic_palace","velvet_cinema") +ASSET=ROOT/"assets"/"imersip" + +class ApprovedSceneAssets(unittest.TestCase): + def test_six_photo_scene_pngs(self): + expected=sorted(ASSET/"scenes"/f"scene_{name}.png" for name in SCENES) + self.assertEqual(sorted((ASSET/"scenes").glob("*.png")),expected) + for path in expected: + with self.subTest(scene=path.name): + with path.open("rb") as f: + header=f.read(33) + self.assertEqual(header[:8],b"\x89PNG\r\n\x1a\n") + self.assertEqual(header[12:16],b"IHDR") + width,height,depth,colour,compression,filtering,interlace=struct.unpack( + ">IIBBBBB",header[16:29]) + # Exact two-times logical venue viewport: no side matte, + # no independent X/Y stretching, no accidental 2:1 fallback. + self.assertEqual((width,height),(2200,922)) + self.assertEqual(width*461,height*1100) + self.assertEqual(depth,8) + self.assertIn(colour,(2,6)) + self.assertEqual((compression,filtering,interlace),(0,0,0)) + + def test_rejected_kit_and_generation_are_gone(self): + for name in ("png","vector","asset_manifest.json", + "imersip_p92_skin_atlas.png","panel_flat_matte.svg"): + self.assertFalse((ASSET/name).exists(),name) + for path in ( + "scripts/generate_imersip_concert_png.py", + "tests/imersip_p92_png_asset_test.py", + ".github/workflows/imersip-p92-materialize-assets.yml", + "docs/IMERSIP_P92_CONCERT_VECTOR_RENDER_QA.md"): + self.assertFalse((ROOT/path).exists(),path) + + def test_no_compilation_or_ci_resurrection(self): + cmake=(ROOT/"CMakeLists.txt").read_text(encoding="utf-8") + skin=(ROOT/"engine/builtin_fx/ImerSipP92VisualSkin.h").read_text(encoding="utf-8") + editor=(ROOT/"engine/builtin_fx/ImerSipP92Editor.h").read_text(encoding="utf-8") + native_test=(ROOT/"tests/imersip_p92_native_test.cpp").read_text(encoding="utf-8") + workflow=(ROOT/".github/workflows/imersip-p92-single-engine.yml").read_text(encoding="utf-8") + self.assertNotIn("imersipP92ConcertBoxes",native_test) + self.assertIn("stageProbe->getMinimum()",native_test) + self.assertIn("distanceProbe->getMaximum()",native_test) + self.assertIn("ARMIX_IMERSIB_SCENE_PNG_SOURCES",cmake) + self.assertIn("BinaryData::scene_live_concert_png",skin) + self.assertIn("BinaryData::scene_velvet_cinema_png",skin) + self.assertIn("getWidth()!=photoWidth",skin) + self.assertIn("getHeight()!=photoHeight",skin) + self.assertIn("photoWidth=2200",skin) + self.assertIn("photoHeight=922",skin) + self.assertIn("int matteCount=0",native_test) + self.assertIn("assert(matteCount<3",native_test) + self.assertIn("skin_.drawScene(g,visualSceneId_)",editor) + self.assertIn("g.fillRect(0,461,1100,219)",skin) + self.assertIn("drawRotarySlider(",skin) + for forbidden in ("ARMIX_IMERSIP_PNG_SOURCES","assets/imersip/png", + "room_background_png","line_array_left_png", + "knob_master_purple_png","slider_thumb_png"): + self.assertNotIn(forbidden,cmake+skin) + for forbidden in ("19-RGBA-PNG-AssetPack","imersip-png-qa", + "all_speakers_composition","generate_imersip_concert_png", + "pillow>=11","test_19_independent_rgba"): + self.assertNotIn(forbidden,workflow) + +if __name__=="__main__":unittest.main() diff --git a/tests/immersib_p98_native_sonic_gate.cpp b/tests/immersib_p98_native_sonic_gate.cpp new file mode 100644 index 000000000..55022b5e2 --- /dev/null +++ b/tests/immersib_p98_native_sonic_gate.cpp @@ -0,0 +1,428 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// ImmerSIB P9.7 Venue golden PCM and P9.8 typed scene diversification. +// No claim of actual source/stem separation; synthetic PCM verifies physical +// stage retention, stereo non-null, finite peaks, and distinct sonic programs. +#if defined(NDEBUG) +#undef NDEBUG +#endif +#if !defined(SONKU_P98_SCENE_VOICING_RESEARCH) || !SONKU_P98_SCENE_VOICING_RESEARCH +#error This test must compile the REAL P9.8 world-engine path +#endif +#include "../engine/builtin_fx/ImerSipP92Scene.h" +#include +#include +#include +#include // test-only energy aggregation +#include +#include +#include +#include +#include +#include +using armix::sonku::Settings; +using armix::sonku::SonKuSpatialCore; +using armix::sonku::SonKuReflectionProfile; +using armix::builtin_fx::imersipP92Factory; +using armix::builtin_fx::imersipP92Presets; +constexpr int n=16384; +constexpr double pi=3.1415926535897932384626433832795; +struct Result {std::uint64_t hash;double power,side;float peak;}; +static Result render(int rate,const Settings& s,bool phaseReverse=false, + bool immersibP99=false){ + auto dsp=std::make_unique(); +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + if(immersibP99)dsp->optInImmerSIBVocalRoom(); +#else + assert(!immersibP99); +#endif + assert(dsp->prepare(rate,SonKuReflectionProfile::SixSurfaceKemarResearch)); + assert(armix::sonku::valid(s) && dsp->setSettings(s)); + std::array,2> pcm{std::vector(n),std::vector(n)}; + for(int i=0;iprocess(pcm[0].data()+i,pcm[1].data()+i,128); + Result result{14695981039346656037ull,0.,0.,0.f}; + for(int i=0;i=4096){ + result.power+=double(l)*l+double(r)*r; + result.side+=double(l-r)*double(l-r); + } + for(float value:{l,r}){ + result.hash^=std::bit_cast(value); + result.hash*=1099511628211ull; + } + } + assert(result.power>1.e-4 && result.side>1.e-7); +#if defined(SONKU_IMMERSIB_PCM_DIAGNOSTICS) && SONKU_IMMERSIB_PCM_DIAGNOSTICS + const auto diag=dsp->dynamicsTrace(); + assert(diag.samples==n && diag.limitedSamples<=diag.samples); + assert(diag.minimumLimiterGain>0.f && diag.minimumLimiterGain<=1.f); + assert(diag.makeupGainSum>=double(diag.samples)); + if(s.sourceDistanceMeters==1.5f && s.stereoSpreadDegrees==134.f && + s.sceneVoicing==4) { + const double meanMakeup=diag.makeupGainSum/diag.samples; + const double limitedPct=100.*diag.limitedSamples/diag.samples; + std::fprintf(stderr, + "IMMERSIB_DYNAMICS,rate=%d,makeup=%.5f,limited=%.2f%%,minLimiter=%.5f,meanReduction=%.5f\n", + rate,meanMakeup,limitedPct,double(diag.minimumLimiterGain), + diag.limiterReductionSum/diag.samples); + // Real PCM adaptive makeup bound, NOT a claim of perceptual no-pumping. + assert(meanMakeup>=1. && meanMakeup<=1.101); + } +#endif + return result; +} +// Whole-engine tone transfer, including HRTF/world reflections, P9.7 +// stage, P9.8 voicing, P9.5 makeup and peak guard. Real PCM, not just a +// narrow EQ coefficient guess. Short deterministic steady-state fixture. +static double acousticTonePower(int rate,const Settings& scene, + double hz,bool mid,bool immersibP99=false) { + auto dsp=std::make_unique(); +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + if(immersibP99)dsp->optInImmerSIBVocalRoom(); +#else + assert(!immersibP99); +#endif + assert(dsp->prepare(rate,SonKuReflectionProfile::SixSurfaceKemarResearch)); + assert(dsp->setSettings(scene)); + std::array,2> pcm{ + std::vector(n),std::vector(n)}; + for(int i=0;i( + .065*std::sin(2*pi*hz*i/static_cast(rate))); + pcm[0][i]=a; + pcm[1][i]=mid?a:-a; + } + for(int i=0;iprocess(pcm[0].data()+i,pcm[1].data()+i,128); + double energy=0.; + for(int i=4096;i1.e-7); + return energy; +} +static Settings ownerVenue(){ + Settings s{}; + s.renderMode=9; + s.moving=false; + s.startAzimuthDegrees=0.f; + s.spacePreset=3; // Large + s.sourceDistanceMeters=10.f; // actual approved Venue 10m + s.stereoSpreadDegrees=106.f; + s.roomAmount=1.f; + s.ambience=1.f; + s.spatialMix=1.f; + s.outputTrim=1.8f; + s.sceneVoicing=0; // exact P9.7, no P9.8 tonal overlay + return s; +} +int main(){ + const auto venue=armix::builtin_fx::imersipP97VenueGoldenScene(); + const auto current=imersipP92Factory(2); + const auto golden=ownerVenue(); + assert(venue.renderMode==9 && !venue.moving && venue.sceneVoicing==0); + assert(venue.sourceDistanceMeters==10.f && venue.stereoSpreadDegrees==106.f); + assert(venue.roomAmount==1.f && venue.ambience==1.f); + assert(venue.outputTrim==1.8f && venue.spatialMix==1.f); + assert(venue.startAzimuthDegrees==0.f && venue.spacePreset==3); + assert(imersipP92Presets.size()==7); + const auto ownerPreset=imersipP92Factory(8); + assert(ownerPreset.spacePreset==3 && ownerPreset.stereoSpreadDegrees==134.f); + assert(ownerPreset.sourceDistanceMeters==1.5f && ownerPreset.roomAmount==1.70f); + assert(ownerPreset.ambience==.94f && ownerPreset.spatialMix==1.f); + assert(ownerPreset.headYawDegrees==0.f && ownerPreset.hrtfElevationTrimDegrees==0.f); + assert(ownerPreset.sceneVoicing==4); + assert(std::abs(ownerPreset.outputTrim-armix::builtin_fx::imersipP92DbToLinear(4.4f))<1.e-6f); + assert(armix::builtin_fx::validImerSipP92Scene(ownerPreset)); + const auto live=imersipP92Factory(2); + // Make XL grand through a larger room RETURN, not a new HRTF or + // a louder-than-Live output trim. Near-row retains front-vocal focus. + assert(ownerPreset.ambience>live.ambience); + assert(ownerPreset.stereoSpreadDegrees>live.stereoSpreadDegrees); + assert(ownerPreset.sourceDistanceMeters1.f && current.sceneVoicing==4); + assert(armix::builtin_fx::validImerSipP92Scene(current)); + for(const auto& preset:imersipP92Presets) { + const auto s=imersipP92Factory(preset.id); + assert(s.sourceDistanceMeters>=1.1f && s.sourceDistanceMeters<=2.5f); + assert(s.roomAmount>1.f && s.roomAmount<=1.8f); + } + assert(armix::sonku::p98::SceneVoicing::valid(4)); + assert(armix::sonku::p98::SceneVoicing::valid(5)); + assert(!armix::sonku::p98::SceneVoicing::valid(6)); + // Drive the upstream compensation detector into a low-output state. + // The ImmerSIB cap must reduce modulation range, while the legacy cap + // remains available for the immutable Venue and other native voicings. + for(int sr:{44100,48000}) { + armix::sonku::p95::MusicalPresence bounded,legacy; + assert(bounded.prepare(sr) && legacy.prepare(sr)); + for(int i=0;i=1.f && bounded.gain()<=1.1001f); + assert(legacy.gain()>1.20f && legacy.gain()<=1.6501f); + } + // Product scene classification: preserve original Venue golden; new + // detail and impact voicings must NEVER silently affect its PCM. + constexpr int expectedProfiles[]{4,4,5,4,4,3,4}; + for(std::size_t i=0;idouble { + armix::sonku::p98::SceneVoicing fx; + assert(fx.prepare(sr)); + double power=0.; + for(int i=0;i<12000;++i){ + const float v=.10f*std::sin(2*pi*hz*i/double(sr)); + const auto out=fx.source(v,mono?v:-v,scene,true); + assert(std::isfinite(out.left)&&std::isfinite(out.right)); + if(mono)assert(std::abs(out.left-out.right)<1.e-7f); + if(i>=7000){ + const double side=.5*(out.left-out.right); + power+=side*side; + } + } + return power; + }; + const double baselinePresence=spectrum(rate,0,2050,false); + const double protectedPresence=spectrum(rate,4,2050,false); + const double baselineEdge=spectrum(rate,0,3450,false); + const double protectedEdge=spectrum(rate,4,3450,false); + const double baselineAir=spectrum(rate,0,7400,false); + const double lateralAir=spectrum(rate,4,7400,false); + assert(protectedPresence7k stereo is retained. + assert(protectedEdgebaselineAir*.75 && + lateralAirdouble { + armix::sonku::p98::SceneVoicing fx; + assert(fx.prepare(sr)); + double energy=0.; + for(int i=0;i<16000;++i) { + (void)fx.source(0.f,0.f,scene,true); + const float v=.10f*std::sin(2*pi*hz*i/double(sr)); + const auto reflected=fx.early(v,mono?v:-v); + assert(std::isfinite(reflected.left)&&std::isfinite(reflected.right)); + if(mono)assert(std::abs(reflected.left-reflected.right)<1.e-6f); + if(i>=9000) { + const double side=.5*(reflected.left-reflected.right); + energy+=side*side; + } + } + return energy; + }; + const double firstAir=earlySide(rate,0,7400,false); + const double warmAir=earlySide(rate,4,7400,false); + const double impactAir=earlySide(rate,5,7400,false); + const double firstMid=earlySide(rate,0,1500,false); + const double warmMid=earlySide(rate,4,1500,false); + const double airLift=warmAir/firstAir; + const double midLift=warmMid/firstMid; + std::fprintf(stderr, + "IMMERSIB_EARLY_LATERAL,rate=%d,air=%.4f,impact=%.4f,mid=%.4f\n", + rate,airLift,impactAir/firstAir,midLift); + assert(airLift>1.15 && airLift<1.80); + assert(impactAir>firstAir*1.10 && impactAirdouble{ + armix::sonku::p98::SceneVoicing fx; + assert(fx.prepare(sr)); + double energy=0.; + for(int i=0;i<12000;++i){ + const float v=.10f*std::sin(2*pi*hz*i/double(sr)); + auto out=fx.source(v,v,scene,true); + if(final)out=fx.finish(out.left,out.right); + assert(std::isfinite(out.left)&&std::isfinite(out.right)); + assert(std::abs(out.left-out.right)<1.e-7f); + if(i>=7000){ + const double mid=.5*(out.left+out.right); + energy+=mid*mid; + } + } + return energy; + }; + const double bodyReference=centeredEnergy(rate,0,285,false); + const double bodyFull=centeredEnergy(rate,4,285,false); + const double noseReference=centeredEnergy(rate,0,2050,false); + const double noseFull=centeredEnergy(rate,4,2050,false); + const double harshReference=centeredEnergy(rate,0,3450,true); + const double harshControlled=centeredEnergy(rate,4,3450,true); + // Genuine center body improvement, not a 2k-only megaphone: + assert(bodyFull>bodyReference*1.20); + assert(noseFull1.08); + assert(edgeRatio<1.05); + assert(airRatio>.65); + } +#if defined(SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH) && SONKU_IMMERSIB_P99_VOCAL_ROOM_RESEARCH + // Whole KEMAR/room/limiter A/B: older P9.8 with no opt-in remains + // a fixed comparison, not a second processing graph. + for(int id:{2,4,8}) { + const auto warm=imersipP92Factory(id); + const auto before=render(rate,warm); + const auto after=render(rate,warm,false,true); + assert(before.hash!=after.hash); + const double ratio=after.power/before.power; + std::fprintf(stderr, + "IMMERSIB_P99_VOCAL_AB,rate=%d,id=%d,powerRatio=%.5f,sideRatio=%.5f,peak=%.5f\n", + rate,id,ratio,after.side/before.side,double(after.peak)); + assert(ratio>.80 && ratio<1.36); + assert(after.peak<=.9805f); + const double chest0=acousticTonePower(rate,warm,330.,true); + const double chest1=acousticTonePower(rate,warm,330.,true,true); + const double bass0=acousticTonePower(rate,warm,86.,true); + const double bass1=acousticTonePower(rate,warm,86.,true,true); + const double high0=acousticTonePower(rate,warm,7600.,true); + const double high1=acousticTonePower(rate,warm,7600.,true,true); + const double chest=chest1/chest0; + const double bass=bass1/bass0; + const double high=high1/high0; + std::fprintf(stderr, + "IMMERSIB_P99_TONAL_AB,rate=%d,id=%d,chest=%.5f,bass=%.5f,high=%.5f\n", + rate,id,chest,bass,high); + assert(chest>1.0001 && chest<1.35); + assert(bass>.87 && bass<1.13); + assert(high>.88 && high<1.12); + auto off=warm;off.spacePreset=0;off.roomAmount=0.f;off.ambience=0.f; + assert(render(rate,off).hash==render(rate,off,false,true).hash); + auto noMix=warm;noMix.spatialMix=0.f; + assert(render(rate,noMix).hash==render(rate,noMix,false,true).hash); + auto neutral=warm;neutral.sceneVoicing=0; + assert(render(rate,neutral).hash==render(rate,neutral,false,true).hash); + } + assert(render(rate,golden).hash==render(rate,golden,false,true).hash); +#endif + // Historical owner Custom screenshot is a valid private audio + // control reference, not a shipped preset or frozen Venue. + auto oldFront=ownerPreset; + oldFront.stereoSpreadDegrees=147.f; + oldFront.sourceDistanceMeters=1.1f; + oldFront.roomAmount=1.8f; + oldFront.ambience=.60f; + oldFront.outputTrim=armix::builtin_fx::imersipP92DbToLinear(2.5f); + const auto oldFrontPcm=render(rate,oldFront); + const auto updatedFrontPcm=render(rate,ownerPreset); + assert(updatedFrontPcm.hash!=oldFrontPcm.hash); + std::fprintf(stderr, + "IMMERSIB_FRONT_ROW_A_B,rate=%d,oldEnergy=%.5f,newEnergy=%.5f,oldSide=%.5f,newSide=%.5f,oldPeak=%.5f,newPeak=%.5f\\n", + rate,oldFrontPcm.power,updatedFrontPcm.power, + oldFrontPcm.side,updatedFrontPcm.side, + double(oldFrontPcm.peak),double(updatedFrontPcm.peak)); + // Electrical guard only: the spatial balance and subjective + // majesty still require level-matched headphone A/B. + assert(updatedFrontPcm.power>oldFrontPcm.power*.90); + const auto base=render(rate,golden); + // Baseline acoustic PCM hashes captured BEFORE any ImmerSIB + // nearfield or M/S tuning. Real regression, not self-comparison. + assert(base.hash==(rate==44100?0x4759c0c588e0e421ull: + 0x13a8e95368edcc04ull)); + const auto migrated=render(rate,venue); + // The operator's approved Venue is a bit-exact audio checkpoint. + assert(base.hash==migrated.hash); + std::array uniquePcm{}; + for(const auto& preset:imersipP92Presets){ + const auto s=imersipP92Factory(preset.id); + assert(s.renderMode==9 && !s.moving); + assert(s.spacePreset==3 && s.sourceDistanceMeters<=2.5f); + const auto heard=render(rate,s); + const auto inverse=render(rate,s,true); + assert(inverse.side>1.e-7); // no catastrophic antiphase null + assert(heard.hash!=base.hash); + // Always print candidate evidence BEFORE its quality floor; + // std::cout/stdout may be buffered and lost by abort(). + std::fprintf(stderr,"NEARFIELD_DIAG,rate=%d,id=%d,meters=%.2f,early=%.2f,energy=%.6f,venue=%.6f,side=%.6f,peak=%.5f\n", + rate,preset.id,s.sourceDistanceMeters,s.roomAmount, + heard.power,base.power,heard.side,double(heard.peak)); + // Safety floor only: older .85 electrical power gate + // rewarded treble-heavy sound even when the owner heard + // shrill, thin vocals. The independent WHOLE-PCM 285Hz/3.45k + // tonal tests above replace it with a physically appropriate + // transfer quality criterion. Still forbid silent presets. + if(preset.id==8) { + // The owner deliberately selected +2.5dB rather than the + // +5.1dB archived Venue trim. Equalize electrical output + // trim for this energy-only *diagnostic*, not for the PCM + // render or production gain. This does not equate to LUFS. + const double matchedPower=heard.power* + (double(golden.outputTrim)*golden.outputTrim)/ + (double(s.outputTrim)*s.outputTrim); + std::fprintf(stderr, + "OWNER_XL_GAIN_MATCH,rate=%d,raw=%.6f,matched=%.6f,venue=%.6f\\n", + rate,heard.power,matchedPower,base.power); + assert(matchedPower>base.power*.70); + }else { + assert(heard.power>base.power*.70); + } + uniquePcm[static_cast(preset.id-2)]=heard.hash; + std::printf("IMMERSIB_P98_SCENE,%d,%d,%s,%d,%.6f,%.6f,%.6f,%016llx\n", + rate,preset.id,preset.label,s.sceneVoicing, + heard.power,heard.side,double(heard.peak), + static_cast(heard.hash)); + } + // Every user-facing scene is a physically distinct PCM program. + for(std::size_t i=0;i +#include + +int main(){ + const auto instance=::GetModuleHandleW(nullptr); + WNDCLASSW cls{}; + cls.lpfnWndProc=::DefWindowProcW; + cls.hInstance=instance; + cls.lpszClassName=L"ArSonMixOwnedFxRegression"; + assert(::RegisterClassW(&cls)!=0); + constexpr DWORD style=WS_OVERLAPPEDWINDOW; + auto mixer=::CreateWindowExW(0,cls.lpszClassName,L"Mixer",style, + 100,100,650,470,nullptr,nullptr,instance,nullptr); + auto popup=::CreateWindowExW(0,cls.lpszClassName,L"Native FX",style, + 200,180,420,300,nullptr,nullptr,instance,nullptr); + auto alternate=::CreateWindowExW(0,cls.lpszClassName,L"Unrelated",style, + 240,210,200,140,nullptr,nullptr,instance,nullptr); + assert(mixer && popup && alternate); + assert(::GetWindow(popup,GW_OWNER)==nullptr); + assert(armix::ui::win32::attachOwnedPopup(popup,mixer)); + assert(::GetWindow(popup,GW_OWNER)==mixer); + armix::ui::win32::preferDarkTitleBar(popup); // graceful if OS DWM unsupported + // Repeated open has no owner churn, even when hidden and shown again. + assert(armix::ui::win32::attachOwnedPopup(popup,mixer)); + ::ShowWindow(popup,SW_HIDE); + ::ShowWindow(popup,SW_SHOWNOACTIVATE); + assert(armix::ui::win32::attachOwnedPopup(popup,mixer)); + assert(::GetWindow(popup,GW_OWNER)==mixer); + assert((::GetWindowLongPtrW(popup,GWL_STYLE)&WS_CHILD)==0); + assert((::GetWindowLongPtrW(popup,GWL_EXSTYLE)&WS_EX_TOPMOST)==0); + assert(::GetAncestor(popup,GA_ROOT)==popup); + assert(::GetWindow(alternate,GW_OWNER)==nullptr); + assert(!armix::ui::win32::attachOwnedPopup(popup,popup)); + assert(!armix::ui::win32::attachOwnedPopup(nullptr,mixer)); + assert(::GetWindow(popup,GW_OWNER)==mixer); + ::DestroyWindow(popup); + ::DestroyWindow(alternate); + ::DestroyWindow(mixer); + ::UnregisterClassW(cls.lpszClassName,instance); + std::puts("PASS: FX HWND owned by mixer, reusable after hide, never system TOPMOST"); +} diff --git a/tests/native_fx_window_lifecycle_contract_test.py b/tests/native_fx_window_lifecycle_contract_test.py new file mode 100644 index 000000000..7d23b6de3 --- /dev/null +++ b/tests/native_fx_window_lifecycle_contract_test.py @@ -0,0 +1,40 @@ +# SPDX-License-Identifier: AGPL-3.0-only +"""Fast source contract for *all* three native editor entrypoints.""" +from pathlib import Path +import unittest +ROOT=Path(__file__).resolve().parents[1] +HOST=(ROOT/"src/Main.cpp").read_text(encoding="utf-8") +OWNER=(ROOT/"src/NativeOwnedFloatingWindow.h").read_text(encoding="utf-8") +WIN32=(ROOT/"src/NativeFxWin32Owner.h").read_text(encoding="utf-8") + +class NativeFxWindowLifecycle(unittest.TestCase): + def test_mixer_owned_not_global_topmost(self): + self.assertIn("attachOwnedFloatingWindow (*this, mixer)",HOST) + self.assertIn("attachOwnedFloatingWindow",OWNER) + self.assertIn("win32::attachOwnedPopup",OWNER) + self.assertIn("GWLP_HWNDPARENT",WIN32) + self.assertIn("GW_OWNER",WIN32) + self.assertIn("WS_CHILD",WIN32) + self.assertNotIn("WS_EX_TOPMOST",WIN32) + self.assertNotIn("::SetParent(",WIN32) + self.assertNotIn("setAlwaysOnTop (true)",HOST) + def test_exact_native_instance_reopen_is_not_recreation(self): + self.assertIn("routedEditorOwner_==owner",HOST) + self.assertIn("editorProcessor_==owner->processor.get()",HOST) + self.assertIn("editorWindow_->present()",HOST) + self.assertIn("if(logicalVendorEditor_)",HOST) + self.assertIn("existing.window->present()",HOST) + self.assertIn("editorProcessor_ == processor",HOST) + self.assertIn("if (!isVisible()) setVisible (true)",HOST) + self.assertIn("toFront (true)",HOST) + self.assertIn("editorWindow_.reset();",HOST) + self.assertIn("routedEditorOwner_.reset();",HOST) + self.assertIn("editorProcessor_=nullptr;",HOST) + def test_all_editor_paths_use_one_host(self): + self.assertEqual(HOST.count("std::make_unique"),3) + self.assertIn("prepared.processor->getName(),editor,*this)",HOST) + self.assertIn("owner->processor->getName(),editor,*this)",HOST) + self.assertIn("processor->getName(), editor, *this",HOST) + self.assertIn("std::make_unique",HOST) + self.assertIn("}, *safe);",HOST) +if __name__=="__main__":unittest.main() diff --git a/tests/native_fx_window_owner/CMakeLists.txt b/tests/native_fx_window_owner/CMakeLists.txt new file mode 100644 index 000000000..834064582 --- /dev/null +++ b/tests/native_fx_window_owner/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.20) +project(ArSonMixNativeFxWindowOwnerTests LANGUAGES CXX) +if(NOT WIN32) + message(FATAL_ERROR "This isolated HWND FAT is Windows-only") +endif() +enable_testing() +add_executable(ArSonMixOwnedFxWindowTest ../native_fx_win32_owner_test.cpp) +target_compile_features(ArSonMixOwnedFxWindowTest PRIVATE cxx_std_20) +target_link_libraries(ArSonMixOwnedFxWindowTest PRIVATE user32 dwmapi) +if(MSVC) + target_compile_options(ArSonMixOwnedFxWindowTest PRIVATE /W4 /WX) +endif() +add_test(NAME NativeFxOwnedWindowNotGlobalTopmostAndReopens + COMMAND ArSonMixOwnedFxWindowTest) diff --git a/tests/release_ci_dispatch_contract.test.mjs b/tests/release_ci_dispatch_contract.test.mjs index adcd207e1..ab2a3411d 100644 --- a/tests/release_ci_dispatch_contract.test.mjs +++ b/tests/release_ci_dispatch_contract.test.mjs @@ -55,6 +55,9 @@ test('Verified release tag is stamped into the native window, not a fake version const configure=workflow.split(' - name: Configure release application')[1] ?.split(' - name: Build release application only')[0]||''; assert.match(configure, /-DARMIX_RELEASE_TAG="\$env:ARMIX_RELEASE_TAG"/); + assert.match(configure, /-DARMIX_IMMERSIB_RELEASE_CANDIDATE=ON/); + assert.match(configure, /-DARMIX_SONKU_APPROVED_P99_MAIN=ON/); + assert.match(configure, /PUBLIC_SPATIAL_FX_RELEASE_FLAG_MISSING/); assert.match(cmake, /set\(ARMIX_RELEASE_TAG "" CACHE STRING/); assert.match(cmake, /if\(NOT ARMIX_RELEASE_TAG MATCHES/); assert.match(cmake, /ARMIX_RELEASE_TAG_PATTERN/); diff --git a/tests/sonku_native_state_test.cpp b/tests/sonku_native_state_test.cpp index 0bc2bfe99..c0b3bf1a5 100644 --- a/tests/sonku_native_state_test.cpp +++ b/tests/sonku_native_state_test.cpp @@ -9,19 +9,23 @@ #include #include #include +#include +#include int main(){ using armix::builtin_fx::SonKuSpatialProcessor; - SonKuSpatialProcessor live; - live.prepareToPlay(48000.,128); - assert(live.isReady()); + // The processor owns large reverb/room buffers. Multiple native FX + // must not exhaust the default Windows test-process stack. + auto live=std::make_unique(); + live->prepareToPlay(48000.,128); + assert(live->isReady()); #if defined(ARMIX_SONKU_EXPERIMENTAL_DIRECTIONAL_RT) && ARMIX_SONKU_EXPERIMENTAL_DIRECTIONAL_RT - assert(live.preparedReflectionProfile()== + assert(live->preparedReflectionProfile()== armix::sonku::SonKuReflectionProfile::DirectionalKemar); #else - assert(live.preparedReflectionProfile()== + assert(live->preparedReflectionProfile()== armix::sonku::SonKuReflectionProfile::Lightweight); #endif - auto scene=live.acceptedSettings(); + auto scene=live->acceptedSettings(); assert(scene.spacePreset==0); // legacy samples always load with ROOM OFF scene.spacePreset=2;scene.sourceDistanceMeters=5.f; scene.roomAmount=.55f;scene.ambience=.30f; @@ -37,35 +41,55 @@ int main(){ incompatible.getDynamicObject()->setProperty("directElevationDegrees",0.f); assert(!decodeSettings(incompatible,decoded)); assert(decoded.spacePreset==2); - assert(live.queueSettings(scene,42)); + // The shared native core accepts 1.1 m for ImmerSIB, but a normal + // production SonKu build must reject it at both JS and PCM gates. + auto rejectedNear=scene; + rejectedNear.sourceDistanceMeters=1.1f; + assert(armix::sonku::valid(rejectedNear)); + assert(!armix::sonku::valid8DSonKuInsertSettings(rejectedNear)); + assert(!decodeSettings(acceptedSettings(rejectedNear),decoded)); + assert(!live->queueSettings(rejectedNear,41)); + assert(live->queueSettings(scene,42)); // Queued does NOT mean accepted; only the actual PCM callback may apply. - assert(live.acceptedSettings().spacePreset==0); + assert(live->acceptedSettings().spacePreset==0); juce::AudioBuffer audio(2,128); juce::MidiBuffer midi; audio.clear(); audio.getWritePointer(0)[0]=.1f; audio.getWritePointer(1)[0]=.1f; - live.processBlock(audio,midi); + live->processBlock(audio,midi); SonKuSpatialProcessor::Completion ack{}; - assert(live.pollCompletion(ack) && ack.applied && ack.requestId==42); - assert(live.acceptedSettings().spacePreset==2); - assert(live.acceptedSettings().sourceDistanceMeters==5.f); + assert(live->pollCompletion(ack) && ack.applied && ack.requestId==42); + assert(live->acceptedSettings().spacePreset==2); + assert(live->acceptedSettings().sourceDistanceMeters==5.f); for(int c=0;c<2;++c) for(int i=0;i<128;++i)assert(std::isfinite(audio.getSample(c,i))); juce::MemoryBlock bytes; - live.getStateInformation(bytes); + live->getStateInformation(bytes); assert(bytes.getSize()==46); - SonKuSpatialProcessor restored; - restored.prepareToPlay(48000.,128); - assert(restored.preparedReflectionProfile()==live.preparedReflectionProfile()); - assert(restored.restoreUnpublishedState(bytes.getData(), + auto forgedNear=bytes; + const float imersibNear=1.1f; + std::memcpy(static_cast(forgedNear.getData())+34, + &imersibNear,sizeof(imersibNear)); + // The processor owns large reverb/room buffers. Multiple native FX + // must not exhaust the default Windows test-process stack. + auto forbidden=std::make_unique(); + assert(!forbidden->restoreUnpublishedState( + forgedNear.getData(),static_cast(forgedNear.getSize()))); + assert(forbidden->acceptedSettings().sourceDistanceMeters==1.6f); + // The processor owns large reverb/room buffers. Multiple native FX + // must not exhaust the default Windows test-process stack. + auto restored=std::make_unique(); + restored->prepareToPlay(48000.,128); + assert(restored->preparedReflectionProfile()==live->preparedReflectionProfile()); + assert(restored->restoreUnpublishedState(bytes.getData(), static_cast(bytes.getSize()))); - const auto got=restored.acceptedSettings(); + const auto got=restored->acceptedSettings(); assert(got.spacePreset==2&&got.sourceDistanceMeters==5.f); assert(got.roomAmount==.55f&&got.ambience==.30f); - assert(restored.getTailLengthSeconds()>=2.); + assert(restored->getTailLengthSeconds()>=2.); audio.clear();audio.getWritePointer(0)[0]=.1f; - restored.processBlock(audio,midi); + restored->processBlock(audio,midi); for(int c=0;c<2;++c) for(int i=0;i<128;++i)assert(std::isfinite(audio.getSample(c,i))); // Strict v1 binary payload: SONK, v1, five floats and two bool bytes. @@ -76,21 +100,25 @@ int main(){ out.writeFloat(1.f);out.writeFloat(.75f); out.writeByte(1);out.writeByte(1);} assert(legacy.getSize()==30); - SonKuSpatialProcessor older; - older.prepareToPlay(48000.,128); - assert(older.restoreUnpublishedState(legacy.getData(),30)); - assert(older.acceptedSettings().spacePreset==0); - assert(!older.restoreUnpublishedState(legacy.getData(),29)); + // The processor owns large reverb/room buffers. Multiple native FX + // must not exhaust the default Windows test-process stack. + auto older=std::make_unique(); + older->prepareToPlay(48000.,128); + assert(older->restoreUnpublishedState(legacy.getData(),30)); + assert(older->acceptedSettings().spacePreset==0); + assert(!older->restoreUnpublishedState(legacy.getData(),29)); juce::MemoryBlock invalid=bytes; auto* data=static_cast(invalid.getData()); // Space preset starts at byte offset 30: reject out-of-range v2 schema. data[30]=99;data[31]=data[32]=data[33]=0; - SonKuSpatialProcessor bad; - bad.prepareToPlay(48000.,128); - assert(!bad.restoreUnpublishedState(invalid.getData(),46)); - assert(bad.acceptedSettings().spacePreset==0); + // The processor owns large reverb/room buffers. Multiple native FX + // must not exhaust the default Windows test-process stack. + auto bad=std::make_unique(); + bad->prepareToPlay(48000.,128); + assert(!bad->restoreUnpublishedState(invalid.getData(),46)); + assert(bad->acceptedSettings().spacePreset==0); // Stale/completed active buffers may not be used as a published restore. - restored.sealForRealtime(); - assert(!restored.restoreUnpublishedState(bytes.getData(),46)); + restored->sealForRealtime(); + assert(!restored->restoreUnpublishedState(bytes.getData(),46)); return 0; } diff --git a/tests/windows_installer_contract_test.mjs b/tests/windows_installer_contract_test.mjs index 232438ea7..b8add8e1d 100644 --- a/tests/windows_installer_contract_test.mjs +++ b/tests/windows_installer_contract_test.mjs @@ -19,7 +19,8 @@ test('per-user Inno Setup upgrades the same app and retains private Studio data' 'DisableWelcomePage=yes', 'DisableDirPage=yes', 'DisableReadyPage=yes', 'DisableFinishedPage=yes', 'SetupMutex=ArSonMix.PerUserInstaller.SingleInstance', - 'Preview', 'verified-gui.exe', 'BUILD_PROVENANCE.json' + 'Preview', 'verified-gui.exe', 'BUILD_PROVENANCE.json', + 'THIRD_PARTY_8D_SONKU_HRTF.md' ]) assert.ok(iss.includes(item), item); assert.doesNotMatch(iss, /^\[UninstallDelete\]/m); @@ -27,6 +28,8 @@ test('per-user Inno Setup upgrades the same app and retains private Studio data' assert.doesNotMatch(iss, /taskkill|Stop-Process|TerminateProcess|CloseApplications=force/i); assert.match(iss, /Name: "\{autoprograms\}\\ArSonMix"/); assert.match(iss, /FactoryFX\\\*.*skipifsourcedoesntexist/); + assert.match(ps, /Installed third-party KEMAR\/MIT notice missing or altered/); + assert.match(ps, /THIRD_PARTY_8D_SONKU_HRTF\.md/); }); test('official standard VB-CABLE ZIP is pinned and checked automatically without elevating ArSonMix', () => { diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index f9d0b8e29..e645717af 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -598,11 +598,14 @@ // structural graph change. Updating them must not replace DOM strips, // steal focus, interrupt a fader drag or reallocate WIRE render objects. // The verified individual bypass flag stays distinct from rack bypass. - function paintNativeFxPowerReadback(ch,t){ - if(typeof ch.fxRackBypassed!=="boolean"||!Array.isArray(ch.inserts)) + function paintNativeFxPowerReadback(ch,t,globalFxBypassed){ + if(typeof ch.fxRackBypassed!=="boolean"||!Array.isArray(ch.inserts)|| + typeof globalFxBypassed!=="boolean") return true; // never synthesize missing DSP readback const enabled=!ch.fxRackBypassed; - const globalEnabled=document.querySelector('.console-body')?.classList.contains('global-fx-bypassed')!==true; + // Read the SAME accepted native PCM snapshot as every slot, not a + // CSS class from the PREVIOUS browser render frame. + const globalEnabled=!globalFxBypassed; const strip=document.querySelector('.strip[data-id="'+t.id+'"]'); // GAIN/SOF are alternate views of the FX area; power readback still // updates the model but must not rebuild the rack or steal knob focus. @@ -753,7 +756,7 @@ const t=id===scope?.master?.id?scope.master: scope?.tracks?.find(x=>x.id===id); if(!t||!ch.controls)continue; - if(!paintNativeFxPowerReadback(ch,t)){ + if(!paintNativeFxPowerReadback(ch,t,next.raw?.globalFxBypassed)){ // A plugin owner or strip DOM changed under us: do not paint an // unrelated instance. Rebuild from the accepted native graph. if(!projection(next))return false; @@ -2979,8 +2982,13 @@ } // Control readback may change at the SAME structural graph revision. // Compare the actual accepted controls/edges, never skip native fader updates. - const signature=next.identity+"|"+JSON.stringify(next.graph.channels.map(ch=>[ - ch.id,ch.controls,ch.inserts,ch.fxRackBypassed,ch.primaryOutId]))+"|"+JSON.stringify(next.graph.edges)+"|"+appearanceRevision; + // GLOBAL A/B is a realtime SCALAR with unchanged graph revision and + // unchanged saved insert flags. Include its accepted PCM readback so + // bypassing every FX repaints each mounted rack without rebuilding DOM. + const signature=next.identity+"|"+String(next.raw?.globalFxBypassed)+"|"+ + JSON.stringify(next.graph.channels.map(ch=>[ + ch.id,ch.controls,ch.inserts,ch.fxRackBypassed,ch.primaryOutId]))+"|"+ + JSON.stringify(next.graph.edges)+"|"+appearanceRevision; if (signature===lastPaintedSignature) { // Telemetry-only snapshots should not traverse all channels. But an // expired/rejected edit with unchanged graph values must not strand its