add levels

add levels to strip and bus class.

strip level values defined as: pre fader input peak level in dB * 100
bus level values defined as: bus output peak level in dB * 100
This commit is contained in:
onyx-and-iris
2022-02-25 18:06:24 +00:00
parent 364e456c94
commit 6432eae3b4
3 changed files with 64 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ class OutputBus(Channel):
"""
OutputBus = PhysicalOutputBus if is_physical else VirtualOutputBus
OB_cls = type(f'Bus{remote.kind.name}', (OutputBus,), {
'levels': BusLevel(remote, index),
})
return OB_cls(remote, index, *args, **kwargs)
@@ -91,3 +92,28 @@ class PhysicalOutputBus(OutputBus):
class VirtualOutputBus(OutputBus):
pass
class BusLevel(OutputBus):
def __init__(self, remote, index):
super().__init__(remote, index)
self.level_map = _bus_maps[remote.kind.id]
def getter_level(self, mode=None):
def fget(data, i):
return data.outputlevels[i]
range_ = self.level_map[self.index]
data = self._remote.get_rt()
levels = tuple(fget(data, i) for i in range(*range_))
return levels
@property
def all(self) -> tuple:
return self.getter_level()
def _make_bus_level_map(kind):
phys_out, virt_out = kind.outs
return tuple((i, i+8) for i in range(0, (phys_out+virt_out)*8, 8))
_bus_maps = {kind.id: _make_bus_level_map(kind) for kind in kinds.all}