add sendtext(), update readme

add sendtext function for multi-parameter strings. Also gives option for settable delay.
This commit is contained in:
onyx-and-iris 2022-03-03 11:34:45 +00:00
parent 2b569153b0
commit ff412ca6ca
2 changed files with 17 additions and 4 deletions

View File

@ -31,11 +31,14 @@ pip install -e .['development']
``` ```
#### Connection: #### Connection:
For sending a text request (remote set) several configuration options are available: For sending a text request (sendtext or set_rt) several configuration options are available:
- `ip`: remote address - `ip`: remote address
- `streamname`: default 'Command1' - `streamname`: default 'Command1'
- `port`: default 6990 - `port`: default 6990
- `channel`: from 0 to 255
- `bps`: bitrate of stream, default 0 should be safe for most cases. - `bps`: bitrate of stream, default 0 should be safe for most cases.
only applies to `sendtext`:
- `delay`: default 0.001
Pass these values as arguments to vban_cmd.connect() as show in the example below. Pass these values as arguments to vban_cmd.connect() as show in the example below.
@ -98,7 +101,6 @@ Factory function for remotes.
### `VbanCmd` (higher level) ### `VbanCmd` (higher level)
#### `vban.type` #### `vban.type`
The kind of the Voicemeeter instance. The kind of the Voicemeeter instance.
#### `vban.version` #### `vban.version`
A tuple of the form `(v1, v2, v3, v4)`. A tuple of the form `(v1, v2, v3, v4)`.
@ -107,6 +109,13 @@ An `InputStrip` tuple, containing both physical and virtual.
#### `vban.bus` #### `vban.bus`
An `OutputBus` tuple, containing both physical and virtual. An `OutputBus` tuple, containing both physical and virtual.
#### `vban.sendtext(cmd)`
Sends a TEXT 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')
```
#### `vban.show()` #### `vban.show()`
Shows Voicemeeter if it's hide. No effect otherwise. Shows Voicemeeter if it's hide. No effect otherwise.
#### `vban.hide()` #### `vban.hide()`

View File

@ -114,8 +114,8 @@ class VbanCmd(abc.ABC):
return data return data
return fget() return fget()
def set_rt(self, id_, param, val): def set_rt(self, id_, param=None, val=None):
cmd = f'{id_}.{param}={val}' cmd = id_ if not param and val else f'{id_}.{param}={val}'
if self._sendrequest_string_socket in self.ready_to_write: if self._sendrequest_string_socket in self.ready_to_write:
self._sendrequest_string_socket.sendto( self._sendrequest_string_socket.sendto(
self._text_header.header + cmd.encode(), (socket.gethostbyname(self._ip), self._port) self._text_header.header + cmd.encode(), (socket.gethostbyname(self._ip), self._port)
@ -123,6 +123,10 @@ class VbanCmd(abc.ABC):
count = int.from_bytes(self._text_header.framecounter, 'little') + 1 count = int.from_bytes(self._text_header.framecounter, 'little') + 1
self._text_header.framecounter = count.to_bytes(4, 'little') self._text_header.framecounter = count.to_bytes(4, 'little')
def sendtext(self, cmd):
self.set_rt(cmd)
sleep(self._delay)
@property @property
def type(self): def type(self):
return self.public_packet.voicemeetertype return self.public_packet.voicemeetertype