fix bus mode prop

add spacing for clarity in Modes dataclass.

bus mode prop now returning correct mode
This commit is contained in:
onyx-and-iris 2022-03-18 07:42:25 +00:00
parent b9d45948f3
commit 6aeef19d38
3 changed files with 64 additions and 51 deletions

View File

@ -133,7 +133,7 @@ _bus_maps = {kind.id: _make_bus_level_map(kind) for kind in kinds.all}
def _make_bus_mode_mixin(cls): def _make_bus_mode_mixin(cls):
""" Creates a mixin of Bus Modes. """ """ Creates a mixin of Bus Modes. """
return type('BusModeMixin', (cls,), { return type('BusModeMixin', (cls,), {
**{f'{mode.lower()}': bus_mode_prop(f'mode.{mode}') for mode in **{f'{mode.lower()}': bus_mode_prop(mode) for mode in
['normal', 'Amix', 'Bmix', 'Repeat', 'Composite', 'TVMix', 'UpMix21', ['normal', 'Amix', 'Bmix', 'Repeat', 'Composite', 'TVMix', 'UpMix21',
'UpMix41', 'UpMix61', 'CenterOnly', 'LFEOnly', 'RearOnly']}, 'UpMix41', 'UpMix61', 'CenterOnly', 'LFEOnly', 'RearOnly']},
}) })

View File

@ -10,6 +10,7 @@ class Modes:
_mono: hex=0x00000004 _mono: hex=0x00000004
_mutec: hex=0x00000008 _mutec: hex=0x00000008
_normal: hex=0x00000000
_amix: hex=0x00000010 _amix: hex=0x00000010
_repeat: hex=0x00000020 _repeat: hex=0x00000020
_bmix: hex=0x00000030 _bmix: hex=0x00000030
@ -18,7 +19,7 @@ class Modes:
_upmix21: hex=0x00000060 _upmix21: hex=0x00000060
_upmix41: hex=0x00000070 _upmix41: hex=0x00000070
_upmix61: hex=0x00000080 _upmix61: hex=0x00000080
_centeronly: hex=0x00000090 _centeronly:hex=0x00000090
_lfeonly: hex=0x000000A0 _lfeonly: hex=0x000000A0
_rearonly: hex=0x000000B0 _rearonly: hex=0x000000B0

View File

@ -1,10 +1,10 @@
from .errors import VMCMDErrors from .errors import VMCMDErrors
from time import sleep
def strip_output_prop(param): def strip_output_prop(param):
""" A strip output prop. """ """ A strip output prop. """
def fget(self): def fget(self):
data = self._remote.public_packet return not int.from_bytes(self.public_packet.stripstate[self.index], 'little') & getattr(self._modes, f'_bus{param.lower()}') == 0
return not int.from_bytes(data.stripstate[self.index], 'little') & getattr(self._modes, f'_bus{param.lower()}') == 0
def fset(self, val): def fset(self, val):
if not isinstance(val, bool) and val not in (0, 1): if not isinstance(val, bool) and val not in (0, 1):
raise VMCMDErrors(f'{param} is a boolean parameter') raise VMCMDErrors(f'{param} is a boolean parameter')
@ -14,18 +14,30 @@ def strip_output_prop(param):
def bus_mode_prop(param): def bus_mode_prop(param):
""" A strip output prop. """ """ A strip output prop. """
def fget(self): def fget(self):
data = self._remote.public_packet data = self.public_packet
if param == 'mode.normal': modes = {
vals = [ 'normal': (False,False,False,False,False,False,False,False,False,False,False,False),
'amix': (False,True,True,False,False,True,False,True,False,True,False,True),
'bmix': (False,True,True,True,False,True,True,True,False,True,True,True),
'repeat': (False,False,True,True,False,False,True,True,False,False,True,True),
'composite': (False,False,False,False,True,True,True,True,False,False,False,False),
'tvmix': (False,True,True,False,True,True,True,True,False,True,False,True),
'upmix21': (False,False,True,True,True,True,True,True,False,False,True,True),
'upmix41': (False,True,True,True,True,True,True,True,False,True,True,True),
'upmix61': (False,False,False,False,False,False,False,False,True,True,True,True),
'centeronly': (False,True,True,False,False,True,False,True,True,True,True,True),
'lfeonly': (False,False,True,True,False,False,True,True,True,True,True,True),
'rearonly': (False,True,True,True,False,True,True,True,True,True,True,True),
}
vals = tuple(
not int.from_bytes(data.busstate[self.index], 'little') & getattr(self._modes, f'_{param.lower()}') == 0 not int.from_bytes(data.busstate[self.index], 'little') & getattr(self._modes, f'_{param.lower()}') == 0
for param in ['Amix', 'Bmix', 'Repeat', 'Composite', 'TVMix', 'UpMix21', for param in ['normal', 'Amix', 'Bmix', 'Repeat', 'Composite', 'TVMix', 'UpMix21',
'UpMix41', 'UpMix61', 'CenterOnly', 'LFEOnly', 'RearOnly'] 'UpMix41', 'UpMix61', 'CenterOnly', 'LFEOnly', 'RearOnly']
] )
return not True in vals return vals == modes[param.lower()]
return not int.from_bytes(data.busstate[self.index], 'little') & getattr(self._modes, f'_{param.lower().split(".")[1]}') == 0
def fset(self, val): def fset(self, val):
if not isinstance(val, bool) and val not in (0, 1): if not isinstance(val, bool) and val not in (0, 1):
raise VMCMDErrors(f'{param} is a boolean parameter') raise VMCMDErrors(f'mode.{param} is a boolean parameter')
self.setter(param, 1 if val else 0) self.setter(f'mode.{param}', 1 if val else 0)
return property(fget, fset) return property(fget, fset)