Skip to content

[FEATURE] add pytta.vbap with vector base amplitude panning - #89

Open
aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-vbap
Open

aguirreSL wants to merge 1 commit into
PyTTaMaster:developmentfrom
aguirreSL:dev-vbap

Conversation

@aguirreSL

Copy link
Copy Markdown

Adds pytta.vbap, vector base amplitude panning (VBAP, Pulkki 1997) for 2D and 3D loudspeaker layouts, with the spread version MDAP (Pulkki 1999). The ITA-Toolbox has VBAP in its spatial audio applications, and this is the first piece of spatial audio in PyTTa.

  1. loudspeaker_pairs(azimuths, max_aperture=None): the adjacent pairs of a 2D layout.
  2. loudspeaker_triplets(directions, max_aperture=None): the triplets of a 3D layout, the faces of the convex hull of the loudspeaker directions. Faces whose outward normal is at 90 degrees or more from their centroid are left out, which removes the faces that close a hemisphere layout.
  3. inverse_matrices(directions, groups): the inverse of the matrix of loudspeaker vectors of each group.
  4. gains(directions, groups, inverses, spread=0): the gains of a set of source directions, non-negative and of norm 1. With a spread, the gains of 9 directions across it are summed (MDAP).

Directions are in degrees, with 0 degrees in front and 90 degrees to the left, and loudspeaker indices are 0-based.

The module is a port of the MATLAB library Vector-Base-Amplitude-Panning by Archontis Politis and Ville Pulkki (https://github.com/polarch/Vector-Base-Amplitude-Panning). Its BSD 3-Clause licence is reproduced in the module header.

The tests in tests/test_vbap.py print the measured differences:

  1. A stereo pair at ±30 degrees follows the tangent law, (g1 - g2)/(g1 + g2) = tan θ / tan 30°, within 2.2e-16, with gains of norm 1.
  2. On a hemisphere layout of 9 loudspeakers, the gains of 200 random sources weight the loudspeaker vectors into the source direction (cross product within 2.3e-16). A source on a loudspeaker gets that loudspeaker alone.
  3. Parity with the MATLAB library on golden data from tests/golden/make_vbap_polarch.m (MATLAB R2026b), for a 5.0 layout and the hemisphere layout: the pairs and triplets are identical, and the inverse matrices and the gains, with and without a spread of 20 degrees, agree within 4.4e-16.

Checked with Python 3.12, numpy 1.26 and scipy 1.17. The 7 failures of development (3 in test_h5io.py, 4 in test_pyttasave.py) are the same with and without this change.

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com

pytta.vbap pans sources on 2D and 3D loudspeaker layouts (Pulkki 1997):
loudspeaker_pairs and loudspeaker_triplets find the groups (the convex
hull of the directions in 3D, without the faces that close a
hemisphere), inverse_matrices inverts the matrix of each group and
gains gives the gains of a set of source directions, with an optional
spread (MDAP).

It is a port of the MATLAB library Vector-Base-Amplitude-Panning of
Archontis Politis, whose BSD 3-Clause licence is reproduced in the
module header.

Tests check the tangent law of a stereo pair, that the 3D gains weight
the loudspeaker vectors into the source direction, and parity with the
MATLAB library on golden data from tests/golden/make_vbap_polarch.m
(groups identical, inverses and gains within 4.4e-16).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant