mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2026-03-12 04:59:09 +00:00
convert Modes class to a Flag Enum type and rename it to ChannelModes
move it into vban_cmd.packet
This commit is contained in:
parent
3e3bec6d50
commit
c9a505df0a
@ -1,82 +1,9 @@
|
|||||||
import abc
|
import abc
|
||||||
import logging
|
import logging
|
||||||
from dataclasses import dataclass
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class Modes:
|
|
||||||
"""Channel Modes"""
|
|
||||||
|
|
||||||
_mute: hex = 0x00000001
|
|
||||||
_solo: hex = 0x00000002
|
|
||||||
_mono: hex = 0x00000004
|
|
||||||
_mc: hex = 0x00000008
|
|
||||||
|
|
||||||
_amix: hex = 0x00000010
|
|
||||||
_repeat: hex = 0x00000020
|
|
||||||
_bmix: hex = 0x00000030
|
|
||||||
_composite: hex = 0x00000040
|
|
||||||
_tvmix: hex = 0x00000050
|
|
||||||
_upmix21: hex = 0x00000060
|
|
||||||
_upmix41: hex = 0x00000070
|
|
||||||
_upmix61: hex = 0x00000080
|
|
||||||
_centeronly: hex = 0x00000090
|
|
||||||
_lfeonly: hex = 0x000000A0
|
|
||||||
_rearonly: hex = 0x000000B0
|
|
||||||
|
|
||||||
_mask: hex = 0x000000F0
|
|
||||||
|
|
||||||
_on: hex = 0x00000100 # eq.on
|
|
||||||
_cross: hex = 0x00000200
|
|
||||||
_ab: hex = 0x00000800 # eq.ab
|
|
||||||
|
|
||||||
_busa: hex = 0x00001000
|
|
||||||
_busa1: hex = 0x00001000
|
|
||||||
_busa2: hex = 0x00002000
|
|
||||||
_busa3: hex = 0x00004000
|
|
||||||
_busa4: hex = 0x00008000
|
|
||||||
_busa5: hex = 0x00080000
|
|
||||||
|
|
||||||
_busb: hex = 0x00010000
|
|
||||||
_busb1: hex = 0x00010000
|
|
||||||
_busb2: hex = 0x00020000
|
|
||||||
_busb3: hex = 0x00040000
|
|
||||||
|
|
||||||
_pan0: hex = 0x00000000
|
|
||||||
_pancolor: hex = 0x00100000
|
|
||||||
_panmod: hex = 0x00200000
|
|
||||||
_panmask: hex = 0x00F00000
|
|
||||||
|
|
||||||
_postfx_r: hex = 0x01000000
|
|
||||||
_postfx_d: hex = 0x02000000
|
|
||||||
_postfx1: hex = 0x04000000
|
|
||||||
_postfx2: hex = 0x08000000
|
|
||||||
|
|
||||||
_sel: hex = 0x10000000
|
|
||||||
_monitor: hex = 0x20000000
|
|
||||||
|
|
||||||
@property
|
|
||||||
def modevals(self):
|
|
||||||
return (
|
|
||||||
val
|
|
||||||
for val in [
|
|
||||||
self._amix,
|
|
||||||
self._repeat,
|
|
||||||
self._bmix,
|
|
||||||
self._composite,
|
|
||||||
self._tvmix,
|
|
||||||
self._upmix21,
|
|
||||||
self._upmix41,
|
|
||||||
self._upmix61,
|
|
||||||
self._centeronly,
|
|
||||||
self._lfeonly,
|
|
||||||
self._rearonly,
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class IRemote(abc.ABC):
|
class IRemote(abc.ABC):
|
||||||
"""
|
"""
|
||||||
Common interface between base class and extended (higher) classes
|
Common interface between base class and extended (higher) classes
|
||||||
@ -88,7 +15,6 @@ class IRemote(abc.ABC):
|
|||||||
self._remote = remote
|
self._remote = remote
|
||||||
self.index = index
|
self.index = index
|
||||||
self.logger = logger.getChild(self.__class__.__name__)
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
self._modes = Modes()
|
|
||||||
|
|
||||||
def getter(self, param):
|
def getter(self, param):
|
||||||
cmd = self._cmd(param)
|
cmd = self._cmd(param)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from .enums import NBS, BusModes
|
from .enums import NBS, BusModes
|
||||||
|
from .packet.enums import ChannelModes
|
||||||
from .util import cache_bool, cache_float, cache_int, cache_string
|
from .util import cache_bool, cache_float, cache_int, cache_string
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ def channel_bool_prop(param):
|
|||||||
elif param.lower() == 'mc':
|
elif param.lower() == 'mc':
|
||||||
return channel_state.mc
|
return channel_state.mc
|
||||||
else:
|
else:
|
||||||
return channel_state.get_mode(getattr(self._modes, f'_{param.lower()}'))
|
return channel_state.get_mode(getattr(ChannelModes, param.upper()))
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
self.setter(param, 1 if val else 0)
|
self.setter(param, 1 if val else 0)
|
||||||
@ -55,7 +56,7 @@ def channel_int_prop(param):
|
|||||||
bit_9 = (channel_state._state >> 9) & 1
|
bit_9 = (channel_state._state >> 9) & 1
|
||||||
return (bit_9 << 1) | bit_2
|
return (bit_9 << 1) | bit_2
|
||||||
else:
|
else:
|
||||||
return channel_state.get_mode_int(getattr(self._modes, f'_{param.lower()}'))
|
return channel_state.get_mode_int(getattr(ChannelModes, param.upper()))
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
self.setter(param, val)
|
self.setter(param, val)
|
||||||
@ -89,7 +90,7 @@ def strip_output_prop(param):
|
|||||||
|
|
||||||
strip_state = self.public_packets[NBS.zero].states.strip[self.index]
|
strip_state = self.public_packets[NBS.zero].states.strip[self.index]
|
||||||
|
|
||||||
return strip_state.get_mode(getattr(self._modes, f'_bus{param.lower()}'))
|
return strip_state.get_mode(getattr(ChannelModes, f'BUS{param.upper()}'))
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
self.setter(param, 1 if val else 0)
|
self.setter(param, 1 if val else 0)
|
||||||
|
|||||||
53
vban_cmd/packet/enums.py
Normal file
53
vban_cmd/packet/enums.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
from enum import Flag
|
||||||
|
|
||||||
|
|
||||||
|
class ChannelModes(Flag):
|
||||||
|
"""Channel Modes - Bit flags that can be combined"""
|
||||||
|
|
||||||
|
MUTE = 0x00000001
|
||||||
|
SOLO = 0x00000002
|
||||||
|
MONO = 0x00000004
|
||||||
|
MC = 0x00000008
|
||||||
|
|
||||||
|
AMIX = 0x00000010
|
||||||
|
REPEAT = 0x00000020
|
||||||
|
BMIX = 0x00000030
|
||||||
|
COMPOSITE = 0x00000040
|
||||||
|
TVMIX = 0x00000050
|
||||||
|
UPMIX21 = 0x00000060
|
||||||
|
UPMIX41 = 0x00000070
|
||||||
|
UPMIX61 = 0x00000080
|
||||||
|
CENTERONLY = 0x00000090
|
||||||
|
LFEONLY = 0x000000A0
|
||||||
|
REARONLY = 0x000000B0
|
||||||
|
|
||||||
|
MASK = 0x000000F0
|
||||||
|
|
||||||
|
ON = 0x00000100 # eq.on
|
||||||
|
CROSS = 0x00000200
|
||||||
|
AB = 0x00000800 # eq.ab
|
||||||
|
|
||||||
|
BUSA = 0x00001000
|
||||||
|
BUSA1 = 0x00001000
|
||||||
|
BUSA2 = 0x00002000
|
||||||
|
BUSA3 = 0x00004000
|
||||||
|
BUSA4 = 0x00008000
|
||||||
|
BUSA5 = 0x00080000
|
||||||
|
|
||||||
|
BUSB = 0x00010000
|
||||||
|
BUSB1 = 0x00010000
|
||||||
|
BUSB2 = 0x00020000
|
||||||
|
BUSB3 = 0x00040000
|
||||||
|
|
||||||
|
PAN0 = 0x00000000
|
||||||
|
PANCOLOR = 0x00100000
|
||||||
|
PANMOD = 0x00200000
|
||||||
|
PANMASK = 0x00F00000
|
||||||
|
|
||||||
|
POSTFX_R = 0x01000000
|
||||||
|
POSTFX_D = 0x02000000
|
||||||
|
POSTFX1 = 0x04000000
|
||||||
|
POSTFX2 = 0x08000000
|
||||||
|
|
||||||
|
SEL = 0x10000000
|
||||||
|
MONITOR = 0x20000000
|
||||||
@ -5,6 +5,7 @@ from vban_cmd.enums import NBS
|
|||||||
from vban_cmd.kinds import KindMapClass
|
from vban_cmd.kinds import KindMapClass
|
||||||
from vban_cmd.util import comp
|
from vban_cmd.util import comp
|
||||||
|
|
||||||
|
from .enums import ChannelModes
|
||||||
from .headers import VbanPacket
|
from .headers import VbanPacket
|
||||||
|
|
||||||
|
|
||||||
@ -31,57 +32,57 @@ class ChannelState:
|
|||||||
# Common boolean modes
|
# Common boolean modes
|
||||||
@property
|
@property
|
||||||
def mute(self) -> bool:
|
def mute(self) -> bool:
|
||||||
return (self._state & 0x00000001) != 0
|
return (self._state & ChannelModes.MUTE) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def solo(self) -> bool:
|
def solo(self) -> bool:
|
||||||
return (self._state & 0x00000002) != 0
|
return (self._state & ChannelModes.SOLO) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mono(self) -> bool:
|
def mono(self) -> bool:
|
||||||
return (self._state & 0x00000004) != 0
|
return (self._state & ChannelModes.MONO) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mc(self) -> bool:
|
def mc(self) -> bool:
|
||||||
return (self._state & 0x00000008) != 0
|
return (self._state & ChannelModes.MC) != 0
|
||||||
|
|
||||||
# EQ modes
|
# EQ modes
|
||||||
@property
|
@property
|
||||||
def eq_on(self) -> bool:
|
def eq_on(self) -> bool:
|
||||||
return (self._state & 0x00000100) != 0
|
return (self._state & ChannelModes.ON) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def eq_ab(self) -> bool:
|
def eq_ab(self) -> bool:
|
||||||
return (self._state & 0x00000800) != 0
|
return (self._state & ChannelModes.AB) != 0
|
||||||
|
|
||||||
# Bus assignments (strip to bus routing)
|
# Bus assignments (strip to bus routing)
|
||||||
@property
|
@property
|
||||||
def busa1(self) -> bool:
|
def busa1(self) -> bool:
|
||||||
return (self._state & 0x00001000) != 0
|
return (self._state & ChannelModes.BUSA1) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def busa2(self) -> bool:
|
def busa2(self) -> bool:
|
||||||
return (self._state & 0x00002000) != 0
|
return (self._state & ChannelModes.BUSA2) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def busa3(self) -> bool:
|
def busa3(self) -> bool:
|
||||||
return (self._state & 0x00004000) != 0
|
return (self._state & ChannelModes.BUSA3) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def busa4(self) -> bool:
|
def busa4(self) -> bool:
|
||||||
return (self._state & 0x00008000) != 0
|
return (self._state & ChannelModes.BUSA4) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def busb1(self) -> bool:
|
def busb1(self) -> bool:
|
||||||
return (self._state & 0x00010000) != 0
|
return (self._state & ChannelModes.BUSB1) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def busb2(self) -> bool:
|
def busb2(self) -> bool:
|
||||||
return (self._state & 0x00020000) != 0
|
return (self._state & ChannelModes.BUSB2) != 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def busb3(self) -> bool:
|
def busb3(self) -> bool:
|
||||||
return (self._state & 0x00040000) != 0
|
return (self._state & ChannelModes.BUSB3) != 0
|
||||||
|
|
||||||
|
|
||||||
class States(NamedTuple):
|
class States(NamedTuple):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user