mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2024-11-15 17:10:46 +00:00
BusModes IntEnum added to bus
get() added to bus mode mixin, returns the current bus mode. added support for setting bus mode by dict fixed bug in apply where bool parameters weren't being applied. bus modes added to all 3 example configs. test_config added to unit tests.
This commit is contained in:
parent
a1d6cf1042
commit
a86a25ca8f
@ -16,13 +16,10 @@ limit = -15
|
||||
|
||||
[strip-3]
|
||||
label = "VirtStrip0"
|
||||
bass = -3.2
|
||||
mid = 1.5
|
||||
treble = 2.1
|
||||
limit = -12
|
||||
|
||||
[strip-4]
|
||||
label = "VirtStrip1"
|
||||
limit = -12
|
||||
|
||||
[bus-0]
|
||||
label = "PhysBus0"
|
||||
@ -35,10 +32,12 @@ mono = true
|
||||
[bus-2]
|
||||
label = "PhysBus2"
|
||||
eq = true
|
||||
mode = "composite"
|
||||
|
||||
[bus-3]
|
||||
label = "VirtBus0"
|
||||
eq_ab = true
|
||||
mode = "upmix61"
|
||||
|
||||
[bus-4]
|
||||
label = "VirtBus1"
|
||||
|
@ -10,14 +10,13 @@ audibility = 3.2
|
||||
|
||||
[strip-2]
|
||||
label = "VirtStrip0"
|
||||
bass = -3.2
|
||||
mid = 1.5
|
||||
treble = 2.1
|
||||
|
||||
[bus-0]
|
||||
label = "PhysBus0"
|
||||
mute = true
|
||||
mode = "composite"
|
||||
|
||||
[bus-1]
|
||||
label = "PhysBus1"
|
||||
label = "VirtBus0"
|
||||
mono = true
|
||||
mode = "amix"
|
||||
|
29
tests/test_configs.py
Normal file
29
tests/test_configs.py
Normal file
@ -0,0 +1,29 @@
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
from tests import data, tests
|
||||
|
||||
|
||||
class TestSetAndGetBoolHigher:
|
||||
__test__ = True
|
||||
|
||||
"""example config tests"""
|
||||
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
tests.apply_config("example")
|
||||
|
||||
def test_it_tests_config_string(self):
|
||||
assert "PhysStrip" in tests.strip[data.phys_in].label
|
||||
assert "VirtStrip" in tests.strip[data.virt_in].label
|
||||
|
||||
def test_it_tests_config_bool(self):
|
||||
assert tests.strip[0].A1 == True
|
||||
|
||||
@pytest.mark.skipif(
|
||||
"not config.getoption('--run-slow')",
|
||||
reason="Only run when --run-slow is given",
|
||||
)
|
||||
def test_it_tests_config_busmode(self):
|
||||
assert tests.bus[data.phys_out].mode.get() == "composite"
|
@ -1,9 +1,18 @@
|
||||
import time
|
||||
from abc import abstractmethod
|
||||
from enum import IntEnum
|
||||
from typing import Union
|
||||
|
||||
from .error import VMCMDErrors
|
||||
from .iremote import IRemote
|
||||
from .meta import bus_mode_prop, channel_bool_prop, channel_label_prop
|
||||
|
||||
BusModes = IntEnum(
|
||||
"BusModes",
|
||||
"normal amix bmix repeat composite tvmix upmix21 upmix41 upmix61 centeronly lfeonly rearonly",
|
||||
start=0,
|
||||
)
|
||||
|
||||
|
||||
class Bus(IRemote):
|
||||
"""
|
||||
@ -95,28 +104,34 @@ def _make_bus_mode_mixin():
|
||||
def identifier(self) -> str:
|
||||
return f"Bus[{self.index}].mode"
|
||||
|
||||
def get(self):
|
||||
time.sleep(0.01)
|
||||
for i, val in enumerate(
|
||||
[
|
||||
self.amix,
|
||||
self.bmix,
|
||||
self.repeat,
|
||||
self.composite,
|
||||
self.tvmix,
|
||||
self.upmix21,
|
||||
self.upmix41,
|
||||
self.upmix61,
|
||||
self.centeronly,
|
||||
self.lfeonly,
|
||||
self.rearonly,
|
||||
]
|
||||
):
|
||||
if val:
|
||||
return BusModes(i + 1).name
|
||||
return "normal"
|
||||
|
||||
return type(
|
||||
"BusModeMixin",
|
||||
(IRemote,),
|
||||
{
|
||||
"identifier": property(identifier),
|
||||
**{
|
||||
mode: bus_mode_prop(mode)
|
||||
for mode in [
|
||||
"normal",
|
||||
"amix",
|
||||
"bmix",
|
||||
"repeat",
|
||||
"composite",
|
||||
"tvmix",
|
||||
"upmix21",
|
||||
"upmix41",
|
||||
"upmix61",
|
||||
"centeronly",
|
||||
"lfeonly",
|
||||
"rearonly",
|
||||
]
|
||||
},
|
||||
**{mode.name: bus_mode_prop(mode.name) for mode in BusModes},
|
||||
"get": get,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -107,9 +107,19 @@ class IRemote(metaclass=ABCMeta):
|
||||
|
||||
def apply(self, data):
|
||||
"""Sets all parameters of a dict for the channel."""
|
||||
script = ""
|
||||
|
||||
def fget(attr, val):
|
||||
if attr == "mode":
|
||||
return (f"mode.{val}", 1)
|
||||
return (attr, val)
|
||||
|
||||
script = str()
|
||||
for attr, val in data.items():
|
||||
if hasattr(self, attr):
|
||||
attr, val = fget(attr, val)
|
||||
if isinstance(val, bool):
|
||||
val = 1 if val else 0
|
||||
|
||||
self._remote.cache[f"{self.identifier}[{self.index}].{attr}"] = val
|
||||
script += f"{self.identifier}[{self.index}].{attr}={val};"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user