mirror of
https://github.com/onyx-and-iris/OBS-to-XAir.git
synced 2025-01-18 04:40:49 +00:00
x32 support added.
mapping.toml added. tomli/tomllib compatibility layer added
This commit is contained in:
parent
fc7b59c48f
commit
96f0e0f789
@ -1,6 +1,6 @@
|
|||||||
# OBS-to-XAir
|
# OBS-to-XAir
|
||||||
|
|
||||||
This is a small script that mutes and unmutes channels on Behringer XAir Mixers depending on the current scene.
|
This is a small script that mutes, unmutes and toggles groups of channels on Behringer XAir Mixers depending on the current scene.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@ -29,9 +29,9 @@ pip install .
|
|||||||
|
|
||||||
- Open the included `config.toml` and set OBS host, port and password as well as the xair mixers ip.
|
- Open the included `config.toml` and set OBS host, port and password as well as the xair mixers ip.
|
||||||
|
|
||||||
- You may also set the kind of mixer in the script. (`XR12, XR16, XR18, MR18`)
|
- You may also set the kind of mixer in the script. (`XR12, XR16, XR18, MR18, X32`)
|
||||||
|
|
||||||
- Set the scene to channel mutes mapping in the script.
|
- Set the scene to channel mutes mapping in `mapping.toml`.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ This script was developed and tested with:
|
|||||||
|
|
||||||
- OBS 28.01
|
- OBS 28.01
|
||||||
- obs-websocket 5.0.1
|
- obs-websocket 5.0.1
|
||||||
- A Behringer XR18 and Midas MR18
|
- A Midas MR18 and an X32 emulator.
|
||||||
|
|
||||||
## Special Thanks
|
## Special Thanks
|
||||||
|
|
||||||
|
41
__main__.py
41
__main__.py
@ -1,14 +1,25 @@
|
|||||||
|
import logging
|
||||||
import time
|
import time
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import obsws_python as obs
|
import obsws_python as obs
|
||||||
import xair_api
|
import xair_api
|
||||||
|
|
||||||
mapping = {
|
try:
|
||||||
"START": 1,
|
import tomllib
|
||||||
"BRB": 2,
|
except ModuleNotFoundError:
|
||||||
"END": 3,
|
import tomli as tomllib
|
||||||
"LIVE": 4,
|
|
||||||
} # set the mapping for the scene to channel mapping here. "scenename": "channel"
|
logging.basicConfig(level=logging.disable())
|
||||||
|
|
||||||
|
|
||||||
|
def _get_mapping():
|
||||||
|
filepath = Path.cwd() / "mapping.toml"
|
||||||
|
with open(filepath, "rb") as f:
|
||||||
|
return tomllib.load(f)
|
||||||
|
|
||||||
|
|
||||||
|
mapping = _get_mapping()
|
||||||
|
|
||||||
|
|
||||||
class Observer:
|
class Observer:
|
||||||
@ -28,10 +39,20 @@ class Observer:
|
|||||||
print(" ".join(info))
|
print(" ".join(info))
|
||||||
|
|
||||||
def on_current_program_scene_changed(self, data):
|
def on_current_program_scene_changed(self, data):
|
||||||
|
def ftoggle(i):
|
||||||
|
self._mixer.strip[i - 1].mix.on = not self._mixer.strip[i - 1].mix.on
|
||||||
|
|
||||||
|
def fset(i, is_muted):
|
||||||
|
self._mixer.strip[i - 1].mix.on = is_muted
|
||||||
|
|
||||||
scene = data.scene_name
|
scene = data.scene_name
|
||||||
print(f"Switched to scene {scene}")
|
print(f"Switched to scene {scene}")
|
||||||
for k, v in mapping.items():
|
if map_ := mapping.get(scene):
|
||||||
self._mixer.strip[v - 1].mix.on = k == scene
|
for key in map_.keys():
|
||||||
|
if key == "toggle":
|
||||||
|
[ftoggle(i) for i in map_[key]]
|
||||||
|
else:
|
||||||
|
[fset(i, key == "mute") for i in map_[key]]
|
||||||
|
|
||||||
def on_exit_started(self, _):
|
def on_exit_started(self, _):
|
||||||
print("OBS closing")
|
print("OBS closing")
|
||||||
@ -40,6 +61,8 @@ class Observer:
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
kind_mixer = "XR18"
|
||||||
|
|
||||||
with xair_api.connect(kind_mixer) as mixer:
|
with xair_api.connect(kind_mixer) as mixer:
|
||||||
o = Observer(mixer)
|
o = Observer(mixer)
|
||||||
|
|
||||||
@ -48,6 +71,4 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
kind_mixer = "XR18"
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
9
mapping.toml
Normal file
9
mapping.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
START.mute = [1, 3, 5]
|
||||||
|
START.unmute = [2, 7]
|
||||||
|
|
||||||
|
BRB.mute = [2, 7]
|
||||||
|
BRB.unmute = [1, 3, 5]
|
||||||
|
|
||||||
|
END.toggle = [12, 14]
|
||||||
|
|
||||||
|
LIVE.toggle = [16]
|
6
setup.py
6
setup.py
@ -4,6 +4,10 @@ setup(
|
|||||||
name="xair-obs",
|
name="xair-obs",
|
||||||
version="0.0.1",
|
version="0.0.1",
|
||||||
description="Syncs Xair states to OBS scenes",
|
description="Syncs Xair states to OBS scenes",
|
||||||
install_requires=["obsws-python", "xair-api"],
|
install_requires=[
|
||||||
|
"obsws-python",
|
||||||
|
"xair-api",
|
||||||
|
"tomli >= 2.0.1;python_version < '3.11'",
|
||||||
|
],
|
||||||
python_requires=">=3.10",
|
python_requires=">=3.10",
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user