Add the 4.0 Surround and 4.0 Quad speaker layouts

This commit is contained in:
TheM14 committed 2026-10-27 23:38:29 +08:00
1 parent a1853f2dc5
commit 8c96f7ac91
6 files changed
+109 -6

No files matched your search

+86
View File
@@ -109,6 +109,84 @@ _RAW_LAYOUTS = {'20': {'out_ch_config': 0,
'axis0_groups': ((0, 2, 1),),
'axis1_groups': (),
'mode': 1})},
'40surround': {'out_ch_config': 255,
'speaker_bitfield': 35,
'channels': ('L', 'R', 'C', 'Cs'),
'internal_to_standard': (0, 1, 2, 3),
'regions': ({'coordinates_q15': ((0, 0, 0), (32767, 0, 0), (16384, 0, 0), (16384, 32767, 0)),
'speaker_ids': (0, 1, 2, 3),
'axis0_groups': ((0, 2, 1), (3,)),
'axis1_groups': (),
'mode': 2},
{'coordinates_q15': ((0, 0, 0), (32767, 0, 0), (16384, 0, 0)),
'speaker_ids': (0, 1, 2),
'axis0_groups': ((0, 2, 1),),
'axis1_groups': (),
'mode': 1},
{'coordinates_q15': ((0, 0, 0), (32767, 0, 0), (16384, 0, 0), (16384, 32767, 0)),
'speaker_ids': (0, 1, 2, 3),
'axis0_groups': ((0, 2, 1), (3,)),
'axis1_groups': (),
'mode': 2},
{'coordinates_q15': ((16384, 0, 0), (16384, 32767, 0)),
'speaker_ids': (2, 3),
'axis0_groups': ((0,), (1,)),
'axis1_groups': (),
'mode': 2},
{'coordinates_q15': ((0, 0, 0), (32767, 0, 0), (16384, 0, 0)),
'speaker_ids': (0, 1, 2),
'axis0_groups': ((0, 2, 1),),
'axis1_groups': (),
'mode': 1},
{'coordinates_q15': ((16384, 32767, 0),),
'speaker_ids': (3,),
'axis0_groups': ((0,),),
'axis1_groups': (),
'mode': 1},
{'coordinates_q15': ((0, 0, 0), (32767, 0, 0), (16384, 0, 0)),
'speaker_ids': (0, 1, 2),
'axis0_groups': ((0, 2, 1),),
'axis1_groups': (),
'mode': 1})},
'40quad': {'out_ch_config': 255,
'speaker_bitfield': 9,
'channels': ('L', 'R', 'Lrs', 'Rrs'),
'internal_to_standard': (0, 1, 2, 3),
'regions': ({'coordinates_q15': ((0, 0, 0), (32767, 0, 0), (0, 32767, 0), (32767, 32767, 0)),
'speaker_ids': (0, 1, 2, 3),
'axis0_groups': ((0, 1), (2, 3)),
'axis1_groups': (),
'mode': 2},
{'coordinates_q15': ((0, 0, 0), (32767, 0, 0), (0, 32767, 0), (32767, 32767, 0)),
'speaker_ids': (0, 1, 2, 3),
'axis0_groups': ((0, 1), (2, 3)),
'axis1_groups': (),
'mode': 2},
{'coordinates_q15': ((0, 0, 0), (32767, 0, 0), (0, 32767, 0), (32767, 32767, 0)),
'speaker_ids': (0, 1, 2, 3),
'axis0_groups': ((0, 1), (2, 3)),
'axis1_groups': (),
'mode': 2},
{'coordinates_q15': ((0, 32767, 0), (32767, 32767, 0)),
'speaker_ids': (2, 3),
'axis0_groups': ((0, 1),),
'axis1_groups': (),
'mode': 1},
{'coordinates_q15': ((0, 0, 0), (32767, 0, 0)),
'speaker_ids': (0, 1),
'axis0_groups': ((0, 1),),
'axis1_groups': (),
'mode': 1},
{'coordinates_q15': ((0, 32767, 0), (32767, 32767, 0)),
'speaker_ids': (2, 3),
'axis0_groups': ((0, 1),),
'axis1_groups': (),
'mode': 1},
{'coordinates_q15': ((0, 0, 0), (32767, 0, 0)),
'speaker_ids': (0, 1),
'axis0_groups': ((0, 1),),
'axis1_groups': (),
'mode': 1})},
'51': {'out_ch_config': 7,
'speaker_bitfield': 15,
'channels': ('L', 'R', 'C', 'LFE', 'Ls', 'Rs'),
@@ -738,6 +816,8 @@ SPEAKER_LAYOUTS = {name: _make_layout(name, item) for name, item in _RAW_LAYOUTS
SPEAKER_LAYOUT_ALIASES = {
"2.0": "20",
"3.1": "31",
"4.0 Surround": "40surround",
"4.0 Quad": "40quad",
"5.1": "51",
"7.1": "71",
"5.1.2": "512",
@@ -747,12 +827,18 @@ SPEAKER_LAYOUT_ALIASES = {
"9.1.4": "914",
"9.1.6": "916",
}
# Spellings accepted for compatibility only: "4.0" has always meant the layout
# with a front trio and one back-centre speaker, which is now called 4.0 Surround.
SPEAKER_LAYOUT_LEGACY_ALIASES = {
"4.0": "40surround",
}
SPEAKER_LAYOUT_CHOICES = tuple(SPEAKER_LAYOUT_ALIASES)
SPEAKER_LAYOUT_DISPLAY_NAMES = {value: key for key, value in SPEAKER_LAYOUT_ALIASES.items()}
def get_speaker_layout(name: str) -> SpeakerLayout:
key = SPEAKER_LAYOUT_ALIASES.get(name, name)
key = SPEAKER_LAYOUT_LEGACY_ALIASES.get(key, key)
try:
return SPEAKER_LAYOUTS[key]
except KeyError as exc: