fadto() fadeby() methods added to strip/bus classes

appgain(), appmute() methods added to virtualstrip class
This commit is contained in:
onyx-and-iris 2022-10-06 20:28:26 +01:00
parent 550df917fb
commit 4ee37f54c5
3 changed files with 57 additions and 1 deletions

View File

@ -124,7 +124,24 @@ example:
```python
vban.strip[3].gain = 3.7
print(strip[0].label)
print(vban.strip[0].label)
```
The following methods are available.
- `appgain(name, value)`: string, float, from 0.0 to 1.0
Set the gain in db by value for the app matching name.
- `appmute(name, value)`: string, bool
Set mute state as value for the app matching name.
example:
```python
vban.strip[5].appmute("Spotify", True)
vban.strip[5].appgain("Spotify", 0.5)
```
##### Gainlayers
@ -213,6 +230,22 @@ print(vban.bus[0].levels.all)
`levels.all` will return -200.0 if no audio detected.
### Strip | Bus
The following methods are available.
- `fadeto(amount, time)`: float, int
- `fadeby(amount, time)`: float, int
Modify gain to or by the selected amount in db over a time interval in ms.
example:
```python
vban.strip[0].fadeto(-10.3, 1000)
vban.bus[3].fadeby(-5.6, 500)
```
### Command
Certain 'special' commands are defined by the API as performing actions rather than setting values. The following methods are available:

View File

@ -43,6 +43,14 @@ class Bus(IRemote):
def gain(self, val: float):
self.setter("gain", val)
def fadeto(self, target: float, time_: int):
self.setter("FadeTo", f"({target}, {time_})")
time.sleep(self._remote.DELAY)
def fadeby(self, change: float, time_: int):
self.setter("FadeBy", f"({change}, {time_})")
time.sleep(self._remote.DELAY)
class PhysicalBus(Bus):
def __str__(self):

View File

@ -1,3 +1,4 @@
import time
from abc import abstractmethod
from typing import Union
@ -40,6 +41,14 @@ class Strip(IRemote):
def gain(self, val: float):
self.setter("gain", val)
def fadeto(self, target: float, time_: int):
self.setter("FadeTo", f"({target}, {time_})")
time.sleep(self._remote.DELAY)
def fadeby(self, change: float, time_: int):
self.setter("FadeBy", f"({change}, {time_})")
time.sleep(self._remote.DELAY)
class PhysicalStrip(Strip):
def __str__(self):
@ -86,6 +95,12 @@ class VirtualStrip(Strip):
def k(self, val: int):
self.setter("karaoke", val)
def appgain(self, name: str, gain: float):
self.setter("AppGain", f'("{name}", {gain})')
def appmute(self, name: str, mute: bool = None):
self.setter("AppMute", f'("{name}", {1 if mute else 0})')
class StripLevel(IRemote):
def __init__(self, remote, index):