From ff412ca6ca03ec8e9efbb229ec8e5ca48efe209d Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Thu, 3 Mar 2022 11:34:45 +0000 Subject: [PATCH] add sendtext(), update readme add sendtext function for multi-parameter strings. Also gives option for settable delay. --- README.md | 13 +++++++++++-- vban_cmd/vban_cmd.py | 8 ++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c37c47d..faba3fd 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,14 @@ pip install -e .['development'] ``` #### 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 - `streamname`: default 'Command1' - `port`: default 6990 +- `channel`: from 0 to 255 - `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. @@ -98,7 +101,6 @@ Factory function for remotes. ### `VbanCmd` (higher level) #### `vban.type` The kind of the Voicemeeter instance. - #### `vban.version` A tuple of the form `(v1, v2, v3, v4)`. @@ -107,6 +109,13 @@ An `InputStrip` tuple, containing both physical and virtual. #### `vban.bus` 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()` Shows Voicemeeter if it's hide. No effect otherwise. #### `vban.hide()` diff --git a/vban_cmd/vban_cmd.py b/vban_cmd/vban_cmd.py index 9ec43c3..400465a 100644 --- a/vban_cmd/vban_cmd.py +++ b/vban_cmd/vban_cmd.py @@ -114,8 +114,8 @@ class VbanCmd(abc.ABC): return data return fget() - def set_rt(self, id_, param, val): - cmd = f'{id_}.{param}={val}' + def set_rt(self, id_, param=None, val=None): + cmd = id_ if not param and val else f'{id_}.{param}={val}' if self._sendrequest_string_socket in self.ready_to_write: self._sendrequest_string_socket.sendto( 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 self._text_header.framecounter = count.to_bytes(4, 'little') + def sendtext(self, cmd): + self.set_rt(cmd) + sleep(self._delay) + @property def type(self): return self.public_packet.voicemeetertype