mirror of
https://github.com/onyx-and-iris/xair-api-python.git
synced 2024-11-22 12:50:58 +00:00
add xair-obs example
This commit is contained in:
parent
d5184d0559
commit
c59c623546
@ -42,9 +42,9 @@ import xair_api
|
|||||||
def main():
|
def main():
|
||||||
with xair_api.connect(kind_id, ip=ip) as mixer:
|
with xair_api.connect(kind_id, ip=ip) as mixer:
|
||||||
mixer.strip[8].config.name = "sm7b"
|
mixer.strip[8].config.name = "sm7b"
|
||||||
mixer.strip[8].config.on = True
|
mixer.strip[8].mix.on = True
|
||||||
print(
|
print(
|
||||||
f"strip 09 ({mixer.strip[8].config.name}) on has been set to {mixer.strip[8].config.on}"
|
f"strip 09 ({mixer.strip[8].config.name}) on has been set to {mixer.strip[8].mix.on}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
26
examples/xair-obs/README.md
Normal file
26
examples/xair-obs/README.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
## Requirements
|
||||||
|
|
||||||
|
- [OBS Studio](https://obsproject.com/)
|
||||||
|
- [OBS Python SDK for Websocket v5](https://github.com/aatikturk/obsws-python)
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
A simple demonstration showing how to sync OBS scene switches to Xair states. The script assumes you have OBS connection info saved in
|
||||||
|
a config file named `config.toml` placed next to `__main__.py`. It also assumes you have scenes named `START` `BRB` `END` and `LIVE`.
|
||||||
|
|
||||||
|
A valid `config.toml` file might look like this:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[connection]
|
||||||
|
host = "localhost"
|
||||||
|
port = 4455
|
||||||
|
password = "mystrongpass"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
Change the xair ip argument from `mixer.local` to the ip of your xair mixer. Run the code and switch between scenes in OBS.
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
This example was inspired by [OBS-to-XAir](https://github.com/lebaston100/OBS-to-XAir)
|
38
examples/xair-obs/__main__.py
Normal file
38
examples/xair-obs/__main__.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import obsws_python as obs
|
||||||
|
import xair_api
|
||||||
|
|
||||||
|
|
||||||
|
class Observer:
|
||||||
|
def __init__(self, cl, mixer):
|
||||||
|
self._cl = cl
|
||||||
|
self._mixer = mixer
|
||||||
|
self._cl.callback.register(self.on_current_program_scene_changed)
|
||||||
|
print(f"Registered events: {self._cl.callback.get()}")
|
||||||
|
|
||||||
|
def on_current_program_scene_changed(self, data):
|
||||||
|
scene = data.scene_name
|
||||||
|
print(f"Switched to scene {scene}")
|
||||||
|
match scene:
|
||||||
|
case "START":
|
||||||
|
print("Toggling strip 01 on")
|
||||||
|
self._mixer.strip[0].mix.on = not self._mixer.strip[0].mix.on
|
||||||
|
case "BRB":
|
||||||
|
print("Setting strip 08 fader")
|
||||||
|
self._mixer.strip[7].mix.fader = -12.8
|
||||||
|
case "END":
|
||||||
|
print("Settings strip 02 color")
|
||||||
|
self._mixer.strip[1].config.color = 8
|
||||||
|
case "LIVE":
|
||||||
|
self._mixer.dca[0].on = True
|
||||||
|
print(f"DCA 1 is {self._mixer.dca[0].on}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
cl = obs.EventClient()
|
||||||
|
|
||||||
|
with xair_api.connect("MR18", ip="mixer.local") as mixer:
|
||||||
|
Observer(cl, mixer)
|
||||||
|
|
||||||
|
while cmd := input("<Enter> to exit\n"):
|
||||||
|
if not cmd:
|
||||||
|
break
|
7
examples/xair-obs/setup.py
Normal file
7
examples/xair-obs/setup.py
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="xair-obs",
|
||||||
|
description="Syncs Xair states to OBS scenes",
|
||||||
|
install_requires=["obsws-python", "xair-api"],
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user