Repository navigation
Conversation
Add upstream remotes and west projects for resonance-audio, eigen, and pffft under modules/audio/resonance-audio so the Google Resonance Audio spatializer can be built as a Zephyr/SOF LLEXT or built-in module. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…LOBAL Zephyr llext_load/llext_link only index and relocate STB_GLOBAL and STB_LOCAL symbols, leaving defined STB_WEAK symbols (such as C++ templates and vtables) unpatched at 0. Promote defined STB_WEAK STT_OBJECT and STT_FUNC symbols to STB_GLOBAL in ET_REL objects so LLEXT resolves them properly. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Register UUID 12f51e05-61d9-4a96-939eca72c615d89b for the resonance_audio spatializer module. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Include resonance_audio.toml in the PTL and WCL rimage manifests when CONFIG_COMP_RESONANCE_AUDIO or LLEXT_FORCE_ALL_MODULAR is enabled. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add the Google Resonance Audio binaural spatializer module supporting Mono, Stereo, 5.1, 7.1, and 1st-order Ambisonics (AmbiX) inputs rendered to 2-channel binaural output using SADIE HRTFs. Includes: - IPC4 dual-pin processing: Pin 0 for PCM audio and non-blocking Pin 1 for low-latency DMA spatial pose metadata frames over ALSA compress mmap - Phase 1 ALSA kcontrol (bytes/switch/enum) pose, room, and speaker-mode configuration alongside Phase 2 DMA pose frame updates (128-byte FNV-1a checksummed frames with circular buffer wrap resync) - .sof_codec_info descriptor registration for SND_AUDIOCODEC_PCM and SND_AUDIOCODEC_BESPOKE compress pose streams - Dependency-free stub backend (COMP_RESONANCE_AUDIO_STUB) and LLEXT packaging for ACE/PTL/WCL Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add native Zephyr ztest unit tests covering Resonance Audio parameter validation, speaker-mode/HRTF configuration, Phase 1 kcontrol pose updates, and Phase 2 DMA pose frame checksum/wrap/playback verification. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
There was a problem hiding this comment.
🟡 Changes recommended
Enabling room reverb fails to build because the standalone compiler lacks the configuration macro, while concurrent instances can misattribute allocations and free memory still used by another instance.
5 open issues
What changed in this PR
Adds Google Resonance Audio as a SOF spatializer module, rendering multichannel and first-order Ambisonics input to binaural stereo. It provides the DSP-side support for the related topology and Linux compress-mmap work.
Changes:
- Adds real and stub backends, ALSA controls, and an optional DMA pose-metadata input.
- Integrates dependencies, firmware manifests, and loadable-module support.
- Adds native Zephyr tests for rendering, controls, and metadata processing.
| File | Description |
|---|---|
west.yml |
Pins Resonance Audio, Eigen, and PFFFT dependencies. |
uuid-registry.txt |
Registers the spatializer UUID. |
tools/rimage/config/wcl.toml.h |
Includes RESAUD in WCL manifests. |
tools/rimage/config/ptl.toml.h |
Includes RESAUD in PTL manifests. |
test/ztest/unit/audio/resonance_audio/testcase.yaml |
Registers the native simulation test suite. |
test/ztest/unit/audio/resonance_audio/resonance_audio_ztest.c |
Tests rendering, controls, bypass, and DMA metadata. |
test/ztest/unit/audio/resonance_audio/resonance_audio_test_alloc.c |
Supplies host allocation helpers for tests. |
test/ztest/unit/audio/resonance_audio/prj.conf |
Configures tests with the real backend. |
test/ztest/unit/audio/resonance_audio/CMakeLists.txt |
Builds the native test application and dependencies. |
src/audio/resonance_audio/resonance_wrapper.h |
Defines the C interface to the C++ renderer. |
src/audio/resonance_audio/resonance_wrapper.cpp |
Implements spatial rendering and runtime controls. |
src/audio/resonance_audio/resonance_shims.cpp |
Provides minimal C++ runtime support. |
src/audio/resonance_audio/resonance_shims.c |
Provides allocation, libc, and math shims. |
src/audio/resonance_audio/resonance_preinc.h |
Redirects library allocations through SOF shims. |
src/audio/resonance_audio/resonance_hrtf_assets.cc |
Embeds and loads first-order SADIE HRTF data. |
src/audio/resonance_audio/resonance_audio.toml |
Defines module identity, pins, and resource metadata. |
src/audio/resonance_audio/resonance_audio.h |
Defines controls, pose packets, and backend state. |
src/audio/resonance_audio/resonance_audio.cmake |
Cross-builds the renderer’s static library. |
src/audio/resonance_audio/resonance_audio.c |
Implements PCM processing, controls, and metadata framing. |
src/audio/resonance_audio/resonance_audio-stub.c |
Adds a dependency-free stereo downmix backend. |
src/audio/resonance_audio/resonance_audio-real.c |
Connects the module lifecycle to the renderer. |
src/audio/resonance_audio/overrides/graph/reverb_node.h |
Stubs reverb when compiled out. |
src/audio/resonance_audio/overrides/graph/reflections_node.h |
Stubs reflections when compiled out. |
src/audio/resonance_audio/overrides/config/global_config.h |
Limits rendering to first-order Ambisonics. |
src/audio/resonance_audio/overrides/base/logging.h |
Replaces heavyweight upstream logging. |
src/audio/resonance_audio/overrides/base/constants_and_types.h |
Caps internal audio buffer sizes. |
src/audio/resonance_audio/overrides/ambisonics/ambisonic_lookup_table.cc |
Optimizes encoder lookup-table generation. |
src/audio/resonance_audio/llext/llext.toml.h |
Defines the loadable-module manifest. |
src/audio/resonance_audio/llext/CMakeLists.txt |
Packages real or stub loadable modules. |
src/audio/resonance_audio/Kconfig |
Exposes module, stub, and room-effects options. |
src/audio/resonance_audio/CMakeLists.txt |
Selects built-in or loadable-module builds. |
src/audio/Kconfig |
Includes the spatializer configuration. |
src/audio/CMakeLists.txt |
Adds the spatializer build directory. |
scripts/llext_link_helper.py |
Promotes defined weak symbols for LLEXT resolution. |
Review effort: Balanced
| file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/resonance-audio-build.sh.tmp" | ||
| "#!/bin/sh | ||
| set -e | ||
| INST=\"${RESONANCE_AUDIO_INSTALL_DIR}\" | ||
| OBJ=\"${CMAKE_CURRENT_BINARY_DIR}/resonance-audio-obj\" | ||
|
|
||
| rm -rf \"\$OBJ\" \"\$INST/lib/libresonance_audio_dsp.a\" | ||
| mkdir -p \"\$OBJ\" \"\$INST/lib\" \"\$INST/include\" | ||
|
|
||
| COMMON_FLAGS=\"-O3 ${_res_arch_flags} ${_res_clang_fp_flags} ${_res_sysroot_inc} -DNDEBUG -D_GNU_SOURCE -DM_PI=3.14159265358979323846 -DPFFFT_SIMD_DISABLE -DDISABLE_SIMD -DEIGEN_MPL2_ONLY -DEIGEN_NO_DEBUG -DEIGEN_DONT_VECTORIZE\" | ||
| INCS=\"-I${_res_mod_dir}/overrides -I${_res_mod_dir} -I${SOF_RESONANCE_AUDIO_SRC_DIR} -I${_res_ra_dir} -I${_res_eigen_dir} -I${_res_pffft_dir}\" | ||
| CFLAGS=\"\$COMMON_FLAGS \$INCS -Dmalloc=res_shim_malloc -Dcalloc=res_shim_calloc -Drealloc=res_shim_realloc -Dfree=res_shim_free -Wno-unused-function -Wno-double-promotion\" | ||
| CXXFLAGS=\"-std=c++17 -fno-exceptions -fno-rtti -fno-threadsafe-statics -include ${_res_mod_dir}/resonance_preinc.h \$COMMON_FLAGS ${_res_cxx_sys_inc} \$INCS -Wno-unused-function -Wno-double-promotion -Wno-deprecated-declarations -Wno-sign-compare\" |
There was a problem hiding this comment.
Fixed in f5b4c39: resonance_audio.cmake now passes -DCONFIG_RESONANCE_AUDIO_ROOM_REVERB=1 to external C++ CXXFLAGS when CONFIG_RESONANCE_AUDIO_ROOM_REVERB=y, and resonance_shims.c exposes its trig/PRNG math shims for built-in firmware builds as well (keeping minimal-libc sqrt/sqrtf guarded). Verified cleanly with a full CONFIG_COMP_RESONANCE_AUDIO=y + CONFIG_RESONANCE_AUDIO_ROOM_REVERB=y PTL build.
| void *res_shim_malloc(size_t size) | ||
| { | ||
| struct res_alloc_hdr *hdr; | ||
| struct processing_module *mod = active_res_mod; |
There was a problem hiding this comment.
Fixed in f5b4c39: serialized built-in backend operations (resonance_audio_backend_enter() / resonance_audio_backend_exit()) using k_mutex / APP_SYSUSER_BSS sys_mutex (matching module/generic.c), and updated res_shim_realloc() to allocate against hdr->owner rather than the global pointer. Added test_multi_instance_isolation in 50833f4.
| } | ||
|
|
||
| cd->sample_rate = in_rate; | ||
| cd->in_channels = in_ch; |
There was a problem hiding this comment.
Fixed in f5b4c39: added resonance_setup_in_chmap() to validate IPC4 ch_map on Pin 0 and build per-channel permutation in_perm[] so semantic layouts such as up_down_mixer 5.1 (0xFF743210, L,C,R,LS,RS,LFE) are reordered to Resonance order (L,R,C,LFE,LS,RS) and incomplete/invalid maps return -EINVAL, while leaving 4ch FOA AmbiX channel interpretation untouched. Added test_up_down_mixer_51_chmap_and_invalid_chmap in 50833f4.
| if (cfg.input_mode <= 4) | ||
| cd->mode_override = cfg.input_mode; |
| if (n <= 0) | ||
| return 0; | ||
|
|
||
| n = MIN(n, RESONANCE_FIFO_FRAMES - cd->buffered_in_frames); |
There was a problem hiding this comment.
Fixed in f5b4c39: resonance_process() now bounds accepted frames n by both input FIFO capacity and available output FIFO block headroom ((RESONANCE_FIFO_FRAMES - buffered_out_frames) / block_frames * block_frames + block_frames - 1 - buffered_in_frames), preventing partial drainage / silent gap insertion. Added test_large_batch_512_frames_no_gap in 50833f4.
…d FIFO
Address code review findings for the Google Resonance Audio module:
- resonance_audio.cmake: pass -DCONFIG_RESONANCE_AUDIO_ROOM_REVERB=1 to the external C++ compiler when enabled
- resonance_shims.c: provide trig/PRNG math shims for built-in firmware builds (avoiding double definitions with minimal libc sqrt/sqrtf), allocate realloc() buffers against hdr->owner, and serialize built-in backend allocation context using k_mutex/sys_mutex
- resonance_audio.{h,c}: accept documented input_mode=0xff (auto), validate and reorder speaker-mode PCM channels per IPC4 ch_map while keeping AmbiX identity untouched, and bound process() batch size by both input and output FIFO headroom
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Suppress Clang -W#warnings on upstream pffft/simd_utils.cc in host/llvm ztest builds and add unit tests covering input_mode=0xff auto reset, up_down_mixer 5.1 semantic ch_map reordering, invalid ch_map rejection, 512-frame batch continuity, and multi-instance isolation. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
|
Addressed all Copilot code review comments (commits
|


Summary
Add the Google Resonance Audio binaural spatializer DSP module to SOF (Phase 1 kcontrols + Phase 2 DMA pose metadata over ALSA compress mmap):
west.yml): add upstreamresonance-audio,eigen, andpffftprojects undermodules/audio/resonance-audio.scripts/llext_link_helper.py): promote definedSTB_WEAKSTT_FUNC/STT_OBJECTsymbols toSTB_GLOBALinET_RELobjects so Zephyr LLEXT resolves C++ templates and vtables.uuid-registry.txt,tools/rimage/config/{ptl,wcl}.toml.h): registerresonance_audio(12f51e05-61d9-4a96-939eca72c615d89b) andRESAUDmodule manifest entries.src/audio/resonance_audio/):magic = 0x4E534552) over ALSA compressmmapwith circular buffer wrap resync.pose,speaker_mode,room) remain active when Pin 1 is closed..sof_codec_infodescriptors (SND_AUDIOCODEC_PCM,SND_AUDIOCODEC_BESPOKE) via<sof/audio/codec_info.h>.COMP_RESONANCE_AUDIO_STUBbackend and LLEXT build support.test/ztest/unit/audio/resonance_audio/): native Zephyrztestsuite covering speaker modes, Phase 1 kcontrol head rotation, and Phase 2 Pin 1 DMA metadata frames.Related Draft PRs
mmapmetadata support: ALSA: compress: mmap playback O_RDWR and SOF raw metadata stream support linux#6071Verification
ztest(resonance_audio_suite): 5/5 passed (west build -b native_sim -d build-ztest-resonance sof/test/ztest/unit/audio/resonance_audio).xtensa-build-zephyr.py -z -p wcl): succeeded and verified.sof_codec_infosection inresonance_audio.llext.CONFIG_COMP_RESONANCE_AUDIO=y,CONFIG_COMP_RESONANCE_AUDIO_STUB=y): succeeded.RT722SoundWire) with 200 Hz and 1 kHz compressmmappose streams alongside 4chS32_LEand 6chS16_LEplayback.