implement midi, text vban streams

kindmaps updated

factory tests updated.

closes #7
This commit is contained in:
onyx-and-iris 2023-07-12 09:45:33 +01:00
parent 278566c2e0
commit 9b2e38aab3
5 changed files with 80 additions and 10 deletions

View File

@ -11,6 +11,16 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
- [x]
## [2.3.2] - 2023-07-12
### Added
- vban.{instream,outstream} tuples now contain classes that represent MIDI and TEXT streams.
### Fixed
- apply_config() now performs a deep merge when extending a config with another.
## [2.3.0] - 2023-07-11
### Added

View File

@ -1,6 +1,6 @@
[tool.poetry]
name = "voicemeeter-api"
version = "2.3.1"
version = "2.3.2"
description = "A Python wrapper for the Voiceemeter API"
authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT"

View File

@ -22,7 +22,7 @@ class TestRemoteFactories:
assert len(vm.strip) == 3
assert len(vm.bus) == 2
assert len(vm.button) == 80
assert len(vm.vban.instream) == 4 and len(vm.vban.outstream) == 4
assert len(vm.vban.instream) == 6 and len(vm.vban.outstream) == 5
@pytest.mark.skipif(
data.name != "banana",
@ -42,7 +42,7 @@ class TestRemoteFactories:
assert len(vm.strip) == 5
assert len(vm.bus) == 5
assert len(vm.button) == 80
assert len(vm.vban.instream) == 8 and len(vm.vban.outstream) == 8
assert len(vm.vban.instream) == 10 and len(vm.vban.outstream) == 9
@pytest.mark.skipif(
data.name != "potato",
@ -63,4 +63,4 @@ class TestRemoteFactories:
assert len(vm.strip) == 8
assert len(vm.bus) == 8
assert len(vm.button) == 80
assert len(vm.vban.instream) == 8 and len(vm.vban.outstream) == 8
assert len(vm.vban.instream) == 10 and len(vm.vban.outstream) == 9

View File

@ -64,7 +64,7 @@ class BasicMap(KindMapClass):
name: str
ins: tuple = (2, 1)
outs: tuple = (1, 1)
vban: tuple = (4, 4)
vban: tuple = (4, 4, 1, 1)
asio: tuple = (0, 0)
insert: int = 0
@ -74,7 +74,7 @@ class BananaMap(KindMapClass):
name: str
ins: tuple = (3, 2)
outs: tuple = (3, 2)
vban: tuple = (8, 8)
vban: tuple = (8, 8, 1, 1)
asio: tuple = (6, 8)
insert: int = 22
@ -84,7 +84,7 @@ class PotatoMap(KindMapClass):
name: str
ins: tuple = (5, 3)
outs: tuple = (5, 3)
vban: tuple = (8, 8)
vban: tuple = (8, 8, 1, 1)
asio: tuple = (10, 8)
insert: int = 34

View File

@ -1,6 +1,7 @@
from abc import abstractmethod
from .iremote import IRemote
from .kinds import kinds_all
class VbanStream(IRemote):
@ -133,6 +134,21 @@ class VbanInstream(VbanStream):
return super(VbanInstream, self).bit
class VbanAudioInstream(VbanInstream):
def __str__(self):
return f"{type(self).__name__}{self._remote.kind}{self.index}"
class VbanMidiInstream(VbanInstream):
def __str__(self):
return f"{type(self).__name__}{self._remote.kind}{self.index}"
class VbanTextInstream(VbanInstream):
def __str__(self):
return f"{type(self).__name__}{self._remote.kind}{self.index}"
class VbanOutstream(VbanStream):
"""
class representing a vban outstream
@ -148,6 +164,52 @@ class VbanOutstream(VbanStream):
return "out"
class VbanAudioOutstream(VbanOutstream):
def __str__(self):
return f"{type(self).__name__}{self._remote.kind}{self.index}"
class VbanMidiOutstream(VbanOutstream):
def __str__(self):
return f"{type(self).__name__}{self._remote.kind}{self.index}"
def _make_stream_pair(remote, kind):
num_instream, num_outstream, num_midi, num_text = kind.vban
def _generate_streams(i, dir):
"""generator function for instream/outstream types"""
if dir == "in":
if i < num_instream:
yield VbanAudioInstream
elif i < num_instream + num_midi:
yield VbanMidiInstream
else:
yield VbanTextInstream
else:
if i < num_outstream:
yield VbanAudioOutstream
else:
yield VbanMidiOutstream
return (
tuple(
cls(remote, i)
for i in range(num_instream + num_midi + num_text)
for cls in _generate_streams(i, "in")
),
tuple(
cls(remote, i)
for i in range(num_outstream + num_midi)
for cls in _generate_streams(i, "out")
),
)
def _make_stream_pairs(remote):
return {kind.name: _make_stream_pair(remote, kind) for kind in kinds_all}
class Vban:
"""
class representing the vban module
@ -157,9 +219,7 @@ class Vban:
def __init__(self, remote):
self.remote = remote
num_instream, num_outstream = remote.kind.vban
self.instream = tuple(VbanInstream(remote, i) for i in range(num_instream))
self.outstream = tuple(VbanOutstream(remote, i) for i in range(num_outstream))
self.instream, self.outstream = _make_stream_pairs(remote)[remote.kind.name]
def enable(self):
self.remote.set("vban.Enable", 1)