Compare commits

..

20 Commits

Author SHA1 Message Date
bfdc0306e3 update default values for each driver type
open advanced settings popup if current tab is settings.

minor version bump
2023-09-13 12:16:28 +01:00
245476adfd Merge remote-tracking branch 'origin/dev' into add-advanced-settings 2023-09-13 11:30:00 +01:00
2562c02b7e lstrip hardware in as well. 2023-09-13 10:59:41 +01:00
aaa2c72668 fixes bug setting devices with trailing spaces
adds rejected_ids to util.
removes Voicemeeter devices as assignable
hardware devices

patch bump
2023-09-13 10:56:09 +01:00
7648b68b85 remove asio devices from hardware out context menus
if not A1

removes `-remove device selection-` from hardware out A1 context menu

patch bump

fixes #7
2023-09-11 12:36:40 +01:00
14c6b937d1 implements advanced settings popup
gives access to driver buffer settings.

may open by button or ctrl-a
2023-09-11 07:51:16 +01:00
5069db97da ensure Virtual Input gets correct label if cleared 2023-09-10 14:32:31 +01:00
681bf8e85c fixes bug renaming virtual strips.
patch bump
2023-09-10 14:23:34 +01:00
8424558f3d special thanks section added to readme 2023-09-07 07:29:04 +01:00
39bd5f21ea patch bump
fixes #3
2023-09-06 19:19:54 +01:00
77dfd00541 reduces the bus mode list for basic kind 2023-09-06 19:18:31 +01:00
790ac10d4a remove EQ button and events if kind is basic 2023-09-06 19:18:14 +01:00
ed5f9ae45b fixes hardware out A2 for basic kind.
patch bump
2023-09-06 16:20:04 +01:00
962b61f60a fixes k, mc layout for banana kind 2023-09-06 15:27:55 +01:00
b2e03aace1 add settings tab screenshot
Installation section added to readme
2023-09-06 15:07:59 +01:00
3a52655811 add Voicemeeter link 2023-09-06 05:29:23 +01:00
178d6e451b add screenshots 2023-09-06 00:58:09 +01:00
fc8ae11555 add badges 2023-09-06 00:42:49 +01:00
e4afe35fb2 initial README 2023-09-06 00:33:59 +01:00
e2edd29b87 hardware ins implemented
strip, bus params implemented
(mute, mono, eq etc)

bus mode buttons now rotate through all bus modes
2023-09-06 00:03:12 +01:00
11 changed files with 590 additions and 185 deletions

101
README.md
View File

