Skip to content

Wave 2: SOFA HRTF loading for binaural~, new bed2hoa~ object#2

Merged
tap merged 1 commit into
mainfrom
claude/ambitap-roadmap-max-assessment-tiuszu
Jul 3, 2026
Merged

Wave 2: SOFA HRTF loading for binaural~, new bed2hoa~ object#2
tap merged 1 commit into
mainfrom
claude/ambitap-roadmap-max-assessment-tiuszu

Conversation

@tap

@tap tap commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Implements ROADMAP Wave 2 (both items):

ambitap.binaural~sofa attribute. Loads HRTF measurements from a SOFA file (resolved through the Max search path, falling back to a literal absolute path), projects them onto the SH basis at the object's order (hrtf_data::decompose_sh), resamples the decomposed FIRs to the host rate (resample_fir), and hands them to binaural_renderer::set_custom_hrtf. An empty symbol reverts to the built-in KEMAR set. Failure modes report to the Max console and keep the previous state (bad file) or fall back to KEMAR (measurement grid that can't support the order). Loading happens on the control thread; like hrtf_dataset, the rebuild is documented as not-RT-safe.

  • Build: the package now sets AMBITAP_ENABLE_SOFA=ON for the submodule (libmysofa via its pinned FetchContent) and binaural~ links the ambitap interface target, which carries the AMBITAP_HAS_SOFA define. The external's SOFA code is #ifdef-guarded so a non-SOFA AmbiTap still builds.
  • Also fixes a latent bug: dspsetup ignored the host sample rate (args[0]), so the built-in 44.1 kHz KEMAR FIRs were never resampled on 48 kHz systems. prepare() now receives the host rate, and SOFA FIRs are re-derived on rate changes.

ambitap.bed2hoa~ — new object. Encodes a channel-based surround bed into HOA by encoding each speaker feed at its canonical direction. Creation args <order> <layout> with the same layout table as decode~ (stereo … surround_7_1_4), so bed2hoa~ → decode~ round-trips a bed through the ambisonic domain. No LFE (not directional — route it around the bus). The encoding matrix is static, so the perform routine is a plain matrix multiply: wait-free, allocation-free.

Help patches for both objects (new ambitap.bed2hoa~.maxhelp; sofa messages added to ambitap.binaural~.maxhelp); README updated; CI bundle count bumped to 12.

Test plan

  • All 12 externals compile clean against the pinned submodule (Linux compile check; link is macOS-CI territory as before)
  • AMBITAP_HAS_SOFA verified present in binaural~'s compile flags; mysofa-static builds
  • Help patches are valid JSON
  • CI: 12 universal externals build fat on macOS (this PR)
  • In-Max verification (Wave 1 + Wave 2 exit criteria — needs a machine with Max)

🤖 Generated with Claude Code

https://claude.ai/code/session_012VeadvCRUHJdneFNwRbFAM


Generated by Claude Code

ambitap.binaural~ gains a 'sofa' attribute: loads a SOFA file (resolved
through the Max search path, falling back to a literal path), projects the
measurements onto the SH basis at the object's order via decompose_sh, and
resamples the decomposed FIRs to the host rate before handing them to
set_custom_hrtf. Empty symbol reverts to the built-in KEMAR set; a grid that
cannot support the order reports to the console and stays on KEMAR. The
package build enables AMBITAP_ENABLE_SOFA (libmysofa via the submodule's
pinned FetchContent) and the code is guarded by AMBITAP_HAS_SOFA so non-SOFA
builds still compile. Also fixes dspsetup ignoring the host sample rate —
the built-in 44.1 kHz KEMAR set was never resampled on 48 kHz systems.

ambitap.bed2hoa~ encodes a channel-based surround bed (same layout table as
decode~: stereo through 7.1.4, no LFE) into the HOA domain by encoding each
speaker feed at its canonical direction — a static matrix multiply in the
perform routine, wait-free and allocation-free.

Help patches for both; CI count bumped to 12 externals. All 12 compile clean
against the pinned submodule (link exercised on macOS CI only, as before).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012VeadvCRUHJdneFNwRbFAM
@tap tap merged commit daaf3e7 into main Jul 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants