mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-18 18:40:47 +00:00
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:
parent
364e456c94
commit
6432eae3b4
@ -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()
|
||||||
|
@ -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}
|
||||||
|
@ -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}
|
||||||
|
Loading…
Reference in New Issue
Block a user