@@ -1 +1,100 @@
# example-package
[![pdm-managed](https://img.shields.io/badge/pdm-managed-blueviolet)](https://pdm.fming.dev)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
# NVDA Voicemeeter
A remote control app for [Voicemeeter][voicemeeter], designed to be used with the [NVDA screen reader][nvda].
This is still an early release but it should be usable.
<img src="./img/settings.png" width=350 alt="Image of Voicemeeter NVDA app settings tab">
## Requirements
- [NVDA screen reader][nvda]
- [NVDA's Controller Client files][controller_client]
- Python 3.10 or greater
### Installation
First clone the source files from this repository
`git clone https://github.com/onyx-and-iris/nvda-voicemeeter.git`
Then download the [Controller Client][controller_client] and place the files into the directory `controllerClient`.
If you want to get started quickly and easily I have uploaded some compiled versions of the app in the [Releases][releases] section.
### Run
Once the repository is downloaded and the controller client files in place you can launch the GUI with the following `__main__.py`:
```python
import voicemeeterlib
import nvda_voicemeeter
KIND_ID = "potato"
with voicemeeterlib.api(KIND_ID, sync=True) as vm:
with nvda_voicemeeter.draw(KIND_ID, vm) as window:
window.run()
```
### KIND_ID
May be one of the following:
- `basic`
- `banana`
- `potato`
### Use
The app presents four tabs `Settings`, `Physical Strip`, `Virtual Strip` and `Buses`. Navigate between the tabs with `Control + TAB` and `Control + SHIFT + TAB`.
All controls within the tabs may be navigated between using `TAB`.
The following controls offer context menus accessed by pressing `SPACE` or `ENTER`:
- Hardware In
- Hardware Out
- Patch Composite
All other buttons can be triggered by pressing `SPACE` or `ENTER`.
To adjust Patch Asio Inputs to Strips and Patch Insert values use `UP` and `DOWN` arrows when in focus.
To rename a strip/bus channel navigate to the relevant tab, then press `F2`. This will open a popup window where you can set the channel index (with a spinbox) and set the new label using a text input box.
Pressing the `OK` button with an empty text input will clear the label. In this case the label will be read as a default value for that channel. For example, if the leftmost Strip label were cleared, the screen reader will now read `Hardware Input 1`.
Pressing `Cancel` will close the popup window with no affect on the label.
A single menu item `Voicemeeter` can be opened using `Alt` and then `v`. The menu allows you to:
- Restart Voicemeeter audio engine
- Save/Load current settings (as an xml file)
- Set a config to load automatically on app startup.
The `Save Settings` option opens a popup window with two buttons, `Browse` and `Cancel`. Browse opens a Save As dialog, Cancel returns to the main app window.
`Load Settings` and `Load on Startup` both open an Open dialog box immediately.
### Issues
If you have any questions/suggestions feel free to raise an issue or open a new discussion.
### Special Thanks
[Mario Loreti](https://www.marioloreti.net/en/) for his help in testing and offering feedback during development.
[NVAccess](https://www.nvaccess.org/) for creating the open source NVDA screen reader and its controller client.
[Vincent Burel](https://github.com/vburel2018) for creating Voicemeeter and its SDK.
[PySimpleGUI](https://github.com/PySimpleGUI) team for creating an awesome GUI framework.
[voicemeeter]: https://voicemeeter.com/
[nvda]: https://www.nvaccess.org/
[controller_client]: https://github.com/nvaccess/nvda/tree/master/extras/controllerClient
[releases]: https://github.com/onyx-and-iris/nvda-voicemeeter/releases

BIN
img/buses.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
img/physical_strip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
img/settings.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
img/virtual_strip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

8
pdm.lock generated
View File

@@ -6,7 +6,7 @@ groups = ["default", "build", "lint", "test"]
cross_platform = true
static_urls = false
lock_version = "4.3"
content_hash = "sha256:2aaf88f0abb701968bc22eb31fd189810850a505bb93553f67216e4d1d259750"
content_hash = "sha256:9051151ac4ac0edefdfaf52faa91dbff89d8bbc942a6ffa61b6ec6fee502aa8a"
[[package]]
name = "altgraph"
@@ -271,13 +271,13 @@ files = [
[[package]]
name = "voicemeeter-api"
version = "2.4.8"
version = "2.4.9"
requires_python = ">=3.10,<4.0"
summary = "A Python wrapper for the Voiceemeter API"
dependencies = [
"tomli<3.0.0,>=2.0.1; python_version < \"3.11\"",
]
files = [
{file = "voicemeeter_api-2.4.8-py3-none-any.whl", hash = "sha256:a3ff9e6f7516d2adedde93f6976526b385d8ae6d86598bfe541a44f498f42ea6"},
{file = "voicemeeter_api-2.4.8.tar.gz", hash = "sha256:0d37a9f2af0f68087aa9c76a8cfb2ba44c6b75bb344e8dfa9fd18ad2c862730c"},
{file = "voicemeeter_api-2.4.9-py3-none-any.whl", hash = "sha256:a09fd07fe3799cd5c880d491048da81d94e49aa97ec753aa1f9289acd27be965"},
{file = "voicemeeter_api-2.4.9.tar.gz", hash = "sha256:47ad614a8b9ccb0b4e47acf65666ce0f0537a0890fffda9949e995bea70e679c"},
]

View File

@@ -1,18 +1,20 @@
[project]
name = "nvda_voicemeeter"
version = "0.1.0"
version = "0.2.0"
description = "A Voicemeeter app compatible with NVDA"
authors = [
{name = "onyx-and-iris", email = "code@onyxandiris.online"},
{ name = "onyx-and-iris", email = "code@onyxandiris.online" },
]
dependencies = [
"pysimplegui>=4.60.5",
"pyparsing>=3.1.1",
"voicemeeter-api>=2.4.8",
"voicemeeter-api>=2.4.9",
]
requires-python = ">=3.10,<3.11"
readme = "README.md"
license = {text = "MIT"}
[project.license]
text = "MIT"
[tool.pdm.dev-dependencies]
build = [
@@ -26,5 +28,5 @@ test = [
"psgdemos>=1.12.1",
]
[tool.pdm.scripts]
build = {shell = "build.ps1"}
[tool.pdm.scripts.build]
shell = "build.ps1"

View File

@@ -5,6 +5,7 @@ from .util import (
get_asio_samples_list,
get_input_device_list,
get_insert_checkbox_index,
get_output_device_list,
get_patch_composite_list,
get_tabs_labels,
)
@@ -23,7 +24,10 @@ class Builder:
layout0 = []
if self.kind.name == "basic":
steps = (self.make_tab0_row0,)
steps = (
self.make_tab0_row0,
self.make_tab0_row1,
)
else:
steps = (
self.make_tab0_row0,
@@ -31,6 +35,7 @@ class Builder:
self.make_tab0_row2,
self.make_tab0_row3,
self.make_tab0_row4,
self.make_tab0_row5,
)
for step in steps:
layout0.append([step()])
@@ -72,11 +77,31 @@ class Builder:
return psg.Menu(menu_def, key="menus")
def make_tab0_row0(self) -> psg.Frame:
"""tab0 row0 represents hardware outs"""
"""tab0 row0 represents hardware ins"""
def add_physical_device_opts(layout):
devices = get_input_device_list(self.vm)
devices.append("- remove device selection -")
layout.append(
[
psg.ButtonMenu(
f"IN {i + 1}",
size=(6, 3),
menu_def=["", devices],
key=f"HARDWARE IN||{i + 1}",
)
for i in range(self.kind.phys_in)
]
)
hardware_in = list()
[step(hardware_in) for step in (add_physical_device_opts,)]
return psg.Frame("Hardware In", hardware_in)
def make_tab0_row1(self) -> psg.Frame:
"""tab0 row1 represents hardware outs"""
def add_physical_device_opts(layout):
if self.kind.name == "basic":
num_outs = self.kind.phys_out + self.kind.virt_out
else:
@@ -86,7 +111,7 @@ class Builder:
psg.ButtonMenu(
f"A{i + 1}",
size=(6, 3),
menu_def=["", devices],
menu_def=["", get_output_device_list(i, self.vm)],
key=f"HARDWARE OUT||A{i + 1}",
)
for i in range(num_outs)
@@ -97,8 +122,8 @@ class Builder:
[step(hardware_out) for step in (add_physical_device_opts,)]
return psg.Frame("Hardware Out", hardware_out)
def make_tab0_row1(self) -> psg.Frame:
"""tab0 row1 represents patch asio inputs to strips"""
def make_tab0_row2(self) -> psg.Frame:
"""tab0 row2 represents patch asio inputs to strips"""
def add_asio_checkboxes(layout, i):
nums = list(range(99))
@@ -134,8 +159,8 @@ class Builder:
asio_checkboxes = [inner]
return psg.Frame("PATCH ASIO Inputs to Strips", asio_checkboxes)
def make_tab0_row2(self) -> psg.Frame:
"""tab0 row2 represents patch composite"""
def make_tab0_row3(self) -> psg.Frame:
"""tab0 row3 represents patch composite"""
def add_physical_device_opts(layout):
outputs = get_patch_composite_list(self.vm.kind)
@@ -155,8 +180,8 @@ class Builder:
[step(hardware_out) for step in (add_physical_device_opts,)]
return psg.Frame("PATCH COMPOSITE", hardware_out)
def make_tab0_row3(self) -> psg.Frame:
"""tab0 row3 represents patch insert"""
def make_tab0_row4(self) -> psg.Frame:
"""tab0 row4 represents patch insert"""
def add_insert_checkboxes(layout, i):
if i <= self.kind.phys_in:
@@ -200,24 +225,21 @@ class Builder:
return psg.Frame("PATCH INSERT", asio_checkboxes)
def make_tab0_row4(self) -> psg.Frame:
"""tab0 row4 represents asio buffer"""
samples = get_asio_samples_list()
samples.append("Default")
def make_tab0_row5(self) -> psg.Frame:
"""tab0 row5 represents advanced settings"""
return psg.Frame(
"ASIO BUFFER",
"ADVANCED SETTINGS",
[
[
psg.ButtonMenu(
"ASIO BUFFER",
size=(14, 2),
menu_def=["", samples],
key="ASIO BUFFER",
psg.Button(
"ADVANCED SETTINGS",
size=(20, 2),
key="ADVANCED SETTINGS",
)
]
],
],
key="ADVANCED SETTINGS FRAME",
)
def make_tab1_row(self, i) -> psg.Frame:
@@ -234,7 +256,14 @@ class Builder:
else f"STRIP {i}||B{j - self.kind.phys_out + 1}",
)
for j in range(self.kind.phys_out + self.kind.virt_out)
]
],
)
layout.append(
[
psg.Button("Mono", size=(6, 2), key=f"STRIP {i}||MONO"),
psg.Button("Solo", size=(6, 2), key=f"STRIP {i}||SOLO"),
psg.Button("Mute", size=(6, 2), key=f"STRIP {i}||MUTE"),
],
)
outputs = list()
@@ -261,6 +290,22 @@ class Builder:
for j in range(self.kind.phys_out + self.kind.virt_out)
]
)
if i == self.kind.phys_in + 1:
layout.append(
[
psg.Button("K", size=(6, 2), key=f"STRIP {i}||MONO"),
psg.Button("Solo", size=(6, 2), key=f"STRIP {i}||SOLO"),
psg.Button("Mute", size=(6, 2), key=f"STRIP {i}||MUTE"),
],
)
else:
layout.append(
[
psg.Button("MC", size=(6, 2), key=f"STRIP {i}||MONO"),
psg.Button("Solo", size=(6, 2), key=f"STRIP {i}||SOLO"),
psg.Button("Mute", size=(6, 2), key=f"STRIP {i}||MUTE"),
],
)
outputs = list()
[step(outputs) for step in (add_strip_outputs,)]
@@ -274,7 +319,20 @@ class Builder:
"""tab3 row represents bus composite toggle"""
def add_strip_outputs(layout):
layout.append([psg.Button(f"BUSMODE", size=(12, 2), key=f"BUS {i}||MODE")])
params = ["MONO", "EQ", "MUTE", "MODE"]
if self.vm.kind.name == "basic":
params.remove("EQ")
label = {"MODE": "BUSMODE"}
layout.append(
[
psg.Button(
label.get(param, param.capitalize()),
size=(12 if param == "MODE" else 6, 2),
key=f"BUS {i}||{param}",
)
for param in params
]
)
outputs = list()
[step(outputs) for step in (add_strip_outputs,)]

View File

@@ -1,16 +1,25 @@
def _make_hardware_ins_cache(vm) -> dict:
return {**{f"HARDWARE IN||{i + 1}": vm.strip[i].device.name for i in range(vm.kind.phys_in)}}
def _make_hardware_outs_cache(vm) -> dict:
return {**{f"HARDWARE OUT||A{i + 1}": vm.bus[i].device.name for i in range(vm.kind.phys_out)}}
hw_outs = {**{f"HARDWARE OUT||A{i + 1}": vm.bus[i].device.name for i in range(vm.kind.phys_out)}}
if vm.kind.name == "basic":
hw_outs |= {f"HARDWARE OUT||A2": vm.bus[1].device.name}
return hw_outs
def _make_output_cache(vm) -> dict:
def _make_param_cache(vm, channel_type) -> dict:
params = {}
if channel_type == "strip":
match vm.kind.name:
case "basic":
return {
params |= {
**{f"STRIP {i}||A1": vm.strip[i].A1 for i in range(vm.kind.num_strip)},
**{f"STRIP {i}||B1": vm.strip[i].B1 for i in range(vm.kind.num_strip)},
}
case "banana":
return {
params |= {
**{f"STRIP {i}||A1": vm.strip[i].A1 for i in range(vm.kind.num_strip)},
**{f"STRIP {i}||A2": vm.strip[i].A2 for i in range(vm.kind.num_strip)},
**{f"STRIP {i}||A3": vm.strip[i].A3 for i in range(vm.kind.num_strip)},
@@ -18,7 +27,7 @@ def _make_output_cache(vm) -> dict:
**{f"STRIP {i}||B2": vm.strip[i].B2 for i in range(vm.kind.num_strip)},
}
case "potato":
return {
params |= {
**{f"STRIP {i}||A1": vm.strip[i].A1 for i in range(vm.kind.num_strip)},
**{f"STRIP {i}||A2": vm.strip[i].A2 for i in range(vm.kind.num_strip)},
**{f"STRIP {i}||A3": vm.strip[i].A3 for i in range(vm.kind.num_strip)},
@@ -28,10 +37,19 @@ def _make_output_cache(vm) -> dict:
**{f"STRIP {i}||B2": vm.strip[i].B2 for i in range(vm.kind.num_strip)},
**{f"STRIP {i}||B3": vm.strip[i].B3 for i in range(vm.kind.num_strip)},
}
def _make_bus_mode_cache(vm) -> dict:
return {**{f"BUS {i}||MODE": vm.bus[i].mode.get() for i in range(vm.kind.num_bus)}}
params |= {
**{f"STRIP {i}||MONO": vm.strip[i].mono for i in range(vm.kind.num_strip)},
**{f"STRIP {i}||SOLO": vm.strip[i].solo for i in range(vm.kind.num_strip)},
**{f"STRIP {i}||MUTE": vm.strip[i].mute for i in range(vm.kind.num_strip)},
}
return params
else:
return {
**{f"BUS {i}||MONO": vm.bus[i].mono for i in range(vm.kind.num_bus)},
**{f"BUS {i}||EQ": vm.bus[i].eq.on for i in range(vm.kind.num_bus)},
**{f"BUS {i}||MUTE": vm.bus[i].mute for i in range(vm.kind.num_bus)},
**{f"BUS {i}||MODE": vm.bus[i].mode.get() for i in range(vm.kind.num_bus)},
}
def _make_label_cache(vm) -> dict:
@@ -56,8 +74,10 @@ def _make_label_cache(vm) -> dict:
def _make_patch_asio_cache(vm) -> dict:
if vm.kind.name != "basic":
return {**{f"ASIO CHECKBOX||{i}": vm.patch.asio[i].get() for i in range(vm.kind.phys_out * 2)}}
def _make_patch_insert_cache(vm) -> dict:
if vm.kind.name != "basic":
return {**{f"INSERT CHECKBOX||{i}": vm.patch.insert[i].on for i in range(vm.kind.num_strip_levels)}}

View File

@@ -13,8 +13,32 @@ def get_insert_checkbox_index(kind, channel, num) -> int:
return (2 * kind.phys_in) + (8 * (num - kind.phys_in - 1)) + channel
_rejected_ids = (
"VBAudio100VMVAIO3",
"{F5735BD4-6EAF-4758-9710-9886E5AD0FF3}",
"{0239BE07-CEEF-4236-A900-AA778D432FD4}",
)
def get_input_device_list(vm) -> list:
return ["{type}: {name}".format(**vm.device.output(i)) for i in range(vm.device.outs)]
devices = []
for j in range(vm.device.ins):
device = vm.device.input(j)
if device["id"] not in _rejected_ids:
devices.append("{type}: {name}".format(**device))
return devices
def get_output_device_list(i, vm) -> list:
devices = []
for j in range(vm.device.outs):
device = vm.device.output(j)
if device["id"] not in _rejected_ids:
devices.append("{type}: {name}".format(**device))
if i == 0:
return devices
devices.append("- remove device selection -")
return [device for device in devices if not device.startswith("asio")]
def get_patch_composite_list(kind) -> list:
@@ -43,28 +67,20 @@ def get_patch_insert_channels() -> list:
_patch_insert_channels = get_patch_insert_channels()
def get_asio_samples_list() -> list:
return [
"1024",
"768",
"704",
"640",
"576",
"512",
"480",
"448",
"441",
"416",
"384",
"352",
"320",
"288",
"256",
"224",
"192",
"160",
"128",
def get_asio_samples_list(driver) -> list:
if driver == "MME":
samples = ["2048", "1536", "1024", "896", "768", "704", "640", "576", "512", "480", "441"]
else:
# fmt: off
samples = [
"2048", "1536", "1024", "768", "704", "640", "576", "512", "480", "448", "441", "416", "384",
"352", "320", "288", "256", "224", "192", "160", "128"
]
# fmt: on
if driver == "ASIO":
samples = [x for x in samples if x not in ("2048", "1536")]
samples.append("Default")
return samples
def get_tabs_labels() -> list:
@@ -88,3 +104,27 @@ def get_channel_identifier_list(vm) -> list:
for j in range(8):
identifiers.append(f"IN{i + 1} {j}")
return identifiers
def get_bus_modes(vm) -> list:
if vm.kind.name == "basic":
return [
"normal",
"amix",
"repeat",
"composite",
]
return [
"normal",
"amix",
"bmix",
"repeat",
"composite",
"tvmix",
"upmix21",
"upmix41",
"upmix61",
"centeronly",
"lfeonly",
"rearonly",
]

View File

@@ -6,10 +6,10 @@ import PySimpleGUI as psg
from .builder import Builder
from .models import (
_make_bus_mode_cache,
_make_hardware_ins_cache,
_make_hardware_outs_cache,
_make_label_cache,
_make_output_cache,
_make_param_cache,
_make_patch_asio_cache,
_make_patch_insert_cache,
)
@@ -18,6 +18,8 @@ from .parser import Parser
from .util import (
_patch_insert_channels,
get_asio_checkbox_index,
get_asio_samples_list,
get_bus_modes,
get_channel_identifier_list,
get_insert_checkbox_index,
get_patch_composite_list,
@@ -39,9 +41,10 @@ class NVDAVMWindow(psg.Window):
self.kind = self.vm.kind
self.logger = logger.getChild(type(self).__name__)
self.cache = {
"hw_ins": _make_hardware_ins_cache(self.vm),
"hw_outs": _make_hardware_outs_cache(self.vm),
"outputs": _make_output_cache(self.vm),
"busmode": _make_bus_mode_cache(self.vm),
"strip": _make_param_cache(self.vm, "strip"),
"bus": _make_param_cache(self.vm, "bus"),
"labels": _make_label_cache(self.vm),
"asio": _make_patch_asio_cache(self.vm),
"insert": _make_patch_insert_cache(self.vm),
@@ -52,11 +55,15 @@ class NVDAVMWindow(psg.Window):
layout = self.builder.run()
super().__init__(title, layout, return_keyboard_events=True, finalize=True)
buttonmenu_opts = {"takefocus": 1, "highlightthickness": 1}
for i in range(self.kind.phys_in):
self[f"HARDWARE IN||{i + 1}"].Widget.config(**buttonmenu_opts)
for i in range(self.kind.phys_out):
self[f"HARDWARE OUT||A{i + 1}"].Widget.config(**buttonmenu_opts)
if self.kind.name == "basic":
self[f"HARDWARE OUT||A2"].Widget.config(**buttonmenu_opts)
if self.kind.name != "basic":
[self[f"PATCH COMPOSITE||PC{i + 1}"].Widget.config(**buttonmenu_opts) for i in range(self.kind.phys_out)]
self["ASIO BUFFER"].Widget.config(**buttonmenu_opts)
self.register_events()
def __enter__(self):
@@ -92,15 +99,17 @@ class NVDAVMWindow(psg.Window):
def on_pdirty(self):
self.cache = {
"hw_ins": _make_hardware_ins_cache(self.vm),
"hw_outs": _make_hardware_outs_cache(self.vm),
"outputs": _make_output_cache(self.vm),
"busmode": _make_bus_mode_cache(self.vm),
"strip": _make_param_cache(self.vm, "strip"),
"bus": _make_param_cache(self.vm, "bus"),
"labels": _make_label_cache(self.vm),
"asio": _make_patch_asio_cache(self.vm),
"insert": _make_patch_insert_cache(self.vm),
}
for key, value in self.cache["labels"].items():
self[key].update(value=value)
if self.kind.name != "basic":
for key, value in self.cache["asio"].items():
identifier, i = key.split("||")
partial = get_channel_identifier_list(self.vm)[int(i)]
@@ -117,12 +126,23 @@ class NVDAVMWindow(psg.Window):
self["tabs"].bind("<FocusIn>", "||FOCUS IN")
self.bind("<Control-KeyPress-Tab>", "CTRL-TAB")
self.bind("<Control-Shift-KeyPress-Tab>", "CTRL-SHIFT-TAB")
self.bind("<Control-a>", "CTRL-A")
# Hardware In
for i in range(self.vm.kind.phys_in):
self[f"HARDWARE IN||{i + 1}"].bind("<FocusIn>", "||FOCUS IN")
self[f"HARDWARE IN||{i + 1}"].bind("<space>", "||KEY SPACE", propagate=False)
self[f"HARDWARE IN||{i + 1}"].bind("<Return>", "||KEY ENTER", propagate=False)
# Hardware Out
for i in range(self.vm.kind.phys_out):
self[f"HARDWARE OUT||A{i + 1}"].bind("<FocusIn>", "||FOCUS IN")
self[f"HARDWARE OUT||A{i + 1}"].bind("<space>", "||KEY SPACE", propagate=False)
self[f"HARDWARE OUT||A{i + 1}"].bind("<Return>", "||KEY ENTER", propagate=False)
if self.vm.kind.name == "basic":
self[f"HARDWARE OUT||A2"].bind("<FocusIn>", "||FOCUS IN")
self[f"HARDWARE OUT||A2"].bind("<space>", "||KEY SPACE", propagate=False)
self[f"HARDWARE OUT||A2"].bind("<Return>", "||KEY ENTER", propagate=False)
# Patch ASIO
if self.kind.name != "basic":
@@ -146,7 +166,12 @@ class NVDAVMWindow(psg.Window):
else:
[self[f"INSERT CHECKBOX||IN{i + 1} {j}"].bind("<FocusIn>", "||FOCUS IN") for j in range(8)]
# Strip Outputs
# Advanced Settings
if self.kind.name != "basic":
self["ADVANCED SETTINGS"].bind("<FocusIn>", "||FOCUS IN")
self["ADVANCED SETTINGS"].bind("<Return>", "||KEY ENTER")
# Strip Params
for i in range(self.kind.num_strip):
for j in range(self.kind.phys_out):
self[f"STRIP {i}||A{j + 1}"].bind("<FocusIn>", "||FOCUS IN")
@@ -154,17 +179,23 @@ class NVDAVMWindow(psg.Window):
for j in range(self.kind.virt_out):
self[f"STRIP {i}||B{j + 1}"].bind("<FocusIn>", "||FOCUS IN")
self[f"STRIP {i}||B{j + 1}"].bind("<Return>", "||KEY ENTER")
if i < self.kind.phys_in:
for param in ("MONO", "SOLO", "MUTE"):
self[f"STRIP {i}||{param}"].bind("<FocusIn>", "||FOCUS IN")
self[f"STRIP {i}||{param}"].bind("<Return>", "||KEY ENTER")
else:
for param in ("MONO", "SOLO", "MUTE"):
self[f"STRIP {i}||{param}"].bind("<FocusIn>", "||FOCUS IN")
self[f"STRIP {i}||{param}"].bind("<Return>", "||KEY ENTER")
# Bus Modes
# Bus Params
params = ["MONO", "EQ", "MUTE", "MODE"]
if self.vm.kind.name == "basic":
params.remove("EQ")
for i in range(self.kind.num_bus):
self[f"BUS {i}||MODE"].bind("<FocusIn>", "||FOCUS IN")
self[f"BUS {i}||MODE"].bind("<Return>", "||KEY ENTER")
# ASIO Buffer
if self.kind.name != "basic":
self["ASIO BUFFER"].bind("<FocusIn>", "||FOCUS IN")
self["ASIO BUFFER"].bind("<space>", "||KEY SPACE", propagate=False)
self["ASIO BUFFER"].bind("<Return>", "||KEY ENTER", propagate=False)
for param in params:
self[f"BUS {i}||{param}"].bind("<FocusIn>", "||FOCUS IN")
self[f"BUS {i}||{param}"].bind("<Return>", "||KEY ENTER")
def popup_save_as(self, message, title=None, initial_folder=None):
layout = [
@@ -186,27 +217,24 @@ class NVDAVMWindow(psg.Window):
self.logger.debug(f"values::{values}")
if event in (psg.WIN_CLOSED, "Cancel"):
break
elif event.endswith("||FOCUS IN"):
match parsed_cmd := self.parser.match.parseString(event):
case [[button], ["FOCUS", "IN"]]:
if values["Browse"]:
filepath = values["Browse"]
break
label = event.split("||")[0]
self.TKroot.after(
200 if label == "Edit" else 1,
self.nvda.speak,
label,
)
elif event.endswith("||KEY ENTER"):
self.nvda.speak(button)
case [[button], ["KEY", "ENTER"]]:
window.find_element_with_focus().click()
self.logger.debug(f"parsed::{parsed_cmd}")
window.close()
if filepath:
return Path(filepath)
def popup_rename(self, message, title=None, tab=None):
if tab == "Physical Strip":
upper = self.kind.phys_out + 1
upper = self.kind.phys_in + 1
elif tab == "Virtual Strip":
upper = self.kind.virt_out + 1
upper = self.kind.virt_in + 1
elif tab == "Buses":
upper = self.kind.num_bus + 1
@@ -236,24 +264,87 @@ class NVDAVMWindow(psg.Window):
self.logger.debug(f"values::{values}")
if event in (psg.WIN_CLOSED, "Cancel"):
break
elif event.endswith("||KEY ENTER"):
window.find_element_with_focus().click()
elif event == "Index":
match parsed_cmd := self.parser.match.parseString(event):
case ["Index"]:
val = values["Index"]
self.nvda.speak(f"Index {val}")
elif event.endswith("||FOCUS IN"):
if event.startswith("Index"):
case [[button], ["FOCUS", "IN"]]:
if button == "Index":
val = values["Index"]
self.nvda.speak(f"Index {val}")
else:
self.nvda.speak(event.split("||")[0])
elif event == "Ok":
self.nvda.speak(button)
case [[button], ["KEY", "ENTER"]]:
window.find_element_with_focus().click()
case ["Ok"]:
data = values
break
self.logger.debug(f"parsed::{parsed_cmd}")
window.close()
return data
def popup_advanced_settings(self, title):
def _make_buffering_frame() -> psg.Frame:
buffer = [
[
psg.ButtonMenu(
driver,
size=(14, 2),
menu_def=["", get_asio_samples_list(driver)],
key=f"BUFFER {driver}",
)
for driver in ("MME", "WDM", "KS", "ASIO")
],
]
return psg.Frame("BUFFERING", buffer)
layout = []
steps = (_make_buffering_frame,)
for step in steps:
layout.append([step()])
layout.append([psg.Button("Exit", size=(8, 2))])
window = psg.Window(title, layout, finalize=True)
buttonmenu_opts = {"takefocus": 1, "highlightthickness": 1}
for driver in ("MME", "WDM", "KS", "ASIO"):
window[f"BUFFER {driver}"].Widget.config(**buttonmenu_opts)
window[f"BUFFER {driver}"].bind("<FocusIn>", "||FOCUS IN")
window[f"BUFFER {driver}"].bind("<space>", "||KEY SPACE", propagate=False)
window[f"BUFFER {driver}"].bind("<Return>", "||KEY ENTER", propagate=False)
window["Exit"].bind("<FocusIn>", "||FOCUS IN")
window["Exit"].bind("<Return>", "||KEY ENTER")
while True:
event, values = window.read()
self.logger.debug(f"event::{event}")
self.logger.debug(f"values::{values}")
if event in (psg.WIN_CLOSED, "Exit"):
break
match parsed_cmd := self.parser.match.parseString(event):
case ["BUFFER MME" | "BUFFER WDM" | "BUFFER KS" | "BUFFER ASIO"]:
if values[event] == "Default":
if "MME" in event:
val = 1024
elif "WDM" in event or "KS" in event:
val = 512
else:
val = 0
else:
val = int(values[event])
driver = event.split()[1]
self.vm.set(f"option.buffer.{driver.lower()}", val)
self.TKroot.after(200, self.nvda.speak, f"{driver} BUFFER {val if val else 'default'}")
case [["BUFFER", driver], ["FOCUS", "IN"]]:
val = int(self.vm.get(f"option.buffer.{driver.lower()}"))
self.nvda.speak(f"{driver} BUFFER {val if val else 'default'}")
case [["BUFFER", driver], ["KEY", "SPACE" | "ENTER"]]:
open_context_menu_for_buttonmenu(window, f"BUFFER {driver}")
case [[button], ["FOCUS", "IN"]]:
self.nvda.speak(button)
case [[button], ["KEY", "ENTER"]]:
window.find_element_with_focus().click()
self.logger.debug(f"parsed::{parsed_cmd}")
window.close()
def run(self):
"""
Parses the event string and matches it to events
@@ -290,7 +381,8 @@ class NVDAVMWindow(psg.Window):
self[f"STRIP {index}||LABEL"].update(value=label)
self.cache["labels"][f"STRIP {index}||LABEL"] = label
case "Virtual Strip":
label = data.get("Edit") or f"Virtual Input {index + 1}"
index += self.kind.phys_in
label = data.get("Edit") or f"Virtual Input {index - self.kind.phys_in + 1}"
self.vm.strip[index].label = label
self[f"STRIP {index}||LABEL"].update(value=label)
self.cache["labels"][f"STRIP {index}||LABEL"] = label
@@ -367,6 +459,27 @@ class NVDAVMWindow(psg.Window):
case [["tabs"], ["FOCUS", "IN"]]:
self.nvda.speak(f"tab {values['tabs']}")
# Hardware In
case [["HARDWARE", "IN"], [key]]:
selection = values[f"HARDWARE IN||{key}"]
index = int(key) - 1
match selection.split(":"):
case [device_name]:
setattr(self.vm.strip[index].device, "wdm", "")
self.TKroot.after(200, self.nvda.speak, f"HARDWARE IN {key} device selection removed")
case [driver, device_name]:
setattr(self.vm.strip[index].device, driver, device_name.lstrip())
phonetic = {"mme": "em em e"}
self.TKroot.after(
200,
self.nvda.speak,
f"HARDWARE IN {key} set {phonetic.get(driver, driver)} {device_name}",
)
case [["HARDWARE", "IN"], [key], ["FOCUS", "IN"]]:
self.nvda.speak(f"HARDWARE INPUT {key} {self.cache['hw_ins'][f'HARDWARE IN||{key}']}")
case [["HARDWARE", "IN"], [key], ["KEY", "SPACE" | "ENTER"]]:
open_context_menu_for_buttonmenu(self, f"HARDWARE IN||{key}")
# Hardware out
case [["HARDWARE", "OUT"], [key]]:
selection = values[f"HARDWARE OUT||{key}"]
@@ -376,7 +489,7 @@ class NVDAVMWindow(psg.Window):
setattr(self.vm.bus[index].device, "wdm", "")
self.TKroot.after(200, self.nvda.speak, f"HARDWARE OUT {key} device selection removed")
case [driver, device_name]:
setattr(self.vm.bus[index].device, driver, device_name.strip())
setattr(self.vm.bus[index].device, driver, device_name.lstrip())
phonetic = {"mme": "em em e"}
self.TKroot.after(
200,
@@ -440,52 +553,125 @@ class NVDAVMWindow(psg.Window):
num = int(in_num[-1])
self.nvda.speak(f"Patch INSERT IN#{num} {channel} {'on' if val else 'off'}")
# ASIO Buffer
case ["ASIO BUFFER"]:
if values[event] == "Default":
val = 0
else:
val = values[event]
self.vm.option.buffer("asio", val)
self.TKroot.after(200, self.nvda.speak, f"ASIO BUFFER {val if val else 'default'}")
case [["ASIO", "BUFFER"], ["FOCUS", "IN"]]:
val = int(self.vm.get("option.buffer.asio"))
self.nvda.speak(f"ASIO BUFFER {val if val else 'default'}")
case [["ASIO", "BUFFER"], ["KEY", "SPACE" | "ENTER"]]:
open_context_menu_for_buttonmenu(self, "ASIO BUFFER")
# Strip outputs
case [["STRIP", index], [output]]:
val = not self.cache["outputs"][f"STRIP {index}||{output}"]
setattr(self.vm.strip[int(index)], output, val)
self.cache["outputs"][f"STRIP {index}||{output}"] = val
self.nvda.speak(f"STRIP {index} {output} {label if label else ''} {'on' if val else 'off'}")
case [["STRIP", index], [output], ["FOCUS", "IN"]]:
val = self.cache["outputs"][f"STRIP {index}||{output}"]
label = self.cache["labels"][f"STRIP {index}||LABEL"]
self.nvda.speak(f"{label} {output} {'on' if val else 'off'}")
case [["STRIP", index], [output], ["KEY", "ENTER"]]:
# Advanced Settings
case ["ADVANCED SETTINGS"] | ["CTRL-A"]:
if values["tabs"] == "Settings":
self.popup_advanced_settings(title="Advanced Settings")
case [["ADVANCED", "SETTINGS"], ["FOCUS", "IN"]]:
self.nvda.speak("ADVANCED SETTINGS")
case [["ADVANCED", "SETTINGS"], ["KEY", "ENTER"]]:
self.find_element_with_focus().click()
# Bus modes
case [["BUS", index], ["MODE"]]:
val = self.cache["busmode"][event]
if val != "normal":
self.vm.bus[int(index)].mode.normal = True
self.cache["busmode"][event] = "normal"
# Strip Params
case [["STRIP", index], [param]]:
label = self.cache["labels"][f"STRIP {index}||LABEL"]
match param:
case "MONO":
if int(index) < self.kind.phys_in:
actual = param.lower()
elif int(index) == self.kind.phys_in + 1:
actual = "k"
else:
self.vm.bus[int(index)].mode.composite = True
self.cache["busmode"][event] = "composite"
actual = "mc"
phonetic = {"k": "karaoke"}
if actual == "k":
next_val = self.vm.strip[int(index)].k + 1
if next_val == 4:
next_val = 0
setattr(self.vm.strip[int(index)], actual, next_val)
self.cache["strip"][f"STRIP {index}||{param}"] = next_val
self.nvda.speak(
f"{label} {phonetic.get(actual, actual)} {['off', 'k m', 'k 1', 'k 2'][next_val]}"
)
else:
val = not self.cache["strip"][f"STRIP {index}||{param}"]
setattr(self.vm.strip[int(index)], actual, val)
self.cache["strip"][f"STRIP {index}||{param}"] = val
self.nvda.speak(f"{label} {phonetic.get(actual, actual)} {'on' if val else 'off'}")
case _:
val = not self.cache["strip"][f"STRIP {index}||{param}"]
setattr(self.vm.strip[int(index)], param if param[0] in ("A", "B") else param.lower(), val)
self.cache["strip"][f"STRIP {index}||{param}"] = val
self.nvda.speak(f"{label} {param} {'on' if val else 'off'}")
case [["STRIP", index], [param], ["FOCUS", "IN"]]:
val = self.cache["strip"][f"STRIP {index}||{param}"]
match param:
case "MONO":
if int(index) < self.kind.phys_in:
actual = param.lower()
elif int(index) == self.kind.phys_in + 1:
actual = "k"
else:
actual = "mc"
case _:
actual = param
phonetic = {"k": "karaoke"}
label = self.cache["labels"][f"STRIP {index}||LABEL"]
if actual == "k":
self.nvda.speak(
f"{label} {phonetic.get(actual, actual)} {['off', 'k m', 'k 1', 'k 2'][self.cache['strip'][f'STRIP {int(index)}||{param}']]}"
)
else:
self.nvda.speak(f"{label} {phonetic.get(actual, actual)} {'on' if val else 'off'}")
case [["STRIP", index], [param], ["KEY", "ENTER"]]:
self.find_element_with_focus().click()
# Bus Params
case [["BUS", index], [param]]:
val = self.cache["bus"][event]
label = self.cache["labels"][f"BUS {index}||LABEL"]
match param:
case "EQ":
val = not val
self.vm.bus[int(index)].eq.on = val
self.cache["bus"][event] = val
self.TKroot.after(
200,
self.nvda.speak,
f"{label} bus mode {self.cache['busmode'][event]}",
f"{label} bus {param} {'on' if val else 'off'}",
)
case [["BUS", index], ["MODE"], ["FOCUS", "IN"]]:
case "MONO" | "MUTE":
val = not val
setattr(self.vm.bus[int(index)], param.lower(), val)
self.cache["bus"][event] = val
self.TKroot.after(
200,
self.nvda.speak,
f"{label} bus {param} {'on' if val else 'off'}",
)
case "MODE":
bus_modes = get_bus_modes(self.vm)
next_index = bus_modes.index(val) + 1
if next_index == len(bus_modes):
next_index = 0
next_bus = bus_modes[next_index]
phonetic = {
"amix": "Mix Down A",
"bmix": "Mix Down B",
"repeat": "Stereo Repeat",
"tvmix": "Up Mix TV",
"upmix21": "Up Mix 2.1",
"upmix41": "Up Mix 4.1",
"upmix61": "Up Mix 6.1",
"centeronly": "Center Only",
"lfeonly": "Low Frequency Effect Only",
"rearonly": "Rear Only",
}
setattr(self.vm.bus[int(index)].mode, next_bus, True)
self.cache["bus"][event] = next_bus
self.TKroot.after(
200,
self.nvda.speak,
f"{label} bus mode {phonetic.get(next_bus, next_bus)}",
)
case [["BUS", index], [param], ["FOCUS", "IN"]]:
label = self.cache["labels"][f"BUS {index}||LABEL"]
self.nvda.speak(f"{label} bus mode {self.cache['busmode'][f'BUS {index}||MODE']}")
case [["BUS", index], ["MODE"], ["KEY", "ENTER"]]:
val = self.cache["bus"][f"BUS {index}||{param}"]
if param == "MODE":
self.nvda.speak(f"{label} bus {param} {val}")
else:
self.nvda.speak(f"{label} bus {param} {'on' if val else 'off'}")
case [["BUS", index], [param], ["KEY", "ENTER"]]:
self.find_element_with_focus().click()
# Unknown