diff --git a/vbancmd/bus.py b/vbancmd/bus.py index 3bfec33..c1f82ba 100644 --- a/vbancmd/bus.py +++ b/vbancmd/bus.py @@ -22,6 +22,9 @@ class OutputBus(Channel): "levels": BusLevel(remote, index), "mode": BusModeMixin(remote, index), **{param: channel_bool_prop(param) for param in ["mute", "mono"]}, + "eq": channel_bool_prop("eq.On"), + "eq_ab": channel_bool_prop("eq.ab"), + "label": channel_label_prop(), }, ) return OB_cls(remote, index, *args, **kwargs) @@ -30,12 +33,6 @@ class OutputBus(Channel): def identifier(self): return "bus" - eq = channel_bool_prop("eq.On") - - eq_ab = channel_bool_prop("eq.ab") - - label = channel_label_prop() - @property def gain(self) -> float: def fget(): diff --git a/vbancmd/channel.py b/vbancmd/channel.py index 7af1b4d..2dd85f7 100644 --- a/vbancmd/channel.py +++ b/vbancmd/channel.py @@ -104,7 +104,11 @@ class Channel(abc.ABC): def apply(self, mapping): """Sets all parameters of a dict for the strip.""" + script = "" for key, val in mapping.items(): if not hasattr(self, key): raise VMCMDErrors(f"Invalid {self.identifier} attribute: {key}") - setattr(self, key, val) + self._remote.cache[f"{self.identifier}[{self.index}].{key}"] = val + script += f"{self.identifier}[{self.index}].{key}={val};" + + self._remote.sendtext(script) diff --git a/vbancmd/strip.py b/vbancmd/strip.py index b5667f8..7d651d5 100644 --- a/vbancmd/strip.py +++ b/vbancmd/strip.py @@ -25,6 +25,7 @@ class InputStrip(Channel): param: channel_bool_prop(param) for param in ["mono", "solo", "mute"] }, + "label": channel_label_prop(), }, ) return IS_cls(remote, index, **kwargs) @@ -33,8 +34,6 @@ class InputStrip(Channel): def identifier(self): return "strip" - label = channel_label_prop() - @property def limit(self) -> int: return diff --git a/vbancmd/util.py b/vbancmd/util.py index fc14dff..db7236d 100644 --- a/vbancmd/util.py +++ b/vbancmd/util.py @@ -34,6 +34,12 @@ def cache_string(func, param): return wrapper +def depth(d): + if isinstance(d, dict): + return 1 + (max(map(depth, d.values())) if d else 0) + return 0 + + def script(func): """Convert dictionary to script""" diff --git a/vbancmd/vbancmd.py b/vbancmd/vbancmd.py index 4a1bd54..f6e8383 100644 --- a/vbancmd/vbancmd.py +++ b/vbancmd/vbancmd.py @@ -67,7 +67,6 @@ class VbanCmd(abc.ABC): self.running = True self._pdirty = False self.cache = {} - self.in_apply = False def __enter__(self): self.login() @@ -204,8 +203,6 @@ class VbanCmd(abc.ABC): self._text_header.framecounter = count.to_bytes(4, "little") if param: self.cache[f"{id_}.{param}"] = val - if self._sync or self.in_apply: - sleep(self._delay) @script def sendtext(self, cmd): @@ -241,7 +238,6 @@ class VbanCmd(abc.ABC): def apply(self, mapping: dict): """Sets all parameters of a di""" - self.in_apply = True for key, submapping in mapping.items(): obj, index = key.split("-") @@ -252,7 +248,6 @@ class VbanCmd(abc.ABC): else: raise ValueError(obj) target.apply(submapping) - self.in_apply = False def apply_profile(self, name: str): try: @@ -266,7 +261,7 @@ class VbanCmd(abc.ABC): else: base[key] = profile[key] profile = base - self.sendtext(profile) + self.apply(profile) except KeyError: raise VMCMDErrors(f"Unknown profile: {self.kind.id}/{name}")