Wave 2: SOFA HRTF loading for binaural~, new bed2hoa~ object#2
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements ROADMAP Wave 2 (both items):
ambitap.binaural~—sofaattribute. 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 tobinaural_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; likehrtf_dataset, the rebuild is documented as not-RT-safe.AMBITAP_ENABLE_SOFA=ONfor the submodule (libmysofa via its pinned FetchContent) andbinaural~links theambitapinterface target, which carries theAMBITAP_HAS_SOFAdefine. The external's SOFA code is#ifdef-guarded so a non-SOFA AmbiTap still builds.dspsetupignored 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 asdecode~(stereo … surround_7_1_4), sobed2hoa~ → 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;sofamessages added toambitap.binaural~.maxhelp); README updated; CI bundle count bumped to 12.Test plan
AMBITAP_HAS_SOFAverified present in binaural~'s compile flags; mysofa-static builds🤖 Generated with Claude Code
https://claude.ai/code/session_012VeadvCRUHJdneFNwRbFAM
Generated by Claude Code