Compare commits

..

6 Commits

Author SHA1 Message Date
28cbef5ef6 patch bump 2026-03-03 15:48:23 +00:00
5b3b35fca3 flag value 2026-03-03 15:48:09 +00:00
7b3149a1e1 patch bump 2026-03-03 15:38:11 +00:00
230d9f0eb3 upd test config 2026-03-03 15:37:38 +00:00
c9a505df0a convert Modes class to a Flag Enum type and rename it to ChannelModes
move it into vban_cmd.packet
2026-03-03 15:36:56 +00:00
3e3bec6d50 remove the sleep(), the @ratelimit decorator already handles this. 2026-03-03 15:31:31 +00:00
7 changed files with 75 additions and 93 deletions

View File

@ -1,6 +1,6 @@
[project] [project]
name = "vban-cmd" name = "vban-cmd"
version = "2.9.2" version = "2.9.4"
description = "Python interface for the VBAN RT Packet Service (Sendtext)" description = "Python interface for the VBAN RT Packet Service (Sendtext)"
authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }] authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }]
license = { text = "MIT" } license = { text = "MIT" }

View File

@ -11,7 +11,7 @@ from vban_cmd.kinds import request_kind_map as kindmap
KIND_ID = os.environ.get('KIND', 'potato') KIND_ID = os.environ.get('KIND', 'potato')
opts = { opts = {
'ip': os.getenv('VBANCMD_IP', 'localhost'), 'host': os.getenv('VBANCMD_HOST', 'localhost'),
'streamname': os.getenv('VBANCMD_STREAMNAME', 'Command1'), 'streamname': os.getenv('VBANCMD_STREAMNAME', 'Command1'),
'port': int(os.getenv('VBANCMD_PORT', 6980)), 'port': int(os.getenv('VBANCMD_PORT', 6980)),
} }

View File

@ -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)

View File

@ -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()).value)
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,9 @@ 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()).value
)
def fset(self, val): def fset(self, val):
self.setter(param, val) self.setter(param, val)
@ -89,7 +92,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()}').value)
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
View 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

View File

@ -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.value) != 0
@property @property
def solo(self) -> bool: def solo(self) -> bool:
return (self._state & 0x00000002) != 0 return (self._state & ChannelModes.SOLO.value) != 0
@property @property
def mono(self) -> bool: def mono(self) -> bool:
return (self._state & 0x00000004) != 0 return (self._state & ChannelModes.MONO.value) != 0
@property @property
def mc(self) -> bool: def mc(self) -> bool:
return (self._state & 0x00000008) != 0 return (self._state & ChannelModes.MC.value) != 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.value) != 0
@property @property
def eq_ab(self) -> bool: def eq_ab(self) -> bool:
return (self._state & 0x00000800) != 0 return (self._state & ChannelModes.AB.value) != 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.value) != 0
@property @property
def busa2(self) -> bool: def busa2(self) -> bool:
return (self._state & 0x00002000) != 0 return (self._state & ChannelModes.BUSA2.value) != 0
@property @property
def busa3(self) -> bool: def busa3(self) -> bool:
return (self._state & 0x00004000) != 0 return (self._state & ChannelModes.BUSA3.value) != 0
@property @property
def busa4(self) -> bool: def busa4(self) -> bool:
return (self._state & 0x00008000) != 0 return (self._state & ChannelModes.BUSA4.value) != 0
@property @property
def busb1(self) -> bool: def busb1(self) -> bool:
return (self._state & 0x00010000) != 0 return (self._state & ChannelModes.BUSB1.value) != 0
@property @property
def busb2(self) -> bool: def busb2(self) -> bool:
return (self._state & 0x00020000) != 0 return (self._state & ChannelModes.BUSB2.value) != 0
@property @property
def busb3(self) -> bool: def busb3(self) -> bool:
return (self._state & 0x00040000) != 0 return (self._state & ChannelModes.BUSB3.value) != 0
class States(NamedTuple): class States(NamedTuple):

View File

@ -312,7 +312,6 @@ class VbanCmd(abc.ABC):
for key, di in data.items(): for key, di in data.items():
target(key).apply(di) target(key).apply(di)
time.sleep(self.DELAY)
def apply_config(self, name): def apply_config(self, name):
"""applies a config from memory""" """applies a config from memory"""