From a4e9e430f9e411d986984644c6ac33b70cc648d2 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Wed, 21 Sep 2022 10:05:31 +0100 Subject: [PATCH] fix mute_group toggle for config class. use mute_group.on in xair-obs example patch bump --- examples/xair-obs/__main__.py | 13 +++++-------- pyproject.toml | 2 +- xair_api/config.py | 32 +++++++++++++++++++++++--------- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/examples/xair-obs/__main__.py b/examples/xair-obs/__main__.py index bc8049e..92c6d74 100644 --- a/examples/xair-obs/__main__.py +++ b/examples/xair-obs/__main__.py @@ -3,11 +3,10 @@ import xair_api class Observer: - def __init__(self, cl, mixer): - self._cl = cl + def __init__(self, mixer): self._mixer = mixer + self._cl = obs.EventClient() 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 @@ -23,15 +22,13 @@ class Observer: 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}") + self._mixer.config.mute_group[0].on = False + print(f"Mute Group 1 is {self._mixer.config.mute_group[0].on}") if __name__ == "__main__": - cl = obs.EventClient() - with xair_api.connect("MR18", ip="mixer.local") as mixer: - Observer(cl, mixer) + Observer(mixer) while cmd := input(" to exit\n"): if not cmd: diff --git a/pyproject.toml b/pyproject.toml index c6719e1..0d429df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "xair-api" -version = "1.1.0" +version = "1.1.1" description = "Remote control Behringer X-Air | Midas MR mixers through OSC" authors = ["onyx-and-iris "] license = "MIT" diff --git a/xair_api/config.py b/xair_api/config.py index 11d95a0..5154c8e 100644 --- a/xair_api/config.py +++ b/xair_api/config.py @@ -35,11 +35,15 @@ class Config(IConfig): Returns a Config class of a kind. """ LINKS_cls = _make_links_mixins[remote.kind.id_] + MUTEGROUP_cls = type(f"MuteGroup", (Config.MuteGroup, cls), {}) MONITOR_cls = type(f"ConfigMonitor", (Config.Monitor, cls), {}) CONFIG_cls = type( f"Config{remote.kind}", (cls, LINKS_cls), - {"monitor": MONITOR_cls(remote)}, + { + "mute_group": tuple(MUTEGROUP_cls(remote, i) for i in range(4)), + "monitor": MONITOR_cls(remote), + }, ) return CONFIG_cls(remote) @@ -67,15 +71,25 @@ class Config(IConfig): raise XAirRemoteError("amixlock is a bool parameter") self.setter("amixlock", 1 if val else 0) - @property - def mute_group(self) -> bool: - return self.getter("mute")[0] == 1 + class MuteGroup: + def __init__(self, remote, i): + super(Config.MuteGroup, self).__init__(remote) + self.i = i + 1 - @mute_group.setter - def mute_group(self, val: bool): - if not isinstance(val, bool): - raise XAirRemoteError("mute_group is a bool parameter") - self.setter("mute", 1 if val else 0) + @property + def address(self) -> str: + root = super(Config.MuteGroup, self).address + return f"{root}/mute" + + @property + def on(self) -> bool: + return self.getter(f"{self.i}")[0] == 1 + + @on.setter + def on(self, val: bool): + if not isinstance(val, bool): + raise XAirRemoteError("on is a boolean parameter") + self.setter(f"{self.i}", 1 if val else 0) class Monitor: @property