mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-22 02:50:47 +00:00
obs example added
This commit is contained in:
parent
8935624044
commit
7d8a1ce1f5
19
examples/obs/README.md
Normal file
19
examples/obs/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
## Requirements
|
||||
|
||||
- [OBS Studio](https://obsproject.com/)
|
||||
- [OBS Websocket Plugin](https://obsproject.com/forum/resources/obs-websocket-remote-control-obs-studio-from-websockets.466/)
|
||||
- [OBS Websocket Py](https://github.com/onyx-and-iris/obs-websocket-py)
|
||||
|
||||
## About
|
||||
|
||||
A simple demonstration showing how to sync OBS scene switches to Voicemeeter states. The script assumes you have connection info saved in
|
||||
a config file named `config.ini` placed next to `__main__.py`. It also assumes you have scenes named `START` `BRB` `END` and `LIVE`.
|
||||
|
||||
A valid `config.ini` file might look like this:
|
||||
|
||||
```ini
|
||||
[connection]
|
||||
ip=localhost
|
||||
port=4444
|
||||
password=mystrongpassword
|
||||
```
|
50
examples/obs/__main__.py
Normal file
50
examples/obs/__main__.py
Normal file
@ -0,0 +1,50 @@
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import voicemeeterlib
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
sys.path.append("../")
|
||||
from obswebsocket import events, obsws
|
||||
|
||||
|
||||
def on_start():
|
||||
vm.strip[0].mute = True
|
||||
|
||||
|
||||
def on_brb():
|
||||
vm.strip[7].fadeto(0, 500)
|
||||
|
||||
|
||||
def on_end():
|
||||
vm.strip[0].mute = True
|
||||
|
||||
|
||||
def on_live():
|
||||
vm.strip[0].mute = False
|
||||
vm.strip[7].fadeto(-6, 500)
|
||||
|
||||
|
||||
def on_switch(message):
|
||||
scene = message.getSceneName()
|
||||
match scene:
|
||||
case "START":
|
||||
on_start()
|
||||
case "BRB":
|
||||
on_brb()
|
||||
case "END":
|
||||
on_end()
|
||||
case "LIVE":
|
||||
on_live()
|
||||
case _:
|
||||
pass
|
||||
|
||||
|
||||
with voicemeeterlib.api("potato") as vm:
|
||||
with obsws() as ws:
|
||||
ws.register(on_switch, events.SwitchScenes)
|
||||
|
||||
while cmd := input("Press <Enter> to exit\n"):
|
||||
if not cmd:
|
||||
break
|
Loading…
Reference in New Issue
Block a user