add recorder.loop forwarder methods

add RecorderArmChannel class.

add logger warning if channel value not from 1 to 8
This commit is contained in:
onyx-and-iris 2023-06-30 23:51:20 +01:00
parent ee3fa0a372
commit de4ce850eb

View File

@ -80,7 +80,9 @@ class Recorder(IRemote):
@channel.setter @channel.setter
def channel(self, val: int): def channel(self, val: int):
self.getter("channel", val) if not 1 <= val <= 8:
self.logger.warning(f"channel got: {val} but expected a value from 1 to 8")
self.setter("channel", val)
@property @property
def kbps(self): def kbps(self):
@ -107,10 +109,14 @@ class Recorder(IRemote):
except UnicodeError: except UnicodeError:
raise VMError("File full directory must be a raw string") raise VMError("File full directory must be a raw string")
def set_loop(self, val: bool): # loop forwarder methods, for backwards compatibility
self.setter("mode.loop", 1 if val else 0) @property
def loop(self):
return self.mode.loop
loop = property(fset=set_loop) @loop.setter
def loop(self, val: bool):
self.mode.loop = val
def goto(self, time_str): def goto(self, time_str):
def get_sec(): def get_sec():
@ -135,7 +141,7 @@ class Recorder(IRemote):
def filetype(self, val: str): def filetype(self, val: str):
opts = {"wav": 1, "aiff": 2, "bwf": 3, "mp3": 100} opts = {"wav": 1, "aiff": 2, "bwf": 3, "mp3": 100}
try: try:
self.setter("filetype", opts[val]) self.setter("filetype", opts[val.lower()])
except KeyError: except KeyError:
self.logger.warning( self.logger.warning(
f"filetype got: {val} but expected a value in {list(opts.keys())}" f"filetype got: {val} but expected a value in {list(opts.keys())}"
@ -143,6 +149,7 @@ class Recorder(IRemote):
class RecorderMode(IRemote): class RecorderMode(IRemote):
@property
def identifier(self): def identifier(self):
return "recorder.mode" return "recorder.mode"
@ -179,31 +186,26 @@ class RecorderMode(IRemote):
self.setter("multitrack", 1 if val else 0) self.setter("multitrack", 1 if val else 0)
class RecorderArmStrip(IRemote): class RecorderArmChannel(IRemote):
def __init__(self, remote, i): def __init__(self, remote, i):
super().__init__(remote) super().__init__(remote)
self._i = i self._i = i
def set(self, val: bool):
self.setter("", 1 if val else 0)
class RecorderArmStrip(RecorderArmChannel):
@property @property
def identifier(self): def identifier(self):
return f"recorder.armstrip[{self._i}]" return f"recorder.armstrip[{self._i}]"
def set(self, val: bool):
self.setter("", 1 if val else 0)
class RecorderArmBus(IRemote):
def __init__(self, remote, i):
super().__init__(remote)
self._i = i
class RecorderArmBus(RecorderArmChannel):
@property @property
def identifier(self): def identifier(self):
return f"recorder.armbus[{self._i}]" return f"recorder.armbus[{self._i}]"
def set(self, val: bool):
self.setter("", 1 if val else 0)
def _make_armchannel_mixin(remote, kind): def _make_armchannel_mixin(remote, kind):
"""Creates an armchannel out mixin""" """Creates an armchannel out mixin"""