mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-18 18:40:47 +00:00
add gain,levels
implement gain, levels for strip/bus classes. add to readme
This commit is contained in:
parent
471abb3ca6
commit
44a66466c2
17
README.md
17
README.md
@ -70,7 +70,7 @@ A *kind* specifies a major Voicemeeter version. Currently this encompasses
|
||||
- `banana`
|
||||
- `potato`
|
||||
|
||||
#### `vban_cmd.connect(kind_id, ip=ip) -> '(VMRemote)'`
|
||||
#### `vban_cmd.connect(kind_id, ip=ip) -> '(VbanCmd)'`
|
||||
Factory function for remotes.
|
||||
- `ip`: remote pc you wish to send requests to.
|
||||
|
||||
@ -102,15 +102,13 @@ The following properties are gettable and settable:
|
||||
- `solo`: boolean
|
||||
- `mute`: boolean
|
||||
- `label`: string
|
||||
- `gainlayer`: float, -60 to 12
|
||||
- Output mapping (e.g. `A1`, `B3`, etc.): boolean, depends on the Voicemeeter kind
|
||||
|
||||
The following properties are settable:
|
||||
- `label`: string
|
||||
- `gain`: float, from -60.0 to 12.0
|
||||
- `comp`: float, from 0.0 to 10.0
|
||||
- `gate`: float, from 0.0 to 10.0
|
||||
- `limit`: int, from -40 to 12
|
||||
- `gainlayer`: float
|
||||
|
||||
### `Bus`
|
||||
The following properties are gettable and settable:
|
||||
@ -119,10 +117,17 @@ The following properties are gettable and settable:
|
||||
- `eq`: boolean
|
||||
- `eq_ab`: boolean
|
||||
- `label`: string
|
||||
- `gain`: float, -60 to 12
|
||||
|
||||
The following properties are settable:
|
||||
- `gain`: float
|
||||
### `VbanCmd` (lower level)
|
||||
#### `vban.public_packet`
|
||||
Fetches a new RT Data Packet (some values will still be in byte form)
|
||||
|
||||
#### `vban.set_rt(id_, param, val)`
|
||||
Sends a string request RT Packet where the command would take the form:
|
||||
```python
|
||||
f'{id_}.{param}={val}'
|
||||
```
|
||||
|
||||
### `Errors`
|
||||
- `errors.VMCMDErrors`: Base VMCMD error class.
|
||||
|
@ -71,8 +71,21 @@ class OutputBus(Channel):
|
||||
raise VMCMDErrors('label is a string parameter')
|
||||
self.setter('Label', val)
|
||||
|
||||
@property
|
||||
def gain(self):
|
||||
return self.public_packet.busgain[self.index]
|
||||
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
|
||||
return round((fget() * 0.01), 1)
|
||||
|
||||
@gain.setter
|
||||
def gain(self, val: float):
|
||||
self.setter('gain', val)
|
||||
|
||||
|
||||
class PhysicalOutputBus(OutputBus):
|
||||
@ -96,11 +109,12 @@ class BusLevel(OutputBus):
|
||||
|
||||
def getter_level(self, mode=None):
|
||||
def fget(i, data):
|
||||
return data.outputlevels[i]
|
||||
val = data.outputlevels[i]
|
||||
return -val * 0.01
|
||||
|
||||
range_ = self.level_map[self.index]
|
||||
data = self.public_packet
|
||||
levels = tuple(fget(i, data) for i in range(*range_))
|
||||
levels = tuple(round(fget(i, data), 1) for i in range(*range_))
|
||||
return levels
|
||||
|
||||
@property
|
||||
|
@ -47,11 +47,11 @@ class VBAN_VMRT_Packet_Data:
|
||||
@property
|
||||
def inputlevels(self) -> tuple:
|
||||
""" returns the entire level array across all inputs """
|
||||
return tuple(int.from_bytes(self._inputLeveldB100[i:i+2], 'little') for i in range(0, 68, 2))
|
||||
return tuple(((1 << 16) - 1) - int.from_bytes(self._inputLeveldB100[i:i+2], 'little') for i in range(0, 68, 2))
|
||||
@property
|
||||
def outputlevels(self) -> tuple:
|
||||
""" returns the entire level array across all outputs """
|
||||
return tuple(int.from_bytes(self._outputLeveldB100[i:i+2], 'little') for i in range(0, 128, 2))
|
||||
return tuple(((1 << 16) - 1) - int.from_bytes(self._outputLeveldB100[i:i+2], 'little') for i in range(0, 128, 2))
|
||||
@property
|
||||
def stripstate(self) -> tuple:
|
||||
""" returns tuple of strip states accessable through bit modes """
|
||||
@ -67,33 +67,33 @@ class VBAN_VMRT_Packet_Data:
|
||||
"""
|
||||
@property
|
||||
def stripgainlayer1(self) -> tuple:
|
||||
return tuple(int.from_bytes(self._stripGaindB100Layer1[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
return tuple(((1 << 16) - 1) - int.from_bytes(self._stripGaindB100Layer1[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
@property
|
||||
def stripgainlayer2(self) -> tuple:
|
||||
return tuple(int.from_bytes(self._stripGaindB100Layer2[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
return tuple(((1 << 16) - 1) - int.from_bytes(self._stripGaindB100Layer2[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
@property
|
||||
def stripgainlayer3(self) -> tuple:
|
||||
return tuple(int.from_bytes(self._stripGaindB100Layer3[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
return tuple(((1 << 16) - 1) - int.from_bytes(self._stripGaindB100Layer3[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
@property
|
||||
def stripgainlayer4(self) -> tuple:
|
||||
return tuple(int.from_bytes(self._stripGaindB100Layer4[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
return tuple(((1 << 16) - 1) - int.from_bytes(self._stripGaindB100Layer4[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
@property
|
||||
def stripgainlayer5(self) -> tuple:
|
||||
return tuple(int.from_bytes(self._stripGaindB100Layer5[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
return tuple(((1 << 16) - 1) - int.from_bytes(self._stripGaindB100Layer5[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
@property
|
||||
def stripgainlayer6(self) -> tuple:
|
||||
return tuple(int.from_bytes(self._stripGaindB100Layer6[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
return tuple(((1 << 16) - 1) - int.from_bytes(self._stripGaindB100Layer6[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
@property
|
||||
def stripgainlayer7(self) -> tuple:
|
||||
return tuple(int.from_bytes(self._stripGaindB100Layer7[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
return tuple(((1 << 16) - 1) - int.from_bytes(self._stripGaindB100Layer7[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
@property
|
||||
def stripgainlayer8(self) -> tuple:
|
||||
return tuple(int.from_bytes(self._stripGaindB100Layer8[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
return tuple(((1 << 16) - 1) - int.from_bytes(self._stripGaindB100Layer8[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
|
||||
@property
|
||||
def busgain(self) -> tuple:
|
||||
""" returns tuple of bus gains """
|
||||
return tuple(int.from_bytes(self._busGaindB100[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
return tuple(((1 << 16) - 1) - int.from_bytes(self._busGaindB100[i:i+2], 'little') for i in range(0, 16, 2))
|
||||
@property
|
||||
def striplabels(self) -> tuple:
|
||||
""" returns tuple of strip labels """
|
||||
|
@ -131,11 +131,12 @@ class StripLevel(InputStrip):
|
||||
|
||||
def getter_level(self, mode=None):
|
||||
def fget(i, data):
|
||||
return data.inputlevels[i]
|
||||
val = data.inputlevels[i]
|
||||
return -val * 0.01
|
||||
|
||||
range_ = self.level_map[self.index]
|
||||
data = self.public_packet
|
||||
levels = tuple(fget(i, data) for i in range(*range_))
|
||||
levels = tuple(round(fget(i, data), 1) for i in range(*range_))
|
||||
return levels
|
||||
|
||||
@property
|
||||
@ -158,7 +159,15 @@ class GainLayer(InputStrip):
|
||||
|
||||
@property
|
||||
def gain(self):
|
||||
return getattr(self.public_packet, f'stripgainlayer{self._i+1}')[self.index]
|
||||
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
|
||||
return round((fget() * 0.01), 1)
|
||||
|
||||
@gain.setter
|
||||
def gain(self, val):
|
||||
|
@ -19,7 +19,7 @@ from .strip import InputStrip
|
||||
from .bus import OutputBus
|
||||
|
||||
class VbanCmd(abc.ABC):
|
||||
def __init__(self, *args, **kwargs):
|
||||
def __init__(self, **kwargs):
|
||||
self._ip = kwargs['ip']
|
||||
self._port = kwargs['port']
|
||||
self._streamname = kwargs['streamname']
|
||||
@ -64,7 +64,7 @@ class VbanCmd(abc.ABC):
|
||||
sleep(10)
|
||||
|
||||
def _fetch_rt_packet(self):
|
||||
data, _ = self._rt_packet_socket.recvfrom(1024*2)
|
||||
data, _ = self._rt_packet_socket.recvfrom(1024*1024*2)
|
||||
# check for packet data
|
||||
if len(data) > HEADER_SIZE:
|
||||
# check if packet is of type rt service
|
||||
@ -93,7 +93,6 @@ class VbanCmd(abc.ABC):
|
||||
_stripLabelUTF8c60=data[452:932],
|
||||
_busLabelUTF8c60=data[932:1412],
|
||||
)
|
||||
return False
|
||||
|
||||
@property
|
||||
def public_packet(self):
|
||||
@ -155,13 +154,13 @@ def _make_remote(kind: NamedTuple) -> VbanCmd:
|
||||
|
||||
The returned class will subclass VbanCmd.
|
||||
"""
|
||||
def init(self, *args, **kwargs):
|
||||
def init(self, **kwargs):
|
||||
defaultkwargs = {
|
||||
'ip': None, 'port': 6990, 'streamname': 'Command1', 'bps': 0,
|
||||
'channel': 0, 'delay': 0.001, 'max_polls': 2
|
||||
}
|
||||
kwargs = defaultkwargs | kwargs
|
||||
VbanCmd.__init__(self, *args, **kwargs)
|
||||
VbanCmd.__init__(self, **kwargs)
|
||||
self.kind = kind
|
||||
self.phys_in, self.virt_in = kind.ins
|
||||
self.phys_out, self.virt_out = kind.outs
|
||||
@ -178,7 +177,7 @@ def _make_remote(kind: NamedTuple) -> VbanCmd:
|
||||
|
||||
_remotes = {kind.id: _make_remote(kind) for kind in kinds.all}
|
||||
|
||||
def connect(kind_id: str, *args, **kwargs):
|
||||
def connect(kind_id: str, **kwargs):
|
||||
try:
|
||||
VBANCMD_cls = _remotes[kind_id]
|
||||
return VBANCMD_cls(**kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user