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

@ -3,7 +3,8 @@ from time import sleep
def main(): def main():
with vban_cmd.connect('potato', ip='ws.local') as vban: with vban_cmd.connect('potato', ip='ws.local') as vban:
pass for i in range(8):
print(vban.bus[i].levels.all)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

View File

@ -14,6 +14,7 @@ class OutputBus(Channel):
""" """
OutputBus = PhysicalOutputBus if is_physical else VirtualOutputBus OutputBus = PhysicalOutputBus if is_physical else VirtualOutputBus
OB_cls = type(f'Bus{remote.kind.name}', (OutputBus,), { OB_cls = type(f'Bus{remote.kind.name}', (OutputBus,), {
'levels': BusLevel(remote, index),
}) })
return OB_cls(remote, index, *args, **kwargs) return OB_cls(remote, index, *args, **kwargs)
@ -91,3 +92,28 @@ class PhysicalOutputBus(OutputBus):
class VirtualOutputBus(OutputBus): class VirtualOutputBus(OutputBus):
pass 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}

View File

@ -15,6 +15,7 @@ class InputStrip(Channel):
PhysStrip, VirtStrip = _strip_pairs[remote.kind.id] PhysStrip, VirtStrip = _strip_pairs[remote.kind.id]
InputStrip = PhysStrip if is_physical else VirtStrip InputStrip = PhysStrip if is_physical else VirtStrip
IS_cls = type(f'Strip{remote.kind.name}', (InputStrip,), { IS_cls = type(f'Strip{remote.kind.name}', (InputStrip,), {
'levels': StripLevel(remote, index),
}) })
return IS_cls(remote, index, **kwargs) return IS_cls(remote, index, **kwargs)
@ -133,6 +134,33 @@ class VirtualInputStrip(InputStrip):
self.setter('karaoke', val) self.setter('karaoke', val)
class StripLevel(InputStrip):
def __init__(self, remote, index):
super().__init__(remote, index)
self.level_map = _strip_maps[remote.kind.id]
def getter_level(self, mode=None):
def fget(data, i):
return data.inputlevels[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 prefader(self) -> tuple:
return self.getter_level()
@property
def postfader(self) -> tuple:
return
@property
def postmute(self) -> tuple:
return
def _make_strip_mixin(kind): def _make_strip_mixin(kind):
""" Creates a mixin with the kind's strip layout set as class variables. """ """ Creates a mixin with the kind's strip layout set as class variables. """
num_A, num_B = kind.outs num_A, num_B = kind.outs
@ -151,3 +179,11 @@ def _make_strip_pair(kind):
return (PhysStrip, VirtStrip) return (PhysStrip, VirtStrip)
_strip_pairs = {kind.id: _make_strip_pair(kind) for kind in kinds.all} _strip_pairs = {kind.id: _make_strip_pair(kind) for kind in kinds.all}
def _make_strip_level_map(kind):
phys_in, virt_in = kind.ins
phys_map = tuple((i, i+2) for i in range(0, phys_in*2, 2))
virt_map = tuple((i, i+8) for i in range(phys_in*2, phys_in*2+virt_in*8, 8))
return phys_map+virt_map
_strip_maps = {kind.id: _make_strip_level_map(kind) for kind in kinds.all}