implement midi, text vban streams

kindmaps updated

factory tests updated.

closes #2
This commit is contained in:
onyx-and-iris 2023-07-12 10:24:03 +01:00
parent a4b91bf5c6
commit dab519be9f
5 changed files with 97 additions and 8 deletions

View File

@ -11,12 +11,29 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
- [x] - [x]
## [2.2.0] - 2023-07-11 ## [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 ### Added
- user configs may now extend other user configs. check `config extends` section in README. - user configs may now extend other user configs. check `config extends` section in README.
## [2.2.0] - 2023-07-08
### Added
- button, vban classes implemented
- \__repr\__() method added to base class
## [2.1.2] - 2023-07-05 ## [2.1.2] - 2023-07-05
### Added ### Added

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "vban-cmd" name = "vban-cmd"
version = "2.3.1" version = "2.3.2"
description = "Python interface for the VBAN RT Packet Service (Sendtext)" description = "Python interface for the VBAN RT Packet Service (Sendtext)"
authors = ["onyx-and-iris <code@onyxandiris.online>"] authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT" license = "MIT"

View File

@ -14,9 +14,13 @@ class TestRemoteFactories:
assert hasattr(vban, "strip") assert hasattr(vban, "strip")
assert hasattr(vban, "bus") assert hasattr(vban, "bus")
assert hasattr(vban, "command") assert hasattr(vban, "command")
assert hasattr(vban, "button")
assert hasattr(vban, "vban")
assert len(vban.strip) == 3 assert len(vban.strip) == 3
assert len(vban.bus) == 2 assert len(vban.bus) == 2
assert len(vban.button) == 80
assert len(vban.vban.instream) == 6 and len(vban.vban.outstream) == 5
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "banana", data.name != "banana",
@ -26,9 +30,13 @@ class TestRemoteFactories:
assert hasattr(vban, "strip") assert hasattr(vban, "strip")
assert hasattr(vban, "bus") assert hasattr(vban, "bus")
assert hasattr(vban, "command") assert hasattr(vban, "command")
assert hasattr(vban, "button")
assert hasattr(vban, "vban")
assert len(vban.strip) == 5 assert len(vban.strip) == 5
assert len(vban.bus) == 5 assert len(vban.bus) == 5
assert len(vban.button) == 80
assert len(vban.vban.instream) == 10 and len(vban.vban.outstream) == 9
@pytest.mark.skipif( @pytest.mark.skipif(
data.name != "potato", data.name != "potato",
@ -38,6 +46,10 @@ class TestRemoteFactories:
assert hasattr(vban, "strip") assert hasattr(vban, "strip")
assert hasattr(vban, "bus") assert hasattr(vban, "bus")
assert hasattr(vban, "command") assert hasattr(vban, "command")
assert hasattr(vban, "button")
assert hasattr(vban, "vban")
assert len(vban.strip) == 8 assert len(vban.strip) == 8
assert len(vban.bus) == 8 assert len(vban.bus) == 8
assert len(vban.button) == 80
assert len(vban.vban.instream) == 10 and len(vban.vban.outstream) == 9

View File

@ -62,7 +62,7 @@ class BasicMap(KindMapClass):
name: str name: str
ins: tuple = (2, 1) ins: tuple = (2, 1)
outs: tuple = (1, 1) outs: tuple = (1, 1)
vban: tuple = (4, 4) vban: tuple = (4, 4, 1, 1)
@dataclass @dataclass
@ -70,7 +70,7 @@ class BananaMap(KindMapClass):
name: str name: str
ins: tuple = (3, 2) ins: tuple = (3, 2)
outs: tuple = (3, 2) outs: tuple = (3, 2)
vban: tuple = (8, 8) vban: tuple = (8, 8, 1, 1)
@dataclass @dataclass
@ -78,7 +78,7 @@ class PotatoMap(KindMapClass):
name: str name: str
ins: tuple = (5, 3) ins: tuple = (5, 3)
outs: tuple = (5, 3) outs: tuple = (5, 3)
vban: tuple = (8, 8) vban: tuple = (8, 8, 1, 1)
def kind_factory(kind_id): def kind_factory(kind_id):

View File

@ -1,6 +1,7 @@
from abc import abstractmethod from abc import abstractmethod
from .iremote import IRemote from .iremote import IRemote
from .kinds import kinds_all
class VbanStream(IRemote): class VbanStream(IRemote):
@ -133,6 +134,21 @@ class VbanInstream(VbanStream):
return return
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 VbanOutstream(VbanStream):
""" """
class representing a vban outstream class representing a vban outstream
@ -148,6 +164,52 @@ class VbanOutstream(VbanStream):
return "out" 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 creating instream/outstream tuples"""
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 Vban:
""" """
class representing the vban module class representing the vban module
@ -157,9 +219,7 @@ class Vban:
def __init__(self, remote): def __init__(self, remote):
self.remote = remote self.remote = remote
num_instream, num_outstream = remote.kind.vban self.instream, self.outstream = _make_stream_pairs(remote)[remote.kind.name]
self.instream = tuple(VbanInstream(remote, i) for i in range(num_instream))
self.outstream = tuple(VbanOutstream(remote, i) for i in range(num_outstream))
def enable(self): def enable(self):
"""if VBAN disabled there can be no communication with it""" """if VBAN disabled there can be no communication with it"""