fix mute_group toggle for config class.

use mute_group.on in xair-obs example

patch bump
This commit is contained in:
onyx-and-iris 2022-09-21 10:05:31 +01:00
parent b8e7254850
commit a4e9e430f9
3 changed files with 29 additions and 18 deletions

View File

@ -3,11 +3,10 @@ import xair_api
class Observer: class Observer:
def __init__(self, cl, mixer): def __init__(self, mixer):
self._cl = cl
self._mixer = mixer self._mixer = mixer
self._cl = obs.EventClient()
self._cl.callback.register(self.on_current_program_scene_changed) 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): def on_current_program_scene_changed(self, data):
scene = data.scene_name scene = data.scene_name
@ -23,15 +22,13 @@ class Observer:
print("Settings strip 02 color") print("Settings strip 02 color")
self._mixer.strip[1].config.color = 8 self._mixer.strip[1].config.color = 8
case "LIVE": case "LIVE":
self._mixer.dca[0].on = True self._mixer.config.mute_group[0].on = False
print(f"DCA 1 is {self._mixer.dca[0].on}") print(f"Mute Group 1 is {self._mixer.config.mute_group[0].on}")
if __name__ == "__main__": if __name__ == "__main__":
cl = obs.EventClient()
with xair_api.connect("MR18", ip="mixer.local") as mixer: with xair_api.connect("MR18", ip="mixer.local") as mixer:
Observer(cl, mixer) Observer(mixer)
while cmd := input("<Enter> to exit\n"): while cmd := input("<Enter> to exit\n"):
if not cmd: if not cmd:

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "xair-api" name = "xair-api"
version = "1.1.0" version = "1.1.1"
description = "Remote control Behringer X-Air | Midas MR mixers through OSC" description = "Remote control Behringer X-Air | Midas MR mixers through OSC"
authors = ["onyx-and-iris <code@onyxandiris.online>"] authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT" license = "MIT"

View File

@ -35,11 +35,15 @@ class Config(IConfig):
Returns a Config class of a kind. Returns a Config class of a kind.
""" """
LINKS_cls = _make_links_mixins[remote.kind.id_] LINKS_cls = _make_links_mixins[remote.kind.id_]
MUTEGROUP_cls = type(f"MuteGroup", (Config.MuteGroup, cls), {})
MONITOR_cls = type(f"ConfigMonitor", (Config.Monitor, cls), {}) MONITOR_cls = type(f"ConfigMonitor", (Config.Monitor, cls), {})
CONFIG_cls = type( CONFIG_cls = type(
f"Config{remote.kind}", f"Config{remote.kind}",
(cls, LINKS_cls), (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) return CONFIG_cls(remote)
@ -67,15 +71,25 @@ class Config(IConfig):
raise XAirRemoteError("amixlock is a bool parameter") raise XAirRemoteError("amixlock is a bool parameter")
self.setter("amixlock", 1 if val else 0) self.setter("amixlock", 1 if val else 0)
@property class MuteGroup:
def mute_group(self) -> bool: def __init__(self, remote, i):
return self.getter("mute")[0] == 1 super(Config.MuteGroup, self).__init__(remote)
self.i = i + 1
@mute_group.setter @property
def mute_group(self, val: bool): 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): if not isinstance(val, bool):
raise XAirRemoteError("mute_group is a bool parameter") raise XAirRemoteError("on is a boolean parameter")
self.setter("mute", 1 if val else 0) self.setter(f"{self.i}", 1 if val else 0)
class Monitor: class Monitor:
@property @property