bit shift bus modes.

make modelist a BusMixin attr

remove vban.public_packet from README. It should be used only internally.

patch bump
This commit is contained in:
onyx-and-iris 2024-07-05 17:43:28 +01:00
parent 074ba4fe77
commit 8436634371
4 changed files with 29 additions and 45 deletions

View File

@ -506,12 +506,6 @@ Sends a script block as a string request, for example:
vban.sendtext("Strip[0].Mute=1;Bus[0].Mono=1") vban.sendtext("Strip[0].Mute=1;Bus[0].Mono=1")
``` ```
#### `vban.public_packet`
Returns a `VbanRtPacket`. Designed to be used internally by the interface but available for parsing through this read only property object.
States not guaranteed to be current (requires use of dirty parameters to confirm).
## Errors ## Errors
- `errors.VBANCMDError`: Base VBANCMD Exception class. - `errors.VBANCMDError`: Base VBANCMD Exception class.

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "vban-cmd" name = "vban-cmd"
version = "2.4.11" version = "2.4.12"
description = "Python interface for the VBAN RT Packet Service (Sendtext)" description = "Python interface for the VBAN RT Packet Service (Sendtext)"
authors = ["onyx-and-iris <code@onyxandiris.online>"] authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT" license = "MIT"

View File

@ -137,35 +137,40 @@ class BusLevel(IRemote):
def _make_bus_mode_mixin(): def _make_bus_mode_mixin():
"""Creates a mixin of Bus Modes.""" """Creates a mixin of Bus Modes."""
modestates = {
"normal": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
"amix": [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],
"repeat": [0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2],
"bmix": [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3],
"composite": [0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0],
"tvmix": [1, 0, 1, 4, 5, 4, 5, 0, 1, 0, 1],
"upmix21": [0, 2, 2, 4, 4, 6, 6, 0, 0, 2, 2],
"upmix41": [1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3],
"upmix61": [0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8],
"centeronly": [1, 0, 1, 0, 1, 0, 1, 8, 9, 8, 9],
"lfeonly": [0, 2, 2, 0, 0, 2, 2, 8, 8, 10, 10],
"rearonly": [1, 2, 3, 0, 1, 2, 3, 8, 9, 10, 11],
}
def identifier(self) -> str: def identifier(self) -> str:
return f"bus[{self.index}].mode" return f"bus[{self.index}].mode"
def get(self): def get(self):
time.sleep(0.01) states = [
for i, val in enumerate( (int.from_bytes(self.public_packet.busstate[self.index], "little") & val)
[ >> 4
self.amix, for val in self._modes.modevals
self.bmix, ]
self.repeat, for k, v in modestates.items():
self.composite, if states == v:
self.tvmix, return k
self.upmix21,
self.upmix41,
self.upmix61,
self.centeronly,
self.lfeonly,
self.rearonly,
]
):
if val:
return BusModes(i + 1).name
return "normal"
return type( return type(
"BusModeMixin", "BusModeMixin",
(IRemote,), (IRemote,),
{ {
"identifier": property(identifier), "identifier": property(identifier),
"modestates": modestates,
**{mode.name: bus_mode_prop(mode.name) for mode in BusModes}, **{mode.name: bus_mode_prop(mode.name) for mode in BusModes},
"get": get, "get": get,
}, },

View File

@ -70,26 +70,11 @@ def bus_mode_prop(param):
def fget(self): def fget(self):
cmd = self._cmd(param) cmd = self._cmd(param)
self.logger.debug(f"getter: {cmd}") self.logger.debug(f"getter: {cmd}")
modelist = { return [
"amix": (1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1), (int.from_bytes(self.public_packet.busstate[self.index], "little") & val)
"repeat": (0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2), >> 4
"bmix": (1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3),
"composite": (0, 0, 0, 4, 4, 4, 4, 0, 0, 0, 0),
"tvmix": (1, 0, 1, 4, 5, 4, 5, 0, 1, 0, 1),
"upmix21": (0, 2, 2, 4, 4, 6, 6, 0, 0, 2, 2),
"upmix41": (1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3),
"upmix61": (0, 0, 0, 0, 0, 0, 0, 8, 8, 8, 8),
"centeronly": (1, 0, 1, 0, 1, 0, 1, 8, 9, 8, 9),
"lfeonly": (0, 2, 2, 0, 0, 2, 2, 8, 8, 10, 10),
"rearonly": (1, 2, 3, 0, 1, 2, 3, 8, 9, 10, 11),
}
vals = (
int.from_bytes(self.public_packet.busstate[self.index], "little") & val
for val in self._modes.modevals for val in self._modes.modevals
) ] == self.modestates[param]
if param == "normal":
return not any(vals)
return tuple(round(val / 16) for val in vals) == modelist[param]
def fset(self, val): def fset(self, val):
self.setter(param, 1 if val else 0) self.setter(param, 1 if val else 0)