Skip to content

Commit 1a859f6

Browse files
committed
add renderer overloads for HOA output
1 parent 7cb9778 commit 1a859f6

File tree

15 files changed

+726
-3
lines changed

15 files changed

+726
-3
lines changed

ear/cmdline/render_file.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import scipy.sparse
55
from itertools import chain
66
from ..core import bs2051, layout, Renderer
7+
from ..core import hoa_overloads # noqa: F401
8+
from ..core.hoa_adapter import HOAFormat
79
from ..core.monitor import PeakMonitor
810
from ..core.metadata_processing import preprocess_rendering_items, convert_objects_to_cartesian, convert_objects_to_polar
911
from ..core.select_items import select_rendering_items
@@ -83,6 +85,10 @@ def load_output_layout(self):
8385
upmix (sparse array or None): optional matrix to apply after rendering
8486
n_channels (int): number of channels required in output file
8587
"""
88+
spkr_layout = HOAFormat.parse_or_none(self.target_layout)
89+
if spkr_layout is not None:
90+
return spkr_layout, None, spkr_layout.num_channels
91+
8692
spkr_layout = bs2051.get_layout(self.target_layout)
8793

8894
if self.speakers_file is not None:

ear/core/data/N003_M6_Octa.dat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
3
2+
6
3+
1 0 0
4+
0 1 0
5+
0 0 1
6+
-1 0 0
7+
0 -1 0
8+
0 0 -1

ear/core/data/N005_M12_Ico.dat

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
3
2+
12
3+
0.8506508083520399 0.5257311121191336 0
4+
0.8506508083520399 -0.5257311121191336 0
5+
-0.8506508083520399 0.5257311121191336 0
6+
-0.8506508083520399 -0.5257311121191336 0
7+
0 0.8506508083520399 0.5257311121191336
8+
0 0.8506508083520399 -0.5257311121191336
9+
0 -0.8506508083520399 0.5257311121191336
10+
0 -0.8506508083520399 -0.5257311121191336
11+
0.5257311121191336 0 0.8506508083520399
12+
-0.5257311121191336 0 0.8506508083520399
13+
0.5257311121191336 0 -0.8506508083520399
14+
-0.5257311121191336 0 -0.8506508083520399

ear/core/data/N007_M24_Octa.dat

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
3
2+
24
3+
0.86624681811 0.42251865376 0.26663540152
4+
0.86624681811 0.26663540152 -0.42251865376
5+
-0.26663540152 0.42251865376 0.86624681811
6+
0.42251865376 -0.86624681811 0.26663540152
7+
0.86624681811 -0.26663540152 0.42251865376
8+
0.26663540152 0.42251865376 -0.86624681811
9+
-0.42251865376 0.86624681811 0.26663540152
10+
0.42251865376 0.26663540152 0.86624681811
11+
0.42251865376 -0.26663540152 -0.86624681811
12+
-0.42251865376 -0.26663540152 0.86624681811
13+
-0.42251865376 0.26663540152 -0.86624681811
14+
0.26663540152 0.86624681811 0.42251865376
15+
-0.26663540152 0.86624681811 -0.42251865376
16+
0.26663540152 -0.86624681811 -0.42251865376
17+
-0.26663540152 -0.86624681811 0.42251865376
18+
0.86624681811 -0.42251865376 -0.26663540152
19+
-0.86624681811 0.42251865376 -0.26663540152
20+
-0.86624681811 -0.42251865376 0.26663540152
21+
0.42251865376 0.86624681811 -0.26663540152
22+
-0.42251865376 -0.86624681811 -0.26663540152
23+
-0.86624681811 0.26663540152 0.42251865376
24+
-0.86624681811 -0.26663540152 -0.42251865376
25+
0.26663540152 -0.42251865376 0.86624681811
26+
-0.26663540152 -0.42251865376 -0.86624681811

ear/core/data/N009_M48_Octa.dat

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
3
2+
48
3+
0.70684169771 0.63974009862 0.30184005797
4+
0.35354218892 0.9333646932 0.061953774232
5+
0.70684169771 0.30184005797 -0.63974009862
6+
0.35354218892 0.061953774232 -0.9333646932
7+
-0.30184005797 0.63974009862 0.70684169771
8+
-0.061953774232 0.9333646932 0.35354218892
9+
0.63974009862 -0.70684169771 0.30184005797
10+
0.9333646932 -0.35354218892 0.061953774232
11+
0.70684169771 -0.30184005797 0.63974009862
12+
0.35354218892 -0.061953774232 0.9333646932
13+
0.30184005797 0.63974009862 -0.70684169771
14+
0.061953774232 0.9333646932 -0.35354218892
15+
-0.63974009862 0.70684169771 0.30184005797
16+
-0.9333646932 0.35354218892 0.061953774232
17+
0.63974009862 0.30184005797 0.70684169771
18+
0.9333646932 0.061953774232 0.35354218892
19+
0.63974009862 -0.30184005797 -0.70684169771
20+
0.9333646932 -0.061953774232 -0.35354218892
21+
-0.63974009862 -0.30184005797 0.70684169771
22+
-0.9333646932 -0.061953774232 0.35354218892
23+
-0.63974009862 0.30184005797 -0.70684169771
24+
-0.9333646932 0.061953774232 -0.35354218892
25+
0.30184005797 0.70684169771 0.63974009862
26+
0.061953774232 0.35354218892 0.9333646932
27+
-0.30184005797 0.70684169771 -0.63974009862
28+
-0.061953774232 0.35354218892 -0.9333646932
29+
0.30184005797 -0.70684169771 -0.63974009862
30+
0.061953774232 -0.35354218892 -0.9333646932
31+
-0.30184005797 -0.70684169771 0.63974009862
32+
-0.061953774232 -0.35354218892 0.9333646932
33+
0.70684169771 -0.63974009862 -0.30184005797
34+
0.35354218892 -0.9333646932 -0.061953774232
35+
-0.70684169771 0.63974009862 -0.30184005797
36+
-0.35354218892 0.9333646932 -0.061953774232
37+
-0.70684169771 -0.63974009862 0.30184005797
38+
-0.35354218892 -0.9333646932 0.061953774232
39+
0.63974009862 0.70684169771 -0.30184005797
40+
0.9333646932 0.35354218892 -0.061953774232
41+
-0.63974009862 -0.70684169771 -0.30184005797
42+
-0.9333646932 -0.35354218892 -0.061953774232
43+
-0.70684169771 0.30184005797 0.63974009862
44+
-0.35354218892 0.061953774232 0.9333646932
45+
-0.70684169771 -0.30184005797 -0.63974009862
46+
-0.35354218892 -0.061953774232 -0.9333646932
47+
0.30184005797 -0.63974009862 0.70684169771
48+
0.061953774232 -0.9333646932 0.35354218892
49+
-0.30184005797 -0.63974009862 -0.70684169771
50+
-0.061953774232 -0.9333646932 -0.35354218892

ear/core/data/N011_M70_C5.dat

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
3
2+
70
3+
0.34697401547 0.92871517263 0.13075611159
4+
0.30826763892 0.86359439267 -0.39896840445
5+
0.19846719975 -0.64131193892 0.74116784038
6+
0.0055580704907 0.98569909422 -0.16842328672
7+
-0.53557664796 0.83430239928 -0.13075611159
8+
0.73865905916 -0.65269931117 0.16842328672
9+
0.87676666988 0.1789933757 0.44636484857
10+
0.84933311523 -0.34562620217 0.39896840445
11+
0.61802851007 -0.2621278183 -0.74116784038
12+
-0.18511501171 -0.275682451 -0.94325586065
13+
-0.71379207496 -0.010481253665 0.70027924219
14+
0.082409348656 0.70909638429 -0.70027924219
15+
-0.32890958018 0.045682265894 0.94325586065
16+
0.71771459795 0.5344568999 -0.44636484857
17+
0.9904814841 -0.043003127119 0.13075611159
18+
0.91658701382 -0.026314603177 -0.39896840445
19+
-0.54859416094 -0.38692981141 0.74116784038
20+
0.9391730849 0.2993117323 -0.16842328672
21+
0.62796644739 0.76717728084 -0.13075611159
22+
-0.39249573074 -0.90420169091 0.16842328672
23+
0.44116861743 -0.77854265969 0.44636484857
24+
-0.066251685284 -0.91456816391 0.39896840445
25+
-0.058317057073 -0.66878199231 -0.74116784038
26+
-0.31939327598 0.090864275742 -0.94325586065
27+
-0.23054214621 0.67561771866 0.70027924219
28+
0.69985662619 0.14074688535 -0.70027924219
29+
-0.058192233229 0.326928196 0.94325586065
30+
0.73008472521 -0.51743088039 -0.44636484857
31+
0.26517720693 -0.95529256681 0.13075611159
32+
0.25821428927 -0.87985771183 -0.39896840445
33+
-0.53751703724 0.40217616421 0.74116784038
34+
0.5748828173 -0.80071427043 -0.16842328672
35+
0.92368125624 -0.36016076432 -0.13075611159
36+
-0.9812347612 0.093871933508 0.16842328672
37+
-0.60410946954 -0.66015920108 0.44636484857
38+
-0.89027890855 -0.21960800816 0.39896840445
39+
-0.65407043346 -0.15120218401 -0.74116784038
40+
-0.012280888625 0.33183966177 -0.94325586065
41+
0.57130919276 0.4280359672 0.70027924219
42+
0.35012583358 -0.62211002533 -0.70027924219
43+
0.29294480216 0.15637047111 0.94325586065
44+
-0.26649742311 -0.85424677081 -0.44636484857
45+
-0.82659295717 -0.54740014837 0.13075611159
46+
-0.75700180667 -0.517467368 -0.39896840445
47+
0.2163903624 0.63548835036 0.74116784038
48+
-0.58387596426 -0.7941803667 -0.16842328672
49+
-0.057100036259 -0.98976887461 -0.13075611159
50+
-0.21394070262 0.96221773641 0.16842328672
51+
-0.81452880253 0.37054183544 0.44636484857
52+
-0.48397093966 0.77884295067 0.39896840445
53+
-0.34592070184 0.57533390341 -0.74116784038
54+
0.3118032694 0.11422391405 -0.94325586065
55+
0.58363064542 -0.41107694253 0.70027924219
56+
-0.4834669607 -0.52523202575 -0.70027924219
57+
0.23924207779 -0.23028593001 0.94325586065
58+
-0.8947891906 -0.01052265875 -0.44636484857
59+
-0.77603974933 0.61698066967 0.13075611159
60+
-0.72606713534 0.56004529034 -0.39896840445
61+
0.67125363604 -0.0094227642326 0.74116784038
62+
-0.93573800843 0.30988381061 -0.16842328672
63+
-0.9589710194 -0.25155004119 -0.13075611159
64+
0.8490121354 0.50081133217 0.16842328672
65+
0.10070298476 0.88916664964 0.44636484857
66+
0.59116841827 0.70095942357 0.39896840445
67+
0.44027968231 0.5067780912 -0.74116784038
68+
0.20498590692 -0.26124540056 -0.94325586065
69+
-0.21060561702 -0.68209548967 0.70027924219
70+
-0.64892484773 0.29749878144 -0.70027924219
71+
-0.14508506654 -0.29869500299 0.94325586065
72+
-0.28651270945 0.84774341005 -0.44636484857

ear/core/data/N013_M94_Inv.dat

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
3
2+
94
3+
0 0 1
4+
0 0 -1
5+
0.90358266073 0.31001584946 0.2956831891
6+
0.27205350245 0.34122479739 0.89975137091
7+
-0.89529983598 -0.012610972536 -0.44528548939
8+
0.26445259993 -0.77933688788 -0.56806587434
9+
0.43894956759 -0.34158306995 0.83105010886
10+
0.26634151334 0.88743464306 -0.37619403579
11+
-0.81969971111 -0.55879654137 0.12585232996
12+
0.41878241801 0.61165538353 -0.67119220657
13+
-0.55856136712 -0.79338207212 0.24197951732
14+
0.97483086114 -0.20783799137 0.080673177117
15+
-0.086784973076 -0.8191723863 -0.56694353331
16+
-0.5820111547 0.72313215495 0.37194475702
17+
-0.081787933469 -0.75049241994 0.65579864407
18+
-0.4631554094 -0.11166755025 0.87921409507
19+
0.92771448215 -0.27035918355 -0.25739415589
20+
-0.86159634658 0.37860838095 -0.3380938175
21+
-0.20955716157 0.64098201137 -0.73839546121
22+
0.59517740918 -0.21952399041 -0.7730285048
23+
0.68855338622 -0.45885662449 -0.56155572517
24+
0.7170376672 -0.12185463063 0.68630054117
25+
0.15050195477 -0.92438144236 0.35052547788
26+
-0.92389877985 -0.24430981897 0.29448897593
27+
0.40598767751 0.91240652107 0.051849262548
28+
0.064339972997 0.96333630215 0.260467919
29+
-0.68068022097 -0.47360457257 -0.55890352086
30+
0.4505293297 -0.89000586376 0.07009197924
31+
0.48492970933 0.80289395461 0.34670516964
32+
0.71324323816 0.21598573096 -0.66680900357
33+
-0.025469278342 -0.99640136296 0.080843303713
34+
0.3618098015 -0.010200555555 0.9321961254
35+
-0.99045389913 -0.13776245782 0.0047517268343
36+
-0.71751057737 0.67721220183 -0.16297915527
37+
0.26703347585 0.3824992502 -0.88452667929
38+
-0.015107452646 -0.51947915579 -0.85434956053
39+
-0.86237250536 0.068182883554 0.50166199416
40+
-0.22770049205 0.19460191187 0.95408730304
41+
0.61911414596 0.22839985808 0.75135289918
42+
0.63740045321 -0.51226586885 0.57559042892
43+
-0.37519412572 -0.64816504176 -0.66265484732
44+
-0.8003485757 0.58426970185 0.13442869067
45+
0.31195345167 -0.92829833165 -0.20235427214
46+
0.43865342261 -0.77020270456 0.46300212604
47+
-0.7579804929 -0.62691890536 -0.18010624219
48+
-0.058344307615 0.35791730653 -0.9319287223
49+
0.68738290323 0.52298205603 -0.50397868349
50+
0.33724668345 -0.52493863322 -0.78147559517
51+
-0.90358266073 -0.31001584946 -0.2956831891
52+
-0.27205350245 -0.34122479739 -0.89975137091
53+
0.89529983598 0.012610972536 0.44528548939
54+
-0.26445259993 0.77933688788 0.56806587434
55+
-0.43894956759 0.34158306995 -0.83105010886
56+
-0.26634151334 -0.88743464306 0.37619403579
57+
0.81969971111 0.55879654137 -0.12585232996
58+
-0.41878241801 -0.61165538353 0.67119220657
59+
0.55856136712 0.79338207212 -0.24197951732
60+
-0.97483086114 0.20783799137 -0.080673177117
61+
0.086784973076 0.8191723863 0.56694353331
62+
0.5820111547 -0.72313215495 -0.37194475702
63+
0.081787933469 0.75049241994 -0.65579864407
64+
0.4631554094 0.11166755025 -0.87921409507
65+
-0.92771448215 0.27035918355 0.25739415589
66+
0.86159634658 -0.37860838095 0.3380938175
67+
0.20955716157 -0.64098201137 0.73839546121
68+
-0.59517740918 0.21952399041 0.7730285048
69+
-0.68855338622 0.45885662449 0.56155572517
70+
-0.7170376672 0.12185463063 -0.68630054117
71+
-0.15050195477 0.92438144236 -0.35052547788
72+
0.92389877985 0.24430981897 -0.29448897593
73+
-0.40598767751 -0.91240652107 -0.051849262548
74+
-0.064339972997 -0.96333630215 -0.260467919
75+
0.68068022097 0.47360457257 0.55890352086
76+
-0.4505293297 0.89000586376 -0.07009197924
77+
-0.48492970933 -0.80289395461 -0.34670516964
78+
-0.71324323816 -0.21598573096 0.66680900357
79+
0.025469278342 0.99640136296 -0.080843303713
80+
-0.3618098015 0.010200555555 -0.9321961254
81+
0.99045389913 0.13776245782 -0.0047517268343
82+
0.71751057737 -0.67721220183 0.16297915527
83+
-0.26703347585 -0.3824992502 0.88452667929
84+
0.015107452646 0.51947915579 0.85434956053
85+
0.86237250536 -0.068182883554 -0.50166199416
86+
0.22770049205 -0.19460191187 -0.95408730304
87+
-0.61911414596 -0.22839985808 -0.75135289918
88+
-0.63740045321 0.51226586885 -0.57559042892
89+
0.37519412572 0.64816504176 0.66265484732
90+
0.8003485757 -0.58426970185 -0.13442869067
91+
-0.31195345167 0.92829833165 0.20235427214
92+
-0.43865342261 0.77020270456 -0.46300212604
93+
0.7579804929 0.62691890536 0.18010624219
94+
0.058344307615 -0.35791730653 0.9319287223
95+
-0.68738290323 -0.52298205603 0.50397868349
96+
-0.33724668345 0.52493863322 0.78147559517

ear/core/data/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22

33
Loudspeaker layouts derived from ITU-R BS.2051-1.
44

5-
# Design_5200_100_random.dat
5+
# t-designs (.dat files)
6+
7+
Obtained from http://homepage.univie.ac.at/manuel.graef/quadrature.php
8+
and https://www-user.tu-chemnitz.de/~potts/workgroup/graef/quadrature/index.php.en
9+
10+
## Design_5200_100_random.dat
611

712
Approximate spherical t-design for t=100, as in [0].
813

914
"The text file for each point set consists of two columns which contain the
1015
spherical coordinates (phi,theta) in [0,2pi] x [0,pi) of the quadrature points
1116
p = ( sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta))."
1217

13-
Obtained from http://homepage.univie.ac.at/manuel.graef/quadrature.php
14-
1518
[0] M. Graf and D. Potts, “On the computation of spherical designs by a new
1619
optimization approach based on fast spherical Fourier transforms,” Numerische
1720
Mathematik, vol. 119, no. 4, pp. 699–724, Dec. 2011.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from ..hoa_adapter import HOAFormat, HOAPointSourceAdapter
2+
from ..screen_edge_lock import ScreenEdgeLockHandler
3+
from .panner import build_direct_speakers_panner, SpeakerLabelHandler
4+
import numpy as np
5+
import warnings
6+
7+
8+
class DirectSpeakersPannerHOA(object):
9+
def __init__(self, fmt, additional_substitutions={}):
10+
self._panner = HOAPointSourceAdapter.build(fmt)
11+
self._label_handler = SpeakerLabelHandler(additional_substitutions)
12+
self._screen_edge_lock_handler = ScreenEdgeLockHandler(fmt.screen, fmt)
13+
14+
def handle(self, type_metadata):
15+
if self._label_handler.is_lfe_channel(type_metadata):
16+
warnings.warn("discarding DirectSpeakers LFE channel")
17+
return np.zeros(self._panner.num_channels)
18+
19+
position = self._screen_edge_lock_handler.handle_ds_position(
20+
type_metadata.block_format.position
21+
)
22+
23+
return self._panner.handle(position.as_cartesian_array())
24+
25+
26+
@build_direct_speakers_panner.register(HOAFormat)
27+
def _build_direct_speakers_panner_hoa(layout, **options):
28+
return DirectSpeakersPannerHOA(layout, **options)

0 commit comments

Comments
 (0)