mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2026-04-06 23:43:30 +00:00
Compare commits
131 Commits
main
...
add-event-
| Author | SHA1 | Date | |
|---|---|---|---|
| 708a7e6d8e | |||
| 409d2deea9 | |||
| 0ee3a223ec | |||
| 6bfd18c1ac | |||
| 103355d265 | |||
| 09cb62ecfa | |||
| cddd04974b | |||
| 50e95d6b8d | |||
| b33926f304 | |||
| 58a26e89a8 | |||
| e96151cd5a | |||
| 6b79c091e8 | |||
| bf77ded007 | |||
| 236125d095 | |||
| 7841dfe10f | |||
| bdf8dc489a | |||
| 160a6f89f9 | |||
| 4fcb2f93ca | |||
| 8acd0b1385 | |||
| 89866bb87b | |||
| f996fc0d9c | |||
| 68177c3c6c | |||
| 54a1938694 | |||
| 9a4205ce64 | |||
| 9b2e38aab3 | |||
| 278566c2e0 | |||
| b0acde6a52 | |||
| 07b04d16d8 | |||
| f854ec7875 | |||
| 5640f54e65 | |||
| 4569e8c760 | |||
| 5e39461966 | |||
| 6de78a4037 | |||
| bafaa58507 | |||
| af368b4b0a | |||
| 32527e37bd | |||
| c21b04e1a8 | |||
| 76960f36d0 | |||
| 2849b37670 | |||
| 7732a26c40 | |||
| c1e23ab250 | |||
| c2daba1a62 | |||
| 3036cdff2f | |||
| b02f3af665 | |||
| 145f85b7cd | |||
| 71f77b7830 | |||
| 4415851816 | |||
| 8b63cbfe8d | |||
| de4ce850eb | |||
| ee3fa0a372 | |||
| f92bb1e457 | |||
| 5b99f8aae3 | |||
| 59624ccb3e | |||
| b2005030f2 | |||
| 88a5686f27 | |||
| d0877dbdfd | |||
| ce9a86de79 | |||
| 58dba331a7 | |||
| 77003940f2 | |||
| d794bd4b78 | |||
| b3febbe831 | |||
| cf18ae6fcc | |||
| 01178082d2 | |||
| 3d98b2accd | |||
| cc26720ae2 | |||
| 2f9864cf60 | |||
| f57475daa0 | |||
| 8fc052d093 | |||
| 8831277160 | |||
| d428694fcf | |||
| 0548d82295 | |||
| 27d7f1fcd5 | |||
| 40d984c44f | |||
| 9ef89852de | |||
| b81c4c4b97 | |||
| 1ee0fc5f06 | |||
| 772a3344ca | |||
| b2f57a9e60 | |||
| c23a6aff6d | |||
| 342a49804f | |||
| 064cfeb23d | |||
| 6c4259d6de | |||
| 9cf048185d | |||
| 435a9e2085 | |||
| b10a90418e | |||
| 7d4d09ff29 | |||
| 6ddfe3044e | |||
| 36fe77f0f0 | |||
| 155e597db5 | |||
| 92e04f1419 | |||
| b5c8641c11 | |||
| c6b203a1df | |||
| 9f27968c5c | |||
| e6ea1e5f4f | |||
|
|
a460c6aeb0 | ||
|
|
bc508f8982 | ||
|
|
a4cc7058b6 | ||
|
|
6fa6d70f9b | ||
|
|
a73ebf364b | ||
|
|
caf05aa789 | ||
|
|
405fa8d5cb | ||
|
|
5ad5622612 | ||
|
|
108c327c52 | ||
|
|
7f1a51f86d | ||
|
|
94bace4f4d | ||
|
|
4e8532e805 | ||
|
|
907df78b37 | ||
|
|
f4fc58cea0 | ||
|
|
816fd76213 | ||
|
|
ad69d2cf14 | ||
|
|
86612a65cb | ||
|
|
08fdad135d | ||
|
|
30370f70ee | ||
|
|
f62a22f563 | ||
|
|
c513e4db19 | ||
|
|
9c8fe0b626 | ||
|
|
af0d51eeb1 | ||
|
|
bd686ef67d | ||
|
|
aefde48c98 | ||
|
|
4c6fc2d396 | ||
|
|
eddccb66c5 | ||
|
|
81a74d136c | ||
|
|
6b7a79173c | ||
|
|
ef0c94a6f1 | ||
|
|
a54a232a82 | ||
|
|
b2156ffade | ||
|
|
496f9d37fa | ||
|
|
3f9c486fa0 | ||
|
|
48b2857c58 | ||
|
|
af0740ddec | ||
|
|
f3eec58c25 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -131,3 +131,7 @@ dmypy.json
|
|||||||
# test/config
|
# test/config
|
||||||
quick.py
|
quick.py
|
||||||
config.toml
|
config.toml
|
||||||
|
vm-api.log
|
||||||
|
logging.json
|
||||||
|
|
||||||
|
.vscode/
|
||||||
168
CHANGELOG.md
168
CHANGELOG.md
@@ -11,6 +11,171 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
|||||||
|
|
||||||
- [x]
|
- [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
|
||||||
|
|
||||||
|
- user configs may now extend other user configs. check `config extends` section in README.
|
||||||
|
|
||||||
|
## [2.2.0] - 2023-07-10
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- CAPIError class now stores fn_name, error code and message as class attributes.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- macrobutton capi calls now use error code -9 on AttributeError (using an old version of the API).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- call to `self.vm_get_midi_message` now wrapped by {CBindings}.call.
|
||||||
|
|
||||||
|
## [2.1.1] - 2023-07-01
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- RecorderMode added to Recorder class. See Recorder section in README for new properties and methods.
|
||||||
|
- recorder.loop is now a forwarder method for recorder.mode.loop for backwards compatibility
|
||||||
|
|
||||||
|
- RecorderArmStrip, RecorderArmBus mixed into Recorder class.
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- Recorder.loop removed from documentation
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- When out of bounds values are passed, log warnings instead of raising Errors. See [Issue #6][Issue 6].
|
||||||
|
|
||||||
|
## [2.0.0] - 2023-06-25
|
||||||
|
|
||||||
|
Where possible I've attempted to make the changes backwards compatible. The breaking changes affect two higher classes, Strip and Bus, as well as the behaviour of events. All other changes are additive or QOL aimed at giving more options to the developer. For example, every low-level CAPI call is now logged and error raised on Exception, you can now register callback functions as well as observer classes, extra examples to demonstrate different use cases etc.
|
||||||
|
|
||||||
|
The breaking changes are as follows:
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `strip[i].comp` now references StripComp class
|
||||||
|
- To change the comp knob you should now use the property `strip[i].comp.knob`
|
||||||
|
- `strip[i].gate` now references StripGate class
|
||||||
|
|
||||||
|
- To change the gate knob you should now use the property `strip[i].gate.knob`
|
||||||
|
|
||||||
|
- `bus[i].eq` now references BusEQ class
|
||||||
|
|
||||||
|
- To set bus[i].{eq,eq_ab} as before you should now use bus[i].eq.on and bus[i].eq.ab
|
||||||
|
|
||||||
|
- by default, <strong>NO</strong> events are checked for. This is reflected in factory.FactoryBase defaultkwargs.
|
||||||
|
- This is a fundamental behaviour change from version 1.0 of the wrapper. It means the following:
|
||||||
|
- Unless any events are explicitly requested with an event kwarg the event emitter thread will not run automatically.
|
||||||
|
- Whether using a context manager or not, you can still initiate the event thread manually and request events with the event object.<br>
|
||||||
|
see `events` example.
|
||||||
|
|
||||||
|
There are other non-breaking changes:
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `strip[i].eq` added to PhysicalStrip
|
||||||
|
- `strip[i].denoiser` added to PhysicalStrip
|
||||||
|
- `Strip.Comp`, `Strip.Gate`, `Strip.Denoiser` sections added to README.
|
||||||
|
- `Events` section in readme updated to reflect changes to events kwargs.
|
||||||
|
- new comp, gate, denoiser and eq tests added to higher tests.
|
||||||
|
- `levels` example to demonstrate use of the interface without a context manager.
|
||||||
|
- `events` example to demonstrate how to interact with event thread/event object.
|
||||||
|
- `gui` example to demonstrate GUI controls.
|
||||||
|
- `{Remote}.observer` can be used in place of `{Remote}.subject` although subject will still work. Check examples.
|
||||||
|
- Subject class extended to allow registering/de-registering callback functions (as well as observer classes). See `events` example.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `comp.knob`, `gate.knob`, `denoiser.knob`, `eq.on` added to phys_strip_params in config.TOMLStrBuilder
|
||||||
|
|
||||||
|
- The `example.toml` config files have been updated to demonstrate setting new comp, gate and eq settings.
|
||||||
|
|
||||||
|
- event kwargs can now be set directly. no need for `subs`. example: `voicemeeterlib.api('banana', midi=True})`
|
||||||
|
|
||||||
|
- factorybuilder steps now logged in DEBUG mode.
|
||||||
|
|
||||||
|
- now using a producer thread to send events to the updater thread.
|
||||||
|
|
||||||
|
- module level loggers implemented (with class loggers as child loggers)
|
||||||
|
|
||||||
|
- config.loader now checks `Path.home() / ".config" / "voicemeeter" / kind.name` for configs.
|
||||||
|
- note. `Path(__file__).parent / "configs" / kind.name,` was removed as a path to check.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- All low level CAPI calls are now wrapped by CBindings.call() which logs any errors raised.
|
||||||
|
- Dynamic binding of Macrobutton functions from the CAPI.
|
||||||
|
Should add backwards compatibility with very old versions of the api. See [Issue #4][issue 4].
|
||||||
|
- factory.request_remote_obj now raises a `VMError` if passed an incorrect kind.
|
||||||
|
|
||||||
|
## [1.0.0] - 2023-06-19
|
||||||
|
|
||||||
|
No changes to the codebase but it has been stable for several months and should already have been bumped to major version 1.0
|
||||||
|
|
||||||
|
I will move this commit to a separate branch in preparation for version 2.0.
|
||||||
|
|
||||||
|
## [0.9.0] - 2022-10-11
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- StripDevice and BusDevice mixins.
|
||||||
|
- README updated to reflect changes.
|
||||||
|
- Minor version bump
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- device, sr properties for physical strip, bus moved into mixin classes
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Event class property setters added.
|
||||||
|
- Event add/remove methods now accept multiple events.
|
||||||
|
- bus levels now printed in observer example.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- initialize channel comps in updater thread. Fixes bug when switching to a kind before any level updates have occurred.
|
||||||
|
|
||||||
|
## [0.8.0] - 2022-09-29
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Logging level INFO set on all examples.
|
||||||
|
- Minor version bump
|
||||||
|
- vm.subject subsection added to README
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Logging module used in place of print statements across the interface.
|
||||||
|
- time.time() now used to steady rate of updates in updater thread.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- call to cache bug in updater thread
|
||||||
|
|
||||||
|
## [0.7.0] - 2022-09-03
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- tomli/tomllib compatibility layer to support python 3.10
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- 3.10 branch
|
||||||
|
|
||||||
## [0.6.0] - 2022-08-02
|
## [0.6.0] - 2022-08-02
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -243,3 +408,6 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
|||||||
- inst module implemented (fetch vm path from registry)
|
- inst module implemented (fetch vm path from registry)
|
||||||
- kind maps implemented as dataclasses
|
- kind maps implemented as dataclasses
|
||||||
- project packaged with poetry and added to pypi.
|
- project packaged with poetry and added to pypi.
|
||||||
|
|
||||||
|
[issue 4]: https://github.com/onyx-and-iris/voicemeeter-api-python/issues/4
|
||||||
|
[Issue 6]: https://github.com/onyx-and-iris/voicemeeter-api-python/issues/6
|
||||||
|
|||||||
382
README.md
382
README.md
@@ -14,21 +14,17 @@ For an outline of past/future changes refer to: [CHANGELOG](CHANGELOG.md)
|
|||||||
|
|
||||||
## Tested against
|
## Tested against
|
||||||
|
|
||||||
- Basic 1.0.8.2
|
- Basic 1.0.8.8
|
||||||
- Banana 2.0.6.2
|
- Banana 2.0.6.8
|
||||||
- Potato 3.0.2.2
|
- Potato 3.0.2.8
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- [Voicemeeter](https://voicemeeter.com/)
|
- [Voicemeeter](https://voicemeeter.com/)
|
||||||
- Python 3.11 or greater
|
- Python 3.10 or greater
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### `Pip`
|
|
||||||
|
|
||||||
Install voicemeeter-api package from your console
|
|
||||||
|
|
||||||
`pip install voicemeeter-api`
|
`pip install voicemeeter-api`
|
||||||
|
|
||||||
## `Use`
|
## `Use`
|
||||||
@@ -55,17 +51,19 @@ class ManyThings:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def other_things(self):
|
def other_things(self):
|
||||||
|
self.vm.bus[3].gain = -6.3
|
||||||
|
self.vm.bus[4].eq.on = True
|
||||||
info = (
|
info = (
|
||||||
f"bus 3 gain has been set to {self.vm.bus[3].gain}",
|
f"bus 3 gain has been set to {self.vm.bus[3].gain}",
|
||||||
f"bus 4 eq has been set to {self.vm.bus[4].eq}",
|
f"bus 4 eq has been set to {self.vm.bus[4].eq.on}",
|
||||||
)
|
)
|
||||||
self.vm.bus[3].gain = -6.3
|
|
||||||
self.vm.bus[4].eq = True
|
|
||||||
print("\n".join(info))
|
print("\n".join(info))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with voicemeeterlib.api(kind_id) as vm:
|
KIND_ID = "banana"
|
||||||
|
|
||||||
|
with voicemeeterlib.api(KIND_ID) as vm:
|
||||||
do = ManyThings(vm)
|
do = ManyThings(vm)
|
||||||
do.things()
|
do.things()
|
||||||
do.other_things()
|
do.other_things()
|
||||||
@@ -74,7 +72,7 @@ def main():
|
|||||||
vm.apply(
|
vm.apply(
|
||||||
{
|
{
|
||||||
"strip-2": {"A1": True, "B1": True, "gain": -6.0},
|
"strip-2": {"A1": True, "B1": True, "gain": -6.0},
|
||||||
"bus-2": {"mute": True},
|
"bus-2": {"mute": True, "eq": {"on": True}},
|
||||||
"button-0": {"state": True},
|
"button-0": {"state": True},
|
||||||
"vban-in-0": {"on": True},
|
"vban-in-0": {"on": True},
|
||||||
"vban-out-1": {"name": "streamname"},
|
"vban-out-1": {"name": "streamname"},
|
||||||
@@ -83,16 +81,15 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
kind_id = "banana"
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Otherwise you must remember to call `vm.login()`, `vm.logout()` at the start/end of your code.
|
Otherwise you must remember to call `vm.login()`, `vm.logout()` at the start/end of your code.
|
||||||
|
|
||||||
## `kind_id`
|
## `KIND_ID`
|
||||||
|
|
||||||
Pass the kind of Voicemeeter as an argument. kind_id may be:
|
Pass the kind of Voicemeeter as an argument. KIND_ID may be:
|
||||||
|
|
||||||
- `basic`
|
- `basic`
|
||||||
- `banana`
|
- `banana`
|
||||||
@@ -108,14 +105,10 @@ The following properties are available.
|
|||||||
- `solo`: boolean
|
- `solo`: boolean
|
||||||
- `mute`: boolean
|
- `mute`: boolean
|
||||||
- `gain`: float, from -60.0 to 12.0
|
- `gain`: float, from -60.0 to 12.0
|
||||||
- `comp`: float, from 0.0 to 10.0
|
|
||||||
- `gate`: float, from 0.0 to 10.0
|
|
||||||
- `audibility`: float, from 0.0 to 10.0
|
- `audibility`: float, from 0.0 to 10.0
|
||||||
- `limit`: int, from -40 to 12
|
- `limit`: int, from -40 to 12
|
||||||
- `A1 - A5`, `B1 - B3`: boolean
|
- `A1 - A5`, `B1 - B3`: boolean
|
||||||
- `label`: string
|
- `label`: string
|
||||||
- `device`: string
|
|
||||||
- `sr`: int
|
|
||||||
- `mc`: boolean
|
- `mc`: boolean
|
||||||
- `k`: int, from 0 to 4
|
- `k`: int, from 0 to 4
|
||||||
- `bass`: float, from -12.0 to 12.0
|
- `bass`: float, from -12.0 to 12.0
|
||||||
@@ -143,7 +136,7 @@ vm.strip[3].gain = 3.7
|
|||||||
print(vm.strip[0].label)
|
print(vm.strip[0].label)
|
||||||
```
|
```
|
||||||
|
|
||||||
The following methods are Available.
|
The following methods are available.
|
||||||
|
|
||||||
- `appgain(name, value)`: string, float, from 0.0 to 1.0
|
- `appgain(name, value)`: string, float, from 0.0 to 1.0
|
||||||
|
|
||||||
@@ -160,7 +153,82 @@ vm.strip[5].appmute("Spotify", True)
|
|||||||
vm.strip[5].appgain("Spotify", 0.5)
|
vm.strip[5].appgain("Spotify", 0.5)
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Gainlayers
|
#### Strip.Comp
|
||||||
|
|
||||||
|
The following properties are available.
|
||||||
|
|
||||||
|
- `knob`: float, from 0.0 to 10.0
|
||||||
|
- `gainin`: float, from -24.0 to 24.0
|
||||||
|
- `ratio`: float, from 1.0 to 8.0
|
||||||
|
- `threshold`: float, from -40.0 to -3.0
|
||||||
|
- `attack`: float, from 0.0 to 200.0
|
||||||
|
- `release`: float, from 0.0 to 5000.0
|
||||||
|
- `knee`: float, from 0.0 to 1.0
|
||||||
|
- `gainout`: float, from -24.0 to 24.0
|
||||||
|
- `makeup`: boolean
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
print(vm.strip[4].comp.knob)
|
||||||
|
```
|
||||||
|
|
||||||
|
Strip Comp parameters are defined for PhysicalStrips.
|
||||||
|
|
||||||
|
`knob` defined for all versions, all other parameters potato only.
|
||||||
|
|
||||||
|
#### Strip.Gate
|
||||||
|
|
||||||
|
The following properties are available.
|
||||||
|
|
||||||
|
- `knob`: float, from 0.0 to 10.0
|
||||||
|
- `threshold`: float, from -60.0 to -10.0
|
||||||
|
- `damping`: float, from -60.0 to -10.0
|
||||||
|
- `bpsidechain`: int, from 100 to 4000
|
||||||
|
- `attack`: float, from 0.0 to 1000.0
|
||||||
|
- `hold`: float, from 0.0 to 5000.0
|
||||||
|
- `release`: float, from 0.0 to 5000.0
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
vm.strip[2].gate.attack = 300.8
|
||||||
|
```
|
||||||
|
|
||||||
|
Strip Gate parameters are defined for PhysicalStrips.
|
||||||
|
|
||||||
|
`knob` defined for all versions, all other parameters potato only.
|
||||||
|
|
||||||
|
#### Strip.Denoiser
|
||||||
|
|
||||||
|
The following properties are available.
|
||||||
|
|
||||||
|
- `knob`: float, from 0.0 to 10.0
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
vm.strip[0].denoiser.knob = 0.5
|
||||||
|
```
|
||||||
|
|
||||||
|
Strip Denoiser parameters are defined for PhysicalStrips, potato version only.
|
||||||
|
|
||||||
|
#### Strip.EQ
|
||||||
|
|
||||||
|
The following properties are available.
|
||||||
|
|
||||||
|
- `on`: boolean
|
||||||
|
- `ab`: boolean
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
vm.strip[0].eq.ab = True
|
||||||
|
```
|
||||||
|
|
||||||
|
Strip EQ parameters are defined for PhysicalStrips, potato version only.
|
||||||
|
|
||||||
|
##### Strip.Gainlayers
|
||||||
|
|
||||||
- `gain`: float, from -60.0 to 12.0
|
- `gain`: float, from -60.0 to 12.0
|
||||||
|
|
||||||
@@ -172,7 +240,7 @@ vm.strip[3].gainlayer[3].gain = 3.7
|
|||||||
|
|
||||||
Gainlayers are defined for potato version only.
|
Gainlayers are defined for potato version only.
|
||||||
|
|
||||||
##### Levels
|
##### Strip.Levels
|
||||||
|
|
||||||
The following properties are available.
|
The following properties are available.
|
||||||
|
|
||||||
@@ -193,14 +261,10 @@ Level properties will return -200.0 if no audio detected.
|
|||||||
The following properties are available.
|
The following properties are available.
|
||||||
|
|
||||||
- `mono`: boolean
|
- `mono`: boolean
|
||||||
- `eq`: boolean
|
|
||||||
- `eq_ab`: boolean
|
|
||||||
- `mute`: boolean
|
- `mute`: boolean
|
||||||
- `sel`: boolean
|
- `sel`: boolean
|
||||||
- `gain`: float, from -60.0 to 12.0
|
- `gain`: float, from -60.0 to 12.0
|
||||||
- `label`: string
|
- `label`: string
|
||||||
- `device`: string
|
|
||||||
- `sr`: int
|
|
||||||
- `returnreverb`: float, from 0.0 to 10.0
|
- `returnreverb`: float, from 0.0 to 10.0
|
||||||
- `returndelay`: float, from 0.0 to 10.0
|
- `returndelay`: float, from 0.0 to 10.0
|
||||||
- `returnfx1`: float, from 0.0 to 10.0
|
- `returnfx1`: float, from 0.0 to 10.0
|
||||||
@@ -216,7 +280,20 @@ print(vm.bus[0].label)
|
|||||||
vm.bus[4].mono = True
|
vm.bus[4].mono = True
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Modes
|
##### Bus.EQ
|
||||||
|
|
||||||
|
The following properties are available.
|
||||||
|
|
||||||
|
- `on`: boolean
|
||||||
|
- `ab`: boolean
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
vm.bus[3].eq.on = True
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Bus.Modes
|
||||||
|
|
||||||
The following properties are available.
|
The following properties are available.
|
||||||
|
|
||||||
@@ -244,7 +321,7 @@ vm.bus[4].mode.amix = True
|
|||||||
print(vm.bus[2].mode.get())
|
print(vm.bus[2].mode.get())
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Levels
|
##### Bus.Levels
|
||||||
|
|
||||||
The following properties are available.
|
The following properties are available.
|
||||||
|
|
||||||
@@ -274,6 +351,28 @@ vm.strip[0].fadeto(-10.3, 1000)
|
|||||||
vm.bus[3].fadeby(-5.6, 500)
|
vm.bus[3].fadeby(-5.6, 500)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Strip.Device | Bus.Device
|
||||||
|
|
||||||
|
The following properties are available
|
||||||
|
|
||||||
|
- `name`: str
|
||||||
|
- `sr`: int
|
||||||
|
- `wdm`: str
|
||||||
|
- `ks`: str
|
||||||
|
- `mme`: str
|
||||||
|
- `asio`: str
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
print(vm.strip[0].device.name)
|
||||||
|
vm.bus[0].device.asio = "Audient USB Audio ASIO Driver"
|
||||||
|
```
|
||||||
|
|
||||||
|
strip|bus device parameters are defined for physical channels only.
|
||||||
|
|
||||||
|
name, sr are read only. wdm, ks, mme, asio are write only.
|
||||||
|
|
||||||
### Macrobuttons
|
### Macrobuttons
|
||||||
|
|
||||||
The following properties are available.
|
The following properties are available.
|
||||||
@@ -299,13 +398,19 @@ The following methods are available
|
|||||||
- `record()`
|
- `record()`
|
||||||
- `ff()`
|
- `ff()`
|
||||||
- `rew()`
|
- `rew()`
|
||||||
- `load(<filepath>)`: string
|
- `load(filepath)`: raw string
|
||||||
|
- `goto(time_string)`: time string in format `hh:mm:ss`
|
||||||
|
- `filetype(filetype)`: string, ("wav", "aiff", "bwf", "mp3")
|
||||||
|
|
||||||
The following properties are available
|
The following properties are available
|
||||||
|
|
||||||
- `loop`: boolean
|
|
||||||
- `A1 - A5`: boolean
|
- `A1 - A5`: boolean
|
||||||
- `B1 - A3`: boolean
|
- `B1 - B3`: boolean
|
||||||
|
- `samplerate`: int, (22050, 24000, 32000, 44100, 48000, 88200, 96000, 176400, 192000)
|
||||||
|
- `bitresolution`: int, (8, 16, 24, 32)
|
||||||
|
- `channel`: int, from 1 to 8
|
||||||
|
- `kbps`: int, (32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320)
|
||||||
|
- `gain`: float, from -60.0 to 12.0
|
||||||
|
|
||||||
example:
|
example:
|
||||||
|
|
||||||
@@ -313,17 +418,46 @@ example:
|
|||||||
vm.recorder.play()
|
vm.recorder.play()
|
||||||
vm.recorder.stop()
|
vm.recorder.stop()
|
||||||
|
|
||||||
# Enable loop play
|
|
||||||
vm.recorder.loop = True
|
|
||||||
|
|
||||||
# Disable recorder out channel B2
|
# Disable recorder out channel B2
|
||||||
vm.recorder.B2 = False
|
vm.recorder.B2 = False
|
||||||
|
|
||||||
# filepath as raw string
|
# filepath as raw string
|
||||||
vm.recorder.load(r'C:\music\mytune.mp3')
|
vm.recorder.load(r'C:\music\mytune.mp3')
|
||||||
|
|
||||||
|
# set the goto time to 1m 30s
|
||||||
|
vm.recorder.goto("00:01:30")
|
||||||
```
|
```
|
||||||
|
|
||||||
Recorder properties are defined as write only.
|
#### Recorder.Mode
|
||||||
|
|
||||||
|
The following properties are available
|
||||||
|
|
||||||
|
- `recbus`: boolean
|
||||||
|
- `playonload`: boolean
|
||||||
|
- `loop`: boolean
|
||||||
|
- `multitrack`: boolean
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
# Enable loop play
|
||||||
|
vm.recorder.mode.loop = True
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Recorder.ArmStrip[i]|ArmBus[i]
|
||||||
|
|
||||||
|
The following method is available
|
||||||
|
|
||||||
|
- `set(val)`: boolean
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
# Arm strip 3
|
||||||
|
vm.recorder.armstrip[3].set(True)
|
||||||
|
# Arm bus 0
|
||||||
|
vm.recorder.armbus[0].set(True)
|
||||||
|
```
|
||||||
|
|
||||||
### VBAN
|
### VBAN
|
||||||
|
|
||||||
@@ -395,7 +529,7 @@ example:
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
import voicemeeterlib
|
import voicemeeterlib
|
||||||
with voicemeeterlib.api(kind_id) as vm:
|
with voicemeeterlib.api(KIND_ID) as vm:
|
||||||
for i in range(vm.device.ins):
|
for i in range(vm.device.ins):
|
||||||
print(vm.device.input(i))
|
print(vm.device.input(i))
|
||||||
```
|
```
|
||||||
@@ -495,7 +629,9 @@ vm.option.sr = 48000
|
|||||||
|
|
||||||
The following methods are available:
|
The following methods are available:
|
||||||
|
|
||||||
- `buffer(driver, buffer)` : Set buffer size for particular audio driver.
|
- `buffer(driver, buf)` : Set buffer size for particular audio driver.
|
||||||
|
- buf: int, from 128 to 2048
|
||||||
|
- driver:str, ("mme", "wdm", "ks", "asio")
|
||||||
|
|
||||||
example:
|
example:
|
||||||
|
|
||||||
@@ -503,10 +639,6 @@ example:
|
|||||||
vm.option.buffer("wdm", 512)
|
vm.option.buffer("wdm", 512)
|
||||||
```
|
```
|
||||||
|
|
||||||
driver defined as one of ("mme", "wdm", "ks", "asio")
|
|
||||||
|
|
||||||
buffer, from 128 to 2048
|
|
||||||
|
|
||||||
##### delay[i]
|
##### delay[i]
|
||||||
|
|
||||||
- `get()`: int
|
- `get()`: int
|
||||||
@@ -548,7 +680,7 @@ get() may return None if no value for requested key in midi cache
|
|||||||
vm.apply(
|
vm.apply(
|
||||||
{
|
{
|
||||||
"strip-2": {"A1": True, "B1": True, "gain": -6.0},
|
"strip-2": {"A1": True, "B1": True, "gain": -6.0},
|
||||||
"bus-2": {"mute": True},
|
"bus-2": {"mute": True, "eq": {"on": True}},
|
||||||
"button-0": {"state": True},
|
"button-0": {"state": True},
|
||||||
"vban-in-0": {"on": True},
|
"vban-in-0": {"on": True},
|
||||||
"vban-out-1": {"name": "streamname"},
|
"vban-out-1": {"name": "streamname"},
|
||||||
@@ -559,17 +691,17 @@ vm.apply(
|
|||||||
Or for each class you may do:
|
Or for each class you may do:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
vm.strip[0].apply(mute: True, gain: 3.2, A1: True)
|
vm.strip[0].apply({"mute": True, "gain": 3.2, "A1": True})
|
||||||
vm.vban.outstream[0].apply(on: True, name: 'streamname', bit: 24)
|
vm.vban.outstream[0].apply({"on": True, "name": "streamname", "bit": 24})
|
||||||
```
|
```
|
||||||
|
|
||||||
## Config Files
|
## Config Files
|
||||||
|
|
||||||
`vm.apply_config(<configname>)`
|
`vm.apply_config(configname)`
|
||||||
|
|
||||||
You may load config files in TOML format.
|
You may load config files in TOML format.
|
||||||
Three example configs have been included with the package. Remember to save
|
Three example configs have been included with the package. Remember to save
|
||||||
current settings before loading a user config. To set one you may do:
|
current settings before loading a user config. To load one you may do:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import voicemeeterlib
|
import voicemeeterlib
|
||||||
@@ -577,75 +709,114 @@ with voicemeeterlib.api('banana') as vm:
|
|||||||
vm.apply_config('example')
|
vm.apply_config('example')
|
||||||
```
|
```
|
||||||
|
|
||||||
will load a user config file at configs/banana/example.toml for Voicemeeter Banana.
|
Your configs may be located in one of the following paths:
|
||||||
|
- \<current working directory\> / "configs" / kind_id
|
||||||
|
- \<user home directory\> / ".config" / "voicemeeter" / kind_id
|
||||||
|
- \<user home directory\> / "Documents" / "Voicemeeter" / "configs" / kind_id
|
||||||
|
|
||||||
## `Base Module`
|
If a config with the same name is located in multiple locations, only the first one found is loaded into memory, in the above order.
|
||||||
|
|
||||||
### Remote class
|
#### `config extends`
|
||||||
|
|
||||||
`voicemeeterlib.api(kind_id: str)`
|
You may also load a config that extends another config with overrides or additional parameters.
|
||||||
|
|
||||||
You may pass the following optional keyword arguments:
|
You just need to define a key `extends` in the config TOML, that names the config to be extended.
|
||||||
|
|
||||||
- `sync`: boolean=False, force the getters to wait for dirty parameters to clear. For most cases leave this as False.
|
Three example 'extender' configs are included with the repo. You may load them with:
|
||||||
- `ratelimit`: float=0.033, how often to check for updates in ms.
|
|
||||||
- `subs`: dict={"pdirty": True, "mdirty": True, "midi": True, "ldirty": False}, initialize which event updates to listen for.
|
|
||||||
- `pdirty`: parameter updates
|
|
||||||
- `mdirty`: macrobutton updates
|
|
||||||
- `midi`: midi updates
|
|
||||||
- `ldirty`: level updates
|
|
||||||
|
|
||||||
#### Event updates
|
```python
|
||||||
|
import voicemeeterlib
|
||||||
|
with voicemeeterlib.api('banana') as vm:
|
||||||
|
vm.apply_config('extender')
|
||||||
|
```
|
||||||
|
|
||||||
To receive event updates you should do the following:
|
## Events
|
||||||
|
|
||||||
- register your app to receive updates using the `vm.subject.add(observer)` method, where observer is your app.
|
By default, NO events are listened for. Use events kwargs to enable specific event types.
|
||||||
- define an `on_update(subject)` callback function in your app. The value of subject may be checked for the type of event.
|
|
||||||
|
|
||||||
See `examples/observer` for a demonstration.
|
|
||||||
|
|
||||||
Level updates are considered high volume, by default they are NOT listened for. However, polling them with strip.levels and bus.levels methods will still work.
|
|
||||||
|
|
||||||
So if you don't wish to receive level updates, or you prefer to handle them yourself simply leave ldirty as default (False).
|
|
||||||
|
|
||||||
Each of the update types may be enabled/disabled separately. Don't use a midi controller? You have the option to disable midi updates.
|
|
||||||
|
|
||||||
example:
|
example:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
import voicemeeterlib
|
import voicemeeterlib
|
||||||
# Set updates to occur every 50ms
|
# Set event updates to occur every 50ms
|
||||||
# Listen for level updates but disable midi updates
|
# Listen for level updates only
|
||||||
with voicemeeterlib.api('banana', ratelimit=0.05, subs={"ldirty": True, "midi": False}) as vm:
|
with voicemeeterlib.api('banana', ratelimit=0.05, ldirty=True) as vm:
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
#### `vm.observer`
|
||||||
|
|
||||||
|
Use the Subject class to register an app as event observer.
|
||||||
|
|
||||||
|
The following methods are available:
|
||||||
|
|
||||||
|
- `add`: registers an app as an event observer
|
||||||
|
- `remove`: deregisters an app as an event observer
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
# register an app to receive updates
|
||||||
|
class App():
|
||||||
|
def __init__(self, vm):
|
||||||
|
vm.observer.add(self)
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `vm.event`
|
#### `vm.event`
|
||||||
|
|
||||||
You may also add/remove event subscriptions as necessary with the Event class.
|
Use the event class to toggle updates as necessary.
|
||||||
|
|
||||||
|
The following properties are available:
|
||||||
|
|
||||||
|
- `pdirty`: boolean
|
||||||
|
- `mdirty`: boolean
|
||||||
|
- `midi`: boolean
|
||||||
|
- `ldirty`: boolean
|
||||||
|
|
||||||
example:
|
example:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
vm.event.add("ldirty")
|
vm.event.ldirty = True
|
||||||
|
|
||||||
vm.event.remove("pdirty")
|
vm.event.pdirty = False
|
||||||
|
```
|
||||||
|
|
||||||
|
Or add, remove a list of events.
|
||||||
|
|
||||||
|
The following methods are available:
|
||||||
|
|
||||||
|
- `add()`
|
||||||
|
- `remove()`
|
||||||
|
- `get()`
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
vm.event.remove(["pdirty", "mdirty", "midi"])
|
||||||
|
|
||||||
# get a list of currently subscribed
|
# get a list of currently subscribed
|
||||||
print(vm.event.get())
|
print(vm.event.get())
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Remote class
|
||||||
|
|
||||||
|
`voicemeeterlib.api(KIND_ID: str)`
|
||||||
|
|
||||||
|
You may pass the following optional keyword arguments:
|
||||||
|
|
||||||
|
- `sync`: boolean=False, force the getters to wait for dirty parameters to clear. For most cases leave this as False.
|
||||||
|
- `ratelimit`: float=0.033, how often to check for updates in ms.
|
||||||
|
- `pdirty`: boolean=False, parameter updates
|
||||||
|
- `mdirty`: boolean=False, macrobutton updates
|
||||||
|
- `midi`: boolean=False, midi updates
|
||||||
|
- `ldirty`: boolean=False, level updates
|
||||||
|
|
||||||
Access to lower level Getters and Setters are provided with these functions:
|
Access to lower level Getters and Setters are provided with these functions:
|
||||||
|
|
||||||
- `vm.get(param, is_string=False)`: For getting the value of any parameter. Set string to True if getting a property value expected to return a string.
|
- `vm.get(param, is_string=False)`: For getting the value of any parameter. Set string to True if getting a property value expected to return a string.
|
||||||
- `vm.set(param, value)`: For setting the value of any parameter.
|
- `vm.set(param, value)`: For setting the value of any parameter.
|
||||||
|
|
||||||
Access to lower level polling functions are provided with these functions:
|
|
||||||
|
|
||||||
- `vm.pdirty()`: Returns True if a parameter has been updated.
|
|
||||||
- `vm.mdirty()`: Returns True if a macrobutton has been updated.
|
|
||||||
- `vm.ldirty()`: Returns True if a level has been updated.
|
|
||||||
|
|
||||||
example:
|
example:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
@@ -654,6 +825,44 @@ vm.set('Strip[4].Label', 'stripname')
|
|||||||
vm.set('Strip[0].Gain', -3.6)
|
vm.set('Strip[0].Gain', -3.6)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Access to lower level polling functions are provided with the following property objects:
|
||||||
|
|
||||||
|
##### `vm.pdirty`
|
||||||
|
|
||||||
|
True iff a parameter has been updated.
|
||||||
|
|
||||||
|
##### `vm.mdirty`
|
||||||
|
|
||||||
|
True iff a macrobutton has been updated.
|
||||||
|
|
||||||
|
##### `vm.ldirty`
|
||||||
|
|
||||||
|
True iff a level has been updated.
|
||||||
|
|
||||||
|
|
||||||
|
### Errors
|
||||||
|
|
||||||
|
- `errors.VMError`: Exception raised when general errors occur.
|
||||||
|
- `errors.InstallError`: Exception raised when installation errors occur.
|
||||||
|
- `errors.CAPIError`: Exception raised when the C-API returns error values.
|
||||||
|
- Error codes are stored in {Exception Class}.code. For a full list of error codes [check the VoicemeeterRemote header file][Voicemeeter Remote Header].
|
||||||
|
|
||||||
|
|
||||||
|
### Logging
|
||||||
|
|
||||||
|
It's possible to see the messages sent by the interface's setters and getters, may be useful for debugging.
|
||||||
|
|
||||||
|
example:
|
||||||
|
```python
|
||||||
|
import voicemeeterlib
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
with voicemeeterlib.api("banana") as vm:
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Run tests
|
### Run tests
|
||||||
|
|
||||||
To run all tests:
|
To run all tests:
|
||||||
@@ -664,4 +873,7 @@ pytest -v
|
|||||||
|
|
||||||
### Official Documentation
|
### Official Documentation
|
||||||
|
|
||||||
- [Voicemeeter Remote C API](https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/main/VoicemeeterRemoteAPI.pdf)
|
- [Voicemeeter Remote C API](https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/update-docs/VoicemeeterRemoteAPI.pdf)
|
||||||
|
|
||||||
|
|
||||||
|
[Voicemeeter Remote Header]: https://github.com/onyx-and-iris/Voicemeeter-SDK/blob/update-docs/VoicemeeterRemote.h
|
||||||
14
__main__.py
14
__main__.py
@@ -13,17 +13,19 @@ class ManyThings:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def other_things(self):
|
def other_things(self):
|
||||||
|
self.vm.bus[3].gain = -6.3
|
||||||
|
self.vm.bus[4].eq.on = True
|
||||||
info = (
|
info = (
|
||||||
f"bus 3 gain has been set to {self.vm.bus[3].gain}",
|
f"bus 3 gain has been set to {self.vm.bus[3].gain}",
|
||||||
f"bus 4 eq has been set to {self.vm.bus[4].eq}",
|
f"bus 4 eq has been set to {self.vm.bus[4].eq.on}",
|
||||||
)
|
)
|
||||||
self.vm.bus[3].gain = -6.3
|
|
||||||
self.vm.bus[4].eq = True
|
|
||||||
print("\n".join(info))
|
print("\n".join(info))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with voicemeeterlib.api(kind_id) as vm:
|
KIND_ID = "banana"
|
||||||
|
|
||||||
|
with voicemeeterlib.api(KIND_ID) as vm:
|
||||||
do = ManyThings(vm)
|
do = ManyThings(vm)
|
||||||
do.things()
|
do.things()
|
||||||
do.other_things()
|
do.other_things()
|
||||||
@@ -32,7 +34,7 @@ def main():
|
|||||||
vm.apply(
|
vm.apply(
|
||||||
{
|
{
|
||||||
"strip-2": {"A1": True, "B1": True, "gain": -6.0},
|
"strip-2": {"A1": True, "B1": True, "gain": -6.0},
|
||||||
"bus-2": {"mute": True},
|
"bus-2": {"mute": True, "eq": {"on": True}},
|
||||||
"button-0": {"state": True},
|
"button-0": {"state": True},
|
||||||
"vban-in-0": {"on": True},
|
"vban-in-0": {"on": True},
|
||||||
"vban-out-1": {"name": "streamname"},
|
"vban-out-1": {"name": "streamname"},
|
||||||
@@ -41,6 +43,4 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
kind_id = "banana"
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
label = "PhysStrip0"
|
label = "PhysStrip0"
|
||||||
A1 = true
|
A1 = true
|
||||||
gain = -8.8
|
gain = -8.8
|
||||||
comp = 3.2
|
comp.knob = 3.2
|
||||||
|
|
||||||
[strip-1]
|
[strip-1]
|
||||||
label = "PhysStrip1"
|
label = "PhysStrip1"
|
||||||
B1 = true
|
B1 = true
|
||||||
gate = 4.1
|
gate.knob = 4.1
|
||||||
|
|
||||||
[strip-2]
|
[strip-2]
|
||||||
label = "PhysStrip2"
|
label = "PhysStrip2"
|
||||||
@@ -34,12 +34,12 @@ mono = true
|
|||||||
|
|
||||||
[bus-2]
|
[bus-2]
|
||||||
label = "PhysBus2"
|
label = "PhysBus2"
|
||||||
eq = true
|
eq.ab = true
|
||||||
mode = "composite"
|
mode = "composite"
|
||||||
|
|
||||||
[bus-3]
|
[bus-3]
|
||||||
label = "VirtBus0"
|
label = "VirtBus0"
|
||||||
eq_ab = true
|
eq.on = true
|
||||||
mode = "upmix61"
|
mode = "upmix61"
|
||||||
|
|
||||||
[bus-4]
|
[bus-4]
|
||||||
|
|||||||
12
configs/banana/extender.toml
Normal file
12
configs/banana/extender.toml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
extends = "example"
|
||||||
|
[strip-0]
|
||||||
|
label = "strip0_extended"
|
||||||
|
A1 = false
|
||||||
|
gain = 0.0
|
||||||
|
|
||||||
|
[bus-0]
|
||||||
|
label = "bus0_extended"
|
||||||
|
mute = false
|
||||||
|
|
||||||
|
[vban-in-3]
|
||||||
|
name = "vban_extended"
|
||||||
12
configs/basic/extender.toml
Normal file
12
configs/basic/extender.toml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
extends = "example"
|
||||||
|
[strip-0]
|
||||||
|
label = "strip0_extended"
|
||||||
|
A1 = false
|
||||||
|
gain = 0.0
|
||||||
|
|
||||||
|
[bus-0]
|
||||||
|
label = "bus0_extended"
|
||||||
|
mute = false
|
||||||
|
|
||||||
|
[vban-in-3]
|
||||||
|
name = "vban_extended"
|
||||||
@@ -2,26 +2,29 @@
|
|||||||
label = "PhysStrip0"
|
label = "PhysStrip0"
|
||||||
A1 = true
|
A1 = true
|
||||||
gain = -8.8
|
gain = -8.8
|
||||||
comp = 3.2
|
comp.knob = 3.2
|
||||||
|
|
||||||
[strip-1]
|
[strip-1]
|
||||||
label = "PhysStrip1"
|
label = "PhysStrip1"
|
||||||
B1 = true
|
B1 = true
|
||||||
gate = 4.1
|
gate.knob = 4.1
|
||||||
|
|
||||||
[strip-2]
|
[strip-2]
|
||||||
label = "PhysStrip2"
|
label = "PhysStrip2"
|
||||||
gain = 1.1
|
gain = 1.1
|
||||||
limit = -15
|
limit = -15
|
||||||
|
comp.threshold = -35.8
|
||||||
|
|
||||||
[strip-3]
|
[strip-3]
|
||||||
label = "PhysStrip3"
|
label = "PhysStrip3"
|
||||||
B2 = false
|
B2 = false
|
||||||
|
eq.on = true
|
||||||
|
|
||||||
[strip-4]
|
[strip-4]
|
||||||
label = "PhysStrip4"
|
label = "PhysStrip4"
|
||||||
B3 = true
|
B3 = true
|
||||||
gain = -8.8
|
gain = -8.8
|
||||||
|
eq.on = true
|
||||||
|
|
||||||
[strip-5]
|
[strip-5]
|
||||||
label = "VirtStrip0"
|
label = "VirtStrip0"
|
||||||
@@ -50,7 +53,7 @@ mono = true
|
|||||||
|
|
||||||
[bus-2]
|
[bus-2]
|
||||||
label = "PhysBus2"
|
label = "PhysBus2"
|
||||||
eq = true
|
eq.on = true
|
||||||
|
|
||||||
[bus-3]
|
[bus-3]
|
||||||
label = "PhysBus3"
|
label = "PhysBus3"
|
||||||
@@ -62,7 +65,7 @@ mode = "composite"
|
|||||||
|
|
||||||
[bus-5]
|
[bus-5]
|
||||||
label = "VirtBus0"
|
label = "VirtBus0"
|
||||||
eq_ab = true
|
eq.ab = true
|
||||||
|
|
||||||
[bus-6]
|
[bus-6]
|
||||||
label = "VirtBus1"
|
label = "VirtBus1"
|
||||||
|
|||||||
12
configs/potato/extender.toml
Normal file
12
configs/potato/extender.toml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
extends = "example"
|
||||||
|
[strip-0]
|
||||||
|
label = "strip0_extended"
|
||||||
|
A1 = false
|
||||||
|
gain = 0.0
|
||||||
|
|
||||||
|
[bus-0]
|
||||||
|
label = "bus0_extended"
|
||||||
|
mute = false
|
||||||
|
|
||||||
|
[vban-in-3]
|
||||||
|
name = "vban_extended"
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
|
import argparse
|
||||||
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import voicemeeterlib
|
|
||||||
from pyparsing import (
|
from pyparsing import (
|
||||||
Combine,
|
Combine,
|
||||||
Group,
|
Group,
|
||||||
@@ -13,6 +14,13 @@ from pyparsing import (
|
|||||||
nums,
|
nums,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
import voicemeeterlib
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
argparser = argparse.ArgumentParser(description="creates a basic dsl")
|
||||||
|
argparser.add_argument("-i", action="store_true")
|
||||||
|
args = argparser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
class Parser:
|
class Parser:
|
||||||
def __init__(self, vm):
|
def __init__(self, vm):
|
||||||
@@ -53,46 +61,36 @@ class Parser:
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def main(cmds=None):
|
def interactive_mode(parser):
|
||||||
kind_id = "banana"
|
|
||||||
|
|
||||||
with voicemeeterlib.api(kind_id) as vm:
|
|
||||||
parser = Parser(vm)
|
|
||||||
if cmds:
|
|
||||||
res = parser.parse(cmds)
|
|
||||||
if res:
|
|
||||||
print(res)
|
|
||||||
else:
|
|
||||||
while cmd := input("Please enter command (Press <Enter> to exit)\n"):
|
while cmd := input("Please enter command (Press <Enter> to exit)\n"):
|
||||||
if not cmd:
|
if res := parser.parse((cmd,)):
|
||||||
break
|
print(res)
|
||||||
res = parser.parse((cmd,))
|
|
||||||
if res:
|
|
||||||
|
def main():
|
||||||
|
# fmt: off
|
||||||
|
cmds = (
|
||||||
|
"strip 0 -> mute -> on", "strip 0 -> mute", "bus 0 -> mute -> on",
|
||||||
|
"strip 0 -> mute -> off", "bus 0 -> mute -> on", "strip 3 -> solo -> on",
|
||||||
|
"strip 3 -> solo -> off", "strip 1 -> A1 -> on", "strip 1 -> A1",
|
||||||
|
"strip 1 -> A1 -> off", "strip 1 -> A1", "bus 3 -> eq -> on",
|
||||||
|
"bus 3 -> eq -> off", "strip 4 -> gain -> 1.2", "strip 0 -> gain -> -8.2",
|
||||||
|
"strip 0 -> gain", "strip 1 -> label -> rode podmic", "strip 2 -> limit -> -28",
|
||||||
|
"strip 2 -> limit",
|
||||||
|
)
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
|
KIND_ID = "banana"
|
||||||
|
|
||||||
|
with voicemeeterlib.api(KIND_ID) as vm:
|
||||||
|
parser = Parser(vm)
|
||||||
|
if args.i:
|
||||||
|
interactive_mode(parser)
|
||||||
|
return
|
||||||
|
|
||||||
|
if res := parser.parse(cmds):
|
||||||
print(res)
|
print(res)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
cmds = (
|
main()
|
||||||
"strip 0 -> mute -> on",
|
|
||||||
"strip 0 -> mute",
|
|
||||||
"bus 0 -> mute -> on",
|
|
||||||
"strip 0 -> mute -> off",
|
|
||||||
"bus 0 -> mute -> on",
|
|
||||||
"strip 3 -> solo -> on",
|
|
||||||
"strip 3 -> solo -> off",
|
|
||||||
"strip 1 -> A1 -> on",
|
|
||||||
"strip 1 -> A1",
|
|
||||||
"strip 1 -> A1 -> off",
|
|
||||||
"strip 1 -> A1",
|
|
||||||
"bus 3 -> eq -> on",
|
|
||||||
"bus 3 -> eq -> off",
|
|
||||||
"strip 4 -> gain -> 1.2",
|
|
||||||
"strip 0 -> gain -> -8.2",
|
|
||||||
"strip 0 -> gain",
|
|
||||||
"strip 1 -> label -> rode podmic",
|
|
||||||
"strip 2 -> limit -> -28",
|
|
||||||
"strip 2 -> limit",
|
|
||||||
)
|
|
||||||
|
|
||||||
# pass cmds to parse cmds, otherwise simply run main() to test stdin parsing
|
|
||||||
main(cmds)
|
|
||||||
|
|||||||
7
examples/dsl/setup.py
Normal file
7
examples/dsl/setup.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="dsl",
|
||||||
|
description="dsl example",
|
||||||
|
install_requires=["pyparsing"],
|
||||||
|
)
|
||||||
33
examples/events/README.md
Normal file
33
examples/events/README.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
## About
|
||||||
|
|
||||||
|
This script demonstrates how to interact with the event thread/event object. It also demonstrates how to register event specific callbacks.
|
||||||
|
|
||||||
|
By default the interface does not broadcast any events. So even though our callbacks are registered, and the event thread has been initiated, we won't receive updates.
|
||||||
|
|
||||||
|
After five seconds the event object is used to subscribe to all events for a total of thirty seconds.
|
||||||
|
|
||||||
|
Remember that events can also be unsubscribed to with `vm.event.remove()`. Callbacks can also be deregistered using vm.observer.remove().
|
||||||
|
|
||||||
|
The same can be done without a context manager:
|
||||||
|
|
||||||
|
```python
|
||||||
|
vm = voicemeeterlib.api(KIND_ID)
|
||||||
|
vm.login()
|
||||||
|
vm.observer.add(on_midi) # register an `on_midi` callback function
|
||||||
|
vm.init_thread()
|
||||||
|
vm.event.add("midi") # in this case we only subscribe to midi events.
|
||||||
|
...
|
||||||
|
vm.end_thread()
|
||||||
|
vm.logout()
|
||||||
|
```
|
||||||
|
|
||||||
|
Once initialized, the event thread will continously run until end_thread() is called. Even if all events are unsubscribed to.
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
Simply run the script and trigger events and you should see the output after 5 seconds. To trigger events do the following:
|
||||||
|
|
||||||
|
- change GUI parameters to trigger pdirty
|
||||||
|
- press any macrobutton to trigger mdirty
|
||||||
|
- play audio through any bus to trigger ldirty
|
||||||
|
- any midi input to trigger midi
|
||||||
53
examples/events/__main__.py
Normal file
53
examples/events/__main__.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
import voicemeeterlib
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
|
class App:
|
||||||
|
def __init__(self, vm):
|
||||||
|
self.vm = vm
|
||||||
|
# register the callbacks for each event
|
||||||
|
self.vm.observer.add(
|
||||||
|
[self.on_pdirty, self.on_mdirty, self.on_ldirty, self.on_midi]
|
||||||
|
)
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
self.vm.init_thread()
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
|
self.vm.end_thread()
|
||||||
|
|
||||||
|
def on_pdirty(self):
|
||||||
|
print("pdirty!")
|
||||||
|
|
||||||
|
def on_mdirty(self):
|
||||||
|
print("mdirty!")
|
||||||
|
|
||||||
|
def on_ldirty(self):
|
||||||
|
for bus in self.vm.bus:
|
||||||
|
if bus.levels.isdirty:
|
||||||
|
print(bus, bus.levels.all)
|
||||||
|
|
||||||
|
def on_midi(self):
|
||||||
|
current = self.vm.midi.current
|
||||||
|
print(f"Value of midi button {current} is {self.vm.midi.get(current)}")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
KIND_ID = "banana"
|
||||||
|
|
||||||
|
with voicemeeterlib.api(KIND_ID) as vm:
|
||||||
|
with App(vm) as app:
|
||||||
|
for i in range(5, 0, -1):
|
||||||
|
print(f"events start in {i} seconds")
|
||||||
|
time.sleep(1)
|
||||||
|
vm.event.add(["pdirty", "ldirty", "midi", "mdirty"])
|
||||||
|
time.sleep(30)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
13
examples/gui/README.md
Normal file
13
examples/gui/README.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
## About
|
||||||
|
|
||||||
|
A single channel GUI demonstrating controls for the first virtual strip if Voicemeeter Banana.
|
||||||
|
|
||||||
|
This example demonstrates (to an extent) two way communication.
|
||||||
|
- Sending parameters values to the Voicemeeter driver.
|
||||||
|
- Receiving level updates
|
||||||
|
|
||||||
|
Parameter updates (pdirty) events are not being received so changing a UI element on the main Voicemeeter app will not be reflected in the example GUI.
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
Simply run the script and try the controls.
|
||||||
109
examples/gui/__main__.py
Normal file
109
examples/gui/__main__.py
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import voicemeeterlib
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
import tkinter as tk
|
||||||
|
from tkinter import ttk
|
||||||
|
|
||||||
|
|
||||||
|
class App(tk.Tk):
|
||||||
|
INDEX = 3
|
||||||
|
|
||||||
|
def __init__(self, vm):
|
||||||
|
super().__init__()
|
||||||
|
self.vm = vm
|
||||||
|
self.title(f"{vm} - version {vm.version}")
|
||||||
|
self.vm.observer.add(self.on_ldirty)
|
||||||
|
|
||||||
|
# create widget variables
|
||||||
|
self.button_var = tk.BooleanVar(value=vm.strip[self.INDEX].mute)
|
||||||
|
self.slider_var = tk.DoubleVar(value=vm.strip[self.INDEX].gain)
|
||||||
|
self.meter_var = tk.DoubleVar(value=self._get_level())
|
||||||
|
self.gainlabel_var = tk.StringVar(value=self.slider_var.get())
|
||||||
|
|
||||||
|
# initialize style table
|
||||||
|
self.style = ttk.Style()
|
||||||
|
self.style.theme_use("clam")
|
||||||
|
self.style.configure(
|
||||||
|
"Mute.TButton",
|
||||||
|
foreground="#cd5c5c" if vm.strip[self.INDEX].mute else "#5a5a5a",
|
||||||
|
)
|
||||||
|
|
||||||
|
# create labelframe and grid it onto the mainframe
|
||||||
|
self.labelframe = tk.LabelFrame(self, text=self.vm.strip[self.INDEX].label)
|
||||||
|
self.labelframe.grid(padx=1)
|
||||||
|
|
||||||
|
# create slider and grid it onto the labelframe
|
||||||
|
slider = ttk.Scale(
|
||||||
|
self.labelframe,
|
||||||
|
from_=12,
|
||||||
|
to_=-60,
|
||||||
|
orient="vertical",
|
||||||
|
variable=self.slider_var,
|
||||||
|
command=lambda arg: self.on_slider_move(arg),
|
||||||
|
)
|
||||||
|
slider.grid(
|
||||||
|
column=0,
|
||||||
|
row=0,
|
||||||
|
)
|
||||||
|
slider.bind("<Double-Button-1>", self.on_button_double_click)
|
||||||
|
|
||||||
|
# create level meter and grid it onto the labelframe
|
||||||
|
level_meter = ttk.Progressbar(
|
||||||
|
self.labelframe,
|
||||||
|
orient="vertical",
|
||||||
|
variable=self.meter_var,
|
||||||
|
maximum=72,
|
||||||
|
mode="determinate",
|
||||||
|
)
|
||||||
|
level_meter.grid(column=1, row=0)
|
||||||
|
|
||||||
|
# create gainlabel and grid it onto the labelframe
|
||||||
|
gainlabel = ttk.Label(self.labelframe, textvariable=self.gainlabel_var)
|
||||||
|
gainlabel.grid(column=0, row=1, columnspan=2)
|
||||||
|
|
||||||
|
# create button and grid it onto the labelframe
|
||||||
|
button = ttk.Button(
|
||||||
|
self.labelframe,
|
||||||
|
text="Mute",
|
||||||
|
style="Mute.TButton",
|
||||||
|
command=lambda: self.on_button_press(),
|
||||||
|
)
|
||||||
|
button.grid(column=0, row=2, columnspan=2, padx=1, pady=2)
|
||||||
|
|
||||||
|
# define callbacks
|
||||||
|
|
||||||
|
def on_slider_move(self, *args):
|
||||||
|
val = round(self.slider_var.get(), 1)
|
||||||
|
self.vm.strip[self.INDEX].gain = val
|
||||||
|
self.gainlabel_var.set(val)
|
||||||
|
|
||||||
|
def on_button_press(self):
|
||||||
|
self.button_var.set(not self.button_var.get())
|
||||||
|
self.vm.strip[self.INDEX].mute = self.button_var.get()
|
||||||
|
self.style.configure(
|
||||||
|
"Mute.TButton", foreground="#cd5c5c" if self.button_var.get() else "#5a5a5a"
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_button_double_click(self, e):
|
||||||
|
self.slider_var.set(0)
|
||||||
|
self.gainlabel_var.set(0)
|
||||||
|
self.vm.strip[self.INDEX].gain = 0
|
||||||
|
|
||||||
|
def _get_level(self):
|
||||||
|
val = max(self.vm.strip[self.INDEX].levels.postfader)
|
||||||
|
return 0 if self.button_var.get() else 72 + val - 12
|
||||||
|
|
||||||
|
def on_ldirty(self):
|
||||||
|
self.meter_var.set(self._get_level())
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
with voicemeeterlib.api("banana", ldirty=True) as vm:
|
||||||
|
app = App(vm)
|
||||||
|
app.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
13
examples/levels/README.md
Normal file
13
examples/levels/README.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
## About
|
||||||
|
|
||||||
|
The purpose of this script is to demonstrate:
|
||||||
|
|
||||||
|
- use of the interface without a context manager.
|
||||||
|
- retrieving level values for channels by polling (instead of receiving data as event)
|
||||||
|
- use of the interface without the events thread running.
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
Configured for potato version.
|
||||||
|
|
||||||
|
Make sure you are playing audio into the first virtual strip and out of the first physical bus, both channels are unmuted and that you aren't monitoring another mixbus. Then run the script.
|
||||||
28
examples/levels/__main__.py
Normal file
28
examples/levels/__main__.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
import voicemeeterlib
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
KIND_ID = "potato"
|
||||||
|
|
||||||
|
vm = voicemeeterlib.api(KIND_ID)
|
||||||
|
vm.login()
|
||||||
|
for _ in range(500):
|
||||||
|
print(
|
||||||
|
"\n".join(
|
||||||
|
[
|
||||||
|
f"{vm.strip[5]}: {vm.strip[5].levels.postmute}",
|
||||||
|
f"{vm.bus[0]}: {vm.bus[0].levels.all}",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
time.sleep(0.033)
|
||||||
|
vm.logout()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -1,64 +1,51 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
import voicemeeterlib
|
import voicemeeterlib
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
class Observer:
|
|
||||||
def __init__(self, vm, midi_btn, macrobutton):
|
class App:
|
||||||
|
MIDI_BUTTON = 48 # leftmost M on korg nanokontrol2 in CC mode
|
||||||
|
MACROBUTTON = 0
|
||||||
|
|
||||||
|
def __init__(self, vm):
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
self.midi_btn = midi_btn
|
self.vm.observer.add(self.on_midi)
|
||||||
self.macrobutton = macrobutton
|
|
||||||
|
|
||||||
def register(self):
|
def on_midi(self):
|
||||||
self.vm.subject.add(self)
|
if self.get_info() == self.MIDI_BUTTON:
|
||||||
|
|
||||||
def on_update(self, subject):
|
|
||||||
"""
|
|
||||||
We expect to only receive midi updates.
|
|
||||||
|
|
||||||
We could skip subject check but check anyway, in case an event is added later.
|
|
||||||
"""
|
|
||||||
if subject == "midi":
|
|
||||||
self.get_info()
|
|
||||||
self.on_midi_press()
|
self.on_midi_press()
|
||||||
|
|
||||||
def get_info(self):
|
def get_info(self):
|
||||||
current = self.vm.midi.current
|
current = self.vm.midi.current
|
||||||
print(f"Value of midi button {current} is {self.vm.midi.get(current)}")
|
print(f"Value of midi button {current} is {self.vm.midi.get(current)}")
|
||||||
|
return current
|
||||||
|
|
||||||
def on_midi_press(self):
|
def on_midi_press(self):
|
||||||
"""
|
"""if midi button 48 is pressed and strip 3 level max > -40, then set trigger for macrobutton 0"""
|
||||||
checks if strip 3 level postfader mode is greater than -40
|
|
||||||
|
|
||||||
checks if midi button 48 velocity is 127 (full velocity for button press).
|
|
||||||
"""
|
|
||||||
if (
|
if (
|
||||||
max(self.vm.strip[3].levels.postfader) > -40
|
self.vm.midi.get(self.MIDI_BUTTON) == 127
|
||||||
and self.vm.midi.get(self.midi_btn) == 127
|
and max(self.vm.strip[3].levels.postfader) > -40
|
||||||
):
|
):
|
||||||
print(
|
print(
|
||||||
f"Strip 3 level is greater than -40 and midi button {self.midi_btn} is pressed"
|
f"Strip 3 level max is greater than -40 and midi button {self.MIDI_BUTTON} is pressed"
|
||||||
)
|
)
|
||||||
self.vm.button[self.macrobutton].trigger = True
|
self.vm.button[self.MACROBUTTON].trigger = True
|
||||||
else:
|
else:
|
||||||
self.vm.button[self.macrobutton].trigger = False
|
self.vm.button[self.MACROBUTTON].trigger = False
|
||||||
self.vm.button[self.macrobutton].state = False
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# we only care about midi events here.
|
KIND_ID = "banana"
|
||||||
subs = {ev: False for ev in ["pdirty", "mdirty", "ldirty"]}
|
|
||||||
with voicemeeterlib.api(kind_id, subs=subs) as vm:
|
with voicemeeterlib.api(KIND_ID, midi=True) as vm:
|
||||||
obs = Observer(vm, midi_btn, macrobutton)
|
App(vm)
|
||||||
obs.register()
|
|
||||||
|
|
||||||
while cmd := input("Press <Enter> to exit\n"):
|
while cmd := input("Press <Enter> to exit\n"):
|
||||||
if not cmd:
|
pass
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
kind_id = "banana"
|
|
||||||
# leftmost M on korg nanokontrol2 in CC mode
|
|
||||||
midi_btn = 48
|
|
||||||
macrobutton = 0
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- [OBS Studio](https://obsproject.com/)
|
- [OBS Studio](https://obsproject.com/)
|
||||||
- [OBS Websocket v5 Plugin](https://github.com/obsproject/obs-websocket/releases/tag/5.0.0)
|
- [OBS Python SDK for Websocket v5](https://github.com/aatikturk/obsws-python)
|
||||||
- [OBS Python SDK for Websocket v5](https://github.com/aatikturk/obsstudio_sdk)
|
|
||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
||||||
@@ -18,8 +17,12 @@ port = 4455
|
|||||||
password = "mystrongpass"
|
password = "mystrongpass"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Closing OBS will end the script.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
For a similar example for streamlabs check:
|
In this example all but `voicemeeterlib.iremote` logs are filtered out. Log level set at DEBUG.
|
||||||
|
|
||||||
[Streamlabs example](https://github.com/onyx-and-iris/PySLOBS/blob/master/examples/scenerotate.py)
|
For a similar Streamlabs Desktop example:
|
||||||
|
|
||||||
|
[Streamlabs example](https://gist.github.com/onyx-and-iris/c864f07126eeae389b011dc49520a19b)
|
||||||
|
|||||||
@@ -1,58 +1,97 @@
|
|||||||
import obsstudio_sdk as obs
|
import time
|
||||||
|
from logging import config
|
||||||
|
|
||||||
|
import obsws_python as obsws
|
||||||
|
|
||||||
import voicemeeterlib
|
import voicemeeterlib
|
||||||
|
|
||||||
|
config.dictConfig(
|
||||||
def on_start():
|
|
||||||
vm.strip[0].mute = True
|
|
||||||
vm.strip[1].B1 = True
|
|
||||||
vm.strip[2].B2 = True
|
|
||||||
|
|
||||||
|
|
||||||
def on_brb():
|
|
||||||
vm.strip[7].fadeto(0, 500)
|
|
||||||
vm.bus[0].mute = True
|
|
||||||
|
|
||||||
|
|
||||||
def on_end():
|
|
||||||
vm.apply(
|
|
||||||
{
|
{
|
||||||
"strip-0": {"mute": True},
|
"version": 1,
|
||||||
"strip-1": {"mute": True, "B1": False},
|
"formatters": {
|
||||||
|
"standard": {
|
||||||
|
"format": "%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"handlers": {
|
||||||
|
"stream": {
|
||||||
|
"level": "DEBUG",
|
||||||
|
"class": "logging.StreamHandler",
|
||||||
|
"formatter": "standard",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"loggers": {
|
||||||
|
"voicemeeterlib.iremote": {"handlers": ["stream"], "level": "DEBUG"}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class MyClient:
|
||||||
|
def __init__(self, vm):
|
||||||
|
self.vm = vm
|
||||||
|
self.client = obsws.EventClient()
|
||||||
|
self.client.callback.register(
|
||||||
|
(
|
||||||
|
self.on_current_program_scene_changed,
|
||||||
|
self.on_exit_started,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
self.is_running = True
|
||||||
|
|
||||||
|
def on_start(self):
|
||||||
|
self.vm.strip[0].mute = True
|
||||||
|
self.vm.strip[1].B1 = True
|
||||||
|
self.vm.strip[2].B2 = True
|
||||||
|
|
||||||
|
def on_brb(self):
|
||||||
|
self.vm.strip[7].fadeto(0, 500)
|
||||||
|
self.vm.bus[0].mute = True
|
||||||
|
|
||||||
|
def on_end(self):
|
||||||
|
self.vm.apply(
|
||||||
|
{
|
||||||
|
"strip-0": {"mute": True, "comp": {"ratio": 4.3}},
|
||||||
|
"strip-1": {"mute": True, "B1": False, "gate": {"attack": 2.3}},
|
||||||
"strip-2": {"mute": True, "B1": False},
|
"strip-2": {"mute": True, "B1": False},
|
||||||
"vban-in-0": {"on": False},
|
"vban-in-0": {"on": False},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def on_live(self):
|
||||||
|
self.vm.strip[0].mute = False
|
||||||
|
self.vm.strip[7].fadeto(-6, 500)
|
||||||
|
self.vm.strip[7].A3 = True
|
||||||
|
self.vm.vban.instream[0].on = True
|
||||||
|
|
||||||
def on_live():
|
def on_current_program_scene_changed(self, data):
|
||||||
vm.strip[0].mute = False
|
def fget(scene):
|
||||||
vm.strip[7].fadeto(-6, 500)
|
run = {
|
||||||
vm.strip[7].A3 = True
|
"START": self.on_start,
|
||||||
vm.vban.instream[0].on = True
|
"BRB": self.on_brb,
|
||||||
|
"END": self.on_end,
|
||||||
|
"LIVE": self.on_live,
|
||||||
|
}
|
||||||
|
return run.get(scene)
|
||||||
|
|
||||||
|
|
||||||
def on_current_program_scene_changed(data):
|
|
||||||
scene = data.scene_name
|
scene = data.scene_name
|
||||||
print(f"Switched to scene {scene}")
|
print(f"Switched to scene {scene}")
|
||||||
|
if fn := fget(scene):
|
||||||
|
fn()
|
||||||
|
|
||||||
match scene:
|
def on_exit_started(self, _):
|
||||||
case "START":
|
self.client.unsubscribe()
|
||||||
on_start()
|
self.is_running = False
|
||||||
case "BRB":
|
|
||||||
on_brb()
|
|
||||||
case "END":
|
def main():
|
||||||
on_end()
|
KIND_ID = "potato"
|
||||||
case "LIVE":
|
|
||||||
on_live()
|
with voicemeeterlib.api(KIND_ID) as vm:
|
||||||
case _:
|
client = MyClient(vm)
|
||||||
pass
|
while client.is_running:
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
with voicemeeterlib.api("potato") as vm:
|
main()
|
||||||
cl = obs.EventClient()
|
|
||||||
cl.callback.register(on_current_program_scene_changed)
|
|
||||||
|
|
||||||
while cmd := input("<Enter> to exit\n"):
|
|
||||||
if not cmd:
|
|
||||||
break
|
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ from setuptools import setup
|
|||||||
setup(
|
setup(
|
||||||
name="obs",
|
name="obs",
|
||||||
description="OBS Example",
|
description="OBS Example",
|
||||||
install_requires=["voicemeeter-api", "obsstudio-sdk"],
|
install_requires=["obsws-python"],
|
||||||
)
|
)
|
||||||
|
|||||||
14
examples/observer/README.md
Normal file
14
examples/observer/README.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
## About
|
||||||
|
|
||||||
|
Registers a class as an observer and defines a callback.
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
Run the script, then:
|
||||||
|
|
||||||
|
- change GUI parameters to trigger pdirty
|
||||||
|
- press any macrobutton to trigger mdirty
|
||||||
|
- play audio through any bus to trigger ldirty
|
||||||
|
- any midi input to trigger midi
|
||||||
|
|
||||||
|
Pressing `<Enter>` will exit.
|
||||||
@@ -1,44 +1,45 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
import voicemeeterlib
|
import voicemeeterlib
|
||||||
|
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
class Observer:
|
|
||||||
|
class App:
|
||||||
def __init__(self, vm):
|
def __init__(self, vm):
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
# register your app as event observer
|
# register your app as event observer
|
||||||
self.vm.subject.add(self)
|
self.vm.observer.add(self)
|
||||||
# add level updates, since they are disabled by default.
|
|
||||||
self.vm.event.add("ldirty")
|
def __str__(self):
|
||||||
|
return type(self).__name__
|
||||||
|
|
||||||
# define an 'on_update' callback function to receive event updates
|
# define an 'on_update' callback function to receive event updates
|
||||||
def on_update(self, subject):
|
def on_update(self, event):
|
||||||
if subject == "pdirty":
|
if event == "pdirty":
|
||||||
print("pdirty!")
|
print("pdirty!")
|
||||||
elif subject == "mdirty":
|
elif event == "mdirty":
|
||||||
print("mdirty!")
|
print("mdirty!")
|
||||||
elif subject == "ldirty":
|
elif event == "ldirty":
|
||||||
info = (
|
for bus in self.vm.bus:
|
||||||
f"[{self.vm.bus[0]} {self.vm.bus[0].levels.isdirty}]",
|
if bus.levels.isdirty:
|
||||||
f"[{self.vm.bus[1]} {self.vm.bus[1].levels.isdirty}]",
|
print(bus, bus.levels.all)
|
||||||
f"[{self.vm.bus[2]} {self.vm.bus[2].levels.isdirty}]",
|
elif event == "midi":
|
||||||
f"[{self.vm.bus[3]} {self.vm.bus[3].levels.isdirty}]",
|
|
||||||
f"[{self.vm.bus[4]} {self.vm.bus[4].levels.isdirty}]",
|
|
||||||
)
|
|
||||||
print(" ".join(info))
|
|
||||||
elif subject == "midi":
|
|
||||||
current = self.vm.midi.current
|
current = self.vm.midi.current
|
||||||
print(f"Value of midi button {current} is {self.vm.midi.get(current)}")
|
print(f"Value of midi button {current} is {self.vm.midi.get(current)}")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
with voicemeeterlib.api(kind_id) as vm:
|
KIND_ID = "banana"
|
||||||
obs = Observer(vm)
|
|
||||||
|
with voicemeeterlib.api(
|
||||||
|
KIND_ID, **{k: True for k in ("pdirty", "mdirty", "ldirty", "midi")}
|
||||||
|
) as vm:
|
||||||
|
App(vm)
|
||||||
|
|
||||||
while cmd := input("Press <Enter> to exit\n"):
|
while cmd := input("Press <Enter> to exit\n"):
|
||||||
if not cmd:
|
pass
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
kind_id = "banana"
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|||||||
365
poetry.lock
generated
365
poetry.lock
generated
@@ -1,38 +1,17 @@
|
|||||||
[[package]]
|
|
||||||
name = "atomicwrites"
|
|
||||||
version = "1.4.1"
|
|
||||||
description = "Atomic file writes."
|
|
||||||
category = "dev"
|
|
||||||
optional = false
|
|
||||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "attrs"
|
|
||||||
version = "22.1.0"
|
|
||||||
description = "Classes Without Boilerplate"
|
|
||||||
category = "dev"
|
|
||||||
optional = false
|
|
||||||
python-versions = ">=3.5"
|
|
||||||
|
|
||||||
[package.extras]
|
|
||||||
dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "mypy (>=0.900,!=0.940)", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"]
|
|
||||||
docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"]
|
|
||||||
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "mypy (>=0.900,!=0.940)", "pytest-mypy-plugins", "zope.interface", "cloudpickle"]
|
|
||||||
tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "mypy (>=0.900,!=0.940)", "pytest-mypy-plugins", "cloudpickle"]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "black"
|
name = "black"
|
||||||
version = "22.6.0"
|
version = "22.12.0"
|
||||||
description = "The uncompromising code formatter."
|
description = "The uncompromising code formatter."
|
||||||
category = "dev"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.6.2"
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
click = ">=8.0.0"
|
click = ">=8.0.0"
|
||||||
mypy-extensions = ">=0.4.3"
|
mypy-extensions = ">=0.4.3"
|
||||||
pathspec = ">=0.9.0"
|
pathspec = ">=0.9.0"
|
||||||
platformdirs = ">=2"
|
platformdirs = ">=2"
|
||||||
|
tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""}
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
colorama = ["colorama (>=0.4.3)"]
|
colorama = ["colorama (>=0.4.3)"]
|
||||||
@@ -40,6 +19,22 @@ d = ["aiohttp (>=3.7.4)"]
|
|||||||
jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]
|
jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]
|
||||||
uvloop = ["uvloop (>=0.15.2)"]
|
uvloop = ["uvloop (>=0.15.2)"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cachetools"
|
||||||
|
version = "5.3.1"
|
||||||
|
description = "Extensible memoizing collections and decorators"
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chardet"
|
||||||
|
version = "5.1.0"
|
||||||
|
description = "Universal encoding detector for Python 3"
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "click"
|
name = "click"
|
||||||
version = "8.1.3"
|
version = "8.1.3"
|
||||||
@@ -53,124 +48,147 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""}
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "colorama"
|
name = "colorama"
|
||||||
version = "0.4.5"
|
version = "0.4.6"
|
||||||
description = "Cross-platform colored terminal text."
|
description = "Cross-platform colored terminal text."
|
||||||
category = "dev"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iniconfig"
|
name = "distlib"
|
||||||
|
version = "0.3.6"
|
||||||
|
description = "Distribution utilities"
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "exceptiongroup"
|
||||||
version = "1.1.1"
|
version = "1.1.1"
|
||||||
description = "iniconfig: brain-dead simple config-ini parsing"
|
description = "Backport of PEP 654 (exception groups)"
|
||||||
category = "dev"
|
|
||||||
optional = false
|
|
||||||
python-versions = "*"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "isort"
|
|
||||||
version = "5.10.1"
|
|
||||||
description = "A Python utility / library to sort Python imports."
|
|
||||||
category = "dev"
|
|
||||||
optional = false
|
|
||||||
python-versions = ">=3.6.1,<4.0"
|
|
||||||
|
|
||||||
[package.extras]
|
|
||||||
pipfile_deprecated_finder = ["pipreqs", "requirementslib"]
|
|
||||||
requirements_deprecated_finder = ["pipreqs", "pip-api"]
|
|
||||||
colors = ["colorama (>=0.4.3,<0.5.0)"]
|
|
||||||
plugins = ["setuptools"]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "mypy-extensions"
|
|
||||||
version = "0.4.3"
|
|
||||||
description = "Experimental type system extensions for programs checked with the mypy typechecker."
|
|
||||||
category = "dev"
|
|
||||||
optional = false
|
|
||||||
python-versions = "*"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "packaging"
|
|
||||||
version = "21.3"
|
|
||||||
description = "Core utilities for Python packages"
|
|
||||||
category = "dev"
|
|
||||||
optional = false
|
|
||||||
python-versions = ">=3.6"
|
|
||||||
|
|
||||||
[package.dependencies]
|
|
||||||
pyparsing = ">=2.0.2,<3.0.5 || >3.0.5"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pathspec"
|
|
||||||
version = "0.9.0"
|
|
||||||
description = "Utility library for gitignore style pattern matching of file paths."
|
|
||||||
category = "dev"
|
|
||||||
optional = false
|
|
||||||
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "platformdirs"
|
|
||||||
version = "2.5.2"
|
|
||||||
description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
|
|
||||||
category = "dev"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
docs = ["furo (>=2021.7.5b38)", "proselint (>=0.10.2)", "sphinx-autodoc-typehints (>=1.12)", "sphinx (>=4)"]
|
test = ["pytest (>=6)"]
|
||||||
test = ["appdirs (==1.4.4)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)", "pytest (>=6)"]
|
|
||||||
|
[[package]]
|
||||||
|
name = "filelock"
|
||||||
|
version = "3.12.2"
|
||||||
|
description = "A platform independent file lock."
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
docs = ["furo (>=2023.5.20)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)", "sphinx (>=7.0.1)"]
|
||||||
|
testing = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "diff-cover (>=7.5)", "pytest-cov (>=4.1)", "pytest-mock (>=3.10)", "pytest-timeout (>=2.1)", "pytest (>=7.3.1)"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "iniconfig"
|
||||||
|
version = "2.0.0"
|
||||||
|
description = "brain-dead simple config-ini parsing"
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "isort"
|
||||||
|
version = "5.12.0"
|
||||||
|
description = "A Python utility / library to sort Python imports."
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.8.0"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
colors = ["colorama (>=0.4.3)"]
|
||||||
|
requirements-deprecated-finder = ["pip-api", "pipreqs"]
|
||||||
|
pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"]
|
||||||
|
plugins = ["setuptools"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mypy-extensions"
|
||||||
|
version = "1.0.0"
|
||||||
|
description = "Type system extensions for programs checked with the mypy type checker."
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "packaging"
|
||||||
|
version = "23.1"
|
||||||
|
description = "Core utilities for Python packages"
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pathspec"
|
||||||
|
version = "0.11.1"
|
||||||
|
description = "Utility library for gitignore style pattern matching of file paths."
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "platformdirs"
|
||||||
|
version = "3.6.0"
|
||||||
|
description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
docs = ["furo (>=2023.5.20)", "proselint (>=0.13)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)", "sphinx (>=7.0.1)"]
|
||||||
|
test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.10)", "pytest (>=7.3.1)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pluggy"
|
name = "pluggy"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
description = "plugin and hook calling mechanisms for python"
|
description = "plugin and hook calling mechanisms for python"
|
||||||
category = "dev"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.6"
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
dev = ["pre-commit", "tox"]
|
dev = ["pre-commit", "tox"]
|
||||||
testing = ["pytest", "pytest-benchmark"]
|
testing = ["pytest", "pytest-benchmark"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "py"
|
name = "pyproject-api"
|
||||||
version = "1.11.0"
|
version = "1.5.2"
|
||||||
description = "library with cross-python path, ini-parsing, io, code, log facilities"
|
description = "API to interact with the python pyproject.toml based projects"
|
||||||
category = "dev"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
[[package]]
|
[package.dependencies]
|
||||||
name = "pyparsing"
|
packaging = ">=23.1"
|
||||||
version = "3.0.9"
|
tomli = {version = ">=2.0.1", markers = "python_version < \"3.11\""}
|
||||||
description = "pyparsing module - Classes and methods to define and execute parsing grammars"
|
|
||||||
category = "dev"
|
|
||||||
optional = false
|
|
||||||
python-versions = ">=3.6.8"
|
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
diagrams = ["railroad-diagrams", "jinja2"]
|
docs = ["furo (>=2023.5.20)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)", "sphinx (>=7.0.1)"]
|
||||||
|
testing = ["covdefaults (>=2.3)", "importlib-metadata (>=6.6)", "pytest-cov (>=4.1)", "pytest-mock (>=3.10)", "pytest (>=7.3.1)", "setuptools (>=67.8)", "wheel (>=0.40)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytest"
|
name = "pytest"
|
||||||
version = "7.1.2"
|
version = "7.3.2"
|
||||||
description = "pytest: simple powerful testing with Python"
|
description = "pytest: simple powerful testing with Python"
|
||||||
category = "dev"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""}
|
|
||||||
attrs = ">=19.2.0"
|
|
||||||
colorama = {version = "*", markers = "sys_platform == \"win32\""}
|
colorama = {version = "*", markers = "sys_platform == \"win32\""}
|
||||||
|
exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""}
|
||||||
iniconfig = "*"
|
iniconfig = "*"
|
||||||
packaging = "*"
|
packaging = "*"
|
||||||
pluggy = ">=0.12,<2.0"
|
pluggy = ">=0.12,<2.0"
|
||||||
py = ">=1.8.2"
|
tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""}
|
||||||
tomli = ">=1.0.0"
|
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"]
|
testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pytest-randomly"
|
name = "pytest-randomly"
|
||||||
@@ -198,97 +216,76 @@ pytest = ">=3.6"
|
|||||||
name = "tomli"
|
name = "tomli"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
description = "A lil' TOML parser"
|
description = "A lil' TOML parser"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tox"
|
||||||
|
version = "4.6.3"
|
||||||
|
description = "tox is a generic virtualenv management and test command line tool"
|
||||||
category = "dev"
|
category = "dev"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = ">=3.7"
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
cachetools = ">=5.3.1"
|
||||||
|
chardet = ">=5.1"
|
||||||
|
colorama = ">=0.4.6"
|
||||||
|
filelock = ">=3.12.2"
|
||||||
|
packaging = ">=23.1"
|
||||||
|
platformdirs = ">=3.5.3"
|
||||||
|
pluggy = ">=1"
|
||||||
|
pyproject-api = ">=1.5.2"
|
||||||
|
tomli = {version = ">=2.0.1", markers = "python_version < \"3.11\""}
|
||||||
|
virtualenv = ">=20.23.1"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
docs = ["furo (>=2023.5.20)", "sphinx-argparse-cli (>=1.11.1)", "sphinx-autodoc-typehints (>=1.23.2,!=1.23.4)", "sphinx-copybutton (>=0.5.2)", "sphinx-inline-tabs (>=2023.4.21)", "sphinx (>=7.0.1)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"]
|
||||||
|
testing = ["build[virtualenv] (>=0.10)", "covdefaults (>=2.3)", "detect-test-pollution (>=1.1.1)", "devpi-process (>=0.3.1)", "diff-cover (>=7.6)", "distlib (>=0.3.6)", "flaky (>=3.7)", "hatch-vcs (>=0.3)", "hatchling (>=1.17.1)", "psutil (>=5.9.5)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)", "pytest-xdist (>=3.3.1)", "pytest (>=7.3.2)", "re-assert (>=1.1)", "time-machine (>=2.10)", "wheel (>=0.40)"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "virtualenv"
|
||||||
|
version = "20.23.1"
|
||||||
|
description = "Virtual Python Environment builder"
|
||||||
|
category = "dev"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.7"
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
distlib = ">=0.3.6,<1"
|
||||||
|
filelock = ">=3.12,<4"
|
||||||
|
platformdirs = ">=3.5.1,<4"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
docs = ["furo (>=2023.5.20)", "proselint (>=0.13)", "sphinx-argparse (>=0.4)", "sphinx (>=7.0.1)", "sphinxcontrib-towncrier (>=0.2.1a0)", "towncrier (>=23.6)"]
|
||||||
|
test = ["covdefaults (>=2.3)", "coverage-enable-subprocess (>=1)", "coverage (>=7.2.7)", "flaky (>=3.7)", "packaging (>=23.1)", "pytest-env (>=0.8.1)", "pytest-freezer (>=0.4.6)", "pytest-mock (>=3.10)", "pytest-randomly (>=3.12)", "pytest-timeout (>=2.1)", "pytest (>=7.3.1)", "setuptools (>=67.8)", "time-machine (>=2.9)"]
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "^3.11"
|
python-versions = "^3.10"
|
||||||
content-hash = "13366a58ff2f3fa0de2cb1e3de2f66fff612610fa66bb909201ebaa434cce014"
|
content-hash = "5d0edd070ea010edb4e2ade88dc37324b8b4b04f22db78e49db161185365849b"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
atomicwrites = []
|
black = []
|
||||||
attrs = []
|
cachetools = []
|
||||||
black = [
|
chardet = []
|
||||||
{file = "black-22.6.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:f586c26118bc6e714ec58c09df0157fe2d9ee195c764f630eb0d8e7ccce72e69"},
|
click = []
|
||||||
{file = "black-22.6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b270a168d69edb8b7ed32c193ef10fd27844e5c60852039599f9184460ce0807"},
|
colorama = []
|
||||||
{file = "black-22.6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6797f58943fceb1c461fb572edbe828d811e719c24e03375fd25170ada53825e"},
|
distlib = []
|
||||||
{file = "black-22.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c85928b9d5f83b23cee7d0efcb310172412fbf7cb9d9ce963bd67fd141781def"},
|
exceptiongroup = []
|
||||||
{file = "black-22.6.0-cp310-cp310-win_amd64.whl", hash = "sha256:f6fe02afde060bbeef044af7996f335fbe90b039ccf3f5eb8f16df8b20f77666"},
|
filelock = []
|
||||||
{file = "black-22.6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:cfaf3895a9634e882bf9d2363fed5af8888802d670f58b279b0bece00e9a872d"},
|
iniconfig = []
|
||||||
{file = "black-22.6.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:94783f636bca89f11eb5d50437e8e17fbc6a929a628d82304c80fa9cd945f256"},
|
isort = []
|
||||||
{file = "black-22.6.0-cp36-cp36m-win_amd64.whl", hash = "sha256:2ea29072e954a4d55a2ff58971b83365eba5d3d357352a07a7a4df0d95f51c78"},
|
mypy-extensions = []
|
||||||
{file = "black-22.6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:e439798f819d49ba1c0bd9664427a05aab79bfba777a6db94fd4e56fae0cb849"},
|
packaging = []
|
||||||
{file = "black-22.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:187d96c5e713f441a5829e77120c269b6514418f4513a390b0499b0987f2ff1c"},
|
pathspec = []
|
||||||
{file = "black-22.6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:074458dc2f6e0d3dab7928d4417bb6957bb834434516f21514138437accdbe90"},
|
platformdirs = []
|
||||||
{file = "black-22.6.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:a218d7e5856f91d20f04e931b6f16d15356db1c846ee55f01bac297a705ca24f"},
|
pluggy = []
|
||||||
{file = "black-22.6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:568ac3c465b1c8b34b61cd7a4e349e93f91abf0f9371eda1cf87194663ab684e"},
|
pyproject-api = []
|
||||||
{file = "black-22.6.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:6c1734ab264b8f7929cef8ae5f900b85d579e6cbfde09d7387da8f04771b51c6"},
|
pytest = []
|
||||||
{file = "black-22.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c9a3ac16efe9ec7d7381ddebcc022119794872abce99475345c5a61aa18c45ad"},
|
pytest-randomly = []
|
||||||
{file = "black-22.6.0-cp38-cp38-win_amd64.whl", hash = "sha256:b9fd45787ba8aa3f5e0a0a98920c1012c884622c6c920dbe98dbd05bc7c70fbf"},
|
|
||||||
{file = "black-22.6.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:7ba9be198ecca5031cd78745780d65a3f75a34b2ff9be5837045dce55db83d1c"},
|
|
||||||
{file = "black-22.6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:a3db5b6409b96d9bd543323b23ef32a1a2b06416d525d27e0f67e74f1446c8f2"},
|
|
||||||
{file = "black-22.6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:560558527e52ce8afba936fcce93a7411ab40c7d5fe8c2463e279e843c0328ee"},
|
|
||||||
{file = "black-22.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b154e6bbde1e79ea3260c4b40c0b7b3109ffcdf7bc4ebf8859169a6af72cd70b"},
|
|
||||||
{file = "black-22.6.0-cp39-cp39-win_amd64.whl", hash = "sha256:4af5bc0e1f96be5ae9bd7aaec219c901a94d6caa2484c21983d043371c733fc4"},
|
|
||||||
{file = "black-22.6.0-py3-none-any.whl", hash = "sha256:ac609cf8ef5e7115ddd07d85d988d074ed00e10fbc3445aee393e70164a2219c"},
|
|
||||||
{file = "black-22.6.0.tar.gz", hash = "sha256:6c6d39e28aed379aec40da1c65434c77d75e65bb59a1e1c283de545fb4e7c6c9"},
|
|
||||||
]
|
|
||||||
click = [
|
|
||||||
{file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"},
|
|
||||||
{file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"},
|
|
||||||
]
|
|
||||||
colorama = [
|
|
||||||
{file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"},
|
|
||||||
{file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"},
|
|
||||||
]
|
|
||||||
iniconfig = [
|
|
||||||
{file = "iniconfig-1.1.1-py2.py3-none-any.whl", hash = "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3"},
|
|
||||||
{file = "iniconfig-1.1.1.tar.gz", hash = "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"},
|
|
||||||
]
|
|
||||||
isort = [
|
|
||||||
{file = "isort-5.10.1-py3-none-any.whl", hash = "sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7"},
|
|
||||||
{file = "isort-5.10.1.tar.gz", hash = "sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951"},
|
|
||||||
]
|
|
||||||
mypy-extensions = [
|
|
||||||
{file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"},
|
|
||||||
{file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"},
|
|
||||||
]
|
|
||||||
packaging = [
|
|
||||||
{file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"},
|
|
||||||
{file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"},
|
|
||||||
]
|
|
||||||
pathspec = [
|
|
||||||
{file = "pathspec-0.9.0-py2.py3-none-any.whl", hash = "sha256:7d15c4ddb0b5c802d161efc417ec1a2558ea2653c2e8ad9c19098201dc1c993a"},
|
|
||||||
{file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"},
|
|
||||||
]
|
|
||||||
platformdirs = [
|
|
||||||
{file = "platformdirs-2.5.2-py3-none-any.whl", hash = "sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788"},
|
|
||||||
{file = "platformdirs-2.5.2.tar.gz", hash = "sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19"},
|
|
||||||
]
|
|
||||||
pluggy = [
|
|
||||||
{file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"},
|
|
||||||
{file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"},
|
|
||||||
]
|
|
||||||
py = [
|
|
||||||
{file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"},
|
|
||||||
{file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"},
|
|
||||||
]
|
|
||||||
pyparsing = [
|
|
||||||
{file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"},
|
|
||||||
{file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"},
|
|
||||||
]
|
|
||||||
pytest = [
|
|
||||||
{file = "pytest-7.1.2-py3-none-any.whl", hash = "sha256:13d0e3ccfc2b6e26be000cb6568c832ba67ba32e719443bfe725814d3c42433c"},
|
|
||||||
{file = "pytest-7.1.2.tar.gz", hash = "sha256:a06a0425453864a270bc45e71f783330a7428defb4230fb5e6a731fde06ecd45"},
|
|
||||||
]
|
|
||||||
pytest-randomly = [
|
|
||||||
{file = "pytest-randomly-3.12.0.tar.gz", hash = "sha256:d60c2db71ac319aee0fc6c4110a7597d611a8b94a5590918bfa8583f00caccb2"},
|
|
||||||
{file = "pytest_randomly-3.12.0-py3-none-any.whl", hash = "sha256:f4f2e803daf5d1ba036cc22bf4fe9dbbf99389ec56b00e5cba732fb5c1d07fdd"},
|
|
||||||
]
|
|
||||||
pytest-repeat = []
|
pytest-repeat = []
|
||||||
tomli = [
|
tomli = []
|
||||||
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
|
tox = []
|
||||||
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
|
virtualenv = []
|
||||||
]
|
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "voicemeeter-api"
|
name = "voicemeeter-api"
|
||||||
version = "0.6.0"
|
version = "2.4.4"
|
||||||
description = "A Python wrapper for the Voiceemeter API"
|
description = "A Python wrapper for the Voiceemeter API"
|
||||||
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/onyx-and-iris/voicemeeter-api-python"
|
repository = "https://github.com/onyx-and-iris/voicemeeter-api-python"
|
||||||
|
|
||||||
packages = [
|
packages = [{ include = "voicemeeterlib" }]
|
||||||
{ include = "voicemeeterlib" },
|
|
||||||
]
|
|
||||||
|
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.11"
|
python = "^3.10"
|
||||||
|
tomli = { version = "^2.0.1", python = "<3.11" }
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
pytest = "^7.1.2"
|
pytest = "^7.1.2"
|
||||||
@@ -20,7 +19,30 @@ pytest-randomly = "^3.12.0"
|
|||||||
pytest-repeat = "^0.9.1"
|
pytest-repeat = "^0.9.1"
|
||||||
black = "^22.3.0"
|
black = "^22.3.0"
|
||||||
isort = "^5.10.1"
|
isort = "^5.10.1"
|
||||||
|
tox = "^4.6.3"
|
||||||
|
|
||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
|
[tool.poetry.scripts]
|
||||||
|
dsl = "scripts:ex_dsl"
|
||||||
|
events = "scripts:ex_events"
|
||||||
|
gui = "scripts:ex_gui"
|
||||||
|
levels = "scripts:ex_levels"
|
||||||
|
midi = "scripts:ex_midi"
|
||||||
|
obs = "scripts:ex_obs"
|
||||||
|
observer = "scripts:ex_observer"
|
||||||
|
test = "scripts:test"
|
||||||
|
|
||||||
|
[tool.tox]
|
||||||
|
legacy_tox_ini = """
|
||||||
|
[tox]
|
||||||
|
envlist = py310,py311
|
||||||
|
|
||||||
|
[testenv]
|
||||||
|
allowlist_externals = poetry
|
||||||
|
commands =
|
||||||
|
poetry install -v
|
||||||
|
poetry run pytest tests/
|
||||||
|
"""
|
||||||
|
|||||||
42
scripts.py
Normal file
42
scripts.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def ex_dsl():
|
||||||
|
scriptpath = Path.cwd() / "examples" / "dsl" / "."
|
||||||
|
subprocess.run([sys.executable, str(scriptpath)])
|
||||||
|
|
||||||
|
|
||||||
|
def ex_events():
|
||||||
|
scriptpath = Path.cwd() / "examples" / "events" / "."
|
||||||
|
subprocess.run([sys.executable, str(scriptpath)])
|
||||||
|
|
||||||
|
|
||||||
|
def ex_gui():
|
||||||
|
scriptpath = Path.cwd() / "examples" / "gui" / "."
|
||||||
|
subprocess.run([sys.executable, str(scriptpath)])
|
||||||
|
|
||||||
|
|
||||||
|
def ex_levels():
|
||||||
|
scriptpath = Path.cwd() / "examples" / "levels" / "."
|
||||||
|
subprocess.run([sys.executable, str(scriptpath)])
|
||||||
|
|
||||||
|
|
||||||
|
def ex_midi():
|
||||||
|
scriptpath = Path.cwd() / "examples" / "midi" / "."
|
||||||
|
subprocess.run([sys.executable, str(scriptpath)])
|
||||||
|
|
||||||
|
|
||||||
|
def ex_obs():
|
||||||
|
scriptpath = Path.cwd() / "examples" / "obs" / "."
|
||||||
|
subprocess.run([sys.executable, str(scriptpath)])
|
||||||
|
|
||||||
|
|
||||||
|
def ex_observer():
|
||||||
|
scriptpath = Path.cwd() / "examples" / "observer" / "."
|
||||||
|
subprocess.run([sys.executable, str(scriptpath)])
|
||||||
|
|
||||||
|
|
||||||
|
def test():
|
||||||
|
subprocess.run(["tox"])
|
||||||
@@ -3,48 +3,60 @@ import sys
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
import voicemeeterlib
|
import voicemeeterlib
|
||||||
from voicemeeterlib.kinds import KindId, kinds_all
|
from voicemeeterlib.kinds import KindId
|
||||||
from voicemeeterlib.kinds import request_kind_map as kindmap
|
from voicemeeterlib.kinds import request_kind_map as kindmap
|
||||||
|
|
||||||
# let's keep things random
|
|
||||||
kind_id = random.choice(tuple(kind_id.name.lower() for kind_id in KindId))
|
|
||||||
|
|
||||||
vmrs = {kind.name: voicemeeterlib.api(kind.name) for kind in kinds_all}
|
|
||||||
tests = vmrs[kind_id]
|
|
||||||
kind = kindmap(kind_id)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Data:
|
class Data:
|
||||||
"""bounds data to map tests to a kind"""
|
"""bounds data to map tests to a kind"""
|
||||||
|
|
||||||
name: str = kind.name
|
name: str
|
||||||
phys_in: int = kind.ins[0] - 1
|
phys_in: int
|
||||||
virt_in: int = kind.ins[0] + kind.ins[-1] - 1
|
virt_in: int
|
||||||
phys_out: int = kind.outs[0] - 1
|
phys_out: int
|
||||||
virt_out: int = kind.outs[0] + kind.outs[-1] - 1
|
virt_out: int
|
||||||
vban_in: int = kind.vban[0] - 1
|
vban_in: int
|
||||||
vban_out: int = kind.vban[-1] - 1
|
vban_out: int
|
||||||
button_lower: int = 0
|
button_lower: int
|
||||||
button_upper: int = 79
|
button_upper: int
|
||||||
asio_in: int = kind.asio[0] - 1
|
asio_in: int
|
||||||
asio_out: int = kind.asio[-1] - 1
|
asio_out: int
|
||||||
insert_lower: int = 0
|
insert_lower: int
|
||||||
insert_higher: int = kind.insert - 1
|
insert_higher: int
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def channels(self):
|
def channels(self):
|
||||||
return (2 * self.phys_in) + (8 * self.virt_in)
|
return (2 * self.phys_in) + (8 * self.virt_in)
|
||||||
|
|
||||||
|
|
||||||
data = Data()
|
# let's keep things random
|
||||||
|
KIND_ID = random.choice(tuple(kind_id.name.lower() for kind_id in KindId))
|
||||||
|
vm = voicemeeterlib.api(KIND_ID)
|
||||||
|
kind = kindmap(KIND_ID)
|
||||||
|
|
||||||
|
data = Data(
|
||||||
|
name=kind.name,
|
||||||
|
phys_in=kind.ins[0] - 1,
|
||||||
|
virt_in=kind.ins[0] + kind.ins[-1] - 1,
|
||||||
|
phys_out=kind.outs[0] - 1,
|
||||||
|
virt_out=kind.outs[0] + kind.outs[-1] - 1,
|
||||||
|
vban_in=kind.vban[0] - 1,
|
||||||
|
vban_out=kind.vban[-1] - 1,
|
||||||
|
button_lower=0,
|
||||||
|
button_upper=79,
|
||||||
|
asio_in=kind.asio[0] - 1,
|
||||||
|
asio_out=kind.asio[-1] - 1,
|
||||||
|
insert_lower=0,
|
||||||
|
insert_higher=kind.insert - 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def setup_module():
|
def setup_module():
|
||||||
print(f"\nRunning tests for kind [{data.name}]\n", file=sys.stdout)
|
print(f"\nRunning tests for kind [{data.name}]\n", file=sys.stdout)
|
||||||
tests.login()
|
vm.login()
|
||||||
tests.command.reset()
|
vm.command.reset()
|
||||||
|
|
||||||
|
|
||||||
def teardown_module():
|
def teardown_module():
|
||||||
tests.logout()
|
vm.logout()
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 140"><title>tests: 140</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">140</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">140</text></g></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 155"><title>tests: 155</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">155</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">155</text></g></svg>
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 114"><title>tests: 114</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">114</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">114</text></g></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 112"><title>tests: 112</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">112</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">112</text></g></svg>
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -1 +1 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 156"><title>tests: 156</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">156</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">156</text></g></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="68" height="20" role="img" aria-label="tests: 164"><title>tests: 164</title><linearGradient id="s" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="r"><rect width="68" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#r)"><rect width="37" height="20" fill="#555"/><rect x="37" width="31" height="20" fill="#4c1"/><rect width="68" height="20" fill="url(#s)"/></g><g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110"><text aria-hidden="true" x="195" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="270">tests</text><text x="195" y="140" transform="scale(.1)" fill="#fff" textLength="270">tests</text><text aria-hidden="true" x="515" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="210">164</text><text x="515" y="140" transform="scale(.1)" fill="#fff" textLength="210">164</text></g></svg>
|
||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -1,36 +1,48 @@
|
|||||||
import time
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tests import data, tests
|
from tests import data, vm
|
||||||
|
|
||||||
|
|
||||||
class TestUserConfigs:
|
class TestUserConfigs:
|
||||||
__test__ = True
|
__test__ = True
|
||||||
|
|
||||||
"""example config tests"""
|
"""example config vm"""
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_class(cls):
|
def setup_class(cls):
|
||||||
tests.apply_config("example")
|
vm.apply_config("example")
|
||||||
|
|
||||||
def test_it_tests_config_string(self):
|
def test_it_vm_config_string(self):
|
||||||
assert "PhysStrip" in tests.strip[data.phys_in].label
|
assert "PhysStrip" in vm.strip[data.phys_in].label
|
||||||
assert "VirtStrip" in tests.strip[data.virt_in].label
|
assert "VirtStrip" in vm.strip[data.virt_in].label
|
||||||
assert "PhysBus" in tests.bus[data.phys_out].label
|
assert "PhysBus" in vm.bus[data.phys_out].label
|
||||||
assert "VirtBus" in tests.bus[data.virt_out].label
|
assert "VirtBus" in vm.bus[data.virt_out].label
|
||||||
|
|
||||||
def test_it_tests_config_bool(self):
|
def test_it_vm_config_bool(self):
|
||||||
assert tests.strip[0].A1 == True
|
assert vm.strip[0].A1 == True
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name != "potato",
|
||||||
|
reason="Skip test if kind is not potato",
|
||||||
|
)
|
||||||
|
def test_it_vm_config_bool_strip_eq_on(self):
|
||||||
|
assert vm.strip[data.phys_in].eq.on == True
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name != "banana",
|
||||||
|
reason="Skip test if kind is not banana",
|
||||||
|
)
|
||||||
|
def test_it_vm_config_bool_bus_eq_ab(self):
|
||||||
|
assert vm.bus[data.phys_out].eq.ab == True
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
"not config.getoption('--run-slow')",
|
"not config.getoption('--run-slow')",
|
||||||
reason="Only run when --run-slow is given",
|
reason="Only run when --run-slow is given",
|
||||||
)
|
)
|
||||||
def test_it_tests_config_busmode(self):
|
def test_it_vm_config_busmode(self):
|
||||||
assert tests.bus[data.phys_out].mode.get() == "composite"
|
assert vm.bus[data.phys_out].mode.get() == "composite"
|
||||||
|
|
||||||
def test_it_tests_config_bass_med_high(self):
|
def test_it_vm_config_bass_med_high(self):
|
||||||
assert tests.strip[data.virt_in].bass == -3.2
|
assert vm.strip[data.virt_in].bass == -3.2
|
||||||
assert tests.strip[data.virt_in].mid == 1.5
|
assert vm.strip[data.virt_in].mid == 1.5
|
||||||
assert tests.strip[data.virt_in].high == 2.1
|
assert vm.strip[data.virt_in].high == 2.1
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tests import data, tests
|
from tests import data, vm
|
||||||
|
|
||||||
|
|
||||||
class TestRemoteFactories:
|
class TestRemoteFactories:
|
||||||
@@ -10,57 +10,57 @@ class TestRemoteFactories:
|
|||||||
data.name != "basic",
|
data.name != "basic",
|
||||||
reason="Skip test if kind is not basic",
|
reason="Skip test if kind is not basic",
|
||||||
)
|
)
|
||||||
def test_it_tests_remote_attrs_for_basic(self):
|
def test_it_vm_remote_attrs_for_basic(self):
|
||||||
assert hasattr(tests, "strip")
|
assert hasattr(vm, "strip")
|
||||||
assert hasattr(tests, "bus")
|
assert hasattr(vm, "bus")
|
||||||
assert hasattr(tests, "command")
|
assert hasattr(vm, "command")
|
||||||
assert hasattr(tests, "button")
|
assert hasattr(vm, "button")
|
||||||
assert hasattr(tests, "vban")
|
assert hasattr(vm, "vban")
|
||||||
assert hasattr(tests, "device")
|
assert hasattr(vm, "device")
|
||||||
assert hasattr(tests, "option")
|
assert hasattr(vm, "option")
|
||||||
|
|
||||||
assert len(tests.strip) == 3
|
assert len(vm.strip) == 3
|
||||||
assert len(tests.bus) == 2
|
assert len(vm.bus) == 2
|
||||||
assert len(tests.button) == 80
|
assert len(vm.button) == 80
|
||||||
assert len(tests.vban.instream) == 4 and len(tests.vban.outstream) == 4
|
assert len(vm.vban.instream) == 6 and len(vm.vban.outstream) == 5
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
data.name != "banana",
|
data.name != "banana",
|
||||||
reason="Skip test if kind is not banana",
|
reason="Skip test if kind is not banana",
|
||||||
)
|
)
|
||||||
def test_it_tests_remote_attrs_for_banana(self):
|
def test_it_vm_remote_attrs_for_banana(self):
|
||||||
assert hasattr(tests, "strip")
|
assert hasattr(vm, "strip")
|
||||||
assert hasattr(tests, "bus")
|
assert hasattr(vm, "bus")
|
||||||
assert hasattr(tests, "command")
|
assert hasattr(vm, "command")
|
||||||
assert hasattr(tests, "button")
|
assert hasattr(vm, "button")
|
||||||
assert hasattr(tests, "vban")
|
assert hasattr(vm, "vban")
|
||||||
assert hasattr(tests, "device")
|
assert hasattr(vm, "device")
|
||||||
assert hasattr(tests, "option")
|
assert hasattr(vm, "option")
|
||||||
assert hasattr(tests, "recorder")
|
assert hasattr(vm, "recorder")
|
||||||
assert hasattr(tests, "patch")
|
assert hasattr(vm, "patch")
|
||||||
|
|
||||||
assert len(tests.strip) == 5
|
assert len(vm.strip) == 5
|
||||||
assert len(tests.bus) == 5
|
assert len(vm.bus) == 5
|
||||||
assert len(tests.button) == 80
|
assert len(vm.button) == 80
|
||||||
assert len(tests.vban.instream) == 8 and len(tests.vban.outstream) == 8
|
assert len(vm.vban.instream) == 10 and len(vm.vban.outstream) == 9
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
data.name != "potato",
|
data.name != "potato",
|
||||||
reason="Skip test if kind is not potato",
|
reason="Skip test if kind is not potato",
|
||||||
)
|
)
|
||||||
def test_it_tests_remote_attrs_for_potato(self):
|
def test_it_vm_remote_attrs_for_potato(self):
|
||||||
assert hasattr(tests, "strip")
|
assert hasattr(vm, "strip")
|
||||||
assert hasattr(tests, "bus")
|
assert hasattr(vm, "bus")
|
||||||
assert hasattr(tests, "command")
|
assert hasattr(vm, "command")
|
||||||
assert hasattr(tests, "button")
|
assert hasattr(vm, "button")
|
||||||
assert hasattr(tests, "vban")
|
assert hasattr(vm, "vban")
|
||||||
assert hasattr(tests, "device")
|
assert hasattr(vm, "device")
|
||||||
assert hasattr(tests, "option")
|
assert hasattr(vm, "option")
|
||||||
assert hasattr(tests, "recorder")
|
assert hasattr(vm, "recorder")
|
||||||
assert hasattr(tests, "patch")
|
assert hasattr(vm, "patch")
|
||||||
assert hasattr(tests, "fx")
|
assert hasattr(vm, "fx")
|
||||||
|
|
||||||
assert len(tests.strip) == 8
|
assert len(vm.strip) == 8
|
||||||
assert len(tests.bus) == 8
|
assert len(vm.bus) == 8
|
||||||
assert len(tests.button) == 80
|
assert len(vm.button) == 80
|
||||||
assert len(tests.vban.instream) == 8 and len(tests.vban.outstream) == 8
|
assert len(vm.vban.instream) == 10 and len(vm.vban.outstream) == 9
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tests import data, tests
|
from tests import data, vm
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("value", [False, True])
|
@pytest.mark.parametrize("value", [False, True])
|
||||||
@@ -19,23 +19,54 @@ class TestSetAndGetBoolHigher:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_strip_bool_params(self, index, param, value):
|
def test_it_sets_and_gets_strip_bool_params(self, index, param, value):
|
||||||
setattr(tests.strip[index], param, value)
|
setattr(vm.strip[index], param, value)
|
||||||
assert getattr(tests.strip[index], param) == value
|
assert getattr(vm.strip[index], param) == value
|
||||||
|
|
||||||
|
""" strip EQ tests, physical """
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name != "potato",
|
||||||
|
reason="Skip test if kind is not potato",
|
||||||
|
)
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"index,param",
|
||||||
|
[
|
||||||
|
(data.phys_in, "on"),
|
||||||
|
(data.phys_in, "ab"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_it_sets_and_gets_strip_eq_bool_params(self, index, param, value):
|
||||||
|
assert hasattr(vm.strip[index].eq, param)
|
||||||
|
setattr(vm.strip[index].eq, param, value)
|
||||||
|
assert getattr(vm.strip[index].eq, param) == value
|
||||||
|
|
||||||
""" bus tests, physical and virtual """
|
""" bus tests, physical and virtual """
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"index,param",
|
"index,param",
|
||||||
[
|
[
|
||||||
(data.phys_out, "eq"),
|
|
||||||
(data.phys_out, "mute"),
|
(data.phys_out, "mute"),
|
||||||
(data.virt_out, "eq_ab"),
|
|
||||||
(data.virt_out, "sel"),
|
(data.virt_out, "sel"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_bus_bool_params(self, index, param, value):
|
def test_it_sets_and_gets_bus_bool_params(self, index, param, value):
|
||||||
setattr(tests.bus[index], param, value)
|
assert hasattr(vm.bus[index], param)
|
||||||
assert getattr(tests.bus[index], param) == value
|
setattr(vm.bus[index], param, value)
|
||||||
|
assert getattr(vm.bus[index], param) == value
|
||||||
|
|
||||||
|
""" bus EQ tests, physical and virtual """
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"index,param",
|
||||||
|
[
|
||||||
|
(data.phys_out, "on"),
|
||||||
|
(data.virt_out, "ab"),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_it_sets_and_gets_bus_eq_bool_params(self, index, param, value):
|
||||||
|
assert hasattr(vm.bus[index].eq, param)
|
||||||
|
setattr(vm.bus[index].eq, param, value)
|
||||||
|
assert getattr(vm.bus[index].eq, param) == value
|
||||||
|
|
||||||
""" bus modes tests, physical and virtual """
|
""" bus modes tests, physical and virtual """
|
||||||
|
|
||||||
@@ -53,8 +84,8 @@ class TestSetAndGetBoolHigher:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_busmode_basic_bool_params(self, index, param, value):
|
def test_it_sets_and_gets_busmode_basic_bool_params(self, index, param, value):
|
||||||
setattr(tests.bus[index].mode, param, value)
|
setattr(vm.bus[index].mode, param, value)
|
||||||
assert getattr(tests.bus[index].mode, param) == value
|
assert getattr(vm.bus[index].mode, param) == value
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
data.name == "basic",
|
data.name == "basic",
|
||||||
@@ -72,8 +103,8 @@ class TestSetAndGetBoolHigher:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_busmode_bool_params(self, index, param, value):
|
def test_it_sets_and_gets_busmode_bool_params(self, index, param, value):
|
||||||
setattr(tests.bus[index].mode, param, value)
|
setattr(vm.bus[index].mode, param, value)
|
||||||
assert getattr(tests.bus[index].mode, param) == value
|
assert getattr(vm.bus[index].mode, param) == value
|
||||||
|
|
||||||
""" macrobutton tests """
|
""" macrobutton tests """
|
||||||
|
|
||||||
@@ -82,8 +113,8 @@ class TestSetAndGetBoolHigher:
|
|||||||
[(data.button_lower, "state"), (data.button_upper, "trigger")],
|
[(data.button_lower, "state"), (data.button_upper, "trigger")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_macrobutton_bool_params(self, index, param, value):
|
def test_it_sets_and_gets_macrobutton_bool_params(self, index, param, value):
|
||||||
setattr(tests.button[index], param, value)
|
setattr(vm.button[index], param, value)
|
||||||
assert getattr(tests.button[index], param) == value
|
assert getattr(vm.button[index], param) == value
|
||||||
|
|
||||||
""" vban instream tests """
|
""" vban instream tests """
|
||||||
|
|
||||||
@@ -92,8 +123,8 @@ class TestSetAndGetBoolHigher:
|
|||||||
[(data.vban_in, "on")],
|
[(data.vban_in, "on")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_vban_instream_bool_params(self, index, param, value):
|
def test_it_sets_and_gets_vban_instream_bool_params(self, index, param, value):
|
||||||
setattr(tests.vban.instream[index], param, value)
|
setattr(vm.vban.instream[index], param, value)
|
||||||
assert getattr(tests.vban.instream[index], param) == value
|
assert getattr(vm.vban.instream[index], param) == value
|
||||||
|
|
||||||
""" vban outstream tests """
|
""" vban outstream tests """
|
||||||
|
|
||||||
@@ -102,8 +133,8 @@ class TestSetAndGetBoolHigher:
|
|||||||
[(data.vban_out, "on")],
|
[(data.vban_out, "on")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_vban_outstream_bool_params(self, index, param, value):
|
def test_it_sets_and_gets_vban_outstream_bool_params(self, index, param, value):
|
||||||
setattr(tests.vban.outstream[index], param, value)
|
setattr(vm.vban.outstream[index], param, value)
|
||||||
assert getattr(tests.vban.outstream[index], param) == value
|
assert getattr(vm.vban.outstream[index], param) == value
|
||||||
|
|
||||||
""" command tests """
|
""" command tests """
|
||||||
|
|
||||||
@@ -112,7 +143,7 @@ class TestSetAndGetBoolHigher:
|
|||||||
[("lock")],
|
[("lock")],
|
||||||
)
|
)
|
||||||
def test_it_sets_command_bool_params(self, param, value):
|
def test_it_sets_command_bool_params(self, param, value):
|
||||||
setattr(tests.command, param, value)
|
setattr(vm.command, param, value)
|
||||||
|
|
||||||
""" recorder tests """
|
""" recorder tests """
|
||||||
|
|
||||||
@@ -125,8 +156,9 @@ class TestSetAndGetBoolHigher:
|
|||||||
[("A1"), ("B2")],
|
[("A1"), ("B2")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_recorder_bool_params(self, param, value):
|
def test_it_sets_and_gets_recorder_bool_params(self, param, value):
|
||||||
setattr(tests.recorder, param, value)
|
assert hasattr(vm.recorder, param)
|
||||||
assert getattr(tests.recorder, param) == value
|
setattr(vm.recorder, param, value)
|
||||||
|
assert getattr(vm.recorder, param) == value
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
data.name == "basic",
|
data.name == "basic",
|
||||||
@@ -137,7 +169,56 @@ class TestSetAndGetBoolHigher:
|
|||||||
[("loop")],
|
[("loop")],
|
||||||
)
|
)
|
||||||
def test_it_sets_recorder_bool_params(self, param, value):
|
def test_it_sets_recorder_bool_params(self, param, value):
|
||||||
setattr(tests.recorder, param, value)
|
assert hasattr(vm.recorder, param)
|
||||||
|
setattr(vm.recorder, param, value)
|
||||||
|
assert getattr(vm.recorder, param) == value
|
||||||
|
|
||||||
|
""" recoder.mode tests """
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name == "basic",
|
||||||
|
reason="Skip test if kind is basic",
|
||||||
|
)
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"param",
|
||||||
|
[("loop"), ("recbus")],
|
||||||
|
)
|
||||||
|
def test_it_sets_recorder_mode_bool_params(self, param, value):
|
||||||
|
assert hasattr(vm.recorder.mode, param)
|
||||||
|
setattr(vm.recorder.mode, param, value)
|
||||||
|
assert getattr(vm.recorder.mode, param) == value
|
||||||
|
|
||||||
|
""" recorder.armstrip """
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name == "basic",
|
||||||
|
reason="Skip test if kind is basic",
|
||||||
|
)
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"index",
|
||||||
|
[
|
||||||
|
(data.phys_out),
|
||||||
|
(data.virt_out),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_it_sets_recorder_armstrip_bool_params(self, index, value):
|
||||||
|
vm.recorder.armstrip[index].set(value)
|
||||||
|
|
||||||
|
""" recorder.armbus """
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name == "basic",
|
||||||
|
reason="Skip test if kind is basic",
|
||||||
|
)
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"index",
|
||||||
|
[
|
||||||
|
(data.phys_out),
|
||||||
|
(data.virt_out),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_it_sets_recorder_armbus_bool_params(self, index, value):
|
||||||
|
vm.recorder.armbus[index].set(True)
|
||||||
|
|
||||||
""" fx tests """
|
""" fx tests """
|
||||||
|
|
||||||
@@ -150,8 +231,8 @@ class TestSetAndGetBoolHigher:
|
|||||||
[("reverb"), ("reverb_ab"), ("delay"), ("delay_ab")],
|
[("reverb"), ("reverb_ab"), ("delay"), ("delay_ab")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_fx_bool_params(self, param, value):
|
def test_it_sets_and_gets_fx_bool_params(self, param, value):
|
||||||
setattr(tests.fx, param, value)
|
setattr(vm.fx, param, value)
|
||||||
assert getattr(tests.fx, param) == value
|
assert getattr(vm.fx, param) == value
|
||||||
|
|
||||||
""" patch tests """
|
""" patch tests """
|
||||||
|
|
||||||
@@ -164,8 +245,8 @@ class TestSetAndGetBoolHigher:
|
|||||||
[("postfadercomposite")],
|
[("postfadercomposite")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_patch_bool_params(self, param, value):
|
def test_it_sets_and_gets_patch_bool_params(self, param, value):
|
||||||
setattr(tests.patch, param, value)
|
setattr(vm.patch, param, value)
|
||||||
assert getattr(tests.patch, param) == value
|
assert getattr(vm.patch, param) == value
|
||||||
|
|
||||||
""" patch.insert tests """
|
""" patch.insert tests """
|
||||||
|
|
||||||
@@ -178,8 +259,8 @@ class TestSetAndGetBoolHigher:
|
|||||||
[(data.insert_lower, "on"), (data.insert_higher, "on")],
|
[(data.insert_lower, "on"), (data.insert_higher, "on")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_patch_insert_bool_params(self, index, param, value):
|
def test_it_sets_and_gets_patch_insert_bool_params(self, index, param, value):
|
||||||
setattr(tests.patch.insert[index], param, value)
|
setattr(vm.patch.insert[index], param, value)
|
||||||
assert getattr(tests.patch.insert[index], param) == value
|
assert getattr(vm.patch.insert[index], param) == value
|
||||||
|
|
||||||
""" option tests """
|
""" option tests """
|
||||||
|
|
||||||
@@ -188,8 +269,8 @@ class TestSetAndGetBoolHigher:
|
|||||||
[("monitoronsel")],
|
[("monitoronsel")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_option_bool_params(self, param, value):
|
def test_it_sets_and_gets_option_bool_params(self, param, value):
|
||||||
setattr(tests.option, param, value)
|
setattr(vm.option, param, value)
|
||||||
assert getattr(tests.option, param) == value
|
assert getattr(vm.option, param) == value
|
||||||
|
|
||||||
|
|
||||||
class TestSetAndGetIntHigher:
|
class TestSetAndGetIntHigher:
|
||||||
@@ -207,8 +288,8 @@ class TestSetAndGetIntHigher:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_strip_bool_params(self, index, param, value):
|
def test_it_sets_and_gets_strip_bool_params(self, index, param, value):
|
||||||
setattr(tests.strip[index], param, value)
|
setattr(vm.strip[index], param, value)
|
||||||
assert getattr(tests.strip[index], param) == value
|
assert getattr(vm.strip[index], param) == value
|
||||||
|
|
||||||
""" vban outstream tests """
|
""" vban outstream tests """
|
||||||
|
|
||||||
@@ -217,8 +298,8 @@ class TestSetAndGetIntHigher:
|
|||||||
[(data.vban_out, "sr", 48000)],
|
[(data.vban_out, "sr", 48000)],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_vban_outstream_bool_params(self, index, param, value):
|
def test_it_sets_and_gets_vban_outstream_bool_params(self, index, param, value):
|
||||||
setattr(tests.vban.outstream[index], param, value)
|
setattr(vm.vban.outstream[index], param, value)
|
||||||
assert getattr(tests.vban.outstream[index], param) == value
|
assert getattr(vm.vban.outstream[index], param) == value
|
||||||
|
|
||||||
""" patch.asio tests """
|
""" patch.asio tests """
|
||||||
|
|
||||||
@@ -234,8 +315,8 @@ class TestSetAndGetIntHigher:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_patch_asio_in_int_params(self, index, value):
|
def test_it_sets_and_gets_patch_asio_in_int_params(self, index, value):
|
||||||
tests.patch.asio[index].set(value)
|
vm.patch.asio[index].set(value)
|
||||||
assert tests.patch.asio[index].get() == value
|
assert vm.patch.asio[index].get() == value
|
||||||
|
|
||||||
""" patch.A2[i]-A5[i] tests """
|
""" patch.A2[i]-A5[i] tests """
|
||||||
|
|
||||||
@@ -251,10 +332,10 @@ class TestSetAndGetIntHigher:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_patch_asio_out_int_params(self, index, value):
|
def test_it_sets_and_gets_patch_asio_out_int_params(self, index, value):
|
||||||
tests.patch.A2[index].set(value)
|
vm.patch.A2[index].set(value)
|
||||||
assert tests.patch.A2[index].get() == value
|
assert vm.patch.A2[index].get() == value
|
||||||
tests.patch.A5[index].set(value)
|
vm.patch.A5[index].set(value)
|
||||||
assert tests.patch.A5[index].get() == value
|
assert vm.patch.A5[index].get() == value
|
||||||
|
|
||||||
""" patch.composite tests """
|
""" patch.composite tests """
|
||||||
|
|
||||||
@@ -272,8 +353,8 @@ class TestSetAndGetIntHigher:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_patch_composite_int_params(self, index, value):
|
def test_it_sets_and_gets_patch_composite_int_params(self, index, value):
|
||||||
tests.patch.composite[index].set(value)
|
vm.patch.composite[index].set(value)
|
||||||
assert tests.patch.composite[index].get() == value
|
assert vm.patch.composite[index].get() == value
|
||||||
|
|
||||||
""" option tests """
|
""" option tests """
|
||||||
|
|
||||||
@@ -289,8 +370,28 @@ class TestSetAndGetIntHigher:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_patch_delay_int_params(self, index, value):
|
def test_it_sets_and_gets_patch_delay_int_params(self, index, value):
|
||||||
tests.option.delay[index].set(value)
|
vm.option.delay[index].set(value)
|
||||||
assert tests.option.delay[index].get() == value
|
assert vm.option.delay[index].get() == value
|
||||||
|
|
||||||
|
""" recorder tests """
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name == "basic",
|
||||||
|
reason="Skip test if kind is basic",
|
||||||
|
)
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"param,value",
|
||||||
|
[
|
||||||
|
("samplerate", 32000),
|
||||||
|
("samplerate", 96000),
|
||||||
|
("bitresolution", 16),
|
||||||
|
("bitresolution", 32),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_it_sets_and_gets_recorder_int_params(self, param, value):
|
||||||
|
assert hasattr(vm.recorder, param)
|
||||||
|
setattr(vm.recorder, param, value)
|
||||||
|
assert getattr(vm.recorder, param) == value
|
||||||
|
|
||||||
|
|
||||||
class TestSetAndGetFloatHigher:
|
class TestSetAndGetFloatHigher:
|
||||||
@@ -303,29 +404,25 @@ class TestSetAndGetFloatHigher:
|
|||||||
[
|
[
|
||||||
(data.phys_in, "gain", -3.6),
|
(data.phys_in, "gain", -3.6),
|
||||||
(data.virt_in, "gain", 5.8),
|
(data.virt_in, "gain", 5.8),
|
||||||
(data.phys_in, "comp", 0.0),
|
|
||||||
(data.virt_in, "comp", 8.2),
|
|
||||||
(data.phys_in, "gate", 2.3),
|
|
||||||
(data.virt_in, "gate", 6.7),
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_strip_float_params(self, index, param, value):
|
def test_it_sets_and_gets_strip_float_params(self, index, param, value):
|
||||||
setattr(tests.strip[index], param, value)
|
setattr(vm.strip[index], param, value)
|
||||||
assert getattr(tests.strip[index], param) == value
|
assert getattr(vm.strip[index], param) == value
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"index,value",
|
"index,value",
|
||||||
[(data.phys_in, 2), (data.phys_in, 2), (data.virt_in, 8), (data.virt_in, 8)],
|
[(data.phys_in, 2), (data.phys_in, 2), (data.virt_in, 8), (data.virt_in, 8)],
|
||||||
)
|
)
|
||||||
def test_it_gets_prefader_levels_and_compares_length_of_array(self, index, value):
|
def test_it_gets_prefader_levels_and_compares_length_of_array(self, index, value):
|
||||||
assert len(tests.strip[index].levels.prefader) == value
|
assert len(vm.strip[index].levels.prefader) == value
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"index,value",
|
"index,value",
|
||||||
[(data.phys_in, 2), (data.phys_in, 2), (data.virt_in, 8), (data.virt_in, 8)],
|
[(data.phys_in, 2), (data.phys_in, 2), (data.virt_in, 8), (data.virt_in, 8)],
|
||||||
)
|
)
|
||||||
def test_it_gets_postmute_levels_and_compares_length_of_array(self, index, value):
|
def test_it_gets_postmute_levels_and_compares_length_of_array(self, index, value):
|
||||||
assert len(tests.strip[index].levels.postmute) == value
|
assert len(vm.strip[index].levels.postmute) == value
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
data.name != "potato",
|
data.name != "potato",
|
||||||
@@ -341,8 +438,8 @@ class TestSetAndGetFloatHigher:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_strip_gainlayer_values(self, index, j, value):
|
def test_it_sets_and_gets_strip_gainlayer_values(self, index, j, value):
|
||||||
tests.strip[index].gainlayer[j].gain = value
|
vm.strip[index].gainlayer[j].gain = value
|
||||||
assert tests.strip[index].gainlayer[j].gain == value
|
assert vm.strip[index].gainlayer[j].gain == value
|
||||||
|
|
||||||
""" strip tests, physical """
|
""" strip tests, physical """
|
||||||
|
|
||||||
@@ -356,9 +453,9 @@ class TestSetAndGetFloatHigher:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_strip_xy_params(self, index, param, value):
|
def test_it_sets_and_gets_strip_xy_params(self, index, param, value):
|
||||||
assert hasattr(tests.strip[index], param)
|
assert hasattr(vm.strip[index], param)
|
||||||
setattr(tests.strip[index], param, value)
|
setattr(vm.strip[index], param, value)
|
||||||
assert getattr(tests.strip[index], param) == value
|
assert getattr(vm.strip[index], param) == value
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
data.name != "potato",
|
data.name != "potato",
|
||||||
@@ -372,23 +469,71 @@ class TestSetAndGetFloatHigher:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_strip_effects_params(self, index, param, value):
|
def test_it_sets_and_gets_strip_effects_params(self, index, param, value):
|
||||||
assert hasattr(tests.strip[index], param)
|
assert hasattr(vm.strip[index], param)
|
||||||
setattr(tests.strip[index], param, value)
|
setattr(vm.strip[index], param, value)
|
||||||
assert getattr(tests.strip[index], param) == value
|
assert getattr(vm.strip[index], param) == value
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name != "potato",
|
||||||
|
reason="Only test if logged into Potato version",
|
||||||
|
)
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"index, param, value",
|
||||||
|
[
|
||||||
|
(data.phys_in, "gainin", -8.6),
|
||||||
|
(data.phys_in, "knee", 0.5),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_it_sets_and_gets_strip_comp_params(self, index, param, value):
|
||||||
|
assert hasattr(vm.strip[index].comp, param)
|
||||||
|
setattr(vm.strip[index].comp, param, value)
|
||||||
|
assert getattr(vm.strip[index].comp, param) == value
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name != "potato",
|
||||||
|
reason="Only test if logged into Potato version",
|
||||||
|
)
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"index, param, value",
|
||||||
|
[
|
||||||
|
(data.phys_in, "bpsidechain", 120),
|
||||||
|
(data.phys_in, "hold", 3000),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_it_sets_and_gets_strip_gate_params(self, index, param, value):
|
||||||
|
assert hasattr(vm.strip[index].gate, param)
|
||||||
|
setattr(vm.strip[index].gate, param, value)
|
||||||
|
assert getattr(vm.strip[index].gate, param) == value
|
||||||
|
|
||||||
|
@pytest.mark.skipif(
|
||||||
|
data.name != "potato",
|
||||||
|
reason="Only test if logged into Potato version",
|
||||||
|
)
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"index, param, value",
|
||||||
|
[
|
||||||
|
(data.phys_in, "knob", -8.6),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_it_sets_and_gets_strip_denoiser_params(self, index, param, value):
|
||||||
|
setattr(vm.strip[index].denoiser, param, value)
|
||||||
|
assert getattr(vm.strip[index].denoiser, param) == value
|
||||||
|
|
||||||
""" strip tests, virtual """
|
""" strip tests, virtual """
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"index, param, value",
|
"index, param, value",
|
||||||
[
|
[
|
||||||
|
(data.virt_in, "pan_x", -0.6),
|
||||||
|
(data.virt_in, "pan_x", 0.6),
|
||||||
(data.virt_in, "treble", -1.6),
|
(data.virt_in, "treble", -1.6),
|
||||||
(data.virt_in, "mid", 5.8),
|
(data.virt_in, "mid", 5.8),
|
||||||
(data.virt_in, "bass", -8.1),
|
(data.virt_in, "bass", -8.1),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_strip_eq_params(self, index, param, value):
|
def test_it_sets_and_gets_strip_eq_params(self, index, param, value):
|
||||||
setattr(tests.strip[index], param, value)
|
setattr(vm.strip[index], param, value)
|
||||||
assert getattr(tests.strip[index], param) == value
|
assert getattr(vm.strip[index], param) == value
|
||||||
|
|
||||||
""" bus tests, physical and virtual """
|
""" bus tests, physical and virtual """
|
||||||
|
|
||||||
@@ -401,24 +546,24 @@ class TestSetAndGetFloatHigher:
|
|||||||
[(data.phys_out, "returnreverb", 3.6), (data.virt_out, "returnfx1", 5.8)],
|
[(data.phys_out, "returnreverb", 3.6), (data.virt_out, "returnfx1", 5.8)],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_bus_effects_float_params(self, index, param, value):
|
def test_it_sets_and_gets_bus_effects_float_params(self, index, param, value):
|
||||||
assert hasattr(tests.bus[index], param)
|
assert hasattr(vm.bus[index], param)
|
||||||
setattr(tests.bus[index], param, value)
|
setattr(vm.bus[index], param, value)
|
||||||
assert getattr(tests.bus[index], param) == value
|
assert getattr(vm.bus[index], param) == value
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"index, param, value",
|
"index, param, value",
|
||||||
[(data.phys_out, "gain", -3.6), (data.virt_out, "gain", 5.8)],
|
[(data.phys_out, "gain", -3.6), (data.virt_out, "gain", 5.8)],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_bus_float_params(self, index, param, value):
|
def test_it_sets_and_gets_bus_float_params(self, index, param, value):
|
||||||
setattr(tests.bus[index], param, value)
|
setattr(vm.bus[index], param, value)
|
||||||
assert getattr(tests.bus[index], param) == value
|
assert getattr(vm.bus[index], param) == value
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"index,value",
|
"index,value",
|
||||||
[(data.phys_out, 8), (data.virt_out, 8)],
|
[(data.phys_out, 8), (data.virt_out, 8)],
|
||||||
)
|
)
|
||||||
def test_it_gets_prefader_levels_and_compares_length_of_array(self, index, value):
|
def test_it_gets_prefader_levels_and_compares_length_of_array(self, index, value):
|
||||||
assert len(tests.bus[index].levels.all) == value
|
assert len(vm.bus[index].levels.all) == value
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("value", ["test0", "test1"])
|
@pytest.mark.parametrize("value", ["test0", "test1"])
|
||||||
@@ -432,8 +577,8 @@ class TestSetAndGetStringHigher:
|
|||||||
[(data.phys_in, "label"), (data.virt_in, "label")],
|
[(data.phys_in, "label"), (data.virt_in, "label")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_strip_string_params(self, index, param, value):
|
def test_it_sets_and_gets_strip_string_params(self, index, param, value):
|
||||||
setattr(tests.strip[index], param, value)
|
setattr(vm.strip[index], param, value)
|
||||||
assert getattr(tests.strip[index], param) == value
|
assert getattr(vm.strip[index], param) == value
|
||||||
|
|
||||||
""" bus tests, physical and virtual """
|
""" bus tests, physical and virtual """
|
||||||
|
|
||||||
@@ -442,8 +587,8 @@ class TestSetAndGetStringHigher:
|
|||||||
[(data.phys_out, "label"), (data.virt_out, "label")],
|
[(data.phys_out, "label"), (data.virt_out, "label")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_bus_string_params(self, index, param, value):
|
def test_it_sets_and_gets_bus_string_params(self, index, param, value):
|
||||||
setattr(tests.bus[index], param, value)
|
setattr(vm.bus[index], param, value)
|
||||||
assert getattr(tests.bus[index], param) == value
|
assert getattr(vm.bus[index], param) == value
|
||||||
|
|
||||||
""" vban instream tests """
|
""" vban instream tests """
|
||||||
|
|
||||||
@@ -452,8 +597,8 @@ class TestSetAndGetStringHigher:
|
|||||||
[(data.vban_in, "name")],
|
[(data.vban_in, "name")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_vban_instream_string_params(self, index, param, value):
|
def test_it_sets_and_gets_vban_instream_string_params(self, index, param, value):
|
||||||
setattr(tests.vban.instream[index], param, value)
|
setattr(vm.vban.instream[index], param, value)
|
||||||
assert getattr(tests.vban.instream[index], param) == value
|
assert getattr(vm.vban.instream[index], param) == value
|
||||||
|
|
||||||
""" vban outstream tests """
|
""" vban outstream tests """
|
||||||
|
|
||||||
@@ -462,8 +607,8 @@ class TestSetAndGetStringHigher:
|
|||||||
[(data.vban_out, "name")],
|
[(data.vban_out, "name")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_vban_outstream_string_params(self, index, param, value):
|
def test_it_sets_and_gets_vban_outstream_string_params(self, index, param, value):
|
||||||
setattr(tests.vban.outstream[index], param, value)
|
setattr(vm.vban.outstream[index], param, value)
|
||||||
assert getattr(tests.vban.outstream[index], param) == value
|
assert getattr(vm.vban.outstream[index], param) == value
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("value", [False, True])
|
@pytest.mark.parametrize("value", [False, True])
|
||||||
@@ -484,5 +629,5 @@ class TestSetAndGetMacroButtonHigher:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_macrobutton_params(self, index, param, value):
|
def test_it_sets_and_gets_macrobutton_params(self, index, param, value):
|
||||||
setattr(tests.button[index], param, value)
|
setattr(vm.button[index], param, value)
|
||||||
assert getattr(tests.button[index], param) == value
|
assert getattr(vm.button[index], param) == value
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tests import data, tests
|
from tests import data, vm
|
||||||
|
|
||||||
|
|
||||||
class TestSetAndGetFloatLower:
|
class TestSetAndGetFloatLower:
|
||||||
@@ -18,8 +18,8 @@ class TestSetAndGetFloatLower:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_mute_eq_float_params(self, param, value):
|
def test_it_sets_and_gets_mute_eq_float_params(self, param, value):
|
||||||
tests.set(param, value)
|
vm.set(param, value)
|
||||||
assert (round(tests.get(param))) == value
|
assert (round(vm.get(param))) == value
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"param,value",
|
"param,value",
|
||||||
@@ -30,8 +30,8 @@ class TestSetAndGetFloatLower:
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_comp_gain_float_params(self, param, value):
|
def test_it_sets_and_gets_comp_gain_float_params(self, param, value):
|
||||||
tests.set(param, value)
|
vm.set(param, value)
|
||||||
assert (round(tests.get(param), 1)) == value
|
assert (round(vm.get(param), 1)) == value
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("value", ["test0", "test1"])
|
@pytest.mark.parametrize("value", ["test0", "test1"])
|
||||||
@@ -45,12 +45,14 @@ class TestSetAndGetStringLower:
|
|||||||
[(f"Strip[{data.phys_out}].label"), (f"Bus[{data.virt_out}].label")],
|
[(f"Strip[{data.phys_out}].label"), (f"Bus[{data.virt_out}].label")],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_string_params(self, param, value):
|
def test_it_sets_and_gets_string_params(self, param, value):
|
||||||
tests.set(param, value)
|
vm.set(param, value)
|
||||||
assert tests.get(param, string=True) == value
|
assert vm.get(param, string=True) == value
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("value", [0, 1])
|
@pytest.mark.parametrize("value", [0, 1])
|
||||||
class TestMacroButtonsLower:
|
class TestMacroButtonsLower:
|
||||||
|
__test__ = True
|
||||||
|
|
||||||
"""VBVMR_MacroButton_SetStatus, VBVMR_MacroButton_GetStatus"""
|
"""VBVMR_MacroButton_SetStatus, VBVMR_MacroButton_GetStatus"""
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
@@ -58,21 +60,21 @@ class TestMacroButtonsLower:
|
|||||||
[(33, 1), (49, 1)],
|
[(33, 1), (49, 1)],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_macrobuttons_state(self, index, mode, value):
|
def test_it_sets_and_gets_macrobuttons_state(self, index, mode, value):
|
||||||
tests.set_buttonstatus(index, value, mode)
|
vm.set_buttonstatus(index, value, mode)
|
||||||
assert tests.get_buttonstatus(index, mode) == value
|
assert vm.get_buttonstatus(index, mode) == value
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"index, mode",
|
"index, mode",
|
||||||
[(14, 2), (12, 2)],
|
[(14, 2), (12, 2)],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_macrobuttons_stateonly(self, index, mode, value):
|
def test_it_sets_and_gets_macrobuttons_stateonly(self, index, mode, value):
|
||||||
tests.set_buttonstatus(index, value, mode)
|
vm.set_buttonstatus(index, value, mode)
|
||||||
assert tests.get_buttonstatus(index, mode) == value
|
assert vm.get_buttonstatus(index, mode) == value
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"index, mode",
|
"index, mode",
|
||||||
[(50, 3), (65, 3)],
|
[(50, 3), (65, 3)],
|
||||||
)
|
)
|
||||||
def test_it_sets_and_gets_macrobuttons_trigger(self, index, mode, value):
|
def test_it_sets_and_gets_macrobuttons_trigger(self, index, mode, value):
|
||||||
tests.set_buttonstatus(index, value, mode)
|
vm.set_buttonstatus(index, value, mode)
|
||||||
assert tests.get_buttonstatus(index, mode) == value
|
assert vm.get_buttonstatus(index, mode) == value
|
||||||
|
|||||||
@@ -1,309 +0,0 @@
|
|||||||
import ctypes as ct
|
|
||||||
import time
|
|
||||||
from abc import abstractmethod
|
|
||||||
from functools import partial
|
|
||||||
from threading import Thread
|
|
||||||
from typing import Iterable, NoReturn, Optional, Self, Union
|
|
||||||
|
|
||||||
from .cbindings import CBindings
|
|
||||||
from .error import CAPIError, VMError
|
|
||||||
from .inst import bits
|
|
||||||
from .kinds import KindId
|
|
||||||
from .misc import Event, Midi
|
|
||||||
from .subject import Subject
|
|
||||||
from .util import comp, grouper, polling, script
|
|
||||||
|
|
||||||
|
|
||||||
class Remote(CBindings):
|
|
||||||
"""Base class responsible for wrapping the C Remote API"""
|
|
||||||
|
|
||||||
DELAY = 0.001
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
self.strip_mode = 0
|
|
||||||
self.cache = {}
|
|
||||||
self.cache["strip_level"], self.cache["bus_level"] = self._get_levels()
|
|
||||||
self.midi = Midi()
|
|
||||||
self.subject = Subject()
|
|
||||||
self.running = None
|
|
||||||
|
|
||||||
for attr, val in kwargs.items():
|
|
||||||
setattr(self, attr, val)
|
|
||||||
|
|
||||||
self.event = Event(self.subs)
|
|
||||||
|
|
||||||
def __enter__(self) -> Self:
|
|
||||||
"""setup procedures"""
|
|
||||||
self.login()
|
|
||||||
self.init_thread()
|
|
||||||
return self
|
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
def __str__(self):
|
|
||||||
"""Ensure subclasses override str magic method"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
def init_thread(self):
|
|
||||||
"""Starts updates thread."""
|
|
||||||
self.running = True
|
|
||||||
print(f"Listening for {', '.join(self.event.get())} events")
|
|
||||||
t = Thread(target=self._updates, daemon=True)
|
|
||||||
t.start()
|
|
||||||
|
|
||||||
def _updates(self):
|
|
||||||
"""
|
|
||||||
Continously update observers of dirty states.
|
|
||||||
|
|
||||||
Generate _strip_comp, _bus_comp and update level cache if ldirty.
|
|
||||||
|
|
||||||
Runs updates at a rate of self.ratelimit.
|
|
||||||
"""
|
|
||||||
while self.running:
|
|
||||||
if self.event.pdirty and self.pdirty:
|
|
||||||
self.subject.notify("pdirty")
|
|
||||||
if self.event.mdirty and self.mdirty:
|
|
||||||
self.subject.notify("mdirty")
|
|
||||||
if self.event.midi and self.get_midi_message():
|
|
||||||
self.subject.notify("midi")
|
|
||||||
if self.event.ldirty and self.ldirty:
|
|
||||||
self._strip_comp, self._bus_comp = (
|
|
||||||
tuple(
|
|
||||||
not x for x in comp(self.cache["strip_level"], self._strip_buf)
|
|
||||||
),
|
|
||||||
tuple(not x for x in comp(self.cache["bus_level"], self._bus_buf)),
|
|
||||||
)
|
|
||||||
self.cache["strip_level"] = self._strip_buf
|
|
||||||
self.cache["bus_level"] = self._bus_buf
|
|
||||||
self.subject.notify("ldirty")
|
|
||||||
|
|
||||||
time.sleep(self.ratelimit if self.event.any() else 0.5)
|
|
||||||
|
|
||||||
def login(self) -> NoReturn:
|
|
||||||
"""Login to the API, initialize dirty parameters"""
|
|
||||||
res = self.vm_login()
|
|
||||||
if res == 1:
|
|
||||||
self.run_voicemeeter(self.kind.name)
|
|
||||||
elif res != 0:
|
|
||||||
raise CAPIError(f"VBVMR_Login returned {res}")
|
|
||||||
print(f"Successfully logged into {self}")
|
|
||||||
self.clear_dirty()
|
|
||||||
|
|
||||||
def run_voicemeeter(self, kind_id: str) -> NoReturn:
|
|
||||||
if kind_id not in (kind.name.lower() for kind in KindId):
|
|
||||||
raise VMError(f"Unexpected Voicemeeter type: '{kind_id}'")
|
|
||||||
if kind_id == "potato" and bits == 8:
|
|
||||||
value = KindId[kind_id.upper()].value + 3
|
|
||||||
else:
|
|
||||||
value = KindId[kind_id.upper()].value
|
|
||||||
self.vm_runvm(value)
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def type(self) -> str:
|
|
||||||
"""Returns the type of Voicemeeter installation (basic, banana, potato)."""
|
|
||||||
type_ = ct.c_long()
|
|
||||||
self.vm_get_type(ct.byref(type_))
|
|
||||||
return KindId(type_.value).name.lower()
|
|
||||||
|
|
||||||
@property
|
|
||||||
def version(self) -> str:
|
|
||||||
"""Returns Voicemeeter's version as a string"""
|
|
||||||
ver = ct.c_long()
|
|
||||||
self.vm_get_version(ct.byref(ver))
|
|
||||||
return "{}.{}.{}.{}".format(
|
|
||||||
(ver.value & 0xFF000000) >> 24,
|
|
||||||
(ver.value & 0x00FF0000) >> 16,
|
|
||||||
(ver.value & 0x0000FF00) >> 8,
|
|
||||||
ver.value & 0x000000FF,
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def pdirty(self) -> bool:
|
|
||||||
"""True iff UI parameters have been updated."""
|
|
||||||
return self.vm_pdirty() == 1
|
|
||||||
|
|
||||||
@property
|
|
||||||
def mdirty(self) -> bool:
|
|
||||||
"""True iff MB parameters have been updated."""
|
|
||||||
return self.vm_mdirty() == 1
|
|
||||||
|
|
||||||
@property
|
|
||||||
def ldirty(self) -> bool:
|
|
||||||
"""True iff levels have been updated."""
|
|
||||||
self._strip_buf, self._bus_buf = self._get_levels()
|
|
||||||
return not (
|
|
||||||
self.cache.get("strip_level") == self._strip_buf
|
|
||||||
and self.cache.get("bus_level") == self._bus_buf
|
|
||||||
)
|
|
||||||
|
|
||||||
def clear_dirty(self):
|
|
||||||
while self.pdirty or self.mdirty:
|
|
||||||
pass
|
|
||||||
|
|
||||||
@polling
|
|
||||||
def get(self, param: str, is_string: Optional[bool] = False) -> Union[str, float]:
|
|
||||||
"""Gets a string or float parameter"""
|
|
||||||
if is_string:
|
|
||||||
buf = ct.create_unicode_buffer(512)
|
|
||||||
self.call(
|
|
||||||
partial(self.vm_get_parameter_string, param.encode(), ct.byref(buf))
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
buf = ct.c_float()
|
|
||||||
self.call(
|
|
||||||
partial(self.vm_get_parameter_float, param.encode(), ct.byref(buf))
|
|
||||||
)
|
|
||||||
return buf.value
|
|
||||||
|
|
||||||
def set(self, param: str, val: Union[str, float]) -> NoReturn:
|
|
||||||
"""Sets a string or float parameter. Caches value"""
|
|
||||||
if isinstance(val, str):
|
|
||||||
if len(val) >= 512:
|
|
||||||
raise VMError("String is too long")
|
|
||||||
self.call(
|
|
||||||
partial(self.vm_set_parameter_string, param.encode(), ct.c_wchar_p(val))
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
self.call(
|
|
||||||
partial(
|
|
||||||
self.vm_set_parameter_float, param.encode(), ct.c_float(float(val))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
self.cache[param] = val
|
|
||||||
|
|
||||||
@polling
|
|
||||||
def get_buttonstatus(self, id: int, mode: int) -> int:
|
|
||||||
"""Gets a macrobutton parameter"""
|
|
||||||
state = ct.c_float()
|
|
||||||
self.call(
|
|
||||||
partial(
|
|
||||||
self.vm_get_buttonstatus,
|
|
||||||
ct.c_long(id),
|
|
||||||
ct.byref(state),
|
|
||||||
ct.c_long(mode),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
return int(state.value)
|
|
||||||
|
|
||||||
def set_buttonstatus(self, id: int, state: int, mode: int) -> NoReturn:
|
|
||||||
"""Sets a macrobutton parameter. Caches value"""
|
|
||||||
c_state = ct.c_float(float(state))
|
|
||||||
self.call(
|
|
||||||
partial(self.vm_set_buttonstatus, ct.c_long(id), c_state, ct.c_long(mode))
|
|
||||||
)
|
|
||||||
self.cache[f"mb_{id}_{mode}"] = int(c_state.value)
|
|
||||||
|
|
||||||
def get_num_devices(self, direction: str = None) -> int:
|
|
||||||
"""Retrieves number of physical devices connected"""
|
|
||||||
if direction not in ("in", "out"):
|
|
||||||
raise VMError("Expected a direction: in or out")
|
|
||||||
func = getattr(self, f"vm_get_num_{direction}devices")
|
|
||||||
return func()
|
|
||||||
|
|
||||||
def get_device_description(self, index: int, direction: str = None) -> tuple:
|
|
||||||
"""Returns a tuple of device parameters"""
|
|
||||||
if direction not in ("in", "out"):
|
|
||||||
raise VMError("Expected a direction: in or out")
|
|
||||||
type_ = ct.c_long()
|
|
||||||
name = ct.create_unicode_buffer(256)
|
|
||||||
hwid = ct.create_unicode_buffer(256)
|
|
||||||
func = getattr(self, f"vm_get_desc_{direction}devices")
|
|
||||||
func(
|
|
||||||
ct.c_long(index),
|
|
||||||
ct.byref(type_),
|
|
||||||
ct.byref(name),
|
|
||||||
ct.byref(hwid),
|
|
||||||
)
|
|
||||||
return (name.value, type_.value, hwid.value)
|
|
||||||
|
|
||||||
def get_level(self, type_: int, index: int) -> float:
|
|
||||||
"""Retrieves a single level value"""
|
|
||||||
val = ct.c_float()
|
|
||||||
self.vm_get_level(ct.c_long(type_), ct.c_long(index), ct.byref(val))
|
|
||||||
return val.value
|
|
||||||
|
|
||||||
def _get_levels(self) -> Iterable:
|
|
||||||
"""
|
|
||||||
returns both level arrays (strip_levels, bus_levels) BEFORE math conversion
|
|
||||||
"""
|
|
||||||
return (
|
|
||||||
tuple(
|
|
||||||
self.get_level(self.strip_mode, i)
|
|
||||||
for i in range(2 * self.kind.phys_in + 8 * self.kind.virt_in)
|
|
||||||
),
|
|
||||||
tuple(
|
|
||||||
self.get_level(3, i)
|
|
||||||
for i in range(8 * (self.kind.phys_out + self.kind.virt_out))
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
def get_midi_message(self):
|
|
||||||
n = ct.c_long(1024)
|
|
||||||
buf = ct.create_string_buffer(1024)
|
|
||||||
res = self.vm_get_midi_message(ct.byref(buf), n)
|
|
||||||
if res > 0:
|
|
||||||
vals = tuple(grouper(3, (int.from_bytes(buf[i]) for i in range(res))))
|
|
||||||
for msg in vals:
|
|
||||||
ch, pitch, vel = msg
|
|
||||||
if not self.midi._channel or self.midi._channel != ch:
|
|
||||||
self.midi._channel = ch
|
|
||||||
self.midi._most_recent = pitch
|
|
||||||
self.midi._set(pitch, vel)
|
|
||||||
return True
|
|
||||||
elif res == -1 or res == -2:
|
|
||||||
raise CAPIError(f"VBVMR_GetMidiMessage returned {res}")
|
|
||||||
|
|
||||||
@script
|
|
||||||
def sendtext(self, script: str):
|
|
||||||
"""Sets many parameters from a script"""
|
|
||||||
if len(script) > 48000:
|
|
||||||
raise ValueError("Script too large, max size 48kB")
|
|
||||||
self.call(partial(self.vm_set_parameter_multi, script.encode()))
|
|
||||||
time.sleep(self.DELAY * 5)
|
|
||||||
|
|
||||||
def apply(self, data: dict):
|
|
||||||
"""
|
|
||||||
Sets all parameters of a dict
|
|
||||||
|
|
||||||
minor delay between each recursion
|
|
||||||
"""
|
|
||||||
|
|
||||||
def param(key):
|
|
||||||
obj, m2, *rem = key.split("-")
|
|
||||||
index = int(m2) if m2.isnumeric() else int(*rem)
|
|
||||||
if obj in ("strip", "bus", "button"):
|
|
||||||
return getattr(self, obj)[index]
|
|
||||||
elif obj == "vban":
|
|
||||||
return getattr(getattr(self, obj), f"{m2}stream")[index]
|
|
||||||
raise ValueError(obj)
|
|
||||||
|
|
||||||
[param(key).apply(datum).then_wait() for key, datum in data.items()]
|
|
||||||
|
|
||||||
def apply_config(self, name):
|
|
||||||
"""applies a config from memory"""
|
|
||||||
error_msg = (
|
|
||||||
f"No config with name '{name}' is loaded into memory",
|
|
||||||
f"Known configs: {list(self.configs.keys())}",
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
self.apply(self.configs[name])
|
|
||||||
print(f"Profile '{name}' applied!")
|
|
||||||
except KeyError as e:
|
|
||||||
print(("\n").join(error_msg))
|
|
||||||
|
|
||||||
def logout(self) -> NoReturn:
|
|
||||||
"""Wait for dirty parameters to clear, then logout of the API"""
|
|
||||||
self.clear_dirty()
|
|
||||||
time.sleep(0.1)
|
|
||||||
res = self.vm_logout()
|
|
||||||
if res != 0:
|
|
||||||
raise CAPIError(f"VBVMR_Logout returned {res}")
|
|
||||||
print(f"Successfully logged out of {self}")
|
|
||||||
|
|
||||||
def end_thread(self):
|
|
||||||
self.running = False
|
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, exc_traceback) -> NoReturn:
|
|
||||||
"""teardown procedures"""
|
|
||||||
self.end_thread()
|
|
||||||
self.logout()
|
|
||||||
@@ -4,10 +4,9 @@ from enum import IntEnum
|
|||||||
from math import log
|
from math import log
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from .error import VMError
|
|
||||||
from .iremote import IRemote
|
from .iremote import IRemote
|
||||||
from .kinds import kinds_all
|
from .kinds import kinds_all
|
||||||
from .meta import bool_prop, bus_mode_prop, float_prop
|
from .meta import bus_mode_prop, device_prop, float_prop
|
||||||
|
|
||||||
BusModes = IntEnum(
|
BusModes = IntEnum(
|
||||||
"BusModes",
|
"BusModes",
|
||||||
@@ -47,22 +46,6 @@ class Bus(IRemote):
|
|||||||
def mono(self, val: bool):
|
def mono(self, val: bool):
|
||||||
self.setter("mono", 1 if val else 0)
|
self.setter("mono", 1 if val else 0)
|
||||||
|
|
||||||
@property
|
|
||||||
def eq(self) -> bool:
|
|
||||||
return self.getter("eq.On") == 1
|
|
||||||
|
|
||||||
@eq.setter
|
|
||||||
def eq(self, val: bool):
|
|
||||||
self.setter("eq.On", 1 if val else 0)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def eq_ab(self) -> bool:
|
|
||||||
return self.getter("eq.ab") == 1
|
|
||||||
|
|
||||||
@eq_ab.setter
|
|
||||||
def eq_ab(self, val: bool):
|
|
||||||
self.setter("eq.ab", 1 if val else 0)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sel(self) -> bool:
|
def sel(self) -> bool:
|
||||||
return self.getter("sel") == 1
|
return self.getter("sel") == 1
|
||||||
@@ -104,9 +87,31 @@ class Bus(IRemote):
|
|||||||
time.sleep(self._remote.DELAY)
|
time.sleep(self._remote.DELAY)
|
||||||
|
|
||||||
|
|
||||||
|
class BusEQ(IRemote):
|
||||||
|
@property
|
||||||
|
def identifier(self) -> str:
|
||||||
|
return f"Bus[{self.index}].eq"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def on(self) -> bool:
|
||||||
|
return self.getter("on") == 1
|
||||||
|
|
||||||
|
@on.setter
|
||||||
|
def on(self, val: bool):
|
||||||
|
self.setter("on", 1 if val else 0)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ab(self) -> bool:
|
||||||
|
return self.getter("ab") == 1
|
||||||
|
|
||||||
|
@ab.setter
|
||||||
|
def ab(self, val: bool):
|
||||||
|
self.setter("ab", 1 if val else 0)
|
||||||
|
|
||||||
|
|
||||||
class PhysicalBus(Bus):
|
class PhysicalBus(Bus):
|
||||||
@classmethod
|
@classmethod
|
||||||
def make(cls, kind):
|
def make(cls, remote, i, kind):
|
||||||
"""
|
"""
|
||||||
Factory method for PhysicalBus.
|
Factory method for PhysicalBus.
|
||||||
|
|
||||||
@@ -116,18 +121,54 @@ class PhysicalBus(Bus):
|
|||||||
if kind.name == "potato":
|
if kind.name == "potato":
|
||||||
EFFECTS_cls = _make_effects_mixin()
|
EFFECTS_cls = _make_effects_mixin()
|
||||||
kls += (EFFECTS_cls,)
|
kls += (EFFECTS_cls,)
|
||||||
return type("PhysicalBus", kls, {})
|
return type(
|
||||||
|
"PhysicalBus",
|
||||||
|
kls,
|
||||||
|
{
|
||||||
|
"device": BusDevice.make(remote, i),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{type(self).__name__}{self.index}"
|
return f"{type(self).__name__}{self.index}"
|
||||||
|
|
||||||
|
|
||||||
|
class BusDevice(IRemote):
|
||||||
|
@classmethod
|
||||||
|
def make(cls, remote, i):
|
||||||
|
"""
|
||||||
|
Factory function for bus.device.
|
||||||
|
|
||||||
|
Returns a BusDevice class of a kind.
|
||||||
|
"""
|
||||||
|
DEVICE_cls = type(
|
||||||
|
f"BusDevice{remote.kind}",
|
||||||
|
(cls,),
|
||||||
|
{
|
||||||
|
**{
|
||||||
|
param: device_prop(param)
|
||||||
|
for param in [
|
||||||
|
"wdm",
|
||||||
|
"ks",
|
||||||
|
"mme",
|
||||||
|
"asio",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return DEVICE_cls(remote, i)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device(self) -> str:
|
def identifier(self) -> str:
|
||||||
return self.getter("device.name", is_string=True)
|
return f"Bus[{self.index}].device"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self.getter("name", is_string=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sr(self) -> int:
|
def sr(self) -> int:
|
||||||
return int(self.getter("device.sr"))
|
return int(self.getter("sr"))
|
||||||
|
|
||||||
|
|
||||||
class VirtualBus(Bus):
|
class VirtualBus(Bus):
|
||||||
@@ -169,7 +210,7 @@ class BusLevel(IRemote):
|
|||||||
def fget(x):
|
def fget(x):
|
||||||
return round(20 * log(x, 10), 1) if x > 0 else -200.0
|
return round(20 * log(x, 10), 1) if x > 0 else -200.0
|
||||||
|
|
||||||
if self._remote.running and self._remote.event.ldirty:
|
if not self._remote.stopped() and self._remote.event.ldirty:
|
||||||
vals = self._remote.cache["bus_level"][self.range[0] : self.range[-1]]
|
vals = self._remote.cache["bus_level"][self.range[0] : self.range[-1]]
|
||||||
else:
|
else:
|
||||||
vals = [self._remote.get_level(mode, i) for i in range(*self.range)]
|
vals = [self._remote.get_level(mode, i) for i in range(*self.range)]
|
||||||
@@ -191,7 +232,7 @@ class BusLevel(IRemote):
|
|||||||
|
|
||||||
Expected to be used in a callback only.
|
Expected to be used in a callback only.
|
||||||
"""
|
"""
|
||||||
if self._remote.running:
|
if not self._remote.stopped():
|
||||||
return any(self._remote._bus_comp[self.range[0] : self.range[-1]])
|
return any(self._remote._bus_comp[self.range[0] : self.range[-1]])
|
||||||
|
|
||||||
is_updated = isdirty
|
is_updated = isdirty
|
||||||
@@ -263,7 +304,9 @@ def bus_factory(is_phys_bus, remote, i) -> Union[PhysicalBus, VirtualBus]:
|
|||||||
Returns a physical or virtual bus subclass
|
Returns a physical or virtual bus subclass
|
||||||
"""
|
"""
|
||||||
BUS_cls = (
|
BUS_cls = (
|
||||||
PhysicalBus.make(remote.kind) if is_phys_bus else VirtualBus.make(remote.kind)
|
PhysicalBus.make(remote, i, remote.kind)
|
||||||
|
if is_phys_bus
|
||||||
|
else VirtualBus.make(remote.kind)
|
||||||
)
|
)
|
||||||
BUSMODEMIXIN_cls = _make_bus_mode_mixin()
|
BUSMODEMIXIN_cls = _make_bus_mode_mixin()
|
||||||
return type(
|
return type(
|
||||||
@@ -272,6 +315,7 @@ def bus_factory(is_phys_bus, remote, i) -> Union[PhysicalBus, VirtualBus]:
|
|||||||
{
|
{
|
||||||
"levels": BusLevel(remote, i),
|
"levels": BusLevel(remote, i),
|
||||||
"mode": BUSMODEMIXIN_cls(remote, i),
|
"mode": BUSMODEMIXIN_cls(remote, i),
|
||||||
|
"eq": BusEQ(remote, i),
|
||||||
},
|
},
|
||||||
)(remote, i)
|
)(remote, i)
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import ctypes as ct
|
import ctypes as ct
|
||||||
|
import logging
|
||||||
from abc import ABCMeta
|
from abc import ABCMeta
|
||||||
from ctypes.wintypes import CHAR, FLOAT, LONG, WCHAR
|
from ctypes.wintypes import CHAR, FLOAT, LONG, WCHAR
|
||||||
|
|
||||||
from .error import CAPIError
|
from .error import CAPIError
|
||||||
from .inst import libc
|
from .inst import libc
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class CBindings(metaclass=ABCMeta):
|
class CBindings(metaclass=ABCMeta):
|
||||||
"""
|
"""
|
||||||
@@ -13,97 +16,110 @@ class CBindings(metaclass=ABCMeta):
|
|||||||
Maps expected ctype argument and res types for each binding.
|
Maps expected ctype argument and res types for each binding.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
vm_login = libc.VBVMR_Login
|
logger_cbindings = logger.getChild("CBindings")
|
||||||
vm_login.restype = LONG
|
|
||||||
vm_login.argtypes = None
|
|
||||||
|
|
||||||
vm_logout = libc.VBVMR_Logout
|
bind_login = libc.VBVMR_Login
|
||||||
vm_logout.restype = LONG
|
bind_login.restype = LONG
|
||||||
vm_logout.argtypes = None
|
bind_login.argtypes = None
|
||||||
|
|
||||||
vm_runvm = libc.VBVMR_RunVoicemeeter
|
bind_logout = libc.VBVMR_Logout
|
||||||
vm_runvm.restype = LONG
|
bind_logout.restype = LONG
|
||||||
vm_runvm.argtypes = [LONG]
|
bind_logout.argtypes = None
|
||||||
|
|
||||||
vm_get_type = libc.VBVMR_GetVoicemeeterType
|
bind_run_voicemeeter = libc.VBVMR_RunVoicemeeter
|
||||||
vm_get_type.restype = LONG
|
bind_run_voicemeeter.restype = LONG
|
||||||
vm_get_type.argtypes = [ct.POINTER(LONG)]
|
bind_run_voicemeeter.argtypes = [LONG]
|
||||||
|
|
||||||
vm_get_version = libc.VBVMR_GetVoicemeeterVersion
|
bind_get_voicemeeter_type = libc.VBVMR_GetVoicemeeterType
|
||||||
vm_get_version.restype = LONG
|
bind_get_voicemeeter_type.restype = LONG
|
||||||
vm_get_version.argtypes = [ct.POINTER(LONG)]
|
bind_get_voicemeeter_type.argtypes = [ct.POINTER(LONG)]
|
||||||
|
|
||||||
vm_mdirty = libc.VBVMR_MacroButton_IsDirty
|
bind_get_voicemeeter_version = libc.VBVMR_GetVoicemeeterVersion
|
||||||
vm_mdirty.restype = LONG
|
bind_get_voicemeeter_version.restype = LONG
|
||||||
vm_mdirty.argtypes = None
|
bind_get_voicemeeter_version.argtypes = [ct.POINTER(LONG)]
|
||||||
|
|
||||||
vm_get_buttonstatus = libc.VBVMR_MacroButton_GetStatus
|
if hasattr(libc, "VBVMR_MacroButton_IsDirty"):
|
||||||
vm_get_buttonstatus.restype = LONG
|
bind_macro_button_is_dirty = libc.VBVMR_MacroButton_IsDirty
|
||||||
vm_get_buttonstatus.argtypes = [LONG, ct.POINTER(FLOAT), LONG]
|
bind_macro_button_is_dirty.restype = LONG
|
||||||
|
bind_macro_button_is_dirty.argtypes = None
|
||||||
|
|
||||||
vm_set_buttonstatus = libc.VBVMR_MacroButton_SetStatus
|
if hasattr(libc, "VBVMR_MacroButton_GetStatus"):
|
||||||
vm_set_buttonstatus.restype = LONG
|
bind_macro_button_get_status = libc.VBVMR_MacroButton_GetStatus
|
||||||
vm_set_buttonstatus.argtypes = [LONG, FLOAT, LONG]
|
bind_macro_button_get_status.restype = LONG
|
||||||
|
bind_macro_button_get_status.argtypes = [LONG, ct.POINTER(FLOAT), LONG]
|
||||||
|
|
||||||
vm_pdirty = libc.VBVMR_IsParametersDirty
|
if hasattr(libc, "VBVMR_MacroButton_SetStatus"):
|
||||||
vm_pdirty.restype = LONG
|
bind_macro_button_set_status = libc.VBVMR_MacroButton_SetStatus
|
||||||
vm_pdirty.argtypes = None
|
bind_macro_button_set_status.restype = LONG
|
||||||
|
bind_macro_button_set_status.argtypes = [LONG, FLOAT, LONG]
|
||||||
|
|
||||||
vm_get_parameter_float = libc.VBVMR_GetParameterFloat
|
bind_is_parameters_dirty = libc.VBVMR_IsParametersDirty
|
||||||
vm_get_parameter_float.restype = LONG
|
bind_is_parameters_dirty.restype = LONG
|
||||||
vm_get_parameter_float.argtypes = [ct.POINTER(CHAR), ct.POINTER(FLOAT)]
|
bind_is_parameters_dirty.argtypes = None
|
||||||
|
|
||||||
vm_set_parameter_float = libc.VBVMR_SetParameterFloat
|
bind_get_parameter_float = libc.VBVMR_GetParameterFloat
|
||||||
vm_set_parameter_float.restype = LONG
|
bind_get_parameter_float.restype = LONG
|
||||||
vm_set_parameter_float.argtypes = [ct.POINTER(CHAR), FLOAT]
|
bind_get_parameter_float.argtypes = [ct.POINTER(CHAR), ct.POINTER(FLOAT)]
|
||||||
|
|
||||||
vm_get_parameter_string = libc.VBVMR_GetParameterStringW
|
bind_set_parameter_float = libc.VBVMR_SetParameterFloat
|
||||||
vm_get_parameter_string.restype = LONG
|
bind_set_parameter_float.restype = LONG
|
||||||
vm_get_parameter_string.argtypes = [ct.POINTER(CHAR), ct.POINTER(WCHAR * 512)]
|
bind_set_parameter_float.argtypes = [ct.POINTER(CHAR), FLOAT]
|
||||||
|
|
||||||
vm_set_parameter_string = libc.VBVMR_SetParameterStringW
|
bind_get_parameter_string_w = libc.VBVMR_GetParameterStringW
|
||||||
vm_set_parameter_string.restype = LONG
|
bind_get_parameter_string_w.restype = LONG
|
||||||
vm_set_parameter_string.argtypes = [ct.POINTER(CHAR), ct.POINTER(WCHAR)]
|
bind_get_parameter_string_w.argtypes = [ct.POINTER(CHAR), ct.POINTER(WCHAR * 512)]
|
||||||
|
|
||||||
vm_set_parameter_multi = libc.VBVMR_SetParameters
|
bind_set_parameter_string_w = libc.VBVMR_SetParameterStringW
|
||||||
vm_set_parameter_multi.restype = LONG
|
bind_set_parameter_string_w.restype = LONG
|
||||||
vm_set_parameter_multi.argtypes = [ct.POINTER(CHAR)]
|
bind_set_parameter_string_w.argtypes = [ct.POINTER(CHAR), ct.POINTER(WCHAR)]
|
||||||
|
|
||||||
vm_get_level = libc.VBVMR_GetLevel
|
bind_set_parameters = libc.VBVMR_SetParameters
|
||||||
vm_get_level.restype = LONG
|
bind_set_parameters.restype = LONG
|
||||||
vm_get_level.argtypes = [LONG, LONG, ct.POINTER(FLOAT)]
|
bind_set_parameters.argtypes = [ct.POINTER(CHAR)]
|
||||||
|
|
||||||
vm_get_num_indevices = libc.VBVMR_Input_GetDeviceNumber
|
bind_get_level = libc.VBVMR_GetLevel
|
||||||
vm_get_num_indevices.restype = LONG
|
bind_get_level.restype = LONG
|
||||||
vm_get_num_indevices.argtypes = None
|
bind_get_level.argtypes = [LONG, LONG, ct.POINTER(FLOAT)]
|
||||||
|
|
||||||
vm_get_desc_indevices = libc.VBVMR_Input_GetDeviceDescW
|
bind_input_get_device_number = libc.VBVMR_Input_GetDeviceNumber
|
||||||
vm_get_desc_indevices.restype = LONG
|
bind_input_get_device_number.restype = LONG
|
||||||
vm_get_desc_indevices.argtypes = [
|
bind_input_get_device_number.argtypes = None
|
||||||
|
|
||||||
|
bind_input_get_device_desc_w = libc.VBVMR_Input_GetDeviceDescW
|
||||||
|
bind_input_get_device_desc_w.restype = LONG
|
||||||
|
bind_input_get_device_desc_w.argtypes = [
|
||||||
LONG,
|
LONG,
|
||||||
ct.POINTER(LONG),
|
ct.POINTER(LONG),
|
||||||
ct.POINTER(WCHAR * 256),
|
ct.POINTER(WCHAR * 256),
|
||||||
ct.POINTER(WCHAR * 256),
|
ct.POINTER(WCHAR * 256),
|
||||||
]
|
]
|
||||||
|
|
||||||
vm_get_num_outdevices = libc.VBVMR_Output_GetDeviceNumber
|
bind_output_get_device_number = libc.VBVMR_Output_GetDeviceNumber
|
||||||
vm_get_num_outdevices.restype = LONG
|
bind_output_get_device_number.restype = LONG
|
||||||
vm_get_num_outdevices.argtypes = None
|
bind_output_get_device_number.argtypes = None
|
||||||
|
|
||||||
vm_get_desc_outdevices = libc.VBVMR_Output_GetDeviceDescW
|
bind_output_get_device_desc_w = libc.VBVMR_Output_GetDeviceDescW
|
||||||
vm_get_desc_outdevices.restype = LONG
|
bind_output_get_device_desc_w.restype = LONG
|
||||||
vm_get_desc_outdevices.argtypes = [
|
bind_output_get_device_desc_w.argtypes = [
|
||||||
LONG,
|
LONG,
|
||||||
ct.POINTER(LONG),
|
ct.POINTER(LONG),
|
||||||
ct.POINTER(WCHAR * 256),
|
ct.POINTER(WCHAR * 256),
|
||||||
ct.POINTER(WCHAR * 256),
|
ct.POINTER(WCHAR * 256),
|
||||||
]
|
]
|
||||||
|
|
||||||
vm_get_midi_message = libc.VBVMR_GetMidiMessage
|
bind_get_midi_message = libc.VBVMR_GetMidiMessage
|
||||||
vm_get_midi_message.restype = LONG
|
bind_get_midi_message.restype = LONG
|
||||||
vm_get_midi_message.argtypes = [ct.POINTER(CHAR * 1024), LONG]
|
bind_get_midi_message.argtypes = [ct.POINTER(CHAR * 1024), LONG]
|
||||||
|
|
||||||
def call(self, func):
|
def call(self, func, *args, ok=(0,), ok_exp=None):
|
||||||
res = func()
|
try:
|
||||||
if res != 0:
|
res = func(*args)
|
||||||
raise CAPIError(f"Function {func.func.__name__} returned {res}")
|
if ok_exp is None:
|
||||||
|
if res not in ok:
|
||||||
|
raise CAPIError(func.__name__, res)
|
||||||
|
elif not ok_exp(res) and res not in ok:
|
||||||
|
raise CAPIError(func.__name__, res)
|
||||||
|
return res
|
||||||
|
except CAPIError as e:
|
||||||
|
self.logger_cbindings.exception(str(e))
|
||||||
|
raise
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
from .error import VMError
|
|
||||||
from .iremote import IRemote
|
from .iremote import IRemote
|
||||||
from .meta import action_prop
|
from .meta import action_fn
|
||||||
|
|
||||||
|
|
||||||
class Command(IRemote):
|
class Command(IRemote):
|
||||||
@@ -22,10 +21,9 @@ class Command(IRemote):
|
|||||||
(cls,),
|
(cls,),
|
||||||
{
|
{
|
||||||
**{
|
**{
|
||||||
param: action_prop(param)
|
param: action_fn(param) for param in ["show", "shutdown", "restart"]
|
||||||
for param in ["show", "shutdown", "restart"]
|
|
||||||
},
|
},
|
||||||
"hide": action_prop("show", val=0),
|
"hide": action_fn("show", val=0),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return CMD_cls(remote)
|
return CMD_cls(remote)
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
import itertools
|
import itertools
|
||||||
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from .error import VMError
|
||||||
|
|
||||||
|
try:
|
||||||
import tomllib
|
import tomllib
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
import tomli as tomllib
|
||||||
|
|
||||||
from .kinds import request_kind_map as kindmap
|
from .kinds import request_kind_map as kindmap
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class TOMLStrBuilder:
|
class TOMLStrBuilder:
|
||||||
"""builds a config profile, as a string, for the toml parser"""
|
"""builds a config profile, as a string, for the toml parser"""
|
||||||
@@ -28,10 +36,17 @@ class TOMLStrBuilder:
|
|||||||
+ [f"B{i} = false" for i in range(1, self.kind.virt_out + 1)]
|
+ [f"B{i} = false" for i in range(1, self.kind.virt_out + 1)]
|
||||||
)
|
)
|
||||||
self.phys_strip_params = self.virt_strip_params + [
|
self.phys_strip_params = self.virt_strip_params + [
|
||||||
"comp = 0.0",
|
"comp.knob = 0.0",
|
||||||
"gate = 0.0",
|
"gate.knob = 0.0",
|
||||||
|
"denoiser.knob = 0.0",
|
||||||
|
"eq.on = false",
|
||||||
|
]
|
||||||
|
self.bus_params = [
|
||||||
|
"mono = false",
|
||||||
|
"eq.on = false",
|
||||||
|
"mute = false",
|
||||||
|
"gain = 0.0",
|
||||||
]
|
]
|
||||||
self.bus_bool = ["mono = false", "eq = false", "mute = false"]
|
|
||||||
|
|
||||||
if profile == "reset":
|
if profile == "reset":
|
||||||
self.reset_config()
|
self.reset_config()
|
||||||
@@ -62,7 +77,7 @@ class TOMLStrBuilder:
|
|||||||
else self.virt_strip_params
|
else self.virt_strip_params
|
||||||
)
|
)
|
||||||
case "bus":
|
case "bus":
|
||||||
toml_str += ("\n").join(self.bus_bool)
|
toml_str += ("\n").join(self.bus_params)
|
||||||
case _:
|
case _:
|
||||||
pass
|
pass
|
||||||
return toml_str + "\n"
|
return toml_str + "\n"
|
||||||
@@ -70,7 +85,6 @@ class TOMLStrBuilder:
|
|||||||
|
|
||||||
class TOMLDataExtractor:
|
class TOMLDataExtractor:
|
||||||
def __init__(self, file):
|
def __init__(self, file):
|
||||||
self._data = dict()
|
|
||||||
with open(file, "rb") as f:
|
with open(file, "rb") as f:
|
||||||
self._data = tomllib.load(f)
|
self._data = tomllib.load(f)
|
||||||
|
|
||||||
@@ -118,6 +132,7 @@ class Loader(metaclass=SingletonType):
|
|||||||
|
|
||||||
def __init__(self, kind):
|
def __init__(self, kind):
|
||||||
self._kind = kind
|
self._kind = kind
|
||||||
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
self._configs = dict()
|
self._configs = dict()
|
||||||
self.defaults(kind)
|
self.defaults(kind)
|
||||||
self.parser = None
|
self.parser = None
|
||||||
@@ -129,14 +144,21 @@ class Loader(metaclass=SingletonType):
|
|||||||
|
|
||||||
def parse(self, identifier, data):
|
def parse(self, identifier, data):
|
||||||
if identifier in self._configs:
|
if identifier in self._configs:
|
||||||
print(f"config file with name {identifier} already in memory, skipping..")
|
self.logger.info(
|
||||||
return False
|
f"config file with name {identifier} already in memory, skipping.."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
try:
|
||||||
self.parser = dataextraction_factory(data)
|
self.parser = dataextraction_factory(data)
|
||||||
|
except tomllib.TOMLDecodeError as e:
|
||||||
|
ERR_MSG = (str(e), f"When attempting to load {identifier}.toml")
|
||||||
|
self.logger.error(f"{type(e).__name__}: {' '.join(ERR_MSG)}")
|
||||||
|
return
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def register(self, identifier, data=None):
|
def register(self, identifier, data=None):
|
||||||
self._configs[identifier] = data if data else self.parser.data
|
self._configs[identifier] = data if data else self.parser.data
|
||||||
print(f"config {self.name}/{identifier} loaded into memory")
|
self.logger.info(f"config {self.name}/{identifier} loaded into memory")
|
||||||
|
|
||||||
def deregister(self):
|
def deregister(self):
|
||||||
self._configs.clear()
|
self._configs.clear()
|
||||||
@@ -159,15 +181,16 @@ def loader(kind):
|
|||||||
|
|
||||||
returns configs loaded into memory
|
returns configs loaded into memory
|
||||||
"""
|
"""
|
||||||
|
logger_loader = logger.getChild("loader")
|
||||||
loader = Loader(kind)
|
loader = Loader(kind)
|
||||||
|
|
||||||
for path in (
|
for path in (
|
||||||
Path.cwd() / "configs" / kind.name,
|
Path.cwd() / "configs" / kind.name,
|
||||||
Path(__file__).parent / "configs" / kind.name,
|
Path.home() / ".config" / "voicemeeter" / kind.name,
|
||||||
Path.home() / "Documents/Voicemeeter" / "configs" / kind.name,
|
Path.home() / "Documents" / "Voicemeeter" / "configs" / kind.name,
|
||||||
):
|
):
|
||||||
if path.is_dir():
|
if path.is_dir():
|
||||||
print(f"Checking [{path}] for TOML config files:")
|
logger_loader.info(f"Checking [{path}] for TOML config files:")
|
||||||
for file in path.glob("*.toml"):
|
for file in path.glob("*.toml"):
|
||||||
identifier = file.with_suffix("").stem
|
identifier = file.with_suffix("").stem
|
||||||
if loader.parse(identifier, file):
|
if loader.parse(identifier, file):
|
||||||
@@ -184,5 +207,5 @@ def request_config(kind_id: str):
|
|||||||
try:
|
try:
|
||||||
configs = loader(kindmap(kind_id))
|
configs = loader(kindmap(kind_id))
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
print(f"Unknown Voicemeeter kind '{kind_id}'")
|
raise VMError(f"Unknown Voicemeeter kind {kind_id}") from e
|
||||||
return configs
|
return configs
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
class InstallError(Exception):
|
|
||||||
"""errors related to installation"""
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class CAPIError(Exception):
|
|
||||||
"""errors related to low-level C API calls"""
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class VMError(Exception):
|
class VMError(Exception):
|
||||||
"""general errors"""
|
"""Base VM Exception class. Raised when general errors occur."""
|
||||||
|
|
||||||
pass
|
def __init__(self, msg):
|
||||||
|
self.message = msg
|
||||||
|
super().__init__(self.message)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return f"{type(self).__name__}: {self.message}"
|
||||||
|
|
||||||
|
|
||||||
|
class InstallError(VMError):
|
||||||
|
"""Exception raised when installation errors occur"""
|
||||||
|
|
||||||
|
|
||||||
|
class CAPIError(VMError):
|
||||||
|
"""Exception raised when the C-API returns an error code"""
|
||||||
|
|
||||||
|
def __init__(self, fn_name, code, msg=None):
|
||||||
|
self.fn_name = fn_name
|
||||||
|
self.code = code
|
||||||
|
super(CAPIError, self).__init__(msg if msg else f"{fn_name} returned {code}")
|
||||||
|
|||||||
74
voicemeeterlib/event.py
Normal file
74
voicemeeterlib/event.py
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import logging
|
||||||
|
from typing import Iterable, Union
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Event:
|
||||||
|
"""Keeps track of event subscriptions"""
|
||||||
|
|
||||||
|
def __init__(self, subs: dict):
|
||||||
|
self.subs = subs
|
||||||
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
|
|
||||||
|
def info(self, msg=None):
|
||||||
|
info = (f"{msg} events",) if msg else ()
|
||||||
|
if self.any():
|
||||||
|
info += (f"now listening for {', '.join(self.get())} events",)
|
||||||
|
else:
|
||||||
|
info += (f"not listening for any events",)
|
||||||
|
self.logger.info(", ".join(info))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pdirty(self) -> bool:
|
||||||
|
return self.subs["pdirty"]
|
||||||
|
|
||||||
|
@pdirty.setter
|
||||||
|
def pdirty(self, val: bool):
|
||||||
|
self.subs["pdirty"] = val
|
||||||
|
self.info(f"pdirty {'added to' if val else 'removed from'}")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mdirty(self) -> bool:
|
||||||
|
return self.subs["mdirty"]
|
||||||
|
|
||||||
|
@mdirty.setter
|
||||||
|
def mdirty(self, val: bool):
|
||||||
|
self.subs["mdirty"] = val
|
||||||
|
self.info(f"mdirty {'added to' if val else 'removed from'}")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def midi(self) -> bool:
|
||||||
|
return self.subs["midi"]
|
||||||
|
|
||||||
|
@midi.setter
|
||||||
|
def midi(self, val: bool):
|
||||||
|
self.subs["midi"] = val
|
||||||
|
self.info(f"midi {'added to' if val else 'removed from'}")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ldirty(self) -> bool:
|
||||||
|
return self.subs["ldirty"]
|
||||||
|
|
||||||
|
@ldirty.setter
|
||||||
|
def ldirty(self, val: bool):
|
||||||
|
self.subs["ldirty"] = val
|
||||||
|
self.info(f"ldirty {'added to' if val else 'removed from'}")
|
||||||
|
|
||||||
|
def get(self) -> list:
|
||||||
|
return [k for k, v in self.subs.items() if v]
|
||||||
|
|
||||||
|
def any(self) -> bool:
|
||||||
|
return any(self.subs.values())
|
||||||
|
|
||||||
|
def add(self, events: Union[str, Iterable[str]]):
|
||||||
|
if isinstance(events, str):
|
||||||
|
events = [events]
|
||||||
|
for event in events:
|
||||||
|
setattr(self, event, True)
|
||||||
|
|
||||||
|
def remove(self, events: Union[str, Iterable[str]]):
|
||||||
|
if isinstance(events, str):
|
||||||
|
events = [events]
|
||||||
|
for event in events:
|
||||||
|
setattr(self, event, False)
|
||||||
@@ -1,21 +1,25 @@
|
|||||||
|
import logging
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from enum import IntEnum
|
from enum import IntEnum
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from typing import Iterable, NoReturn, Self
|
from typing import Iterable
|
||||||
|
|
||||||
from . import misc
|
from . import misc
|
||||||
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
|
||||||
from .config import request_config as configs
|
from .config import request_config as configs
|
||||||
from .device import Device
|
from .device import Device
|
||||||
|
from .error import VMError
|
||||||
from .kinds import KindMapClass
|
from .kinds import KindMapClass
|
||||||
from .kinds import request_kind_map as kindmap
|
from .kinds import request_kind_map as kindmap
|
||||||
from .macrobutton import MacroButton
|
from .macrobutton import MacroButton
|
||||||
from .recorder import Recorder
|
from .recorder import Recorder
|
||||||
|
from .remote import Remote
|
||||||
from .strip import request_strip_obj as strip
|
from .strip import request_strip_obj as strip
|
||||||
from .vban import request_vban_obj as vban
|
from .vban import request_vban_obj as vban
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class FactoryBuilder:
|
class FactoryBuilder:
|
||||||
"""
|
"""
|
||||||
@@ -45,55 +49,56 @@ class FactoryBuilder:
|
|||||||
f"Finished building patch for {self._factory}",
|
f"Finished building patch for {self._factory}",
|
||||||
f"Finished building fx for {self._factory}",
|
f"Finished building fx for {self._factory}",
|
||||||
)
|
)
|
||||||
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
|
|
||||||
def _pinfo(self, name: str) -> NoReturn:
|
def _pinfo(self, name: str) -> None:
|
||||||
"""prints progress status for each step"""
|
"""prints progress status for each step"""
|
||||||
name = name.split("_")[1]
|
name = name.split("_")[1]
|
||||||
print(self._info[int(getattr(self.BuilderProgress, name))])
|
self.logger.debug(self._info[int(getattr(self.BuilderProgress, name))])
|
||||||
|
|
||||||
def make_strip(self) -> Self:
|
def make_strip(self):
|
||||||
self._factory.strip = tuple(
|
self._factory.strip = tuple(
|
||||||
strip(i < self.kind.phys_in, self._factory, i)
|
strip(i < self.kind.phys_in, self._factory, i)
|
||||||
for i in range(self.kind.num_strip)
|
for i in range(self.kind.num_strip)
|
||||||
)
|
)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def make_bus(self) -> Self:
|
def make_bus(self):
|
||||||
self._factory.bus = tuple(
|
self._factory.bus = tuple(
|
||||||
bus(i < self.kind.phys_out, self._factory, i)
|
bus(i < self.kind.phys_out, self._factory, i)
|
||||||
for i in range(self.kind.num_bus)
|
for i in range(self.kind.num_bus)
|
||||||
)
|
)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def make_command(self) -> Self:
|
def make_command(self):
|
||||||
self._factory.command = Command.make(self._factory)
|
self._factory.command = Command.make(self._factory)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def make_macrobutton(self) -> Self:
|
def make_macrobutton(self):
|
||||||
self._factory.button = tuple(MacroButton(self._factory, i) for i in range(80))
|
self._factory.button = tuple(MacroButton(self._factory, i) for i in range(80))
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def make_vban(self) -> Self:
|
def make_vban(self):
|
||||||
self._factory.vban = vban(self._factory)
|
self._factory.vban = vban(self._factory)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def make_device(self) -> Self:
|
def make_device(self):
|
||||||
self._factory.device = Device.make(self._factory)
|
self._factory.device = Device.make(self._factory)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def make_option(self) -> Self:
|
def make_option(self):
|
||||||
self._factory.option = misc.Option.make(self._factory)
|
self._factory.option = misc.Option.make(self._factory)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def make_recorder(self) -> Self:
|
def make_recorder(self):
|
||||||
self._factory.recorder = Recorder.make(self._factory)
|
self._factory.recorder = Recorder.make(self._factory)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def make_patch(self) -> Self:
|
def make_patch(self):
|
||||||
self._factory.patch = misc.Patch.make(self._factory)
|
self._factory.patch = misc.Patch.make(self._factory)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def make_fx(self) -> Self:
|
def make_fx(self):
|
||||||
self._factory.fx = misc.FX(self._factory)
|
self._factory.fx = misc.FX(self._factory)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@@ -102,10 +107,16 @@ class FactoryBase(Remote):
|
|||||||
"""Base class for factories, subclasses Remote."""
|
"""Base class for factories, subclasses Remote."""
|
||||||
|
|
||||||
def __init__(self, kind_id: str, **kwargs):
|
def __init__(self, kind_id: str, **kwargs):
|
||||||
defaultevents = {"pdirty": True, "mdirty": True, "midi": True, "ldirty": False}
|
defaultkwargs = {
|
||||||
|
"sync": False,
|
||||||
|
"ratelimit": 0.033,
|
||||||
|
"pdirty": False,
|
||||||
|
"mdirty": False,
|
||||||
|
"midi": False,
|
||||||
|
"ldirty": False,
|
||||||
|
}
|
||||||
if "subs" in kwargs:
|
if "subs" in kwargs:
|
||||||
defaultevents = defaultevents | kwargs.pop("subs")
|
defaultkwargs |= kwargs.pop("subs") # for backwards compatibility
|
||||||
defaultkwargs = {"sync": False, "ratelimit": 0.033, "subs": defaultevents}
|
|
||||||
kwargs = defaultkwargs | kwargs
|
kwargs = defaultkwargs | kwargs
|
||||||
self.kind = kindmap(kind_id)
|
self.kind = kindmap(kind_id)
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
@@ -229,9 +240,13 @@ def request_remote_obj(kind_id: str, **kwargs) -> Remote:
|
|||||||
|
|
||||||
Returns a reference to a Remote class of a kind
|
Returns a reference to a Remote class of a kind
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
logger_entry = logger.getChild("request_remote_obj")
|
||||||
|
|
||||||
REMOTE_obj = None
|
REMOTE_obj = None
|
||||||
try:
|
try:
|
||||||
REMOTE_obj = remote_factory(kind_id, **kwargs)
|
REMOTE_obj = remote_factory(kind_id, **kwargs)
|
||||||
except (ValueError, TypeError) as e:
|
except (ValueError, TypeError) as e:
|
||||||
raise SystemExit(e)
|
logger_entry.exception(f"{type(e).__name__}: {e}")
|
||||||
|
raise VMError(str(e)) from e
|
||||||
return REMOTE_obj
|
return REMOTE_obj
|
||||||
|
|||||||
@@ -25,17 +25,19 @@ def get_vmpath():
|
|||||||
with winreg.OpenKey(
|
with winreg.OpenKey(
|
||||||
winreg.HKEY_LOCAL_MACHINE, r"{}".format(REG_KEY + "\\" + VM_KEY)
|
winreg.HKEY_LOCAL_MACHINE, r"{}".format(REG_KEY + "\\" + VM_KEY)
|
||||||
) as vm_key:
|
) as vm_key:
|
||||||
path = winreg.QueryValueEx(vm_key, r"UninstallString")[0]
|
return winreg.QueryValueEx(vm_key, r"UninstallString")[0]
|
||||||
return path
|
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
vm_path = Path(get_vmpath())
|
vm_path = Path(get_vmpath())
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
raise InstallError(f"Unable to fetch DLL path from the registry") from e
|
||||||
vm_parent = vm_path.parent
|
vm_parent = vm_path.parent
|
||||||
|
|
||||||
DLL_NAME = f'VoicemeeterRemote{"64" if bits == 64 else ""}.dll'
|
DLL_NAME = f'VoicemeeterRemote{"64" if bits == 64 else ""}.dll'
|
||||||
|
|
||||||
dll_path = vm_parent.joinpath(DLL_NAME)
|
dll_path = vm_parent.joinpath(DLL_NAME)
|
||||||
if not dll_path.is_file():
|
if not dll_path.is_file():
|
||||||
raise InstallError(f"Could not find {DLL_NAME}")
|
raise InstallError(f"Could not find {dll_path}")
|
||||||
|
|
||||||
libc = ct.CDLL(str(dll_path))
|
libc = ct.CDLL(str(dll_path))
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import logging
|
||||||
import time
|
import time
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
from typing import Self
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class IRemote(metaclass=ABCMeta):
|
class IRemote(metaclass=ABCMeta):
|
||||||
@@ -13,29 +15,44 @@ class IRemote(metaclass=ABCMeta):
|
|||||||
def __init__(self, remote, index=None):
|
def __init__(self, remote, index=None):
|
||||||
self._remote = remote
|
self._remote = remote
|
||||||
self.index = index
|
self.index = index
|
||||||
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
|
|
||||||
def getter(self, param, **kwargs):
|
def getter(self, param, **kwargs):
|
||||||
"""Gets a parameter value"""
|
"""Gets a parameter value"""
|
||||||
return self._remote.get(f"{self.identifier}.{param}", **kwargs)
|
self.logger.debug(f"getter: {self._cmd(param)}")
|
||||||
|
return self._remote.get(self._cmd(param), **kwargs)
|
||||||
|
|
||||||
def setter(self, param, val):
|
def setter(self, param, val):
|
||||||
"""Sets a parameter value"""
|
"""Sets a parameter value"""
|
||||||
self._remote.set(f"{self.identifier}.{param}", val)
|
self.logger.debug(f"setter: {self._cmd(param)}={val}")
|
||||||
|
self._remote.set(self._cmd(param), val)
|
||||||
|
|
||||||
|
def _cmd(self, param):
|
||||||
|
cmd = (self.identifier,)
|
||||||
|
if param:
|
||||||
|
cmd += (f".{param}",)
|
||||||
|
return "".join(cmd)
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def identifier(self):
|
def identifier(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def apply(self, data: dict) -> Self:
|
def apply(self, data: dict):
|
||||||
def fget(attr, val):
|
def fget(attr, val):
|
||||||
if attr == "mode":
|
if attr == "mode":
|
||||||
return (getattr(self, attr), val, 1)
|
return (getattr(self, attr), val, 1)
|
||||||
return (self, attr, val)
|
return (self, attr, val)
|
||||||
|
|
||||||
for attr, val in data.items():
|
for attr, val in data.items():
|
||||||
if hasattr(self, attr):
|
if not isinstance(val, dict):
|
||||||
|
if attr in dir(self): # avoid calling getattr (with hasattr)
|
||||||
target, attr, val = fget(attr, val)
|
target, attr, val = fget(attr, val)
|
||||||
setattr(target, attr, val)
|
setattr(target, attr, val)
|
||||||
|
else:
|
||||||
|
self.logger.error(f"invalid attribute {attr} for {self}")
|
||||||
|
else:
|
||||||
|
target = getattr(self, attr)
|
||||||
|
target.apply(val)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def then_wait(self):
|
def then_wait(self):
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from enum import Enum, unique
|
from enum import Enum, unique
|
||||||
|
|
||||||
|
from .error import VMError
|
||||||
|
|
||||||
|
|
||||||
@unique
|
@unique
|
||||||
class KindId(Enum):
|
class KindId(Enum):
|
||||||
@@ -30,29 +32,37 @@ class KindMapClass(metaclass=SingletonType):
|
|||||||
insert: int
|
insert: int
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def phys_in(self):
|
def phys_in(self) -> int:
|
||||||
return self.ins[0]
|
return self.ins[0]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def virt_in(self):
|
def virt_in(self) -> int:
|
||||||
return self.ins[-1]
|
return self.ins[-1]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def phys_out(self):
|
def phys_out(self) -> int:
|
||||||
return self.outs[0]
|
return self.outs[0]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def virt_out(self):
|
def virt_out(self) -> int:
|
||||||
return self.outs[-1]
|
return self.outs[-1]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def num_strip(self):
|
def num_strip(self) -> int:
|
||||||
return sum(self.ins)
|
return sum(self.ins)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def num_bus(self):
|
def num_bus(self) -> int:
|
||||||
return sum(self.outs)
|
return sum(self.outs)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def num_strip_levels(self) -> int:
|
||||||
|
return 2 * self.phys_in + 8 * self.virt_in
|
||||||
|
|
||||||
|
@property
|
||||||
|
def num_bus_levels(self) -> int:
|
||||||
|
return 8 * (self.phys_out + self.virt_out)
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return self.name.capitalize()
|
return self.name.capitalize()
|
||||||
|
|
||||||
@@ -62,7 +72,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)
|
||||||
asio: tuple = (0, 0)
|
asio: tuple = (0, 0)
|
||||||
insert: int = 0
|
insert: int = 0
|
||||||
|
|
||||||
@@ -72,7 +82,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)
|
||||||
asio: tuple = (6, 8)
|
asio: tuple = (6, 8)
|
||||||
insert: int = 22
|
insert: int = 22
|
||||||
|
|
||||||
@@ -82,7 +92,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)
|
||||||
asio: tuple = (10, 8)
|
asio: tuple = (10, 8)
|
||||||
insert: int = 34
|
insert: int = 34
|
||||||
|
|
||||||
@@ -105,7 +115,7 @@ def request_kind_map(kind_id):
|
|||||||
try:
|
try:
|
||||||
KIND_obj = kind_factory(kind_id)
|
KIND_obj = kind_factory(kind_id)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
print(e)
|
raise VMError(str(e)) from e
|
||||||
return KIND_obj
|
return KIND_obj
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,13 @@
|
|||||||
from .error import VMError
|
from enum import IntEnum
|
||||||
|
|
||||||
from .iremote import IRemote
|
from .iremote import IRemote
|
||||||
|
|
||||||
|
ButtonModes = IntEnum(
|
||||||
|
"ButtonModes",
|
||||||
|
"state stateonly trigger",
|
||||||
|
start=1,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Adapter(IRemote):
|
class Adapter(IRemote):
|
||||||
"""Adapter to the common interface."""
|
"""Adapter to the common interface."""
|
||||||
@@ -9,9 +16,13 @@ class Adapter(IRemote):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def getter(self, mode):
|
def getter(self, mode):
|
||||||
|
self.logger.debug(f"getter: button[{self.index}].{ButtonModes(mode).name}")
|
||||||
return self._remote.get_buttonstatus(self.index, mode)
|
return self._remote.get_buttonstatus(self.index, mode)
|
||||||
|
|
||||||
def setter(self, val, mode):
|
def setter(self, mode, val):
|
||||||
|
self.logger.debug(
|
||||||
|
f"setter: button[{self.index}].{ButtonModes(mode).name}={val}"
|
||||||
|
)
|
||||||
self._remote.set_buttonstatus(self.index, val, mode)
|
self._remote.set_buttonstatus(self.index, val, mode)
|
||||||
|
|
||||||
|
|
||||||
@@ -23,24 +34,24 @@ class MacroButton(Adapter):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self) -> bool:
|
def state(self) -> bool:
|
||||||
return self.getter(1) == 1
|
return self.getter(ButtonModes.state) == 1
|
||||||
|
|
||||||
@state.setter
|
@state.setter
|
||||||
def state(self, val):
|
def state(self, val: bool):
|
||||||
self.setter(1 if val else 0, 1)
|
self.setter(ButtonModes.state, 1 if val else 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def stateonly(self) -> bool:
|
def stateonly(self) -> bool:
|
||||||
return self.getter(2) == 1
|
return self.getter(ButtonModes.stateonly) == 1
|
||||||
|
|
||||||
@stateonly.setter
|
@stateonly.setter
|
||||||
def stateonly(self, val):
|
def stateonly(self, val: bool):
|
||||||
self.setter(1 if val else 0, 2)
|
self.setter(ButtonModes.stateonly, 1 if val else 0)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def trigger(self) -> bool:
|
def trigger(self) -> bool:
|
||||||
return self.getter(3) == 1
|
return self.getter(ButtonModes.trigger) == 1
|
||||||
|
|
||||||
@trigger.setter
|
@trigger.setter
|
||||||
def trigger(self, val):
|
def trigger(self, val: bool):
|
||||||
self.setter(1 if val else 0, 3)
|
self.setter(ButtonModes.trigger, 1 if val else 0)
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ def float_prop(param):
|
|||||||
return property(fget, fset)
|
return property(fget, fset)
|
||||||
|
|
||||||
|
|
||||||
def action_prop(param, val: int = 1):
|
def action_fn(param, val: int = 1):
|
||||||
"""A param that performs an action"""
|
"""meta function that performs an action"""
|
||||||
|
|
||||||
def fdo(self):
|
def fdo(self):
|
||||||
self.setter(param, val)
|
self.setter(param, val)
|
||||||
@@ -42,3 +42,12 @@ def bus_mode_prop(param):
|
|||||||
self.setter(param, 1 if val else 0)
|
self.setter(param, 1 if val else 0)
|
||||||
|
|
||||||
return property(fget, fset)
|
return property(fget, fset)
|
||||||
|
|
||||||
|
|
||||||
|
def device_prop(param):
|
||||||
|
"""meta function for strip device parameters"""
|
||||||
|
|
||||||
|
def fset(self, val: str):
|
||||||
|
self.setter(param, val)
|
||||||
|
|
||||||
|
return property(fset=fset)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from .error import VMError
|
|
||||||
from .iremote import IRemote
|
from .iremote import IRemote
|
||||||
from .kinds import kinds_all
|
from .kinds import kinds_all
|
||||||
|
|
||||||
@@ -196,7 +195,7 @@ class Option(IRemote):
|
|||||||
def sr(self, val: int):
|
def sr(self, val: int):
|
||||||
opts = (44100, 48000, 88200, 96000, 176400, 192000)
|
opts = (44100, 48000, 88200, 96000, 176400, 192000)
|
||||||
if val not in opts:
|
if val not in opts:
|
||||||
raise VMError(f"Expected one of: {opts}")
|
self.logger.warning(f"sr got: {val} but expected a value in {opts}")
|
||||||
self.setter("sr", val)
|
self.setter("sr", val)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -252,43 +251,17 @@ class Midi:
|
|||||||
self.cache[key] = velocity
|
self.cache[key] = velocity
|
||||||
|
|
||||||
|
|
||||||
class Event:
|
class VmGui:
|
||||||
def __init__(self, subs: dict):
|
_launched = None
|
||||||
self.subs = subs
|
|
||||||
|
|
||||||
def info(self, msg):
|
|
||||||
info = (
|
|
||||||
f"{msg} events",
|
|
||||||
f"Now listening for {', '.join(self.get())} events",
|
|
||||||
)
|
|
||||||
print("\n".join(info))
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pdirty(self):
|
def launched(self) -> bool:
|
||||||
return self.subs["pdirty"]
|
return self._launched
|
||||||
|
|
||||||
|
@launched.setter
|
||||||
|
def launched(self, val: bool):
|
||||||
|
self._launched = val
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mdirty(self):
|
def launched_by_api(self):
|
||||||
return self.subs["mdirty"]
|
return not self.launched
|
||||||
|
|
||||||
@property
|
|
||||||
def midi(self):
|
|
||||||
return self.subs["midi"]
|
|
||||||
|
|
||||||
@property
|
|
||||||
def ldirty(self):
|
|
||||||
return self.subs["ldirty"]
|
|
||||||
|
|
||||||
def get(self) -> list:
|
|
||||||
return [k for k, v in self.subs.items() if v]
|
|
||||||
|
|
||||||
def any(self) -> bool:
|
|
||||||
return any(self.subs.values())
|
|
||||||
|
|
||||||
def add(self, event):
|
|
||||||
self.subs[event] = True
|
|
||||||
self.info(f"{event} added to")
|
|
||||||
|
|
||||||
def remove(self, event):
|
|
||||||
self.subs[event] = False
|
|
||||||
self.info(f"{event} removed from")
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
from .error import VMError
|
from .error import VMError
|
||||||
from .iremote import IRemote
|
from .iremote import IRemote
|
||||||
from .kinds import kinds_all
|
from .kinds import kinds_all
|
||||||
from .meta import action_prop, bool_prop
|
from .meta import action_fn, bool_prop
|
||||||
|
|
||||||
|
|
||||||
class Recorder(IRemote):
|
class Recorder(IRemote):
|
||||||
@@ -19,12 +21,13 @@ class Recorder(IRemote):
|
|||||||
Returns a Recorder class of a kind.
|
Returns a Recorder class of a kind.
|
||||||
"""
|
"""
|
||||||
CHANNELOUTMIXIN_cls = _make_channelout_mixins[remote.kind.name]
|
CHANNELOUTMIXIN_cls = _make_channelout_mixins[remote.kind.name]
|
||||||
|
ARMCHANNELMIXIN_cls = _make_armchannel_mixins(remote)[remote.kind.name]
|
||||||
REC_cls = type(
|
REC_cls = type(
|
||||||
f"Recorder{remote.kind}",
|
f"Recorder{remote.kind}",
|
||||||
(cls, CHANNELOUTMIXIN_cls),
|
(cls, CHANNELOUTMIXIN_cls, ARMCHANNELMIXIN_cls),
|
||||||
{
|
{
|
||||||
**{
|
**{
|
||||||
param: action_prop(param)
|
param: action_fn(param)
|
||||||
for param in [
|
for param in [
|
||||||
"play",
|
"play",
|
||||||
"stop",
|
"stop",
|
||||||
@@ -35,6 +38,7 @@ class Recorder(IRemote):
|
|||||||
"rew",
|
"rew",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"mode": RecorderMode(remote),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return REC_cls(remote)
|
return REC_cls(remote)
|
||||||
@@ -46,20 +50,183 @@ class Recorder(IRemote):
|
|||||||
def identifier(self) -> str:
|
def identifier(self) -> str:
|
||||||
return "recorder"
|
return "recorder"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def samplerate(self) -> int:
|
||||||
|
return int(self.getter("samplerate"))
|
||||||
|
|
||||||
|
@samplerate.setter
|
||||||
|
def samplerate(self, val: int):
|
||||||
|
opts = (22050, 24000, 32000, 44100, 48000, 88200, 96000, 176400, 192000)
|
||||||
|
if val not in opts:
|
||||||
|
self.logger.warning(f"samplerate got: {val} but expected a value in {opts}")
|
||||||
|
self.setter("samplerate", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def bitresolution(self) -> int:
|
||||||
|
return int(self.getter("bitresolution"))
|
||||||
|
|
||||||
|
@bitresolution.setter
|
||||||
|
def bitresolution(self, val: int):
|
||||||
|
opts = (8, 16, 24, 32)
|
||||||
|
if val not in opts:
|
||||||
|
self.logger.warning(
|
||||||
|
f"bitresolution got: {val} but expected a value in {opts}"
|
||||||
|
)
|
||||||
|
self.setter("bitresolution", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def channel(self) -> int:
|
||||||
|
return int(self.getter("channel"))
|
||||||
|
|
||||||
|
@channel.setter
|
||||||
|
def channel(self, val: int):
|
||||||
|
if not 1 <= val <= 8:
|
||||||
|
self.logger.warning(f"channel got: {val} but expected a value from 1 to 8")
|
||||||
|
self.setter("channel", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def kbps(self):
|
||||||
|
return int(self.getter("kbps"))
|
||||||
|
|
||||||
|
@kbps.setter
|
||||||
|
def kbps(self, val: int):
|
||||||
|
opts = (32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320)
|
||||||
|
if val not in opts:
|
||||||
|
self.logger.warning(f"kbps got: {val} but expected a value in {opts}")
|
||||||
|
self.setter("kbps", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def gain(self) -> float:
|
||||||
|
return round(self.getter("gain"), 1)
|
||||||
|
|
||||||
|
@gain.setter
|
||||||
|
def gain(self, val: float):
|
||||||
|
self.setter("gain", val)
|
||||||
|
|
||||||
def load(self, file: str):
|
def load(self, file: str):
|
||||||
try:
|
try:
|
||||||
self.setter("load", file)
|
self.setter("load", file)
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
raise VMError("File full directory must be a raw string")
|
raise VMError("File full directory must be a raw string")
|
||||||
|
|
||||||
def set_loop(self, val: bool):
|
# loop forwarder methods, for backwards compatibility
|
||||||
self.setter("mode.loop", 1 if val else 0)
|
@property
|
||||||
|
def loop(self):
|
||||||
|
return self.mode.loop
|
||||||
|
|
||||||
loop = property(fset=set_loop)
|
@loop.setter
|
||||||
|
def loop(self, val: bool):
|
||||||
|
self.mode.loop = val
|
||||||
|
|
||||||
|
def goto(self, time_str):
|
||||||
|
def get_sec():
|
||||||
|
"""Get seconds from time string"""
|
||||||
|
h, m, s = time_str.split(":")
|
||||||
|
return int(h) * 3600 + int(m) * 60 + int(s)
|
||||||
|
|
||||||
|
time_str = str(time_str) # coerce the type
|
||||||
|
if (
|
||||||
|
match := re.match(
|
||||||
|
r"^(?:[01]\d|2[0123]):(?:[012345]\d):(?:[012345]\d)$",
|
||||||
|
time_str,
|
||||||
|
)
|
||||||
|
is not None
|
||||||
|
):
|
||||||
|
self.setter("goto", get_sec())
|
||||||
|
else:
|
||||||
|
self.logger.warning(
|
||||||
|
f"goto expects a string that matches the format 'hh:mm:ss'"
|
||||||
|
)
|
||||||
|
|
||||||
|
def filetype(self, val: str):
|
||||||
|
opts = {"wav": 1, "aiff": 2, "bwf": 3, "mp3": 100}
|
||||||
|
try:
|
||||||
|
self.setter("filetype", opts[val.lower()])
|
||||||
|
except KeyError:
|
||||||
|
self.logger.warning(
|
||||||
|
f"filetype got: {val} but expected a value in {list(opts.keys())}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class RecorderMode(IRemote):
|
||||||
|
@property
|
||||||
|
def identifier(self):
|
||||||
|
return "recorder.mode"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def recbus(self) -> bool:
|
||||||
|
return self.getter("recbus") == 1
|
||||||
|
|
||||||
|
@recbus.setter
|
||||||
|
def recbus(self, val: bool):
|
||||||
|
self.setter("recbus", 1 if val else 0)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def playonload(self) -> bool:
|
||||||
|
return self.getter("playonload") == 1
|
||||||
|
|
||||||
|
@playonload.setter
|
||||||
|
def playonload(self, val: bool):
|
||||||
|
self.setter("playonload", 1 if val else 0)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def loop(self) -> bool:
|
||||||
|
return self.getter("loop") == 1
|
||||||
|
|
||||||
|
@loop.setter
|
||||||
|
def loop(self, val: bool):
|
||||||
|
self.setter("loop", 1 if val else 0)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def multitrack(self) -> bool:
|
||||||
|
return self.getter("multitrack") == 1
|
||||||
|
|
||||||
|
@multitrack.setter
|
||||||
|
def multitrack(self, val: bool):
|
||||||
|
self.setter("multitrack", 1 if val else 0)
|
||||||
|
|
||||||
|
|
||||||
|
class RecorderArmChannel(IRemote):
|
||||||
|
def __init__(self, remote, i):
|
||||||
|
super().__init__(remote)
|
||||||
|
self._i = i
|
||||||
|
|
||||||
|
def set(self, val: bool):
|
||||||
|
self.setter("", 1 if val else 0)
|
||||||
|
|
||||||
|
|
||||||
|
class RecorderArmStrip(RecorderArmChannel):
|
||||||
|
@property
|
||||||
|
def identifier(self):
|
||||||
|
return f"recorder.armstrip[{self._i}]"
|
||||||
|
|
||||||
|
|
||||||
|
class RecorderArmBus(RecorderArmChannel):
|
||||||
|
@property
|
||||||
|
def identifier(self):
|
||||||
|
return f"recorder.armbus[{self._i}]"
|
||||||
|
|
||||||
|
|
||||||
|
def _make_armchannel_mixin(remote, kind):
|
||||||
|
"""Creates an armchannel out mixin"""
|
||||||
|
return type(
|
||||||
|
f"ArmChannelMixin{kind}",
|
||||||
|
(),
|
||||||
|
{
|
||||||
|
"armstrip": tuple(
|
||||||
|
RecorderArmStrip(remote, i) for i in range(kind.num_strip)
|
||||||
|
),
|
||||||
|
"armbus": tuple(RecorderArmBus(remote, i) for i in range(kind.num_bus)),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _make_armchannel_mixins(remote):
|
||||||
|
return {kind.name: _make_armchannel_mixin(remote, kind) for kind in kinds_all}
|
||||||
|
|
||||||
|
|
||||||
def _make_channelout_mixin(kind):
|
def _make_channelout_mixin(kind):
|
||||||
"""Creates a channel out property mixin"""
|
"""Creates a channel out mixin"""
|
||||||
return type(
|
return type(
|
||||||
f"ChannelOutMixin{kind}",
|
f"ChannelOutMixin{kind}",
|
||||||
(),
|
(),
|
||||||
|
|||||||
353
voicemeeterlib/remote.py
Normal file
353
voicemeeterlib/remote.py
Normal file
@@ -0,0 +1,353 @@
|
|||||||
|
import ctypes as ct
|
||||||
|
import logging
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
from abc import abstractmethod
|
||||||
|
from queue import Queue
|
||||||
|
from typing import Iterable, Optional, Union
|
||||||
|
|
||||||
|
from .cbindings import CBindings
|
||||||
|
from .error import CAPIError, VMError
|
||||||
|
from .event import Event
|
||||||
|
from .inst import bits
|
||||||
|
from .kinds import KindId
|
||||||
|
from .misc import Midi, VmGui
|
||||||
|
from .subject import Subject
|
||||||
|
from .updater import Producer, Updater
|
||||||
|
from .util import deep_merge, grouper, polling, script
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Remote(CBindings):
|
||||||
|
"""Base class responsible for wrapping the C Remote API"""
|
||||||
|
|
||||||
|
DELAY = 0.001
|
||||||
|
|
||||||
|
def __init__(self, **kwargs):
|
||||||
|
self.strip_mode = 0
|
||||||
|
self.cache = {}
|
||||||
|
self.midi = Midi()
|
||||||
|
self.subject = self.observer = Subject()
|
||||||
|
self.event = Event(
|
||||||
|
{k: kwargs.pop(k) for k in ("pdirty", "mdirty", "midi", "ldirty")}
|
||||||
|
)
|
||||||
|
self.gui = VmGui()
|
||||||
|
self.stop_event = None
|
||||||
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
|
|
||||||
|
for attr, val in kwargs.items():
|
||||||
|
setattr(self, attr, val)
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
"""setup procedures"""
|
||||||
|
self.login()
|
||||||
|
if self.event.any():
|
||||||
|
self.init_thread()
|
||||||
|
return self
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def __str__(self):
|
||||||
|
"""Ensure subclasses override str magic method"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
def init_thread(self):
|
||||||
|
"""Starts updates thread."""
|
||||||
|
self.event.info()
|
||||||
|
|
||||||
|
self.logger.debug("initiating events thread")
|
||||||
|
self.stop_event = threading.Event()
|
||||||
|
self.stop_event.clear()
|
||||||
|
queue = Queue()
|
||||||
|
self.updater = Updater(self, queue)
|
||||||
|
self.updater.start()
|
||||||
|
self.producer = Producer(self, queue, self.stop_event)
|
||||||
|
self.producer.start()
|
||||||
|
|
||||||
|
def stopped(self):
|
||||||
|
return self.stop_event is None or self.stop_event.is_set()
|
||||||
|
|
||||||
|
def login(self) -> None:
|
||||||
|
"""Login to the API, initialize dirty parameters"""
|
||||||
|
self.gui.launched = self.call(self.bind_login, ok=(0, 1)) == 0
|
||||||
|
if not self.gui.launched:
|
||||||
|
self.logger.info(
|
||||||
|
"Voicemeeter engine running but GUI not launched. Launching the GUI now."
|
||||||
|
)
|
||||||
|
self.run_voicemeeter(self.kind.name)
|
||||||
|
self.logger.info(
|
||||||
|
f"{type(self).__name__}: Successfully logged into {self} version {self.version}"
|
||||||
|
)
|
||||||
|
self.clear_dirty()
|
||||||
|
|
||||||
|
def run_voicemeeter(self, kind_id: str) -> None:
|
||||||
|
if kind_id not in (kind.name.lower() for kind in KindId):
|
||||||
|
raise VMError(f"Unexpected Voicemeeter type: '{kind_id}'")
|
||||||
|
if kind_id == "potato" and bits == 8:
|
||||||
|
value = KindId[kind_id.upper()].value + 3
|
||||||
|
else:
|
||||||
|
value = KindId[kind_id.upper()].value
|
||||||
|
self.call(self.bind_run_voicemeeter, value)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def type(self) -> str:
|
||||||
|
"""Returns the type of Voicemeeter installation (basic, banana, potato)."""
|
||||||
|
type_ = ct.c_long()
|
||||||
|
self.call(self.bind_get_voicemeeter_type, ct.byref(type_))
|
||||||
|
return KindId(type_.value).name.lower()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def version(self) -> str:
|
||||||
|
"""Returns Voicemeeter's version as a string"""
|
||||||
|
ver = ct.c_long()
|
||||||
|
self.call(self.bind_get_voicemeeter_version, ct.byref(ver))
|
||||||
|
return "{}.{}.{}.{}".format(
|
||||||
|
(ver.value & 0xFF000000) >> 24,
|
||||||
|
(ver.value & 0x00FF0000) >> 16,
|
||||||
|
(ver.value & 0x0000FF00) >> 8,
|
||||||
|
ver.value & 0x000000FF,
|
||||||
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def pdirty(self) -> bool:
|
||||||
|
"""True iff UI parameters have been updated."""
|
||||||
|
return self.call(self.bind_is_parameters_dirty, ok=(0, 1)) == 1
|
||||||
|
|
||||||
|
@property
|
||||||
|
def mdirty(self) -> bool:
|
||||||
|
"""True iff MB parameters have been updated."""
|
||||||
|
try:
|
||||||
|
return self.call(self.bind_macro_button_is_dirty, ok=(0, 1)) == 1
|
||||||
|
except AttributeError as e:
|
||||||
|
self.logger.exception(f"{type(e).__name__}: {e}")
|
||||||
|
ERR_MSG = (
|
||||||
|
"no bind for VBVMR_MacroButton_IsDirty.",
|
||||||
|
"are you using an old version of the API?",
|
||||||
|
)
|
||||||
|
raise CAPIError(
|
||||||
|
"VBVMR_MacroButton_IsDirty", -9, msg=" ".join(ERR_MSG)
|
||||||
|
) from e
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ldirty(self) -> bool:
|
||||||
|
"""True iff levels have been updated."""
|
||||||
|
self._strip_buf, self._bus_buf = self._get_levels()
|
||||||
|
return not (
|
||||||
|
self.cache.get("strip_level") == self._strip_buf
|
||||||
|
and self.cache.get("bus_level") == self._bus_buf
|
||||||
|
)
|
||||||
|
|
||||||
|
def clear_dirty(self) -> None:
|
||||||
|
try:
|
||||||
|
while self.pdirty or self.mdirty:
|
||||||
|
pass
|
||||||
|
except CAPIError as e:
|
||||||
|
if not (e.fn_name == "VBVMR_MacroButton_IsDirty" and e.code == -9):
|
||||||
|
raise
|
||||||
|
self.logger.error(f"{e} clearing pdirty only.")
|
||||||
|
while self.pdirty:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@polling
|
||||||
|
def get(self, param: str, is_string: Optional[bool] = False) -> Union[str, float]:
|
||||||
|
"""Gets a string or float parameter"""
|
||||||
|
if is_string:
|
||||||
|
buf = ct.create_unicode_buffer(512)
|
||||||
|
self.call(self.bind_get_parameter_string_w, param.encode(), ct.byref(buf))
|
||||||
|
else:
|
||||||
|
buf = ct.c_float()
|
||||||
|
self.call(self.bind_get_parameter_float, param.encode(), ct.byref(buf))
|
||||||
|
return buf.value
|
||||||
|
|
||||||
|
def set(self, param: str, val: Union[str, float]) -> None:
|
||||||
|
"""Sets a string or float parameter. Caches value"""
|
||||||
|
if isinstance(val, str):
|
||||||
|
if len(val) >= 512:
|
||||||
|
raise VMError("String is too long")
|
||||||
|
self.call(
|
||||||
|
self.bind_set_parameter_string_w, param.encode(), ct.c_wchar_p(val)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
self.call(
|
||||||
|
self.bind_set_parameter_float, param.encode(), ct.c_float(float(val))
|
||||||
|
)
|
||||||
|
self.cache[param] = val
|
||||||
|
|
||||||
|
@polling
|
||||||
|
def get_buttonstatus(self, id_: int, mode: int) -> int:
|
||||||
|
"""Gets a macrobutton parameter"""
|
||||||
|
c_state = ct.c_float()
|
||||||
|
try:
|
||||||
|
self.call(
|
||||||
|
self.bind_macro_button_get_status,
|
||||||
|
ct.c_long(id_),
|
||||||
|
ct.byref(c_state),
|
||||||
|
ct.c_long(mode),
|
||||||
|
)
|
||||||
|
except AttributeError as e:
|
||||||
|
self.logger.exception(f"{type(e).__name__}: {e}")
|
||||||
|
ERR_MSG = (
|
||||||
|
"no bind for VBVMR_MacroButton_GetStatus.",
|
||||||
|
"are you using an old version of the API?",
|
||||||
|
)
|
||||||
|
raise CAPIError(
|
||||||
|
"VBVMR_MacroButton_GetStatus", -9, msg=" ".join(ERR_MSG)
|
||||||
|
) from e
|
||||||
|
return int(c_state.value)
|
||||||
|
|
||||||
|
def set_buttonstatus(self, id_: int, val: int, mode: int) -> None:
|
||||||
|
"""Sets a macrobutton parameter. Caches value"""
|
||||||
|
c_state = ct.c_float(float(val))
|
||||||
|
try:
|
||||||
|
self.call(
|
||||||
|
self.bind_macro_button_set_status,
|
||||||
|
ct.c_long(id_),
|
||||||
|
c_state,
|
||||||
|
ct.c_long(mode),
|
||||||
|
)
|
||||||
|
except AttributeError as e:
|
||||||
|
self.logger.exception(f"{type(e).__name__}: {e}")
|
||||||
|
ERR_MSG = (
|
||||||
|
"no bind for VBVMR_MacroButton_SetStatus.",
|
||||||
|
"are you using an old version of the API?",
|
||||||
|
)
|
||||||
|
raise CAPIError(
|
||||||
|
"VBVMR_MacroButton_SetStatus", -9, msg=" ".join(ERR_MSG)
|
||||||
|
) from e
|
||||||
|
self.cache[f"mb_{id_}_{mode}"] = int(c_state.value)
|
||||||
|
|
||||||
|
def get_num_devices(self, direction: str = None) -> int:
|
||||||
|
"""Retrieves number of physical devices connected"""
|
||||||
|
if direction not in ("in", "out"):
|
||||||
|
raise VMError("Expected a direction: in or out")
|
||||||
|
func = getattr(self, f"bind_{direction}put_get_device_number")
|
||||||
|
res = self.call(func, ok_exp=lambda r: r >= 0)
|
||||||
|
return res
|
||||||
|
|
||||||
|
def get_device_description(self, index: int, direction: str = None) -> tuple:
|
||||||
|
"""Returns a tuple of device parameters"""
|
||||||
|
if direction not in ("in", "out"):
|
||||||
|
raise VMError("Expected a direction: in or out")
|
||||||
|
type_ = ct.c_long()
|
||||||
|
name = ct.create_unicode_buffer(256)
|
||||||
|
hwid = ct.create_unicode_buffer(256)
|
||||||
|
func = getattr(self, f"bind_{direction}put_get_device_desc_w")
|
||||||
|
self.call(
|
||||||
|
func,
|
||||||
|
ct.c_long(index),
|
||||||
|
ct.byref(type_),
|
||||||
|
ct.byref(name),
|
||||||
|
ct.byref(hwid),
|
||||||
|
)
|
||||||
|
return (name.value, type_.value, hwid.value)
|
||||||
|
|
||||||
|
def get_level(self, type_: int, index: int) -> float:
|
||||||
|
"""Retrieves a single level value"""
|
||||||
|
val = ct.c_float()
|
||||||
|
self.call(
|
||||||
|
self.bind_get_level, ct.c_long(type_), ct.c_long(index), ct.byref(val)
|
||||||
|
)
|
||||||
|
return val.value
|
||||||
|
|
||||||
|
def _get_levels(self) -> Iterable:
|
||||||
|
"""
|
||||||
|
returns both level arrays (strip_levels, bus_levels) BEFORE math conversion
|
||||||
|
"""
|
||||||
|
return (
|
||||||
|
tuple(
|
||||||
|
self.get_level(self.strip_mode, i)
|
||||||
|
for i in range(self.kind.num_strip_levels)
|
||||||
|
),
|
||||||
|
tuple(self.get_level(3, i) for i in range(self.kind.num_bus_levels)),
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_midi_message(self):
|
||||||
|
n = ct.c_long(1024)
|
||||||
|
buf = ct.create_string_buffer(1024)
|
||||||
|
res = self.call(
|
||||||
|
self.bind_get_midi_message,
|
||||||
|
ct.byref(buf),
|
||||||
|
n,
|
||||||
|
ok=(-5, -6), # no data received from midi device
|
||||||
|
ok_exp=lambda r: r >= 0,
|
||||||
|
)
|
||||||
|
if res > 0:
|
||||||
|
vals = tuple(
|
||||||
|
grouper(3, (int.from_bytes(buf[i], "little") for i in range(res)))
|
||||||
|
)
|
||||||
|
for msg in vals:
|
||||||
|
ch, pitch, vel = msg
|
||||||
|
if not self.midi._channel or self.midi._channel != ch:
|
||||||
|
self.midi._channel = ch
|
||||||
|
self.midi._most_recent = pitch
|
||||||
|
self.midi._set(pitch, vel)
|
||||||
|
return True
|
||||||
|
|
||||||
|
@script
|
||||||
|
def sendtext(self, script: str):
|
||||||
|
"""Sets many parameters from a script"""
|
||||||
|
if len(script) > 48000:
|
||||||
|
raise ValueError("Script too large, max size 48kB")
|
||||||
|
self.call(self.bind_set_parameters, script.encode())
|
||||||
|
time.sleep(self.DELAY * 5)
|
||||||
|
|
||||||
|
def apply(self, data: dict):
|
||||||
|
"""
|
||||||
|
Sets all parameters of a dict
|
||||||
|
|
||||||
|
minor delay between each recursion
|
||||||
|
"""
|
||||||
|
|
||||||
|
def param(key):
|
||||||
|
obj, m2, *rem = key.split("-")
|
||||||
|
index = int(m2) if m2.isnumeric() else int(*rem)
|
||||||
|
if obj in ("strip", "bus", "button"):
|
||||||
|
return getattr(self, obj)[index]
|
||||||
|
elif obj == "vban":
|
||||||
|
return getattr(getattr(self, obj), f"{m2}stream")[index]
|
||||||
|
raise ValueError(obj)
|
||||||
|
|
||||||
|
[param(key).apply(datum).then_wait() for key, datum in data.items()]
|
||||||
|
|
||||||
|
def apply_config(self, name):
|
||||||
|
"""applies a config from memory"""
|
||||||
|
ERR_MSG = (
|
||||||
|
f"No config with name '{name}' is loaded into memory",
|
||||||
|
f"Known configs: {list(self.configs.keys())}",
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
config = self.configs[name]
|
||||||
|
except KeyError as e:
|
||||||
|
self.logger.error(("\n").join(ERR_MSG))
|
||||||
|
raise VMError(("\n").join(ERR_MSG)) from e
|
||||||
|
|
||||||
|
if "extends" in config:
|
||||||
|
extended = config["extends"]
|
||||||
|
config = {
|
||||||
|
k: v
|
||||||
|
for k, v in deep_merge(self.configs[extended], config)
|
||||||
|
if k not in ("extends")
|
||||||
|
}
|
||||||
|
self.logger.debug(
|
||||||
|
f"profile '{name}' extends '{extended}', profiles merged.."
|
||||||
|
)
|
||||||
|
self.apply(config)
|
||||||
|
self.logger.info(f"Profile '{name}' applied!")
|
||||||
|
|
||||||
|
def end_thread(self):
|
||||||
|
if not self.stopped():
|
||||||
|
self.logger.debug("events thread shutdown started")
|
||||||
|
self.stop_event.set()
|
||||||
|
self.producer.join() # wait for producer thread to complete cycle
|
||||||
|
|
||||||
|
def logout(self) -> None:
|
||||||
|
"""Logout of the API"""
|
||||||
|
time.sleep(0.1)
|
||||||
|
self.call(self.bind_logout)
|
||||||
|
self.logger.info(f"{type(self).__name__}: Successfully logged out of {self}")
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_value, exc_traceback) -> None:
|
||||||
|
"""teardown procedures"""
|
||||||
|
self.end_thread()
|
||||||
|
self.logout()
|
||||||
@@ -5,7 +5,7 @@ from typing import Union
|
|||||||
|
|
||||||
from .iremote import IRemote
|
from .iremote import IRemote
|
||||||
from .kinds import kinds_all
|
from .kinds import kinds_all
|
||||||
from .meta import bool_prop, float_prop
|
from .meta import bool_prop, device_prop, float_prop
|
||||||
|
|
||||||
|
|
||||||
class Strip(IRemote):
|
class Strip(IRemote):
|
||||||
@@ -82,34 +82,28 @@ class Strip(IRemote):
|
|||||||
|
|
||||||
class PhysicalStrip(Strip):
|
class PhysicalStrip(Strip):
|
||||||
@classmethod
|
@classmethod
|
||||||
def make(cls, kind):
|
def make(cls, remote, i, is_phys):
|
||||||
"""
|
"""
|
||||||
Factory method for PhysicalStrip.
|
Factory method for PhysicalStrip.
|
||||||
|
|
||||||
Returns a PhysicalStrip class.
|
Returns a PhysicalStrip class.
|
||||||
"""
|
"""
|
||||||
EFFECTS_cls = _make_effects_mixins[kind.name]
|
EFFECTS_cls = _make_effects_mixins(is_phys)[remote.kind.name]
|
||||||
return type(f"PhysicalStrip", (cls, EFFECTS_cls), {})
|
return type(
|
||||||
|
f"PhysicalStrip",
|
||||||
|
(cls, EFFECTS_cls),
|
||||||
|
{
|
||||||
|
"comp": StripComp(remote, i),
|
||||||
|
"gate": StripGate(remote, i),
|
||||||
|
"denoiser": StripDenoiser(remote, i),
|
||||||
|
"eq": StripEQ(remote, i),
|
||||||
|
"device": StripDevice.make(remote, i),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{type(self).__name__}{self.index}"
|
return f"{type(self).__name__}{self.index}"
|
||||||
|
|
||||||
@property
|
|
||||||
def comp(self) -> float:
|
|
||||||
return round(self.getter("Comp"), 1)
|
|
||||||
|
|
||||||
@comp.setter
|
|
||||||
def comp(self, val: float):
|
|
||||||
self.setter("Comp", val)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def gate(self) -> float:
|
|
||||||
return round(self.getter("Gate"), 1)
|
|
||||||
|
|
||||||
@gate.setter
|
|
||||||
def gate(self, val: float):
|
|
||||||
self.setter("Gate", val)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def audibility(self) -> float:
|
def audibility(self) -> float:
|
||||||
return round(self.getter("audibility"), 1)
|
return round(self.getter("audibility"), 1)
|
||||||
@@ -118,16 +112,236 @@ class PhysicalStrip(Strip):
|
|||||||
def audibility(self, val: float):
|
def audibility(self, val: float):
|
||||||
self.setter("audibility", val)
|
self.setter("audibility", val)
|
||||||
|
|
||||||
|
|
||||||
|
class StripComp(IRemote):
|
||||||
@property
|
@property
|
||||||
def device(self):
|
def identifier(self) -> str:
|
||||||
return self.getter("device.name", is_string=True)
|
return f"Strip[{self.index}].comp"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sr(self):
|
def knob(self) -> float:
|
||||||
return int(self.getter("device.sr"))
|
return round(self.getter(""), 1)
|
||||||
|
|
||||||
|
@knob.setter
|
||||||
|
def knob(self, val: float):
|
||||||
|
self.setter("", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def gainin(self) -> float:
|
||||||
|
return round(self.getter("GainIn"), 1)
|
||||||
|
|
||||||
|
@gainin.setter
|
||||||
|
def gainin(self, val: float):
|
||||||
|
self.setter("GainIn", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ratio(self) -> float:
|
||||||
|
return round(self.getter("Ratio"), 1)
|
||||||
|
|
||||||
|
@ratio.setter
|
||||||
|
def ratio(self, val: float):
|
||||||
|
self.setter("Ratio", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def threshold(self) -> float:
|
||||||
|
return round(self.getter("Threshold"), 1)
|
||||||
|
|
||||||
|
@threshold.setter
|
||||||
|
def threshold(self, val: float):
|
||||||
|
self.setter("Threshold", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def attack(self) -> float:
|
||||||
|
return round(self.getter("Attack"), 1)
|
||||||
|
|
||||||
|
@attack.setter
|
||||||
|
def attack(self, val: float):
|
||||||
|
self.setter("Attack", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def release(self) -> float:
|
||||||
|
return round(self.getter("Release"), 1)
|
||||||
|
|
||||||
|
@release.setter
|
||||||
|
def release(self, val: float):
|
||||||
|
self.setter("Release", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def knee(self) -> float:
|
||||||
|
return round(self.getter("Knee"), 1)
|
||||||
|
|
||||||
|
@knee.setter
|
||||||
|
def knee(self, val: float):
|
||||||
|
self.setter("Knee", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def gainout(self) -> float:
|
||||||
|
return round(self.getter("GainOut"), 1)
|
||||||
|
|
||||||
|
@gainout.setter
|
||||||
|
def gainout(self, val: float):
|
||||||
|
self.setter("GainOut", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def makeup(self) -> bool:
|
||||||
|
return self.getter("makeup") == 1
|
||||||
|
|
||||||
|
@makeup.setter
|
||||||
|
def makeup(self, val: bool):
|
||||||
|
self.setter("makeup", 1 if val else 0)
|
||||||
|
|
||||||
|
|
||||||
|
class StripGate(IRemote):
|
||||||
|
@property
|
||||||
|
def identifier(self) -> str:
|
||||||
|
return f"Strip[{self.index}].gate"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def knob(self) -> float:
|
||||||
|
return round(self.getter(""), 1)
|
||||||
|
|
||||||
|
@knob.setter
|
||||||
|
def knob(self, val: float):
|
||||||
|
self.setter("", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def threshold(self) -> float:
|
||||||
|
return round(self.getter("Threshold"), 1)
|
||||||
|
|
||||||
|
@threshold.setter
|
||||||
|
def threshold(self, val: float):
|
||||||
|
self.setter("Threshold", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def damping(self) -> float:
|
||||||
|
return round(self.getter("Damping"), 1)
|
||||||
|
|
||||||
|
@damping.setter
|
||||||
|
def damping(self, val: float):
|
||||||
|
self.setter("Damping", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def bpsidechain(self) -> int:
|
||||||
|
return int(self.getter("BPSidechain"))
|
||||||
|
|
||||||
|
@bpsidechain.setter
|
||||||
|
def bpsidechain(self, val: int):
|
||||||
|
self.setter("BPSidechain", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def attack(self) -> float:
|
||||||
|
return round(self.getter("Attack"), 1)
|
||||||
|
|
||||||
|
@attack.setter
|
||||||
|
def attack(self, val: float):
|
||||||
|
self.setter("Attack", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hold(self) -> float:
|
||||||
|
return round(self.getter("Hold"), 1)
|
||||||
|
|
||||||
|
@hold.setter
|
||||||
|
def hold(self, val: float):
|
||||||
|
self.setter("Hold", val)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def release(self) -> float:
|
||||||
|
return round(self.getter("Release"), 1)
|
||||||
|
|
||||||
|
@release.setter
|
||||||
|
def release(self, val: float):
|
||||||
|
self.setter("Release", val)
|
||||||
|
|
||||||
|
|
||||||
|
class StripDenoiser(IRemote):
|
||||||
|
@property
|
||||||
|
def identifier(self) -> str:
|
||||||
|
return f"Strip[{self.index}].denoiser"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def knob(self) -> float:
|
||||||
|
return round(self.getter(""), 1)
|
||||||
|
|
||||||
|
@knob.setter
|
||||||
|
def knob(self, val: float):
|
||||||
|
self.setter("", val)
|
||||||
|
|
||||||
|
|
||||||
|
class StripEQ(IRemote):
|
||||||
|
@property
|
||||||
|
def identifier(self) -> str:
|
||||||
|
return f"Strip[{self.index}].eq"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def on(self) -> bool:
|
||||||
|
return self.getter("on") == 1
|
||||||
|
|
||||||
|
@on.setter
|
||||||
|
def on(self, val: bool):
|
||||||
|
self.setter("on", 1 if val else 0)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ab(self) -> bool:
|
||||||
|
return self.getter("ab") == 1
|
||||||
|
|
||||||
|
@ab.setter
|
||||||
|
def ab(self, val: bool):
|
||||||
|
self.setter("ab", 1 if val else 0)
|
||||||
|
|
||||||
|
|
||||||
|
class StripDevice(IRemote):
|
||||||
|
@classmethod
|
||||||
|
def make(cls, remote, i):
|
||||||
|
"""
|
||||||
|
Factory function for strip.device.
|
||||||
|
|
||||||
|
Returns a StripDevice class of a kind.
|
||||||
|
"""
|
||||||
|
DEVICE_cls = type(
|
||||||
|
f"StripDevice{remote.kind}",
|
||||||
|
(cls,),
|
||||||
|
{
|
||||||
|
**{
|
||||||
|
param: device_prop(param)
|
||||||
|
for param in [
|
||||||
|
"wdm",
|
||||||
|
"ks",
|
||||||
|
"mme",
|
||||||
|
"asio",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return DEVICE_cls(remote, i)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def identifier(self) -> str:
|
||||||
|
return f"Strip[{self.index}].device"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self.getter("name", is_string=True)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sr(self) -> int:
|
||||||
|
return int(self.getter("sr"))
|
||||||
|
|
||||||
|
|
||||||
class VirtualStrip(Strip):
|
class VirtualStrip(Strip):
|
||||||
|
@classmethod
|
||||||
|
def make(cls, remote, i, is_phys):
|
||||||
|
"""
|
||||||
|
Factory method for VirtualStrip.
|
||||||
|
|
||||||
|
Returns a VirtualStrip class.
|
||||||
|
"""
|
||||||
|
EFFECTS_cls = _make_effects_mixins(is_phys)[remote.kind.name]
|
||||||
|
return type(
|
||||||
|
f"VirtualStrip",
|
||||||
|
(cls, EFFECTS_cls),
|
||||||
|
{},
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{type(self).__name__}{self.index}"
|
return f"{type(self).__name__}{self.index}"
|
||||||
|
|
||||||
@@ -150,7 +364,7 @@ class VirtualStrip(Strip):
|
|||||||
self.setter("karaoke", val)
|
self.setter("karaoke", val)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def bass(self):
|
def bass(self) -> float:
|
||||||
return round(self.getter("EQGain1"), 1)
|
return round(self.getter("EQGain1"), 1)
|
||||||
|
|
||||||
@bass.setter
|
@bass.setter
|
||||||
@@ -158,7 +372,7 @@ class VirtualStrip(Strip):
|
|||||||
self.setter("EQGain1", val)
|
self.setter("EQGain1", val)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mid(self):
|
def mid(self) -> float:
|
||||||
return round(self.getter("EQGain2"), 1)
|
return round(self.getter("EQGain2"), 1)
|
||||||
|
|
||||||
@mid.setter
|
@mid.setter
|
||||||
@@ -168,7 +382,7 @@ class VirtualStrip(Strip):
|
|||||||
med = mid
|
med = mid
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def treble(self):
|
def treble(self) -> float:
|
||||||
return round(self.getter("EQGain3"), 1)
|
return round(self.getter("EQGain3"), 1)
|
||||||
|
|
||||||
high = treble
|
high = treble
|
||||||
@@ -201,7 +415,7 @@ class StripLevel(IRemote):
|
|||||||
def fget(x):
|
def fget(x):
|
||||||
return round(20 * log(x, 10), 1) if x > 0 else -200.0
|
return round(20 * log(x, 10), 1) if x > 0 else -200.0
|
||||||
|
|
||||||
if self._remote.running and self._remote.event.ldirty:
|
if not self._remote.stopped() and self._remote.event.ldirty:
|
||||||
vals = self._remote.cache["strip_level"][self.range[0] : self.range[-1]]
|
vals = self._remote.cache["strip_level"][self.range[0] : self.range[-1]]
|
||||||
else:
|
else:
|
||||||
vals = [self._remote.get_level(mode, i) for i in range(*self.range)]
|
vals = [self._remote.get_level(mode, i) for i in range(*self.range)]
|
||||||
@@ -234,7 +448,7 @@ class StripLevel(IRemote):
|
|||||||
|
|
||||||
Expected to be used in a callback only.
|
Expected to be used in a callback only.
|
||||||
"""
|
"""
|
||||||
if self._remote.running:
|
if not self._remote.stopped():
|
||||||
return any(self._remote._strip_comp[self.range[0] : self.range[-1]])
|
return any(self._remote._strip_comp[self.range[0] : self.range[-1]])
|
||||||
|
|
||||||
is_updated = isdirty
|
is_updated = isdirty
|
||||||
@@ -304,36 +518,38 @@ _make_channelout_mixins = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _make_effects_mixin(kind):
|
def _make_effects_mixin(kind, is_phys):
|
||||||
"""creates an effects mixin for a kind"""
|
"""creates an effects mixin for a kind"""
|
||||||
XY_cls = type(
|
|
||||||
"XY",
|
def _make_xy_cls():
|
||||||
|
pan = {param: float_prop(param) for param in ["pan_x", "pan_y"]}
|
||||||
|
color = {param: float_prop(param) for param in ["color_x", "color_y"]}
|
||||||
|
fx = {param: float_prop(param) for param in ["fx_x", "fx_y"]}
|
||||||
|
if is_phys:
|
||||||
|
return type(
|
||||||
|
"XYPhys",
|
||||||
(),
|
(),
|
||||||
{
|
{
|
||||||
param: float_prop(param)
|
**pan,
|
||||||
for param in [
|
**color,
|
||||||
"pan_x",
|
**fx,
|
||||||
"pan_y",
|
|
||||||
"color_x",
|
|
||||||
"color_y",
|
|
||||||
"fx_x",
|
|
||||||
"fx_y",
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
return type(
|
||||||
|
"XYVirt",
|
||||||
|
(),
|
||||||
|
{**pan},
|
||||||
|
)
|
||||||
|
|
||||||
FX_cls = type(
|
def _make_fx_cls():
|
||||||
|
if is_phys:
|
||||||
|
return type(
|
||||||
"FX",
|
"FX",
|
||||||
(),
|
(),
|
||||||
{
|
{
|
||||||
**{
|
**{
|
||||||
param: float_prop(param)
|
param: float_prop(param)
|
||||||
for param in [
|
for param in ["reverb", "delay", "fx1", "fx2"]
|
||||||
"reverb",
|
|
||||||
"delay",
|
|
||||||
"fx1",
|
|
||||||
"fx2",
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
**{
|
**{
|
||||||
f"post{param}": bool_prop(f"post{param}")
|
f"post{param}": bool_prop(f"post{param}")
|
||||||
@@ -341,13 +557,19 @@ def _make_effects_mixin(kind):
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
return type("FX", (), {})
|
||||||
|
|
||||||
if kind.name == "potato":
|
if kind.name == "basic":
|
||||||
return type(f"Effects{kind}", (XY_cls, FX_cls), {})
|
steps = (_make_xy_cls,)
|
||||||
return type(f"Effects{kind}", (XY_cls,), {})
|
elif kind.name == "banana":
|
||||||
|
steps = (_make_xy_cls,)
|
||||||
|
elif kind.name == "potato":
|
||||||
|
steps = (_make_xy_cls, _make_fx_cls)
|
||||||
|
return type(f"Effects{kind}", tuple(step() for step in steps), {})
|
||||||
|
|
||||||
|
|
||||||
_make_effects_mixins = {kind.name: _make_effects_mixin(kind) for kind in kinds_all}
|
def _make_effects_mixins(is_phys):
|
||||||
|
return {kind.name: _make_effects_mixin(kind, is_phys) for kind in kinds_all}
|
||||||
|
|
||||||
|
|
||||||
def strip_factory(is_phys_strip, remote, i) -> Union[PhysicalStrip, VirtualStrip]:
|
def strip_factory(is_phys_strip, remote, i) -> Union[PhysicalStrip, VirtualStrip]:
|
||||||
@@ -358,7 +580,11 @@ def strip_factory(is_phys_strip, remote, i) -> Union[PhysicalStrip, VirtualStrip
|
|||||||
|
|
||||||
Returns a physical or virtual strip subclass
|
Returns a physical or virtual strip subclass
|
||||||
"""
|
"""
|
||||||
STRIP_cls = PhysicalStrip.make(remote.kind) if is_phys_strip else VirtualStrip
|
STRIP_cls = (
|
||||||
|
PhysicalStrip.make(remote, i, is_phys_strip)
|
||||||
|
if is_phys_strip
|
||||||
|
else VirtualStrip.make(remote, i, is_phys_strip)
|
||||||
|
)
|
||||||
CHANNELOUTMIXIN_cls = _make_channelout_mixins[remote.kind.name]
|
CHANNELOUTMIXIN_cls = _make_channelout_mixins[remote.kind.name]
|
||||||
|
|
||||||
_kls = (STRIP_cls, CHANNELOUTMIXIN_cls)
|
_kls = (STRIP_cls, CHANNELOUTMIXIN_cls)
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
class Subject:
|
import logging
|
||||||
"""Adds support for observers"""
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Subject:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""list of current observers"""
|
"""Adds support for observers and callbacks"""
|
||||||
|
|
||||||
self._observers = list()
|
self._observers = list()
|
||||||
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def observers(self) -> list:
|
def observers(self) -> list:
|
||||||
@@ -12,28 +16,57 @@ class Subject:
|
|||||||
|
|
||||||
return self._observers
|
return self._observers
|
||||||
|
|
||||||
def notify(self, modifier):
|
def notify(self, event):
|
||||||
"""run callbacks on update"""
|
"""run callbacks on update"""
|
||||||
|
|
||||||
[o.on_update(modifier) for o in self._observers]
|
for o in self._observers:
|
||||||
|
if hasattr(o, "on_update"):
|
||||||
|
o.on_update(event)
|
||||||
|
else:
|
||||||
|
if o.__name__ == f"on_{event}":
|
||||||
|
o()
|
||||||
|
|
||||||
def add(self, observer):
|
def add(self, observer):
|
||||||
"""adds an observer to _observers"""
|
"""adds an observer to observers"""
|
||||||
|
|
||||||
if observer not in self._observers:
|
|
||||||
self._observers.append(observer)
|
|
||||||
else:
|
|
||||||
print(f"Failed to add: {observer}")
|
|
||||||
|
|
||||||
def remove(self, observer):
|
|
||||||
"""removes an observer from _observers"""
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._observers.remove(observer)
|
iterator = iter(observer)
|
||||||
|
for o in iterator:
|
||||||
|
if o not in self._observers:
|
||||||
|
self._observers.append(o)
|
||||||
|
self.logger.info(f"{o} added to event observers")
|
||||||
|
else:
|
||||||
|
self.logger.error(f"Failed to add {o} to event observers")
|
||||||
|
except TypeError:
|
||||||
|
if observer not in self._observers:
|
||||||
|
self._observers.append(observer)
|
||||||
|
self.logger.info(f"{observer} added to event observers")
|
||||||
|
else:
|
||||||
|
self.logger.error(f"Failed to add {observer} to event observers")
|
||||||
|
|
||||||
|
register = add
|
||||||
|
|
||||||
|
def remove(self, observer):
|
||||||
|
"""removes an observer from observers"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
iterator = iter(observer)
|
||||||
|
for o in iterator:
|
||||||
|
try:
|
||||||
|
self._observers.remove(o)
|
||||||
|
self.logger.info(f"{o} removed from event observers")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print(f"Failed to remove: {observer}")
|
self.logger.error(f"Failed to remove {o} from event observers")
|
||||||
|
except TypeError:
|
||||||
|
try:
|
||||||
|
self._observers.remove(observer)
|
||||||
|
self.logger.info(f"{observer} removed from event observers")
|
||||||
|
except ValueError:
|
||||||
|
self.logger.error(f"Failed to remove {observer} from event observers")
|
||||||
|
|
||||||
|
deregister = remove
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
"""clears the _observers list"""
|
"""clears the observers list"""
|
||||||
|
|
||||||
self._observers.clear()
|
self._observers.clear()
|
||||||
|
|||||||
75
voicemeeterlib/updater.py
Normal file
75
voicemeeterlib/updater.py
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
import logging
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
|
||||||
|
from .util import comp
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class Producer(threading.Thread):
|
||||||
|
"""Continously send job queue to the Updater thread at a rate of self._remote.ratelimit."""
|
||||||
|
|
||||||
|
def __init__(self, remote, queue, stop_event):
|
||||||
|
super().__init__(name="producer", daemon=False)
|
||||||
|
self._remote = remote
|
||||||
|
self.queue = queue
|
||||||
|
self.stop_event = stop_event
|
||||||
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
|
|
||||||
|
def stopped(self):
|
||||||
|
return self.stop_event.is_set()
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
while not self.stopped():
|
||||||
|
if self._remote.event.pdirty:
|
||||||
|
self.queue.put("pdirty")
|
||||||
|
if self._remote.event.mdirty:
|
||||||
|
self.queue.put("mdirty")
|
||||||
|
if self._remote.event.midi:
|
||||||
|
self.queue.put("midi")
|
||||||
|
if self._remote.event.ldirty:
|
||||||
|
self.queue.put("ldirty")
|
||||||
|
time.sleep(self._remote.ratelimit)
|
||||||
|
self.logger.debug(f"terminating {self.name} thread")
|
||||||
|
self.queue.put(None)
|
||||||
|
|
||||||
|
|
||||||
|
class Updater(threading.Thread):
|
||||||
|
def __init__(self, remote, queue):
|
||||||
|
super().__init__(name="updater", daemon=True)
|
||||||
|
self._remote = remote
|
||||||
|
self.queue = queue
|
||||||
|
self._remote._strip_comp = [False] * (self._remote.kind.num_strip_levels)
|
||||||
|
self._remote._bus_comp = [False] * (self._remote.kind.num_bus_levels)
|
||||||
|
(
|
||||||
|
self._remote.cache["strip_level"],
|
||||||
|
self._remote.cache["bus_level"],
|
||||||
|
) = self._remote._get_levels()
|
||||||
|
self.logger = logger.getChild(self.__class__.__name__)
|
||||||
|
|
||||||
|
def _update_comps(self, strip_level, bus_level):
|
||||||
|
self._remote._strip_comp, self._remote._bus_comp = (
|
||||||
|
tuple(not x for x in comp(self._remote.cache["strip_level"], strip_level)),
|
||||||
|
tuple(not x for x in comp(self._remote.cache["bus_level"], bus_level)),
|
||||||
|
)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
"""
|
||||||
|
Continously update observers of dirty states.
|
||||||
|
|
||||||
|
Generate _strip_comp, _bus_comp and update level cache if ldirty.
|
||||||
|
"""
|
||||||
|
while event := self.queue.get():
|
||||||
|
if event == "pdirty" and self._remote.pdirty:
|
||||||
|
self._remote.subject.notify(event)
|
||||||
|
elif event == "mdirty" and self._remote.mdirty:
|
||||||
|
self._remote.subject.notify(event)
|
||||||
|
elif event == "midi" and self._remote.get_midi_message():
|
||||||
|
self._remote.subject.notify(event)
|
||||||
|
elif event == "ldirty" and self._remote.ldirty:
|
||||||
|
self._update_comps(self._remote._strip_buf, self._remote._bus_buf)
|
||||||
|
self._remote.cache["strip_level"] = self._remote._strip_buf
|
||||||
|
self._remote.cache["bus_level"] = self._remote._bus_buf
|
||||||
|
self._remote.subject.notify(event)
|
||||||
|
self.logger.debug(f"terminating {self.name} thread")
|
||||||
@@ -70,3 +70,17 @@ def grouper(n, iterable, fillvalue=None):
|
|||||||
"""
|
"""
|
||||||
args = [iter(iterable)] * n
|
args = [iter(iterable)] * n
|
||||||
return zip_longest(fillvalue=fillvalue, *args)
|
return zip_longest(fillvalue=fillvalue, *args)
|
||||||
|
|
||||||
|
|
||||||
|
def deep_merge(dict1, dict2):
|
||||||
|
"""Generator function for deep merging two dicts"""
|
||||||
|
for k in set(dict1) | set(dict2):
|
||||||
|
if k in dict1 and k in dict2:
|
||||||
|
if isinstance(dict1[k], dict) and isinstance(dict2[k], dict):
|
||||||
|
yield k, dict(deep_merge(dict1[k], dict2[k]))
|
||||||
|
else:
|
||||||
|
yield k, dict2[k]
|
||||||
|
elif k in dict1:
|
||||||
|
yield k, dict1[k]
|
||||||
|
else:
|
||||||
|
yield k, dict2[k]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
|
|
||||||
from .error import VMError
|
|
||||||
from .iremote import IRemote
|
from .iremote import IRemote
|
||||||
|
from .kinds import kinds_all
|
||||||
|
|
||||||
|
|
||||||
class VbanStream(IRemote):
|
class VbanStream(IRemote):
|
||||||
@@ -50,7 +50,9 @@ class VbanStream(IRemote):
|
|||||||
@port.setter
|
@port.setter
|
||||||
def port(self, val: int):
|
def port(self, val: int):
|
||||||
if not 1024 <= val <= 65535:
|
if not 1024 <= val <= 65535:
|
||||||
raise VMError("Expected value from 1024 to 65535")
|
self.logger.warning(
|
||||||
|
f"port got: {val} but expected a value from 1024 to 65535"
|
||||||
|
)
|
||||||
self.setter("port", val)
|
self.setter("port", val)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -61,7 +63,7 @@ class VbanStream(IRemote):
|
|||||||
def sr(self, val: int):
|
def sr(self, val: int):
|
||||||
opts = (11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000)
|
opts = (11025, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000)
|
||||||
if val not in opts:
|
if val not in opts:
|
||||||
raise VMError(f"Expected one of: {opts}")
|
self.logger.warning(f"sr got: {val} but expected a value in {opts}")
|
||||||
self.setter("sr", val)
|
self.setter("sr", val)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -71,7 +73,7 @@ class VbanStream(IRemote):
|
|||||||
@channel.setter
|
@channel.setter
|
||||||
def channel(self, val: int):
|
def channel(self, val: int):
|
||||||
if not 1 <= val <= 8:
|
if not 1 <= val <= 8:
|
||||||
raise VMError("Expected value from 1 to 8")
|
self.logger.warning(f"channel got: {val} but expected a value from 1 to 8")
|
||||||
self.setter("channel", val)
|
self.setter("channel", val)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -81,7 +83,7 @@ class VbanStream(IRemote):
|
|||||||
@bit.setter
|
@bit.setter
|
||||||
def bit(self, val: int):
|
def bit(self, val: int):
|
||||||
if val not in (16, 24):
|
if val not in (16, 24):
|
||||||
raise VMError("Expected value 16 or 24")
|
self.logger.warning(f"bit got: {val} but expected value 16 or 24")
|
||||||
self.setter("bit", 1 if (val == 16) else 2)
|
self.setter("bit", 1 if (val == 16) else 2)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -91,7 +93,7 @@ class VbanStream(IRemote):
|
|||||||
@quality.setter
|
@quality.setter
|
||||||
def quality(self, val: int):
|
def quality(self, val: int):
|
||||||
if not 0 <= val <= 4:
|
if not 0 <= val <= 4:
|
||||||
raise VMError("Expected value from 0 to 4")
|
self.logger.warning(f"quality got: {val} but expected a value from 0 to 4")
|
||||||
self.setter("quality", val)
|
self.setter("quality", val)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -101,7 +103,7 @@ class VbanStream(IRemote):
|
|||||||
@route.setter
|
@route.setter
|
||||||
def route(self, val: int):
|
def route(self, val: int):
|
||||||
if not 0 <= val <= 8:
|
if not 0 <= val <= 8:
|
||||||
raise VMError("Expected value from 0 to 8")
|
self.logger.warning(f"route got: {val} but expected a value from 0 to 8")
|
||||||
self.setter("route", val)
|
self.setter("route", val)
|
||||||
|
|
||||||
|
|
||||||
@@ -132,6 +134,18 @@ class VbanInstream(VbanStream):
|
|||||||
return super(VbanInstream, self).bit
|
return super(VbanInstream, self).bit
|
||||||
|
|
||||||
|
|
||||||
|
class VbanAudioInstream(VbanInstream):
|
||||||
|
"""Represents a VBAN Audio Instream"""
|
||||||
|
|
||||||
|
|
||||||
|
class VbanMidiInstream(VbanInstream):
|
||||||
|
"""Represents a VBAN Midi Instream"""
|
||||||
|
|
||||||
|
|
||||||
|
class VbanTextInstream(VbanInstream):
|
||||||
|
"""Represents a VBAN Text Instream"""
|
||||||
|
|
||||||
|
|
||||||
class VbanOutstream(VbanStream):
|
class VbanOutstream(VbanStream):
|
||||||
"""
|
"""
|
||||||
class representing a vban outstream
|
class representing a vban outstream
|
||||||
@@ -147,6 +161,42 @@ class VbanOutstream(VbanStream):
|
|||||||
return "out"
|
return "out"
|
||||||
|
|
||||||
|
|
||||||
|
class VbanAudioOutstream(VbanOutstream):
|
||||||
|
"""Represents a VBAN Audio Outstream"""
|
||||||
|
|
||||||
|
|
||||||
|
class VbanMidiOutstream(VbanOutstream):
|
||||||
|
"""Represents a VBAN Midi Outstream"""
|
||||||
|
|
||||||
|
|
||||||
|
def _make_stream_pair(remote, kind):
|
||||||
|
num_instream, num_outstream, num_midi, num_text = kind.vban
|
||||||
|
|
||||||
|
def _make_cls(i, dir):
|
||||||
|
match dir:
|
||||||
|
case "in":
|
||||||
|
if i < num_instream:
|
||||||
|
return VbanAudioInstream(remote, i)
|
||||||
|
elif i < num_instream + num_midi:
|
||||||
|
return VbanMidiInstream(remote, i)
|
||||||
|
else:
|
||||||
|
return VbanTextInstream(remote, i)
|
||||||
|
case "out":
|
||||||
|
if i < num_outstream:
|
||||||
|
return VbanAudioOutstream(remote, i)
|
||||||
|
else:
|
||||||
|
return VbanMidiOutstream(remote, i)
|
||||||
|
|
||||||
|
return (
|
||||||
|
tuple(_make_cls(i, "in") for i in range(num_instream + num_midi + num_text)),
|
||||||
|
tuple(_make_cls(i, "out") for i in range(num_outstream + num_midi)),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
@@ -156,9 +206,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):
|
||||||
self.remote.set("vban.Enable", 1)
|
self.remote.set("vban.Enable", 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user