Compare commits

...

13 Commits

Author SHA1 Message Date
719328c6de adds check bounds.
bump pre-release a3
2023-09-15 23:01:26 +01:00
65a148aa7b bump to pre-release a2 2023-09-15 19:16:30 +01:00
ba1fb28187 use gain getters. 2023-09-15 19:12:07 +01:00
e35bad9e1e a1 version bump 2023-09-15 13:48:19 +01:00
804af85e65 adds up,down bind events 2023-09-15 12:35:10 +01:00
96de917b64 gain slider control events registered
allows adjusting gain by different amounts.
2023-09-15 11:35:27 +01:00
bc14116cd7 places gain sliders on slider tabs
slider focus in/out events registered.
2023-09-15 10:55:22 +01:00
086fbc1b8c start laying out nested tab structure
focus in events added for tabgroups

focus the settings tab on startup
2023-09-14 13:46:26 +01:00
047577265c documentation changes
python version upper limit increased to support 3.11
2023-09-14 08:43:15 +01:00
7ab7c30e80 adds advanced settings for Basic kind. 2023-09-13 14:12:48 +01:00
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
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
8 changed files with 569 additions and 177 deletions

View File

@@ -6,7 +6,7 @@
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.
For an outline of this projects goals see the [SPECIFICATION][spec].
<img src="./img/settings.png" width=350 alt="Image of Voicemeeter NVDA app settings tab">
@@ -18,11 +18,31 @@ This is still an early release but it should be usable.
### Installation
First clone the source files from this repository
#### `From Source`
`git clone https://github.com/onyx-and-iris/nvda-voicemeeter.git`
First clone the source files from this repository and install the dependencies.
Then download the [Controller Client][controller_client] and place the files into the directory `controllerClient`.
```
git clone https://github.com/onyx-and-iris/nvda-voicemeeter.git
cd nvda-voicemeeter
pip install .
```
Then download the [Controller Client][controller_client] and place the dll files into the directory `controllerClient`.
Your directory structure should look like this:
├── `controllerClient/`
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── `x64/`
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── nvdaControllerClient64.dll
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── `x86/`
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── nvdaControllerClient32.dll
#### `From Releases`
If you want to get started quickly and easily I have uploaded some compiled versions of the app in the [Releases][releases] section.
@@ -52,24 +72,38 @@ May be one of the following:
### Use
The app presents four tabs `Settings`, `Physical Strip`, `Virtual Strip` and `Buses`. Navigate between the tabs with `Control + TAB` and `Control + SHIFT + TAB`.
#### `Tabs`
The app presents four tabs `Settings`, `Physical Strip`, `Virtual Strip` and `Buses`. Navigate between the tabs with `Control + TAB` and `Control + SHIFT + TAB` or once focused on any tab, `Left` and `Right` arrow keys.
All controls within the tabs may be navigated between using `TAB`.
#### `Settings`
The following controls offer context menus accessed by pressing `SPACE` or `ENTER`:
- Hardware In
- Hardware Out
- Patch Composite
Press `ESCAPE` to exit any context menu.
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 access Advanced Settings you may press the Advanced Settings button or use `Control + A` when in the `Settings` tab.
#### `Strip/Bus`
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.
#### `Menu`
A single menu item `Voicemeeter` can be opened using `Alt` and then `v`. The menu allows you to:
- Restart Voicemeeter audio engine
@@ -94,6 +128,7 @@ If you have any questions/suggestions feel free to raise an issue or open a new
[PySimpleGUI](https://github.com/PySimpleGUI) team for creating an awesome GUI framework.
[spec]: ./SPECIFICATION.md
[voicemeeter]: https://voicemeeter.com/
[nvda]: https://www.nvaccess.org/
[controller_client]: https://github.com/nvaccess/nvda/tree/master/extras/controllerClient

30
SPECIFICATION.md Normal file
View File

@@ -0,0 +1,30 @@
# Software Specification
## Description
A remote control utility for Voicemeeter designed to be used with the NVDA screen reader.
## Requirements
#### Functional Goals
- Parameter updates caused by user input should be read back to the user via the screen reader.
- When focusing a control the current value for that control should be read back to the user.
- The application should scale correctly according to each kind of Voicemeeter (basic, banana, potato). This means the following:
- Correct number of strips/buses.
- Correct number of bus assignments for each strip.
- Where certain controls are valid for one kind they may not be for another.
- Where possible set limits on data entry and keep controls appropriate for the type of parameter.
#### Accessibility Goals
- Every control must be usable with a keyboard.
- Navigation around the application must be doable with a keyboard.
- Should use standard Windows controls only.
## Limitations
- May not cover 100% of the Voicemeeter GUI, for example the many EQ parameters.
- Only designed to work with the NVDA screen reader. Other screen readers not supported.
- Only the main Voicemeeter GUI supported by this application. No support for Matrix or other Voicemeeter products.
- Runs on Python version 3.10 or greater.

2
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:9051151ac4ac0edefdfaf52faa91dbff89d8bbc942a6ffa61b6ec6fee502aa8a"
content_hash = "sha256:ba53368b628b713c9cf4eb54e6f5c5c4af207c8e247d473417e4c2a4b47f645d"
[[package]]
name = "altgraph"

View File

@@ -1,6 +1,6 @@
[project]
name = "nvda_voicemeeter"
version = "0.1.5"
version = "0.2.1a3"
description = "A Voicemeeter app compatible with NVDA"
authors = [
{ name = "onyx-and-iris", email = "code@onyxandiris.online" },
@@ -10,7 +10,7 @@ dependencies = [
"pyparsing>=3.1.1",
"voicemeeter-api>=2.4.9",
]
requires-python = ">=3.10,<3.11"
requires-python = ">=3.10,<3.12"
readme = "README.md"
[project.license]

View File

@@ -2,7 +2,6 @@ import PySimpleGUI as psg
from .util import (
get_asio_checkbox_index,
get_asio_samples_list,
get_input_device_list,
get_insert_checkbox_index,
get_output_device_list,
@@ -27,6 +26,7 @@ class Builder:
steps = (
self.make_tab0_row0,
self.make_tab0_row1,
self.make_tab0_row5,
)
else:
steps = (
@@ -40,25 +40,61 @@ class Builder:
for step in steps:
layout0.append([step()])
layout1 = []
steps = (self.make_tab1_rows,)
layout1_1 = []
steps = (self.make_tab1_button_rows,)
for step in steps:
layout1.append([step()])
layout2 = []
steps = (self.make_tab2_rows,)
layout1_1.append([step()])
layout1_2 = []
steps = (self.make_tab1_slider_rows,)
for step in steps:
layout2.append([step()])
layout1_2.append([step()])
layout3 = []
steps = (self.make_tab3_rows,)
layout2_1 = []
steps = (self.make_tab2_button_rows,)
for step in steps:
layout3.append([step()])
layout2_1.append([step()])
layout2_2 = []
steps = (self.make_tab2_slider_rows,)
for step in steps:
layout2_2.append([step()])
layouts = [layout0, layout1, layout2, layout3]
layout3_1 = []
steps = (self.make_tab3_button_rows,)
for step in steps:
layout3_1.append([step()])
layout3_2 = []
steps = (self.make_tab3_slider_rows,)
for step in steps:
layout3_2.append([step()])
tabs = [psg.Tab(identifier, layouts[i], key=identifier) for i, identifier in enumerate(get_tabs_labels())]
tab_group = psg.TabGroup([tabs], change_submits=True, key="tabs")
def _make_inner_tabgroup(layouts, identifier) -> psg.TabGroup:
inner_layout = []
for i, tabname in enumerate(("buttons", "sliders")):
inner_layout.append([psg.Tab(tabname.capitalize(), layouts[i], key=f"tab||{identifier}||{tabname}")])
return psg.TabGroup(
inner_layout,
change_submits=True,
enable_events=True,
key=f"tabgroup||{identifier}",
)
def _make_tabs(identifier) -> psg.Tab:
match identifier:
case "Settings":
return psg.Tab("Settings", layout0, key="tab||Settings")
case "Physical Strip":
tabgroup = _make_inner_tabgroup((layout1_1, layout1_2), identifier)
case "Virtual Strip":
tabgroup = _make_inner_tabgroup((layout2_1, layout2_2), identifier)
case "Buses":
tabgroup = _make_inner_tabgroup((layout3_1, layout3_2), identifier)
return psg.Tab(identifier, [[tabgroup]], key=f"tab||{identifier}")
tabs = []
for tab in get_tabs_labels():
tabs.append(_make_tabs(tab))
tab_group = psg.TabGroup([tabs], change_submits=True, enable_events=True, key="tabgroup")
return [[menu], [tab_group]]
@@ -94,7 +130,7 @@ class Builder:
]
)
hardware_in = list()
hardware_in = []
[step(hardware_in) for step in (add_physical_device_opts,)]
return psg.Frame("Hardware In", hardware_in)
@@ -118,7 +154,7 @@ class Builder:
]
)
hardware_out = list()
hardware_out = []
[step(hardware_out) for step in (add_physical_device_opts,)]
return psg.Frame("Hardware Out", hardware_out)
@@ -150,7 +186,7 @@ class Builder:
],
)
inner = list()
inner = []
asio_checkboxlists = ([] for _ in range(self.kind.phys_out))
for i, checkbox_list in enumerate(asio_checkboxlists):
[step(checkbox_list, i + 1) for step in (add_asio_checkboxes,)]
@@ -176,7 +212,7 @@ class Builder:
]
)
hardware_out = list()
hardware_out = []
[step(hardware_out) for step in (add_physical_device_opts,)]
return psg.Frame("PATCH COMPOSITE", hardware_out)
@@ -211,8 +247,8 @@ class Builder:
],
)
asio_checkboxes = list()
inner = list()
asio_checkboxes = []
inner = []
checkbox_lists = ([] for _ in range(self.kind.num_strip))
for i, checkbox_list in enumerate(checkbox_lists):
if i < self.kind.phys_in:
@@ -226,27 +262,23 @@ class Builder:
return psg.Frame("PATCH INSERT", asio_checkboxes)
def make_tab0_row5(self) -> psg.Frame:
"""tab0 row5 represents asio buffer"""
samples = get_asio_samples_list()
samples.append("Default")
"""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="ASIO BUFFER FRAME",
key="ADVANCED SETTINGS FRAME",
)
def make_tab1_row(self, i) -> psg.Frame:
def make_tab1_button_row(self, i) -> psg.Frame:
"""tab1 row represents a strip's outputs (A1-A5, B1-B3)"""
def add_strip_outputs(layout):
@@ -270,15 +302,40 @@ class Builder:
],
)
outputs = list()
outputs = []
[step(outputs) for step in (add_strip_outputs,)]
return psg.Frame(self.window.cache["labels"][f"STRIP {i}||LABEL"], outputs, key=f"STRIP {i}||LABEL")
def make_tab1_rows(self) -> psg.Frame:
layout = [[self.make_tab1_row(i)] for i in range(self.kind.phys_in)]
def make_tab1_button_rows(self) -> psg.Frame:
layout = [[self.make_tab1_button_row(i)] for i in range(self.kind.phys_in)]
return psg.Frame(None, layout, border_width=0)
def make_tab2_row(self, i) -> psg.Frame:
def make_tab1_slider_row(self, i) -> psg.Frame:
def add_gain_slider(layout):
layout.append(
[
psg.Slider(
range=(-60, 12),
default_value=self.vm.strip[i].gain,
resolution=0.1,
disable_number_display=True,
expand_x=True,
enable_events=True,
orientation="horizontal",
key=f"STRIP {i}||SLIDER GAIN",
)
]
)
outputs = []
[step(outputs) for step in (add_gain_slider,)]
return psg.Frame(self.window.cache["labels"][f"STRIP {i}||LABEL"], outputs, key=f"STRIP {i}||LABEL||SLIDER")
def make_tab1_slider_rows(self) -> psg.Frame:
layout = [[self.make_tab1_slider_row(i)] for i in range(self.kind.phys_in)]
return psg.Frame(None, layout, border_width=0)
def make_tab2_button_row(self, i) -> psg.Frame:
"""tab2 row represents a strip's outputs (A1-A5, B1-B3)"""
def add_strip_outputs(layout):
@@ -311,15 +368,44 @@ class Builder:
],
)
outputs = list()
outputs = []
[step(outputs) for step in (add_strip_outputs,)]
return psg.Frame(self.window.cache["labels"][f"STRIP {i}||LABEL"], outputs, key=f"STRIP {i}||LABEL")
def make_tab2_rows(self) -> psg.Frame:
layout = [[self.make_tab2_row(i)] for i in range(self.kind.phys_in, self.kind.phys_in + self.kind.virt_in)]
def make_tab2_button_rows(self) -> psg.Frame:
layout = [
[self.make_tab2_button_row(i)] for i in range(self.kind.phys_in, self.kind.phys_in + self.kind.virt_in)
]
return psg.Frame(None, layout, border_width=0)
def make_tab3_row(self, i) -> psg.Frame:
def make_tab2_slider_row(self, i) -> psg.Frame:
def add_gain_slider(layout):
layout.append(
[
psg.Slider(
range=(-60, 12),
default_value=self.vm.strip[i].gain,
resolution=0.1,
disable_number_display=True,
expand_x=True,
enable_events=True,
orientation="horizontal",
key=f"STRIP {i}||SLIDER GAIN",
)
]
)
outputs = []
[step(outputs) for step in (add_gain_slider,)]
return psg.Frame(self.window.cache["labels"][f"STRIP {i}||LABEL"], outputs, key=f"STRIP {i}||LABEL||SLIDER")
def make_tab2_slider_rows(self) -> psg.Frame:
layout = [
[self.make_tab2_slider_row(i)] for i in range(self.kind.phys_in, self.kind.phys_in + self.kind.virt_in)
]
return psg.Frame(None, layout, border_width=0)
def make_tab3_button_row(self, i) -> psg.Frame:
"""tab3 row represents bus composite toggle"""
def add_strip_outputs(layout):
@@ -338,10 +424,35 @@ class Builder:
]
)
outputs = list()
outputs = []
[step(outputs) for step in (add_strip_outputs,)]
return psg.Frame(self.window.cache["labels"][f"BUS {i}||LABEL"], outputs, key=f"BUS {i}||LABEL")
def make_tab3_rows(self) -> psg.Frame:
layout = [[self.make_tab3_row(i)] for i in range(self.kind.num_bus)]
def make_tab3_button_rows(self) -> psg.Frame:
layout = [[self.make_tab3_button_row(i)] for i in range(self.kind.num_bus)]
return psg.Frame(None, layout, border_width=0)
def make_tab3_slider_row(self, i) -> psg.Frame:
def add_gain_slider(layout):
layout.append(
[
psg.Slider(
range=(-60, 12),
default_value=self.vm.bus[i].gain,
resolution=0.1,
disable_number_display=True,
expand_x=True,
enable_events=True,
orientation="horizontal",
key=f"BUS {i}||SLIDER GAIN",
)
]
)
outputs = []
[step(outputs) for step in (add_gain_slider,)]
return psg.Frame(self.window.cache["labels"][f"BUS {i}||LABEL"], outputs, key=f"BUS {i}||LABEL||SLIDER")
def make_tab3_slider_rows(self) -> psg.Frame:
layout = [[self.make_tab3_slider_row(i)] for i in range(self.kind.num_bus)]
return psg.Frame(None, layout, border_width=0)

