-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from ...metadata_input import HOATypeMetadata | ||
from ...hoa_adapter import HOAFormat | ||
from ..design import build_hoa_decoder_design | ||
from .. import design_hoa # noqa: F401 | ||
from ...hoa import norm_SN3D, norm_FuMa | ||
import numpy as np | ||
|
||
|
||
def test_convert_order_norm(): | ||
fmt = HOAFormat(max_order=1, normalization="SN3D", channel_order="ACN") | ||
|
||
tm = HOATypeMetadata( | ||
orders=[0, 1, 1, 1], degrees=[0, 1, -1, 0], normalization="FuMa" | ||
) | ||
|
||
designer = build_hoa_decoder_design(fmt) | ||
actual = designer.design(tm) | ||
|
||
# [out, in] | ||
expected = np.zeros((4, 4)) | ||
|
||
expected[0, 0] = 1 | ||
expected[1, 2] = 1 | ||
expected[2, 3] = 1 | ||
expected[3, 1] = 1 | ||
|
||
n, m = fmt.orders_degrees | ||
expected *= (norm_SN3D(n, np.abs(m)) / norm_FuMa(n, np.abs(m)))[:, np.newaxis] | ||
|
||
np.testing.assert_allclose(actual, expected) | ||
|
||
|
||
def test_upmix(): | ||
fmt = HOAFormat(max_order=2, normalization="SN3D", channel_order="ACN") | ||
|
||
tm = HOATypeMetadata( | ||
orders=[0, 1, 1, 1], degrees=[0, -1, 0, 1], normalization="SN3D" | ||
) | ||
|
||
designer = build_hoa_decoder_design(fmt) | ||
actual = designer.design(tm) | ||
|
||
# [out, in] | ||
expected = np.eye(9, 4) | ||
|
||
np.testing.assert_allclose(actual, expected) | ||
|
||
|
||
def test_downmix(): | ||
fmt = HOAFormat(max_order=1, normalization="SN3D", channel_order="ACN") | ||
|
||
tm = HOATypeMetadata( | ||
orders=[0, 1, 1, 1, 2, 2, 2, 2, 2], | ||
degrees=[0, -1, 0, 1, -2, -1, 0, 1, 2], | ||
normalization="SN3D", | ||
) | ||
|
||
designer = build_hoa_decoder_design(fmt) | ||
actual = designer.design(tm) | ||
|
||
# [out, in] | ||
expected = np.eye(4, 9) | ||
|
||
np.testing.assert_allclose(actual, expected) |