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.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.VBANCMDError`: Base VBANCMD Exception class.

View File

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

View File

@ -137,35 +137,40 @@ class BusLevel(IRemote):
def _make_bus_mode_mixin():
"""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:
return f"bus[{self.index}].mode"
def get(self):
time.sleep(0.01)
for i, val in enumerate(
[
self.amix,
self.bmix,
self.repeat,
self.composite,
self.tvmix,
self.upmix21,
self.upmix41,
self.upmix61,
self.centeronly,
self.lfeonly,
self.rearonly,
]
):
if val:
return BusModes(i + 1).name
return "normal"
states = [
(int.from_bytes(self.public_packet.busstate[self.index], "little") & val)
>> 4
for val in self._modes.modevals
]
for k, v in modestates.items():
if states == v:
return k
return type(
"BusModeMixin",
(IRemote,),
{
"identifier": property(identifier),
"modestates": modestates,
**{mode.name: bus_mode_prop(mode.name) for mode in BusModes},
"get": get,
},

View File

@ -70,26 +70,11 @@ def bus_mode_prop(param):
def fget(self):
cmd = self._cmd(param)
self.logger.debug(f"getter: {cmd}")
modelist = {
"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),
}
vals = (
int.from_bytes(self.public_packet.busstate[self.index], "little") & val
return [
(int.from_bytes(self.public_packet.busstate[self.index], "little") & val)
>> 4
for val in self._modes.modevals
)
if param == "normal":
return not any(vals)
return tuple(round(val / 16) for val in vals) == modelist[param]
] == self.modestates[param]
def fset(self, val):
self.setter(param, 1 if val else 0)