mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-18 18:40:47 +00:00
add apply
add apply to vbancmd and channel modules. add apply to readme
This commit is contained in:
parent
127ef1e10f
commit
3e0152082b
38
README.md
38
README.md
@ -1,6 +1,6 @@
|
|||||||
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/onyx-and-iris/vban-cmd-python/blob/dev/LICENSE)
|
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/onyx-and-iris/vban-cmd-python/blob/dev/LICENSE)
|
||||||
# VBAN CMD
|
# VBAN CMD
|
||||||
This package offers a Python interface for [Voicemeeter VBAN TEXT](https://vb-audio.com/Voicemeeter/VBANProtocol_Specifications.pdf#page=19) as well as the [Voicemeeter RT Packet Service](https://vb-audio.com/Voicemeeter/VBANProtocol_Specifications.pdf#page=27) which allows a client to send and receive parameter values over a network.
|
This package offers a Python interface for [Voicemeeter VBAN TEXT](https://vb-audio.com/Voicemeeter/VBANProtocol_Specifications.pdf#page=19) as well as the [Voicemeeter RT Packet Service](https://vb-audio.com/Voicemeeter/VBANProtocol_Specifications.pdf#page=27) which allows a client to send and receive parameter values over a local network.
|
||||||
|
|
||||||
It may be used standalone or to extend the [Voicemeeter Remote Python API](https://github.com/onyx-and-iris/voicemeeter-api-python)
|
It may be used standalone or to extend the [Voicemeeter Remote Python API](https://github.com/onyx-and-iris/voicemeeter-api-python)
|
||||||
|
|
||||||
@ -31,14 +31,6 @@ With development dependencies:
|
|||||||
pip install -e .['development']
|
pip install -e .['development']
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Connection:
|
|
||||||
For sending a text command several configuration options are available:
|
|
||||||
- `ip`: remote address
|
|
||||||
- `streamname`: default 'Command1'
|
|
||||||
- `port`: default 6990
|
|
||||||
- `channel`: from 0 to 255
|
|
||||||
- `bps`: bitrate of stream, default 0 should be safe for most cases.
|
|
||||||
|
|
||||||
#### Use with a context manager:
|
#### Use with a context manager:
|
||||||
It is advised to use this code with a context manager.
|
It is advised to use this code with a context manager.
|
||||||
Parameter coverage is not as extensive for the RT Packet Service as with the Remote API.
|
Parameter coverage is not as extensive for the RT Packet Service as with the Remote API.
|
||||||
@ -81,9 +73,13 @@ A *kind* specifies a major Voicemeeter version. Currently this encompasses
|
|||||||
- `banana`
|
- `banana`
|
||||||
- `potato`
|
- `potato`
|
||||||
|
|
||||||
#### `vbancmd.connect(kind_id, ip=ip) -> '(VbanCmd)'`
|
#### `vbancmd.connect(kind_id, **kwargs) -> '(VbanCmd)'`
|
||||||
Factory function for remotes.
|
Factory function for remotes. Keyword arguments include:
|
||||||
- `ip`: remote pc you wish to send requests to.
|
- `ip`: remote pc you wish to send requests to.
|
||||||
|
- `streamname`: default 'Command1'
|
||||||
|
- `port`: default 6990
|
||||||
|
- `channel`: from 0 to 255
|
||||||
|
- `bps`: bitrate of stream, default 0 should be safe for most cases.
|
||||||
|
|
||||||
|
|
||||||
### `VbanCmd` (higher level)
|
### `VbanCmd` (higher level)
|
||||||
@ -106,13 +102,18 @@ Hides Voicemeeter if it's shown. No effect otherwise.
|
|||||||
Closes Voicemeeter.
|
Closes Voicemeeter.
|
||||||
#### `vban.restart()`
|
#### `vban.restart()`
|
||||||
Restarts Voicemeeter's audio engine.
|
Restarts Voicemeeter's audio engine.
|
||||||
#### `vban.sendtext(cmd)`
|
|
||||||
Sends a TEXT command, for example:
|
#### `vban.apply(mapping)`
|
||||||
|
Updates values through a dict.
|
||||||
|
Example:
|
||||||
```python
|
```python
|
||||||
# Use ';' or ',' for delimiters.
|
vban.apply({
|
||||||
vban.sendtext('Strip[0].Mute=1;Strip[3].A3=0;Bus[2].Mute=0;Bus[3].Eq.On=1')
|
'strip-2': dict(A1=True, B1=True, gain=-6.0),
|
||||||
|
'bus-2': dict(mute=True),
|
||||||
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### `Strip`
|
### `Strip`
|
||||||
The following properties are gettable and settable:
|
The following properties are gettable and settable:
|
||||||
- `mono`: boolean
|
- `mono`: boolean
|
||||||
@ -150,6 +151,13 @@ Used for updating the RT data packet, used internally by the Interface.
|
|||||||
vban.public_packet = vban._get_rt()
|
vban.public_packet = vban._get_rt()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### `vban.sendtext(cmd)`
|
||||||
|
Sends a multi parameter TEXT string command, for example:
|
||||||
|
```python
|
||||||
|
# Use ';' or ',' for delimiters.
|
||||||
|
vban.sendtext('Strip[0].Mute=1;Strip[3].A3=0;Bus[2].Mute=0;Bus[3].Eq.On=1')
|
||||||
|
```
|
||||||
|
|
||||||
### `Errors`
|
### `Errors`
|
||||||
- `errors.VMCMDErrors`: Base VMCMD error class.
|
- `errors.VMCMDErrors`: Base VMCMD error class.
|
||||||
|
|
||||||
|
@ -73,3 +73,10 @@ class Channel(abc.ABC):
|
|||||||
def public_packet(self):
|
def public_packet(self):
|
||||||
""" Returns an RT data packet. """
|
""" Returns an RT data packet. """
|
||||||
return self._remote.public_packet
|
return self._remote.public_packet
|
||||||
|
|
||||||
|
def apply(self, mapping):
|
||||||
|
""" Sets all parameters of a dict for the strip. """
|
||||||
|
for key, val in mapping.items():
|
||||||
|
if not hasattr(self, key):
|
||||||
|
raise VMCMDErrors(f'Invalid {self.identifier} attribute: {key}')
|
||||||
|
setattr(self, key, val)
|
||||||
|
@ -74,7 +74,7 @@ class VbanCmd(abc.ABC):
|
|||||||
while self.running:
|
while self.running:
|
||||||
if self._rt_register_socket in self.ready_to_write:
|
if self._rt_register_socket in self.ready_to_write:
|
||||||
self._rt_register_socket.sendto(
|
self._rt_register_socket.sendto(
|
||||||
self._register_rt_header.header + bytes(1), (socket.gethostbyname(self._ip), self._port)
|
self._register_rt_header.header, (socket.gethostbyname(self._ip), self._port)
|
||||||
)
|
)
|
||||||
count = int.from_bytes(self._register_rt_header.framecounter, 'little') + 1
|
count = int.from_bytes(self._register_rt_header.framecounter, 'little') + 1
|
||||||
self._register_rt_header.framecounter = count.to_bytes(4, 'little')
|
self._register_rt_header.framecounter = count.to_bytes(4, 'little')
|
||||||
@ -185,6 +185,19 @@ class VbanCmd(abc.ABC):
|
|||||||
""" Restarts Voicemeeter's audio engine. """
|
""" Restarts Voicemeeter's audio engine. """
|
||||||
self.set_rt('Command', 'Restart', 1)
|
self.set_rt('Command', 'Restart', 1)
|
||||||
|
|
||||||
|
def apply(self, mapping: dict):
|
||||||
|
""" Sets all parameters of a di """
|
||||||
|
for key, submapping in mapping.items():
|
||||||
|
obj, index = key.split('-')
|
||||||
|
|
||||||
|
if obj in ('strip'):
|
||||||
|
target = self.strip[int(index)]
|
||||||
|
elif obj in ('bus'):
|
||||||
|
target = self.bus[int(index)]
|
||||||
|
else:
|
||||||
|
raise ValueError(obj)
|
||||||
|
target.apply(submapping)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
""" sets thread flag, closes sockets """
|
""" sets thread flag, closes sockets """
|
||||||
self.running = False
|
self.running = False
|
||||||
|
Loading…
Reference in New Issue
Block a user