mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-16 00:40:46 +00:00
misc module added.
fx added to potato remote class. factory unit tests added.
This commit is contained in:
parent
be2b89e3fa
commit
1a6f3d6c73
60
tests/test_factory.py
Normal file
60
tests/test_factory.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from tests import data, tests
|
||||||
|
|
||||||
|
|
||||||
|
class TestRemoteFactories:
|
||||||
|
__test__ = True
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name != "basic",
|
||||||
|
reason="Skip test if kind is not basic",
|
||||||
|
)
|
||||||
|
def test_it_tests_remote_attrs_for_basic(self):
|
||||||
|
assert hasattr(tests, "strip")
|
||||||
|
assert hasattr(tests, "bus")
|
||||||
|
assert hasattr(tests, "command")
|
||||||
|
assert hasattr(tests, "button")
|
||||||
|
assert hasattr(tests, "vban")
|
||||||
|
assert hasattr(tests, "device")
|
||||||
|
|
||||||
|
assert len(tests.strip) == 3
|
||||||
|
assert len(tests.bus) == 2
|
||||||
|
assert len(tests.button) == 80
|
||||||
|
assert len(tests.vban.instream) == 4 and len(tests.vban.outstream) == 4
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name != "banana",
|
||||||
|
reason="Skip test if kind is not basic",
|
||||||
|
)
|
||||||
|
def test_it_tests_remote_attrs_for_banana(self):
|
||||||
|
assert hasattr(tests, "strip")
|
||||||
|
assert hasattr(tests, "bus")
|
||||||
|
assert hasattr(tests, "command")
|
||||||
|
assert hasattr(tests, "button")
|
||||||
|
assert hasattr(tests, "vban")
|
||||||
|
assert hasattr(tests, "device")
|
||||||
|
assert hasattr(tests, "recorder")
|
||||||
|
|
||||||
|
assert len(tests.strip) == 5
|
||||||
|
assert len(tests.bus) == 5
|
||||||
|
assert len(tests.button) == 80
|
||||||
|
assert len(tests.vban.instream) == 8 and len(tests.vban.outstream) == 8
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name != "potato",
|
||||||
|
reason="Skip test if kind is not basic",
|
||||||
|
)
|
||||||
|
def test_it_tests_remote_attrs_for_potato(self):
|
||||||
|
assert hasattr(tests, "strip")
|
||||||
|
assert hasattr(tests, "bus")
|
||||||
|
assert hasattr(tests, "command")
|
||||||
|
assert hasattr(tests, "button")
|
||||||
|
assert hasattr(tests, "vban")
|
||||||
|
assert hasattr(tests, "device")
|
||||||
|
assert hasattr(tests, "fx")
|
||||||
|
|
||||||
|
assert len(tests.strip) == 8
|
||||||
|
assert len(tests.bus) == 8
|
||||||
|
assert len(tests.button) == 80
|
||||||
|
assert len(tests.vban.instream) == 8 and len(tests.vban.outstream) == 8
|
@ -3,6 +3,7 @@ from enum import IntEnum
|
|||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from typing import Iterable, NoReturn, Self
|
from typing import Iterable, NoReturn, Self
|
||||||
|
|
||||||
|
from . import misc
|
||||||
from .base import Remote
|
from .base import Remote
|
||||||
from .bus import request_bus_obj as bus
|
from .bus import request_bus_obj as bus
|
||||||
from .command import Command
|
from .command import Command
|
||||||
@ -24,7 +25,9 @@ class FactoryBuilder:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
BuilderProgress = IntEnum(
|
BuilderProgress = IntEnum(
|
||||||
"BuilderProgress", "strip bus command macrobutton vban device recorder", start=0
|
"BuilderProgress",
|
||||||
|
"strip bus command macrobutton vban device recorder fx",
|
||||||
|
start=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
def __init__(self, factory, kind: KindMapClass):
|
def __init__(self, factory, kind: KindMapClass):
|
||||||
@ -38,6 +41,7 @@ class FactoryBuilder:
|
|||||||
f"Finished building vban in/out streams for {self._factory}",
|
f"Finished building vban in/out streams for {self._factory}",
|
||||||
f"Finished building device for {self._factory}",
|
f"Finished building device for {self._factory}",
|
||||||
f"Finished building recorder for {self._factory}",
|
f"Finished building recorder for {self._factory}",
|
||||||
|
f"Finished building fx for {self._factory}",
|
||||||
)
|
)
|
||||||
|
|
||||||
def _pinfo(self, name: str) -> NoReturn:
|
def _pinfo(self, name: str) -> NoReturn:
|
||||||
@ -79,6 +83,10 @@ class FactoryBuilder:
|
|||||||
self._factory.recorder = Recorder.make(self._factory)
|
self._factory.recorder = Recorder.make(self._factory)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
def make_fx(self) -> Self:
|
||||||
|
self._factory.fx = misc.FX(self._factory)
|
||||||
|
return self
|
||||||
|
|
||||||
|
|
||||||
class FactoryBase(Remote):
|
class FactoryBase(Remote):
|
||||||
"""Base class for factories, subclasses Remote."""
|
"""Base class for factories, subclasses Remote."""
|
||||||
@ -176,7 +184,7 @@ class PotatoFactory(FactoryBase):
|
|||||||
@property
|
@property
|
||||||
def steps(self) -> Iterable:
|
def steps(self) -> Iterable:
|
||||||
"""steps required to build the interface for a kind"""
|
"""steps required to build the interface for a kind"""
|
||||||
return self._steps + (self.builder.make_recorder,)
|
return self._steps + (self.builder.make_recorder, self.builder.make_fx)
|
||||||
|
|
||||||
|
|
||||||
def remote_factory(kind_id: str, **kwargs) -> Remote:
|
def remote_factory(kind_id: str, **kwargs) -> Remote:
|
||||||
|
39
voicemeeterlib/misc.py
Normal file
39
voicemeeterlib/misc.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
from .iremote import IRemote
|
||||||
|
|
||||||
|
|
||||||
|
class FX(IRemote):
|
||||||
|
@property
|
||||||
|
def identifier(self) -> str:
|
||||||
|
return f"FX"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def reverb(self) -> bool:
|
||||||
|
return self.getter("reverb.On") == 1
|
||||||
|
|
||||||
|
@reverb.setter
|
||||||
|
def reverb(self, val: bool):
|
||||||
|
self.setter("reverb.On", 1 if val else 0)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def reverb_ab(self) -> bool:
|
||||||
|
return self.getter("reverb.ab") == 1
|
||||||
|
|
||||||
|
@reverb_ab.setter
|
||||||
|
def reverb_ab(self, val: bool):
|
||||||
|
self.setter("reverb.ab", 1 if val else 0)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def delay(self) -> bool:
|
||||||
|
return self.getter("delay.On") == 1
|
||||||
|
|
||||||
|
@delay.setter
|
||||||
|
def delay(self, val: bool):
|
||||||
|
self.setter("delay.On", 1 if val else 0)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def delay_ab(self) -> bool:
|
||||||
|
return self.getter("delay.ab") == 1
|
||||||
|
|
||||||
|
@delay_ab.setter
|
||||||
|
def delay_ab(self, val: bool):
|
||||||
|
self.setter("delay.ab", 1 if val else 0)
|
Loading…
Reference in New Issue
Block a user