phenyque / pyvbap

VBAP (Vector base amplitude panning) implementation in python with example application.
10 stars 1 forks source link

Singular matrix when there are sky channels and pan el is not zero #7

Open happyTonakai opened 6 months ago

happyTonakai commented 6 months ago

I'd like to build a 5.1.2 panner with two sky channels but have singular matrix error at line 62 in vbap_panner.py when the pan elevation is not zero. A minimum working example can be:

ls_az = [30, 0, -30, 110, 110, 45, -45, 120, -120]
ls_el = [0] * 5 + [45] * 4
panner = VbapPanner(ls_az, ls_el)
pan_az = 15
pan_el = 0
gains = panner.calc_gains(pan_az, pan_el)

And if I change the pan_el from 0 to 0.001 the error is gone. I think if panning elevation is zero the panner should be in 2D mode and only activate the horizontal loudspeakers so that it won't get a singular triangle.

happyTonakai commented 6 months ago

Find a bug, line 20 should be:

if ls_el is None or np.all(((el_arr := np.asarray(ls_el, dtype=float)) == 0)):

otherwise el_arr will be an array of bool.

phenyque commented 5 months ago

Hi @happyTonakai, sorry for the late response. I have never used this code for panning to 3D layouts tbh (mostly because I did not have one available for listening). If you found a way to make it work, feel free to open a pull request. I can't promise that I can look into this anytime soon...