changes to level/gain properties in VbanRtPacket

level getters in strip, bus fetch from public packet if not in cache
This commit is contained in:
onyx-and-iris 2022-09-28 18:07:10 +01:00
parent 1169435104
commit db96872965
3 changed files with 41 additions and 45 deletions

View File

@ -32,17 +32,12 @@ class Bus(IRemote):
def gain(self) -> float:
def fget():
val = self.public_packet.busgain[self.index]
if val < 10000:
return -val
elif val == ((1 << 16) - 1):
return 0
else:
return ((1 << 16) - 1) - val
if 0 <= val <= 1200:
return val * 0.01
return (((1 << 16) - 1) - val) * -0.01
val = self.getter("gain")
if val is None:
val = fget() * 0.01
return round(val, 1)
return round(val if val else fget(), 1)
@gain.setter
def gain(self, val: float):
@ -79,9 +74,16 @@ class BusLevel(IRemote):
def getter(self):
"""Returns a tuple of level values for the channel."""
if self._remote.running and self._remote.event.ldirty:
return tuple(
round(i * -0.01, 1)
for i in self._remote.cache["bus_level"][self.range[0] : self.range[-1]]
)
return tuple(
round(-i * 0.01, 1)
for i in self._remote.cache["bus_level"][self.range[0] : self.range[-1]]
round(i * -0.01, 1)
for i in self._remote._get_levels(self.public_packet)[1][
self.range[0] : self.range[-1]
]
)
@property

View File

@ -80,9 +80,7 @@ class VbanRtPacket:
def inputlevels(self) -> Generator[float, None, None]:
"""returns the entire level array across all inputs"""
for i in range(0, 68, 2):
val = ((1 << 16) - 1) - int.from_bytes(
self._inputLeveldB100[i : i + 2], "little"
)
val = int.from_bytes(self._inputLeveldB100[i : i + 2], "little")
if val != ((1 << 16) - 1):
yield val
@ -90,9 +88,7 @@ class VbanRtPacket:
def outputlevels(self) -> Generator[float, None, None]:
"""returns the entire level array across all outputs"""
for i in range(0, 128, 2):
val = ((1 << 16) - 1) - int.from_bytes(
self._outputLeveldB100[i : i + 2], "little"
)
val = int.from_bytes(self._outputLeveldB100[i : i + 2], "little")
if val != ((1 << 16) - 1):
yield val
@ -114,64 +110,56 @@ class VbanRtPacket:
@property
def stripgainlayer1(self) -> tuple:
return tuple(
((1 << 16) - 1)
- int.from_bytes(self._stripGaindB100Layer1[i : i + 2], "little")
int.from_bytes(self._stripGaindB100Layer1[i : i + 2], "little")
for i in range(0, 16, 2)
)
@property
def stripgainlayer2(self) -> tuple:
return tuple(
((1 << 16) - 1)
- int.from_bytes(self._stripGaindB100Layer2[i : i + 2], "little")
int.from_bytes(self._stripGaindB100Layer2[i : i + 2], "little")
for i in range(0, 16, 2)
)
@property
def stripgainlayer3(self) -> tuple:
return tuple(
((1 << 16) - 1)
- int.from_bytes(self._stripGaindB100Layer3[i : i + 2], "little")
int.from_bytes(self._stripGaindB100Layer3[i : i + 2], "little")
for i in range(0, 16, 2)
)
@property
def stripgainlayer4(self) -> tuple:
return tuple(
((1 << 16) - 1)
- int.from_bytes(self._stripGaindB100Layer4[i : i + 2], "little")
int.from_bytes(self._stripGaindB100Layer4[i : i + 2], "little")
for i in range(0, 16, 2)
)
@property
def stripgainlayer5(self) -> tuple:
return tuple(
((1 << 16) - 1)
- int.from_bytes(self._stripGaindB100Layer5[i : i + 2], "little")
int.from_bytes(self._stripGaindB100Layer5[i : i + 2], "little")
for i in range(0, 16, 2)
)
@property
def stripgainlayer6(self) -> tuple:
return tuple(
((1 << 16) - 1)
- int.from_bytes(self._stripGaindB100Layer6[i : i + 2], "little")
int.from_bytes(self._stripGaindB100Layer6[i : i + 2], "little")
for i in range(0, 16, 2)
)
@property
def stripgainlayer7(self) -> tuple:
return tuple(
((1 << 16) - 1)
- int.from_bytes(self._stripGaindB100Layer7[i : i + 2], "little")
int.from_bytes(self._stripGaindB100Layer7[i : i + 2], "little")
for i in range(0, 16, 2)
)
@property
def stripgainlayer8(self) -> tuple:
return tuple(
((1 << 16) - 1)
- int.from_bytes(self._stripGaindB100Layer8[i : i + 2], "little")
int.from_bytes(self._stripGaindB100Layer8[i : i + 2], "little")
for i in range(0, 16, 2)
)
@ -179,7 +167,7 @@ class VbanRtPacket:
def busgain(self) -> tuple:
"""returns tuple of bus gains"""
return tuple(
((1 << 16) - 1) - int.from_bytes(self._busGaindB100[i : i + 2], "little")
int.from_bytes(self._busGaindB100[i : i + 2], "little")
for i in range(0, 16, 2)
)

View File

@ -103,9 +103,20 @@ class StripLevel(IRemote):
self.range = self.level_map[self.index]
def getter(self):
"""Returns a tuple of level values for the channel."""
if self._remote.running and self._remote.event.ldirty:
return tuple(
round(i * -0.01, 1)
for i in self._remote.cache["strip_level"][
self.range[0] : self.range[-1]
]
)
return tuple(
round(-i * 0.01, 1)
for i in self._remote.cache["strip_level"][self.range[0] : self.range[-1]]
round(i * -0.01, 1)
for i in self._remote._get_levels(self.public_packet)[0][
self.range[0] : self.range[-1]
]
)
@property
@ -149,17 +160,12 @@ class GainLayer(IRemote):
def gain(self) -> float:
def fget():
val = getattr(self.public_packet, f"stripgainlayer{self._i+1}")[self.index]
if val < 10000:
return -val
elif val == ((1 << 16) - 1):
return 0
else:
return ((1 << 16) - 1) - val
if 0 <= val <= 1200:
return val * 0.01
return (((1 << 16) - 1) - val) * -0.01
val = self.getter(f"GainLayer[{self._i}]")
if val is None:
val = fget() * 0.01
return round(val, 1)
return round(val if val else fget(), 1)
@gain.setter
def gain(self, val: float):