mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-18 18:40:47 +00:00
rename Channel to IChannel to signify it as the common interface.
bus mode mixin now subclasses IChannel bus mode properties lowercased in array.
This commit is contained in:
parent
b3762de5be
commit
b6695fbc4d
@ -1,10 +1,10 @@
|
|||||||
from .errors import VMCMDErrors
|
from .errors import VMCMDErrors
|
||||||
from .channel import Channel
|
from .channel import IChannel
|
||||||
from . import kinds
|
from . import kinds
|
||||||
from .meta import bus_mode_prop, channel_bool_prop, channel_label_prop
|
from .meta import bus_mode_prop, channel_bool_prop, channel_label_prop
|
||||||
|
|
||||||
|
|
||||||
class OutputBus(Channel):
|
class OutputBus(IChannel):
|
||||||
"""Base class for output buses."""
|
"""Base class for output buses."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -13,7 +13,7 @@ class OutputBus(Channel):
|
|||||||
Factory function for output busses.
|
Factory function for output busses.
|
||||||
Returns a physical/virtual bus of a kind.
|
Returns a physical/virtual bus of a kind.
|
||||||
"""
|
"""
|
||||||
BusModeMixin = _make_bus_mode_mixin(cls)
|
BusModeMixin = _make_bus_mode_mixin(IChannel)
|
||||||
OutputBus = PhysicalOutputBus if is_physical else VirtualOutputBus
|
OutputBus = PhysicalOutputBus if is_physical else VirtualOutputBus
|
||||||
OB_cls = type(
|
OB_cls = type(
|
||||||
f"Bus{remote.kind.name}",
|
f"Bus{remote.kind.name}",
|
||||||
@ -68,11 +68,15 @@ class VirtualOutputBus(OutputBus):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class BusLevel(OutputBus):
|
class BusLevel(IChannel):
|
||||||
def __init__(self, remote, index):
|
def __init__(self, remote, index):
|
||||||
super().__init__(remote, index)
|
super().__init__(remote, index)
|
||||||
self.level_map = _bus_maps[remote.kind.id]
|
self.level_map = _bus_maps[remote.kind.id]
|
||||||
|
|
||||||
|
@property
|
||||||
|
def identifier(self) -> str:
|
||||||
|
return f"Bus[{self.index}]"
|
||||||
|
|
||||||
def getter_level(self, mode=None):
|
def getter_level(self, mode=None):
|
||||||
def fget(i, data):
|
def fget(i, data):
|
||||||
val = data.outputlevels[i]
|
val = data.outputlevels[i]
|
||||||
@ -96,27 +100,32 @@ def _make_bus_level_map(kind):
|
|||||||
_bus_maps = {kind.id: _make_bus_level_map(kind) for kind in kinds.all}
|
_bus_maps = {kind.id: _make_bus_level_map(kind) for kind in kinds.all}
|
||||||
|
|
||||||
|
|
||||||
def _make_bus_mode_mixin(cls):
|
def _make_bus_mode_mixin(kls):
|
||||||
"""Creates a mixin of Bus Modes."""
|
"""Creates a mixin of Bus Modes."""
|
||||||
|
|
||||||
|
def identifier(self) -> str:
|
||||||
|
return f"Bus[{self.index}].mode"
|
||||||
|
|
||||||
return type(
|
return type(
|
||||||
"BusModeMixin",
|
"BusModeMixin",
|
||||||
(cls,),
|
(kls,),
|
||||||
{
|
{
|
||||||
|
"identifier": property(identifier),
|
||||||
**{
|
**{
|
||||||
f"{mode.lower()}": bus_mode_prop(mode.lower())
|
mode: bus_mode_prop(mode)
|
||||||
for mode in [
|
for mode in [
|
||||||
"normal",
|
"normal",
|
||||||
"Amix",
|
"amix",
|
||||||
"Bmix",
|
"bmix",
|
||||||
"Repeat",
|
"repeat",
|
||||||
"Composite",
|
"composite",
|
||||||
"TVMix",
|
"tvmix",
|
||||||
"UpMix21",
|
"upmix21",
|
||||||
"UpMix41",
|
"upmix41",
|
||||||
"UpMix61",
|
"upmix61",
|
||||||
"CenterOnly",
|
"centeronly",
|
||||||
"LFEOnly",
|
"lfeonly",
|
||||||
"RearOnly",
|
"rearonly",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -76,7 +76,7 @@ class Modes:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Channel(abc.ABC):
|
class IChannel(abc.ABC):
|
||||||
"""Base class for InputStrip and OutputBus."""
|
"""Base class for InputStrip and OutputBus."""
|
||||||
|
|
||||||
def __init__(self, remote, index):
|
def __init__(self, remote, index):
|
||||||
|
@ -63,7 +63,7 @@ def strip_output_prop(param):
|
|||||||
def bus_mode_prop(param):
|
def bus_mode_prop(param):
|
||||||
"""A bus mode prop."""
|
"""A bus mode prop."""
|
||||||
|
|
||||||
@partial(cache_bool, param=f"mode.{param}")
|
@partial(cache_bool, param=param)
|
||||||
def fget(self):
|
def fget(self):
|
||||||
modelist = {
|
modelist = {
|
||||||
"amix": (1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1),
|
"amix": (1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1),
|
||||||
@ -88,8 +88,8 @@ def bus_mode_prop(param):
|
|||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
if not isinstance(val, bool) and val not in (0, 1):
|
if not isinstance(val, bool) and val not in (0, 1):
|
||||||
raise VMCMDErrors(f"mode.{param} is a boolean parameter")
|
raise VMCMDErrors(f"{param} is a boolean parameter")
|
||||||
self.setter(f"mode.{param}", 1 if val else 0)
|
self.setter(param, 1 if val else 0)
|
||||||
|
|
||||||
return property(fget, fset)
|
return property(fget, fset)
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
from .errors import VMCMDErrors
|
from .errors import VMCMDErrors
|
||||||
from .channel import Channel
|
from .channel import IChannel
|
||||||
from . import kinds
|
from . import kinds
|
||||||
from .meta import strip_output_prop, channel_bool_prop, channel_label_prop
|
from .meta import strip_output_prop, channel_bool_prop, channel_label_prop
|
||||||
|
|
||||||
|
|
||||||
class InputStrip(Channel):
|
class InputStrip(IChannel):
|
||||||
"""Base class for input strips."""
|
"""Base class for input strips."""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user