Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .github/workflows/p1-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,18 @@ jobs:
if [[ "${{ github.head_ref }}" == feat/sonku-p95-* ]]; then
g++ $FLAGS -DSONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1 -DSONKU_P95_MUSICAL_PRESENCE_RESEARCH=1 tests/sonku_p95_musical_presence_source_test.cpp -o /tmp/sonku-p95
/tmp/sonku-p95
if [[ "${{ github.head_ref }}" == feat/sonku-p95-p96-* ]]; then
g++ -std=c++20 -O2 -Wall -Wextra -Werror -pedantic tests/sonku_p96_distance_reinforcement_source_test.cpp -o /tmp/sonku-p96-bands
/tmp/sonku-p96-bands
g++ $FLAGS -DSONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1 -DSONKU_P95_MUSICAL_PRESENCE_RESEARCH=1 -DSONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH=1 tests/sonku_p95_musical_presence_source_test.cpp -o /tmp/sonku-p96-full
/tmp/sonku-p96-full
g++ $FLAGS -DSONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1 -DSONKU_P95_MUSICAL_PRESENCE_RESEARCH=1 tests/sonku_p96_integrated_bands_test.cpp -o /tmp/sonku-p96-reference
/tmp/sonku-p96-reference > /tmp/sonku-p96-reference.csv
g++ $FLAGS -DSONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1 -DSONKU_P95_MUSICAL_PRESENCE_RESEARCH=1 -DSONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH=1 tests/sonku_p96_integrated_bands_test.cpp -o /tmp/sonku-p96-candidate
/tmp/sonku-p96-candidate > /tmp/sonku-p96-candidate.csv
cat /tmp/sonku-p96-reference.csv /tmp/sonku-p96-candidate.csv
python3 scripts/verify_sonku_p96_bands.py /tmp/sonku-p96-reference.csv /tmp/sonku-p96-candidate.csv
fi
fi
g++ $FLAGS tests/sonku_p89_stereo_room_depth_source_test.cpp -o /tmp/sonku-p89
/tmp/sonku-p89
Expand Down Expand Up @@ -718,6 +730,7 @@ jobs:
shell: pwsh
run: |
$p95flag = if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-*') { 'ON' } else { 'OFF' }
$p96flag = if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-p96-*') { 'ON' } else { 'OFF' }
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" `
Expand All @@ -735,6 +748,7 @@ jobs:
-DARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT=ON `
-DARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH=ON `
-DARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE=$p95flag `
-DARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT=$p96flag `
-DBUILD_TESTING=ON
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
$cache = Get-Content build/CMakeCache.txt -Raw
Expand All @@ -749,13 +763,15 @@ jobs:
run: |
$targets = @('ARMixSonKuP94SourceTests','ARMixSonKuP94ReferenceTests','ARMixSonKuP91P92MusicBassTests','ARMixSonKuP90NativeTests','ARMixSonKuP90SourceTests','ARMixSonKuP89NativeTests','ARMixSonKuP89SourceTests','ARMixConsole')
if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-*') { $targets += 'ARMixSonKuP95MusicTests' }
if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-p96-*') { $targets += 'ARMixSonKuP96DistanceTests' }
cmake --build build --config Release --parallel 2 --target $targets
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
if (-not (Test-Path -LiteralPath 'build/ARMixConsole_artefacts/Release/AR MIX Studio.exe' -PathType Leaf)) {
throw 'SONKU_P90_NATIVE_GUI_EXE_MISSING'
}
$tests = '^NativeSonKuP(89RoomAnchoredStereoAndP88GoldenParity|89JuceV10AppliedAckAndV9Restore|90StereoExternalizationSource|90JuceV11AppliedAckAndLegacyRestore|91P92MusicFidelityWorldBassAndRoom|94FrontBackDepthA_BSource|94LevelMatchedAB'
if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-*') { $tests += '|95MusicPresenceVenue' }
if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-p96-*') { $tests += '|96DistanceBassAndTrebleRetention' }
$tests += ')$'
ctest --test-dir build -C Release --output-on-failure -R $tests
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Expand All @@ -774,13 +790,16 @@ jobs:
Copy-Item docs/SONKU_P94_FRONT_REAR_EXTERNALIZATION_FAT_20261116.md dist/SONKU_P94_FRONT_REAR_FAT.md
if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-*') {
Copy-Item docs/SONKU_P95_IMMERSIVE_MUSIC_VENUE_FAT_20261116.md dist/SONKU_P95_MUSIC_VENUE_FAT.md
if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-p96-*') {
Copy-Item docs/SONKU_P96_DISTANCE_REINFORCEMENT_FAT_20261116.md dist/SONKU_P96_DISTANCE_FAT.md
}
}
$provenance = Get-Content -LiteralPath dist/BUILD_PROVENANCE.json -Raw | ConvertFrom-Json
if ($provenance.sourceCommit -ne (git rev-parse HEAD).Trim()) {
throw 'SONKU_P90_SOURCE_COMMIT_MISMATCH'
}
$provenance | Add-Member -Force -NotePropertyName sonkuExperiment -NotePropertyValue @{
mode = if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-*') { 'P9.5_IMMERSIVE_MUSIC_VENUE_FOUNDATION' } else { 'P9.4_FRONT_REAR_DEPTH_EXPERIMENT' }
mode = if ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-p96-*') { 'P9.6_STAGE_BASS_AIR_DISTANCE_RESEARCH' } elseif ($env:GITHUB_HEAD_REF -like 'feat/sonku-p95-*') { 'P9.5_IMMERSIVE_MUSIC_VENUE_FOUNDATION' } else { 'P9.4_FRONT_REAR_DEPTH_EXPERIMENT' }
stateSchema = 11
headphoneFat = 'PENDING'
publicRelease = $false
Expand Down
21 changes: 19 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ if(ARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE AND
NOT ARMIX_SONKU_EXPERIMENTAL_P90_NATIVE_RT)
message(FATAL_ERROR "P9.5 requires P9 measured spatial engine")
endif()
# Private stage-speaker reinforcement, isolated from P9.5 production.
option(ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT
"Private P9.6 stage-speaker LF/HF distance retention over 2m" OFF)
if(ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT AND
NOT ARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE)
message(FATAL_ERROR "P9.6 requires P9.5 musical presence and P9 world speaker")
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Expand Down Expand Up @@ -330,7 +337,9 @@ target_compile_definitions(ARMixConsole PRIVATE
$<$<BOOL:${ARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH}>:SONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1>
$<$<BOOL:${ARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH}>:ARMIX_SONKU_EXPERIMENTAL_P94_FRONT_BACK_DEPTH=1>
$<$<BOOL:${ARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE}>:ARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE=1>
$<$<BOOL:${ARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE}>:SONKU_P95_MUSICAL_PRESENCE_RESEARCH=1>)
$<$<BOOL:${ARMIX_SONKU_EXPERIMENTAL_P95_MUSICAL_PRESENCE}>:SONKU_P95_MUSICAL_PRESENCE_RESEARCH=1>
$<$<BOOL:${ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT}>:SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH=1>
$<$<BOOL:${ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT}>:ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT=1>)
if(WIN32)
# Windows retains its proven ASIO-first / WASAPI / static WebView2 distribution.
# Never link Windows loader or sound APIs into macOS/Linux builds.
Expand Down Expand Up @@ -864,10 +873,18 @@ if(BUILD_TESTING)
target_compile_definitions(ARMixSonKuP95MusicTests PRIVATE
$<TARGET_PROPERTY:ARMixSonKuP91P92MusicBassTests,COMPILE_DEFINITIONS>
SONKU_P94_FRONT_BACK_DEPTH_RESEARCH=1
SONKU_P95_MUSICAL_PRESENCE_RESEARCH=1)
SONKU_P95_MUSICAL_PRESENCE_RESEARCH=1
$<$<BOOL:${ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT}>:SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH=1>)
add_test(NAME NativeSonKuP95MusicPresenceVenue
COMMAND ARMixSonKuP95MusicTests)
endif()
if(ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT)
add_executable(ARMixSonKuP96DistanceTests
tests/sonku_p96_distance_reinforcement_source_test.cpp)
target_compile_features(ARMixSonKuP96DistanceTests PRIVATE cxx_std_20)
add_test(NAME NativeSonKuP96DistanceBassAndTrebleRetention
COMMAND ARMixSonKuP96DistanceTests)
endif()
juce_add_console_app(ARMixSonKuP90NativeTests
PRODUCT_NAME "ArSonMix SonKu P90 JUCE v11 State Tests")
target_sources(ARMixSonKuP90NativeTests PRIVATE
Expand Down
25 changes: 25 additions & 0 deletions docs/SONKU_P96_DISTANCE_REINFORCEMENT_FAT_20261116.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SonKu P9.6 — Distance Without Losing Bass & Air (PRIVATE FAT, 2026-11-16)

**Research branch, not approved sound, no public release.** Child of P9.5 PR #725 exact head b895d92c1706ab0e098bfe49447fa7b83058f865. Do not merge competing P9.5 #724 changes or alter frozen operator-approved P9.1/P9.2 checkpoint 763706a1. Preserve approved visual ellipse and P9.5 bypass/GUI fixes.

## Proven source root cause

In native P9 mode 9, with ROOM enabled, the complete direct KEMAR ear pressure is multiplied by 1/(1+0.27*(distanceMeters-1.6)), reaching **0.306x at 10m**. World-speaker LF shares the attenuation, while independent room returns can still dominate midrange. P9.5 RMS makeup / output trim do not selectively restore LF / HF. This identifies an engineering mechanism, not a listening-quality proof.

Research basis: https://pmc.ncbi.nlm.nih.gov/articles/PMC5479918/ finds atmospheric HF loss in the 1–15m range relatively small; https://pmc.ncbi.nlm.nih.gov/articles/PMC4744263/ discusses distance/DRR. The target is a **sound-reinforced concert speaker** rather than literal free-field attenuation.

## Narrow change

- OFF-by-default native flag ARMIX_SONKU_EXPERIMENTAL_P96_DISTANCE_REINFORCEMENT, requires P9.5 and P9 world source. P9.5 with flag OFF is preserved.
- P9 mode 9 only, with room ON and distance above 2m: split SAME HRTF-positioned direct ear pressure with causal 170Hz and 4.2kHz complementary first-order filters; retain more bass and air while preserving early/late wet and original source position.
- Slowly ramp distance retention over 35ms, no headlocked dry bass, no second graph, no extra FIR/delay/FFT/heap. P9.4 front/rear calibration remains multiplicative outside this band split.
- At 10m, target LF/mid/HF direct pressure gains ~0.83/0.50/0.77 before crossover rolloffs; locally tested sinus probes are approximately 0.79 at 70Hz, 0.50 at 800Hz and 0.65 at 7.5kHz. NOT verified final-output/headphone loudness.
- ROOM OFF / <=2m preserves original direct samples after transition settles; schema v11 unchanged. Native capability p96DistanceReinforcement is emitted only from the opted-in native build.
- Existing limiter (linked 0.98 sample peak), P9.5 music presence and saved sessions are unchanged.

## Acceptance before merge or release

1. 44.1/48k isolated native tests: ROOM OFF, <=2m exact direct samples, LF/MID/HF spectral energy, anti-phase, finite output; full P9.5 core P96-on source compile/render at 0/90/180/270 and 64/256 buffers.
2. Exact-head Windows JUCE/native ACK/CTest and source-provenance bundle. Do not claim CI or audio-device FAT until inspected.
3. A/B reference P9.5 versus P9.6 on headphones at 2m / 5m / 7.5m / 10m, identical input, source angle and gain; compare measured band RMS, LUFS/crest/peak protection, then loudness-match for subjective depth.
4. REJECT if distance collapses, highs become harsh, kick masks vocal, reverb becomes dry or limiter pumps. Do not claim dearVR parity without headphone evidence.
61 changes: 61 additions & 0 deletions engine/builtin_fx/sonku/SonKuP96DistanceReinforcement.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: AGPL-3.0-only
#pragma once
#include <algorithm>
#include <array>
#include <cmath>

// Private P9.6 sound-reinforcement hypothesis, downstream of the SAME measured
// two-loudspeaker HRIR and world-anchored LF handover. Split only DIRECT ear
// pressure, not late/early reflections, the original L/R music or dry side.
// The 170 Hz / 4.2 kHz complementary crossovers are causal one-poles; their
// components sum to the exact unfiltered ear signal at equal gains.
// No allocations, FFT, virtual mono sub, added latency or callback trig.
namespace armix::sonku::p96 {
class DistanceReinforcement final {
public:
struct Ears {float left=0.f,right=0.f;};
bool prepare(double rate) noexcept {
if(!std::isfinite(rate) ||
(std::abs(rate-44100.)>.1 && std::abs(rate-48000.)>.1))return false;
constexpr double pi=3.14159265358979323846;
lowAlpha_=static_cast<float>(1.-std::exp(-2.*pi*170./rate));
highAlpha_=static_cast<float>(1.-std::exp(-2.*pi*4200./rate));
depthAlpha_=static_cast<float>(1.-std::exp(-1./(rate*.035)));
reset();
return true;
}
void reset() noexcept {low_.fill(0.f);wide_.fill(0.f);depth_=0.f;}
bool active() const noexcept {return depth_!=0.f;}
Ears process(float left,float right,float distanceGain,
float distanceMeters,bool roomEnabled) noexcept {
// Preserve OFF and <=2m P9.5 PCM exactly. The state filters still
// warm every sample, preventing stale memory on a live distance edit.
const float target=roomEnabled?
std::clamp((distanceMeters-2.f)/8.f,0.f,1.f):0.f;
depth_+=depthAlpha_*(target-depth_);
if(std::abs(depth_-target)<1.e-6f)depth_=target;
const std::array<float,2> ears{left,right};
std::array<float,2> out{};
for(int c=0;c<2;++c){
low_[c]+=lowAlpha_*(ears[c]-low_[c]);
wide_[c]+=highAlpha_*(ears[c]-wide_[c]);
}
if(depth_==0.f)
return {distanceGain*left,distanceGain*right};
// The normal distance cue remains in the mid-band and in the native
// early/late DRR. Reinforced speaker direct LF and HF retain musical
// body/air instead of making 10m sound like only a midrange reverb.
// This is NOT a physical free-field SPL model or a loudness guarantee.
const float reinforcible=std::max(0.f,1.f-distanceGain)*depth_;
const float midGain=distanceGain+.24f*reinforcible;
const float lowLift=.52f*reinforcible; // total LF retention 0.76
const float highLift=.43f*reinforcible; // total HF retention 0.67
for(int c=0;c<2;++c)
out[c]=midGain*ears[c]+lowLift*low_[c]+highLift*(ears[c]-wide_[c]);
return {out[0],out[1]};
}
private:
std::array<float,2> low_{},wide_{};
float lowAlpha_=0.f,highAlpha_=0.f,depthAlpha_=0.f,depth_=0.f;
};
} // namespace armix::sonku::p96
36 changes: 34 additions & 2 deletions engine/builtin_fx/sonku/SonKuSpatialCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH
#include "SonKuP95MusicalPresence.h"
#endif
#if defined(SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH) && SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH
#include "SonKuP96DistanceReinforcement.h"
#endif
#if defined(SONKU_P94_FRONT_BACK_DEPTH_RESEARCH) && SONKU_P94_FRONT_BACK_DEPTH_RESEARCH
#include "SonKuP94FrontBackDepthCue.h"
#endif
Expand Down Expand Up @@ -210,6 +213,9 @@ class SonKuSpatialCore final {
#if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH
if(!p90Decoder_.prepare(rate))return false;
if(!p92Bass_.prepare(rate))return false;
#if defined(SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH) && SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH
if(!p96Reinforcement_.prepare(rate))return false;
#endif
#if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH
if(!p95Presence_.prepare(rate))return false;
#endif
Expand Down Expand Up @@ -284,6 +290,9 @@ class SonKuSpatialCore final {
#if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH
p90Decoder_.reset();
p92Bass_.reset();
#if defined(SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH) && SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH
p96Reinforcement_.reset();
#endif
#if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH
p95Presence_.reset();
#endif
Expand Down Expand Up @@ -341,6 +350,9 @@ class SonKuSpatialCore final {
if((s.renderMode==9)!=(settings_.renderMode==9)){
p90Decoder_.reset();
p92Bass_.reset();
#if defined(SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH) && SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH
p96Reinforcement_.reset();
#endif
#if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH
p95Presence_.reset();
#endif
Expand Down Expand Up @@ -904,10 +916,27 @@ class SonKuSpatialCore final {
#else
constexpr float calibratedDirect=1.f,calibratedEarly=1.f;
#endif
float spatialL=smoothedDistanceGain_*calibratedDirect*ears[0]+
float directL=smoothedDistanceGain_*calibratedDirect*ears[0];
float directR=smoothedDistanceGain_*calibratedDirect*ears[1];
#if defined(SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH) && SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH
if(p90World){
// Same KEMAR world speakers; do not EQ/repan wet returns.
// P94's independent directional calibration stays outside.
const auto reinforced=p96Reinforcement_.process(
ears[0],ears[1],smoothedDistanceGain_,
settings_.sourceDistanceMeters,roomEnabled);
// Keep P9.5 floating-point operation order bit-exact
// whenever ROOM OFF or <=2m has no P9.6 reinforcement.
if(p96Reinforcement_.active()){
directL=calibratedDirect*reinforced.left;
directR=calibratedDirect*reinforced.right;
}
}
#endif
float spatialL=directL+
smoothedErPresence_*calibratedEarly*reflection.left+
smoothedTailPresence_*late.left;
float spatialR=smoothedDistanceGain_*calibratedDirect*ears[1]+
float spatialR=directR+
smoothedErPresence_*calibratedEarly*reflection.right+
smoothedTailPresence_*late.right;
#if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH
Expand Down Expand Up @@ -1296,6 +1325,9 @@ class SonKuSpatialCore final {
#if defined(SONKU_P90_TRUE_EXTERNAL_RESEARCH) && SONKU_P90_TRUE_EXTERNAL_RESEARCH
p90::StereoDecoder p90Decoder_{};
p92::WorldBassFoundation p92Bass_{};
#if defined(SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH) && SONKU_P96_DISTANCE_REINFORCEMENT_RESEARCH
p96::DistanceReinforcement p96Reinforcement_{};
#endif
#if defined(SONKU_P95_MUSICAL_PRESENCE_RESEARCH) && SONKU_P95_MUSICAL_PRESENCE_RESEARCH
p95::MusicalPresence p95Presence_{};
#endif
Expand Down
Loading
Loading