View File

@@ -42,14 +42,14 @@ def _make_param_cache(vm, channel_type) -> dict:
**{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 {
params |= {
**{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)},
}
return params
def _make_label_cache(vm) -> dict:

View File

@@ -67,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:
@@ -136,3 +128,12 @@ def get_bus_modes(vm) -> list:
"lfeonly",
"rearonly",
]
def check_bounds(val, bounds):
lower, upper = bounds
if val > upper:
val = upper
elif val < lower:
val = lower
return val

View File

@@ -17,11 +17,14 @@ from .nvda import Nvda
from .parser import Parser
from .util import (
_patch_insert_channels,
check_bounds,
get_asio_checkbox_index,
get_asio_samples_list,
get_bus_modes,
get_channel_identifier_list,
get_insert_checkbox_index,
get_patch_composite_list,
get_tabs_labels,
open_context_menu_for_buttonmenu,
)
@@ -62,11 +65,14 @@ class NVDAVMWindow(psg.Window):
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)
if self.kind.name != "basic":
self["ASIO BUFFER FRAME"].update(visible=False)
self["ASIO BUFFER FRAME"].hide_row()
slider_opts = {"takefocus": 1, "highlightthickness": 1}
for i in range(self.kind.num_strip):
self[f"STRIP {i}||SLIDER GAIN"].Widget.config(**slider_opts)
for i in range(self.kind.num_bus):
self[f"BUS {i}||SLIDER GAIN"].Widget.config(**slider_opts)
self.register_events()
self["tabgroup"].set_focus()
def __enter__(self):
settings_path = Path.cwd() / self.SETTINGS
@@ -111,6 +117,11 @@ class NVDAVMWindow(psg.Window):
}
for key, value in self.cache["labels"].items():
self[key].update(value=value)
self[f"{key}||SLIDER"].update(value=value)
for i in range(self.kind.num_strip):
self[f"STRIP {i}||SLIDER GAIN"].update(value=self.vm.strip[i].gain)
for i in range(self.kind.num_bus):
self[f"BUS {i}||SLIDER GAIN"].update(value=self.vm.bus[i].gain)
if self.kind.name != "basic":
for key, value in self.cache["asio"].items():
identifier, i = key.split("||")
@@ -125,9 +136,13 @@ class NVDAVMWindow(psg.Window):
"""Registers events for widgets"""
# TABS
self["tabs"].bind("<FocusIn>", "||FOCUS IN")
self["tabgroup"].bind("<FocusIn>", "||FOCUS IN")
for tabname in get_tabs_labels()[1:]:
self[f"tabgroup||{tabname}"].bind("<FocusIn>", "||FOCUS IN")
self[f"tabgroup||{tabname}"].bind("<Shift-KeyPress-Tab>", "||KEY SHIFT TAB")
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):
@@ -167,6 +182,10 @@ class NVDAVMWindow(psg.Window):
else:
[self[f"INSERT CHECKBOX||IN{i + 1} {j}"].bind("<FocusIn>", "||FOCUS IN") for j in range(8)]
# Advanced Settings
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):
@@ -184,6 +203,23 @@ class NVDAVMWindow(psg.Window):
self[f"STRIP {i}||{param}"].bind("<FocusIn>", "||FOCUS IN")
self[f"STRIP {i}||{param}"].bind("<Return>", "||KEY ENTER")
# Strip Sliders
for i in range(self.kind.num_strip):
self[f"STRIP {i}||SLIDER GAIN"].bind("<FocusIn>", "||FOCUS IN")
self[f"STRIP {i}||SLIDER GAIN"].bind("<FocusOut>", "||FOCUS OUT")
self[f"STRIP {i}||SLIDER GAIN"].bind("<Left>", "||KEY LEFT")
self[f"STRIP {i}||SLIDER GAIN"].bind("<Right>", "||KEY RIGHT")
self[f"STRIP {i}||SLIDER GAIN"].bind("<Shift-KeyPress-Left>", "||KEY SHIFT LEFT")
self[f"STRIP {i}||SLIDER GAIN"].bind("<Shift-KeyPress-Right>", "||KEY SHIFT RIGHT")
self[f"STRIP {i}||SLIDER GAIN"].bind("<Control-KeyPress-Left>", "||KEY CTRL LEFT")
self[f"STRIP {i}||SLIDER GAIN"].bind("<Control-KeyPress-Right>", "||KEY CTRL RIGHT")
self[f"STRIP {i}||SLIDER GAIN"].bind("<Up>", "||KEY UP")
self[f"STRIP {i}||SLIDER GAIN"].bind("<Down>", "||KEY DOWN")
self[f"STRIP {i}||SLIDER GAIN"].bind("<Shift-KeyPress-Up>", "||KEY SHIFT UP")
self[f"STRIP {i}||SLIDER GAIN"].bind("<Shift-KeyPress-Down>", "||KEY SHIFT DOWN")
self[f"STRIP {i}||SLIDER GAIN"].bind("<Control-KeyPress-Up>", "||KEY CTRL UP")
self[f"STRIP {i}||SLIDER GAIN"].bind("<Control-KeyPress-Down>", "||KEY CTRL DOWN")
# Bus Params
params = ["MONO", "EQ", "MUTE", "MODE"]
if self.vm.kind.name == "basic":
@@ -193,11 +229,22 @@ class NVDAVMWindow(psg.Window):
self[f"BUS {i}||{param}"].bind("<FocusIn>", "||FOCUS IN")
self[f"BUS {i}||{param}"].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)
# Bus Sliders
for i in range(self.kind.num_bus):
self[f"BUS {i}||SLIDER GAIN"].bind("<FocusIn>", "||FOCUS IN")
self[f"BUS {i}||SLIDER GAIN"].bind("<FocusOut>", "||FOCUS OUT")
self[f"BUS {i}||SLIDER GAIN"].bind("<Left>", "||KEY LEFT")
self[f"BUS {i}||SLIDER GAIN"].bind("<Right>", "||KEY RIGHT")
self[f"BUS {i}||SLIDER GAIN"].bind("<Shift-KeyPress-Left>", "||KEY SHIFT LEFT")
self[f"BUS {i}||SLIDER GAIN"].bind("<Shift-KeyPress-Right>", "||KEY SHIFT RIGHT")
self[f"BUS {i}||SLIDER GAIN"].bind("<Control-KeyPress-Left>", "||KEY CTRL LEFT")
self[f"BUS {i}||SLIDER GAIN"].bind("<Control-KeyPress-Right>", "||KEY CTRL RIGHT")
self[f"BUS {i}||SLIDER GAIN"].bind("<Up>", "||KEY UP")
self[f"BUS {i}||SLIDER GAIN"].bind("<Down>", "||KEY DOWN")
self[f"BUS {i}||SLIDER GAIN"].bind("<Shift-KeyPress-Up>", "||KEY SHIFT UP")
self[f"BUS {i}||SLIDER GAIN"].bind("<Shift-KeyPress-Down>", "||KEY SHIFT DOWN")
self[f"BUS {i}||SLIDER GAIN"].bind("<Control-KeyPress-Up>", "||KEY CTRL UP")
self[f"BUS {i}||SLIDER GAIN"].bind("<Control-KeyPress-Down>", "||KEY CTRL DOWN")
def popup_save_as(self, message, title=None, initial_folder=None):
layout = [
@@ -219,18 +266,15 @@ class NVDAVMWindow(psg.Window):
self.logger.debug(f"values::{values}")
if event in (psg.WIN_CLOSED, "Cancel"):
break
elif event.endswith("||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"):
window.find_element_with_focus().click()
match parsed_cmd := self.parser.match.parseString(event):
case [[button], ["FOCUS", "IN"]]:
if values["Browse"]:
filepath = values["Browse"]
break
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)
@@ -269,24 +313,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":
val = values["Index"]
self.nvda.speak(f"Index {val}")
elif event.endswith("||FOCUS IN"):
if event.startswith("Index"):
match parsed_cmd := self.parser.match.parseString(event):
case ["Index"]:
val = values["Index"]
self.nvda.speak(f"Index {val}")
else:
self.nvda.speak(event.split("||")[0])
elif event == "Ok":
data = values
break
case [[button], ["FOCUS", "IN"]]:
if button == "Index":
val = values["Index"]
self.nvda.speak(f"Index {val}")
else:
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
@@ -300,17 +407,16 @@ class NVDAVMWindow(psg.Window):
self.logger.debug(f"values::{values}")
if event in (psg.WIN_CLOSED, "Exit"):
break
elif event == "tabs":
self.nvda.speak(f"tab {values['tabs']}")
match parsed_cmd := self.parser.match.parseString(event):
# Focus tabgroup
case ["CTRL-TAB"] | ["CTRL-SHIFT-TAB"]:
self["tabs"].set_focus()
self["tabgroup"].set_focus()
self.nvda.speak(f"{values['tabgroup']}")
# Rename popups
case ["F2:113"]:
tab = values["tabs"]
tab = values["tabgroup"]
if tab in ("Physical Strip", "Virtual Strip", "Buses"):
data = self.popup_rename("Label", title=f"Rename {tab}", tab=tab)
if not data: # cancel was pressed
@@ -395,11 +501,18 @@ class NVDAVMWindow(psg.Window):
else:
with open(self.SETTINGS, "wb") as f:
f.truncate()
self.logger.debug("default bin was truncated")
self.logger.debug("settings.json was truncated")
# Tabs
case [["tabs"], ["FOCUS", "IN"]]:
self.nvda.speak(f"tab {values['tabs']}")
case ["tabgroup"] | [["tabgroup"], ["FOCUS", "IN"]]:
if self.find_element_with_focus() is None:
self.nvda.speak(f"{values['tabgroup']}")
case [["tabgroup"], tabname] | [["tabgroup"], tabname, ["FOCUS", "IN"]]:
if self.find_element_with_focus() is None:
name = " ".join(tabname)
self.nvda.speak(f"{values[f'tabgroup||{name}']}")
case [["tabgroup"], _, ["KEY", "SHIFT", "TAB"]]:
self.nvda.speak(values["tabgroup"])
# Hardware In
case [["HARDWARE", "IN"], [key]]:
@@ -418,7 +531,8 @@ class NVDAVMWindow(psg.Window):
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}']}")
if self.find_element_with_focus() is not None:
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}")
@@ -439,7 +553,8 @@ class NVDAVMWindow(psg.Window):
f"HARDWARE OUT {key} set {phonetic.get(driver, driver)} {device_name}",
)
case [["HARDWARE", "OUT"], [key], ["FOCUS", "IN"]]:
self.nvda.speak(f"HARDWARE OUT {key} {self.cache['hw_outs'][f'HARDWARE OUT||{key}']}")
if self.find_element_with_focus() is not None:
self.nvda.speak(f"HARDWARE OUT {key} {self.cache['hw_outs'][f'HARDWARE OUT||{key}']}")
case [["HARDWARE", "OUT"], [key], ["KEY", "SPACE" | "ENTER"]]:
open_context_menu_for_buttonmenu(self, f"HARDWARE OUT||{key}")
@@ -451,10 +566,11 @@ class NVDAVMWindow(psg.Window):
channel = ("left", "right")[int(channel)]
self.nvda.speak(f"Patch ASIO {in_num} {channel} set to {val}")
case [["ASIO", "CHECKBOX"], [in_num, channel], ["FOCUS", "IN"]]:
val = values[f"ASIO CHECKBOX||{in_num} {channel}"]
channel = ("left", "right")[int(channel)]
num = int(in_num[-1])
self.nvda.speak(f"Patch ASIO inputs to strips IN#{num} {channel} {val}")
if self.find_element_with_focus() is not None:
val = values[f"ASIO CHECKBOX||{in_num} {channel}"]
channel = ("left", "right")[int(channel)]
num = int(in_num[-1])
self.nvda.speak(f"Patch ASIO inputs to strips IN#{num} {channel} {val}")
# Patch COMPOSITE
case [["PATCH", "COMPOSITE"], [key]]:
@@ -463,12 +579,13 @@ class NVDAVMWindow(psg.Window):
self.vm.patch.composite[index].set(get_patch_composite_list(self.kind).index(val) + 1)
self.TKroot.after(200, self.nvda.speak, f"PATCH COMPOSITE {key[-1]} set {val}")
case [["PATCH", "COMPOSITE"], [key], ["FOCUS", "IN"]]:
if values[f"PATCH COMPOSITE||{key}"]:
val = values[f"PATCH COMPOSITE||{key}"]
else:
index = int(key[-1]) - 1
val = get_patch_composite_list(self.kind)[self.vm.patch.composite[index].get() - 1]
self.nvda.speak(f"Patch COMPOSITE {key[-1]} {val}")
if self.find_element_with_focus() is not None:
if values[f"PATCH COMPOSITE||{key}"]:
val = values[f"PATCH COMPOSITE||{key}"]
else:
index = int(key[-1]) - 1
val = get_patch_composite_list(self.kind)[self.vm.patch.composite[index].get() - 1]
self.nvda.speak(f"Patch COMPOSITE {key[-1]} {val}")
case [["PATCH", "COMPOSITE"], [key], ["KEY", "SPACE" | "ENTER"]]:
open_context_menu_for_buttonmenu(self, f"PATCH COMPOSITE||{key}")
@@ -485,29 +602,25 @@ class NVDAVMWindow(psg.Window):
f"PATCH INSERT {in_num} {_patch_insert_channels[int(channel)]} set to {'on' if val else 'off'}"
)
case [["INSERT", "CHECKBOX"], [in_num, channel], ["FOCUS", "IN"]]:
index = get_insert_checkbox_index(
self.kind,
int(channel),
int(in_num[-1]),
)
val = values[f"INSERT CHECKBOX||{in_num} {channel}"]
channel = _patch_insert_channels[int(channel)]
num = int(in_num[-1])
self.nvda.speak(f"Patch INSERT IN#{num} {channel} {'on' if val else 'off'}")
if self.find_element_with_focus() is not None:
index = get_insert_checkbox_index(
self.kind,
int(channel),
int(in_num[-1]),
)
val = values[f"INSERT CHECKBOX||{in_num} {channel}"]
channel = _patch_insert_channels[int(channel)]
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")
# Advanced Settings
case ["ADVANCED SETTINGS"] | ["CTRL-A"]:
if values["tabgroup"] == "tab||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()
# Strip Params
case [["STRIP", index], [param]]:
@@ -541,28 +654,79 @@ class NVDAVMWindow(psg.Window):
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'}")
if self.find_element_with_focus() is not None:
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()
# Strip Sliders
case [["STRIP", index], ["SLIDER", "GAIN"]]:
label = self.cache["labels"][f"STRIP {index}||LABEL"]
val = values[event]
self.vm.strip[int(index)].gain = val
self.nvda.speak(f"{label} gain slider {val}")
case [["STRIP", index], ["SLIDER", "GAIN"], ["FOCUS", "IN"]]:
if self.find_element_with_focus() is not None:
self.vm.event.pdirty = False
label = self.cache["labels"][f"STRIP {index}||LABEL"]
val = values[f"STRIP {index}||SLIDER GAIN"]
self.nvda.speak(f"{label} gain slider {val}")
case [["STRIP", index], ["SLIDER", "GAIN"], ["FOCUS", "OUT"]]:
self.vm.event.pdirty = True
case [["STRIP", index], ["SLIDER", "GAIN"], ["KEY", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction]]:
val = self.vm.strip[int(index)].gain
match direction:
case "RIGHT" | "UP":
val += 1
case "LEFT" | "DOWN":
val -= 1
self.vm.strip[int(index)].gain = check_bounds(val, (-60, 12))
self[f"STRIP {index}||SLIDER GAIN"].update(value=val)
case [
["STRIP", index],
["SLIDER", "GAIN"],
["KEY", "CTRL", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
]:
val = self.vm.strip[int(index)].gain
match direction:
case "RIGHT" | "UP":
val += 3
case "LEFT" | "DOWN":
val -= 3
self.vm.strip[int(index)].gain = check_bounds(val, (-60, 12))
self[f"STRIP {index}||SLIDER GAIN"].update(value=val)
case [
["STRIP", index],
["SLIDER", "GAIN"],
["KEY", "SHIFT", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
]:
val = self.vm.strip[int(index)].gain
match direction:
case "RIGHT" | "UP":
val += 0.1
case "LEFT" | "DOWN":
val -= 0.1
self.vm.strip[int(index)].gain = check_bounds(val, (-60, 12))
self[f"STRIP {index}||SLIDER GAIN"].update(value=val)
# Bus Params
case [["BUS", index], [param]]:
val = self.cache["bus"][event]
@@ -612,15 +776,66 @@ class NVDAVMWindow(psg.Window):
f"{label} bus mode {phonetic.get(next_bus, next_bus)}",
)
case [["BUS", index], [param], ["FOCUS", "IN"]]:
label = self.cache["labels"][f"BUS {index}||LABEL"]
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'}")
if self.find_element_with_focus() is not None:
label = self.cache["labels"][f"BUS {index}||LABEL"]
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()
# Bus Sliders
case [["BUS", index], ["SLIDER", "GAIN"]]:
label = self.cache["labels"][f"BUS {index}||LABEL"]
val = values[event]
self.vm.bus[int(index)].gain = val
self.nvda.speak(f"{label} gain slider {val}")
case [["BUS", index], ["SLIDER", "GAIN"], ["FOCUS", "IN"]]:
if self.find_element_with_focus() is not None:
self.vm.event.pdirty = False
label = self.cache["labels"][f"BUS {index}||LABEL"]
val = values[f"BUS {index}||SLIDER GAIN"]
self.nvda.speak(f"{label} gain slider {val}")
case [["BUS", index], ["SLIDER", "GAIN"], ["FOCUS", "OUT"]]:
self.vm.event.pdirty = True
case [["BUS", index], ["SLIDER", "GAIN"], ["KEY", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction]]:
val = self.vm.bus[int(index)].gain
match direction:
case "RIGHT" | "UP":
val += 1
case "LEFT" | "DOWN":
val -= 1
self.vm.bus[int(index)].gain = check_bounds(val, (-60, 12))
self[f"BUS {index}||SLIDER GAIN"].update(value=val)
case [
["BUS", index],
["SLIDER", "GAIN"],
["KEY", "CTRL", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
]:
val = self.vm.bus[int(index)].gain
match direction:
case "RIGHT" | "UP":
val += 3
case "LEFT" | "DOWN":
val -= 3
self.vm.bus[int(index)].gain = check_bounds(val, (-60, 12))
self[f"BUS {index}||SLIDER GAIN"].update(value=val)
case [
["BUS", index],
["SLIDER", "GAIN"],
["KEY", "SHIFT", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
]:
val = self.vm.bus[int(index)].gain
match direction:
case "RIGHT" | "UP":
val += 0.1
case "LEFT" | "DOWN":
val -= 0.1
self.vm.bus[int(index)].gain = check_bounds(val, (-60, 12))
self[f"BUS {index}||SLIDER GAIN"].update(value=val)
# Unknown
case _:
self.logger.debug(f"Unknown event {event}")