2022-03-09 06:30:48 +00:00
[![License: MIT ](https://img.shields.io/badge/License-MIT-yellow.svg )](https://github.com/onyx-and-iris/vban-cmd-python/blob/dev/LICENSE)
2022-03-26 23:43:51 +00:00
[![Code style: black ](https://img.shields.io/badge/code%20style-black-000000.svg )](https://github.com/psf/black)
2022-04-28 11:34:48 +01:00
![Tests Status ](./tests/basic.svg?dummy=8484744 )
![Tests Status ](./tests/banana.svg?dummy=8484744 )
![Tests Status ](./tests/potato.svg?dummy=8484744 )
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
# VBAN CMD
2022-04-27 20:00:30 +01:00
2022-03-11 19:21:26 +00:00
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.
2022-03-06 14:44:30 +00:00
It may be used standalone or to extend the [Voicemeeter Remote Python API ](https://github.com/onyx-and-iris/voicemeeter-api-python )
2022-02-27 18:57:16 +00:00
2022-03-04 14:44:07 +00:00
For sending audio across a network with VBAN you will need to look elsewhere.
2022-03-02 23:28:42 +00:00
## Tested against
2022-04-27 20:00:30 +01:00
- Basic 1.0.8.1
- Banana 2.0.6.1
- Potato 3.0.2.1
2022-02-27 18:57:16 +00:00
## Prerequisites
2022-04-27 20:00:30 +01:00
- Voicemeeter 1 (Basic), 2 (Banana) or 3 (Potato)
- Python 3.9+
2022-02-27 18:57:16 +00:00
## Installation
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
```
git clone https://github.com/onyx-and-iris/vban-cmd-python
cd vban-cmd-python
```
2022-03-05 06:17:12 +00:00
Just the interface:
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
```
pip install .
```
With development dependencies:
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
```
pip install -e .['development']
```
2022-03-26 23:06:38 +00:00
## Usage
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
#### Use with a context manager:
2022-04-27 20:00:30 +01:00
2022-03-05 06:17:12 +00:00
Parameter coverage is not as extensive for the RT Packet Service as with the Remote API.
2022-03-02 23:28:42 +00:00
2022-02-27 18:57:16 +00:00
### Example 1
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
```python
2022-03-04 14:22:29 +00:00
import vbancmd
2022-02-27 18:57:16 +00:00
class ManyThings:
def __init__ (self, vban):
self.vban = vban
def things(self):
# Set the mapping of the second input strip
self.vban.strip[1].A3 = True
print(f'Output A3 of Strip {self.vban.strip[1].label}: {self.vban.strip[1].A3}')
def other_things(self):
# Toggle mute for the leftmost output bus
self.vban.bus[0].mute = not self.vban.bus[0].mute
def main():
2022-03-04 14:22:29 +00:00
with vbancmd.connect(kind_id, ip=ip) as vban:
2022-02-27 18:57:16 +00:00
do = ManyThings(vban)
do.things()
do.other_things()
if __name__ == '__main__':
kind_id = 'potato'
ip = '< ip address > '
main()
```
2022-03-20 12:26:01 +00:00
#### Or perform setup/teardown independently:
2022-04-27 20:00:30 +01:00
2022-03-20 12:26:01 +00:00
for example:
### Example 2
2022-04-27 20:00:30 +01:00
2022-03-20 12:26:01 +00:00
```python
import vbancmd
kind_id = 'potato'
ip = '< ip address > '
vban = vbancmd.connect(kind_id, ip=ip)
# call login() at the start of your code
vban.login()
# Toggle mute for leftmost input strip
vban.strip[0].mute = not vban.strip[0].mute
# Toggle eq for leftmost output bus
vban.bus[0].eq = not vban.bus[0].eq
# call logout() at the end of your code
vban.logout()
```
2022-03-23 11:31:28 +00:00
## Profiles
2022-04-27 20:00:30 +01:00
2022-03-23 11:31:28 +00:00
Profiles through config files are supported.
Three example profiles are provided with the package, one for each kind of Voicemeeter.
2022-04-27 20:00:30 +01:00
To test one first rename \_profiles directory to profiles.
2022-03-23 11:31:28 +00:00
They will be loaded into memory but not applied. To apply one you may do:
`vmr.apply_profile('config')` , but remember to save your current settings first.
profiles directory can be safely deleted if you don't wish to load them each time.
2022-03-23 11:32:12 +00:00
A config can contain any key that `connect.apply()` would accept. Additionally, `extends` can be provided to inherit from another profile. Two profiles are available by default:
2022-04-27 20:00:30 +01:00
- `blank` , all strip off and all sliders to `0.0` . mono, solo, mute, eq all disabled.
- `base` , all physical strip to `A1` , all virtual strip to `B1` , all sliders to `0.0` .
2022-03-23 11:31:28 +00:00
Sample `mySetup.toml`
2022-04-27 20:00:30 +01:00
2022-03-23 11:31:28 +00:00
```toml
extends = 'base'
[strip-0]
mute = 1
[strip-5]
A1 = 0
A2 = 1
A4 = 1
gain = 0.0
[strip-6]
A1 = 0
A2 = 1
A4 = 1
gain = 0.0
```
2022-02-27 18:57:16 +00:00
## API
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
### Kinds
2022-04-27 20:00:30 +01:00
A _kind_ specifies a major Voicemeeter version. Currently this encompasses
- `basic`
- `banana`
- `potato`
2022-02-27 18:57:16 +00:00
2022-03-11 19:21:26 +00:00
#### `vbancmd.connect(kind_id, **kwargs) -> '(VbanCmd)'`
2022-04-27 20:00:30 +01:00
2022-03-11 19:21:26 +00:00
Factory function for remotes. Keyword arguments include:
2022-02-27 18:57:16 +00:00
2022-04-27 20:00:30 +01:00
- `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.
2022-02-27 18:57:16 +00:00
### `VbanCmd` (higher level)
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
#### `vban.type`
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
The kind of the Voicemeeter instance.
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
#### `vban.version`
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
A tuple of the form `(v1, v2, v3, v4)` .
#### `vban.strip`
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
An `InputStrip` tuple, containing both physical and virtual.
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
#### `vban.bus`
2022-04-27 20:00:30 +01:00
An `OutputBus` tuple, containing both physical and virtual.
2022-03-03 11:34:45 +00:00
2022-02-27 18:57:16 +00:00
#### `vban.show()`
2022-04-27 20:00:30 +01:00
2022-03-04 14:22:29 +00:00
Shows Voicemeeter if it's hidden. No effect otherwise.
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
#### `vban.hide()`
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
Hides Voicemeeter if it's shown. No effect otherwise.
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
#### `vban.shutdown()`
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
Closes Voicemeeter.
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
#### `vban.restart()`
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
Restarts Voicemeeter's audio engine.
2022-03-11 19:21:26 +00:00
#### `vban.apply(mapping)`
2022-04-27 20:00:30 +01:00
2022-03-11 19:21:26 +00:00
Updates values through a dict.
Example:
2022-04-27 20:00:30 +01:00
2022-03-04 14:33:11 +00:00
```python
2022-03-11 19:21:26 +00:00
vban.apply({
'strip-2': dict(A1=True, B1=True, gain=-6.0),
'bus-2': dict(mute=True),
})
2022-03-04 14:33:11 +00:00
```
2022-02-27 18:57:16 +00:00
### `Strip`
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
The following properties are gettable and settable:
2022-04-27 20:00:30 +01:00
- `mono` : boolean
- `solo` : boolean
- `mute` : boolean
- `label` : string
- `gain` : float, -60 to 12
- Output mapping (e.g. `A1` , `B3` , etc.): boolean, depends on the Voicemeeter kind
2022-03-18 07:40:24 +00:00
2022-02-27 18:57:16 +00:00
The following properties are settable:
2022-04-27 20:00:30 +01:00
- `comp` : float, from 0.0 to 10.0
- `gate` : float, from 0.0 to 10.0
- `limit` : int, from -40 to 12
2022-02-27 18:57:16 +00:00
2022-03-18 07:40:24 +00:00
#### `gainlayer`
2022-04-27 20:00:30 +01:00
- `gainlayer[j].gain` : float, -60 to 12
2022-03-18 07:40:24 +00:00
for example:
2022-04-27 20:00:30 +01:00
2022-03-18 07:40:24 +00:00
```python
# set and get the value of the second input strip, fourth gainlayer
vban.strip[1].gainlayer[3].gain = -6.3
print(vban.strip[1].gainlayer[3].gain)
```
2022-04-27 20:00:30 +01:00
2022-03-18 07:40:24 +00:00
Gainlayers defined for Potato version only.
2022-02-27 18:57:16 +00:00
### `Bus`
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
The following properties are gettable and settable:
2022-04-27 20:00:30 +01:00
- `mute` : boolean
- `mono` : boolean
- `eq` : boolean
- `eq_ab` : boolean
- `label` : string
- `gain` : float, -60 to 12
2022-02-27 18:57:16 +00:00
2022-03-18 07:40:24 +00:00
#### `mode`
2022-04-27 20:00:30 +01:00
2022-03-18 07:40:24 +00:00
Bus modes are gettable and settable
2022-04-27 20:00:30 +01:00
- `normal` , `amix` , `bmix` , `repeat` , `composite` , `tvmix` , `upmix21` ,
- `upmix41` , `upmix61` , `centeronly` , `lfeonly` , `rearonly`
2022-03-18 07:40:24 +00:00
for example:
2022-04-27 20:00:30 +01:00
2022-03-18 07:40:24 +00:00
```python
# set leftmost bus mode to tvmix
vban.bus[0].mode.tvmix = True
```
2022-02-28 14:03:51 +00:00
### `VbanCmd` (lower level)
2022-04-27 20:00:30 +01:00
2022-04-29 21:57:16 +01:00
#### `vban.pdirty`
2022-04-29 22:31:22 +01:00
True iff a parameter has been changed. Typically this is checked periodically to update states.
2022-04-29 21:57:16 +01:00
2022-02-28 14:03:51 +00:00
#### `vban.set_rt(id_, param, val)`
2022-04-27 20:00:30 +01:00
2022-02-28 14:03:51 +00:00
Sends a string request RT Packet where the command would take the form:
2022-04-27 20:00:30 +01:00
2022-02-28 14:03:51 +00:00
```python
f'{id_}.{param}={val}'
```
2022-02-27 18:57:16 +00:00
2022-04-29 21:57:16 +01:00
#### `vban.public_packet`
2022-04-27 20:00:30 +01:00
2022-04-29 22:30:21 +01:00
Returns a Voicemeeter rt data packet. Designed to be used internally by the interface but available for parsing through this read only property object. States may or may not be current, use the polling parameter pdirty to be sure.
2022-03-11 19:21:26 +00:00
2022-02-27 18:57:16 +00:00
### `Errors`
2022-04-27 20:00:30 +01:00
- `errors.VMCMDErrors` : Base VMCMD error class.
2022-02-27 18:57:16 +00:00
### `Tests`
2022-04-27 20:00:30 +01:00
2022-02-27 18:57:16 +00:00
First make sure you installed the [development dependencies ](https://github.com/onyx-and-iris/vban-cmd-python#installation )
2022-04-27 20:00:30 +01:00
Then from tests directory:
2022-02-27 18:57:16 +00:00
2022-04-27 20:00:30 +01:00
`pytest -v`
2022-02-27 18:57:16 +00:00
## Resources
2022-04-27 20:00:30 +01:00
- [Voicemeeter RT Packet Service ](https://vb-audio.com/Voicemeeter/VBANProtocol_Specifications.pdf )