Skip to content

Instantly share code, notes, and snippets.

@onyx-and-iris
Created September 21, 2022 21:40
Show Gist options
  • Save onyx-and-iris/a924fec392d690624bb4417984880327 to your computer and use it in GitHub Desktop.
Save onyx-and-iris/a924fec392d690624bb4417984880327 to your computer and use it in GitHub Desktop.
sync XAir mute states to OBS scene switches
import obsws_python as obs
import xair_api
mapping = {
"START": 1,
"BRB": 2,
"END": 3,
"LIVE": 4,
} # set the mapping for the scene to channel mapping here. "scenename": "channel"
obsip = "localhost" # set the obs machine ip here. localhost works if you run this script on the same machine.
obsport = 4455 # set the obs websocket port here. 4455 is default
obspassword = None # set the obs websocket password here.
xairip = "mixer.local" # set the xairip here
class Observer:
def __init__(self, mixer):
self._mixer = mixer
def on_current_program_scene_changed(self, data):
scene = data.scene_name
print(f"Switched to scene {scene}")
for k, v in mapping.items():
self._mixer.strip[v - 1].mix.on = k == scene
if __name__ == "__main__":
with xair_api.connect("XR18", ip=xairip) as mixer:
o = Observer(mixer)
obs.EventClient(
host=obsip, port=obsport, password=obspassword
).callback.register(o.on_current_program_scene_changed)
while cmd := input("<Enter> to exit\n"):
if not cmd:
break
@onyx-and-iris
Copy link
Author

onyx-and-iris commented Sep 21, 2022

This script works in a similar way to OBS-to-XAir but for websocket v5.

Requires the following packages:
obsws-python
xair-api

Requires Python 3.10+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment