From be2b89e3fa04aaf5a6ccae6031b50b27f422ea70 Mon Sep 17 00:00:00 2001 From: onyx-and-iris <75868496+onyx-and-iris@users.noreply.github.com> Date: Sat, 16 Jul 2022 21:19:10 +0100 Subject: [PATCH] added support for setting bus mode through dict bus modes added to all 3 example configs. config unit tests added --- configs/banana/example.toml | 10 ++++++---- configs/basic/example.toml | 4 +++- configs/potato/example.toml | 8 +++++--- tests/test_configs.py | 34 ++++++++++++++++++++++++++++++++++ voicemeeterlib/iremote.py | 8 +++++++- 5 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 tests/test_configs.py diff --git a/configs/banana/example.toml b/configs/banana/example.toml index 9f3d62e..a4788a6 100644 --- a/configs/banana/example.toml +++ b/configs/banana/example.toml @@ -16,13 +16,13 @@ limit = -15 [strip-3] label = "VirtStrip0" -bass = -3.2 -mid = 1.5 -treble = 2.1 +limit = -12 [strip-4] label = "VirtStrip1" -limit = -12 +bass = -3.2 +mid = 1.5 +treble = 2.1 [bus-0] label = "PhysBus0" @@ -35,10 +35,12 @@ mono = true [bus-2] label = "PhysBus2" eq = true +mode = "composite" [bus-3] label = "VirtBus0" eq_ab = true +mode = "upmix61" [bus-4] label = "VirtBus1" diff --git a/configs/basic/example.toml b/configs/basic/example.toml index edd2cf6..60562ce 100644 --- a/configs/basic/example.toml +++ b/configs/basic/example.toml @@ -17,7 +17,9 @@ treble = 2.1 [bus-0] label = "PhysBus0" mute = true +mode = "composite" [bus-1] -label = "PhysBus1" +label = "VirtBus0" mono = true +mode = "amix" diff --git a/configs/potato/example.toml b/configs/potato/example.toml index 9c43f21..47bf4ef 100644 --- a/configs/potato/example.toml +++ b/configs/potato/example.toml @@ -27,9 +27,6 @@ gain = -8.8 label = "VirtStrip0" A3 = true A5 = true -bass = -3.2 -mid = 1.5 -treble = 2.1 [strip-6] label = "VirtStrip1" @@ -38,6 +35,9 @@ k = 3 [strip-7] label = "VirtStrip2" +bass = -3.2 +mid = 1.5 +treble = 2.1 mc = true [bus-0] @@ -54,9 +54,11 @@ eq = true [bus-3] label = "PhysBus3" +mode = "upmix61" [bus-4] label = "PhysBus4" +mode = "composite" [bus-5] label = "VirtBus0" diff --git a/tests/test_configs.py b/tests/test_configs.py new file mode 100644 index 0000000..e652d6d --- /dev/null +++ b/tests/test_configs.py @@ -0,0 +1,34 @@ +import time + +import pytest + +from tests import data, tests + + +class TestUserConfigs: + __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" + + def test_it_tests_config_bass_med_high(self): + assert tests.strip[data.virt_in].bass == -3.2 + assert tests.strip[data.virt_in].mid == 1.5 + assert tests.strip[data.virt_in].high == 2.1 diff --git a/voicemeeterlib/iremote.py b/voicemeeterlib/iremote.py index 7b6765f..01489f9 100644 --- a/voicemeeterlib/iremote.py +++ b/voicemeeterlib/iremote.py @@ -27,9 +27,15 @@ class IRemote(metaclass=ABCMeta): pass def apply(self, data: dict) -> Self: + def fget(attr, val): + if attr == "mode": + return (getattr(self, attr), val, 1) + return (self, attr, val) + for attr, val in data.items(): if hasattr(self, attr): - setattr(self, attr, val) + target, attr, val = fget(attr, val) + setattr(target, attr, val) return self def then_wait(self):