mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-30 23:00:51 +00:00
add bus modes, update Modes dataclass
add bus mode property objects update references in Modes dataclass
This commit is contained in:
parent
ae2129c1fe
commit
863debdbe7
@ -2,6 +2,7 @@ from .errors import VMCMDErrors
|
||||
from . import channel
|
||||
from .channel import Channel
|
||||
from . import kinds
|
||||
from .meta import bus_mode_prop
|
||||
|
||||
class OutputBus(Channel):
|
||||
""" Base class for output buses. """
|
||||
@ -11,9 +12,11 @@ class OutputBus(Channel):
|
||||
Factory function for output busses.
|
||||
Returns a physical/virtual bus of a kind.
|
||||
"""
|
||||
BusModeMixin = _make_bus_mode_mixin(cls)
|
||||
OutputBus = PhysicalOutputBus if is_physical else VirtualOutputBus
|
||||
OB_cls = type(f'Bus{remote.kind.name}', (OutputBus,), {
|
||||
'levels': BusLevel(remote, index),
|
||||
'mode': BusModeMixin(remote, index),
|
||||
})
|
||||
return OB_cls(remote, index, *args, **kwargs)
|
||||
|
||||
@ -126,3 +129,11 @@ def _make_bus_level_map(kind):
|
||||
return tuple((i, i+8) for i in range(0, (phys_out+virt_out)*8, 8))
|
||||
|
||||
_bus_maps = {kind.id: _make_bus_level_map(kind) for kind in kinds.all}
|
||||
|
||||
def _make_bus_mode_mixin(cls):
|
||||
""" Creates a mixin of Bus Modes. """
|
||||
return type('BusModeMixin', (cls,), {
|
||||
**{f'{mode.lower()}': bus_mode_prop(f'mode.{mode}') for mode in
|
||||
['normal', 'Amix', 'Bmix', 'Repeat', 'Composite', 'TVMix', 'UpMix21',
|
||||
'UpMix41', 'UpMix61', 'CenterOnly', 'LFEOnly', 'RearOnly']},
|
||||
})
|
||||
|
@ -10,17 +10,17 @@ class Modes:
|
||||
_mono: hex=0x00000004
|
||||
_mutec: hex=0x00000008
|
||||
|
||||
_mixdown: hex=0x00000010
|
||||
_amix: hex=0x00000010
|
||||
_repeat: hex=0x00000020
|
||||
_mixdownb: hex=0x00000030
|
||||
_bmix: hex=0x00000030
|
||||
_composite: hex=0x00000040
|
||||
_upmixtv: hex=0x00000050
|
||||
_updmix2: hex=0x00000060
|
||||
_upmix4: hex=0x00000070
|
||||
_upmix6: hex=0x00000080
|
||||
_center: hex=0x00000090
|
||||
_lfe: hex=0x000000A0
|
||||
_rear: hex=0x000000B0
|
||||
_tvmix: hex=0x00000050
|
||||
_upmix21: hex=0x00000060
|
||||
_upmix41: hex=0x00000070
|
||||
_upmix61: hex=0x00000080
|
||||
_centeronly: hex=0x00000090
|
||||
_lfeonly: hex=0x000000A0
|
||||
_rearonly: hex=0x000000B0
|
||||
|
||||
_mask: hex=0x000000F0
|
||||
|
||||
|
@ -10,3 +10,22 @@ def strip_output_prop(param):
|
||||
raise VMCMDErrors(f'{param} is a boolean parameter')
|
||||
self.setter(param, 1 if val else 0)
|
||||
return property(fget, fset)
|
||||
|
||||
def bus_mode_prop(param):
|
||||
""" A strip output prop. """
|
||||
def fget(self):
|
||||
data = self._remote.public_packet
|
||||
if param == 'mode.normal':
|
||||
vals = [
|
||||
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',
|
||||
'UpMix41', 'UpMix61', 'CenterOnly', 'LFEOnly', 'RearOnly']
|
||||
]
|
||||
return not True in vals
|
||||
return not int.from_bytes(data.busstate[self.index], 'little') & getattr(self._modes, f'_{param.lower().split(".")[1]}') == 0
|
||||
def fset(self, val):
|
||||
if not isinstance(val, bool) and val not in (0, 1):
|
||||
raise VMCMDErrors(f'{param} is a boolean parameter')
|
||||
self.setter(param, 1 if val else 0)
|
||||
return property(fget, fset)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user