Compare commits

..

17 Commits

Author SHA1 Message Date
0dd6c89f96 implements up/down slider mode binds
adjustments to pdirty event toggling.

press/release events defined for slider binds

note:
the main window no longer returns keyboard events

minor bump
2023-09-23 16:36:48 +01:00
893f9f59ff patch asio spinboxes set as readonly
patch insert checkboxes enter bind added
2023-09-21 16:39:21 +01:00
3ca9e14e96 adds bass, mid and treble slider modes
patch bump
2023-09-21 09:33:22 +01:00
4ca64f94bc re 2023-09-21 08:35:55 +01:00
22bf109499 removes the spinbox from the rename popup
updates README

fixes #12

b1 bump
2023-09-20 18:24:24 +01:00
a19aab3936 closes #10
minor bump
2023-09-20 16:58:33 +01:00
7134b6d209 adds alt + number in quick binds to readme 2023-09-20 16:51:40 +01:00
1525710d31 upd readme image 2023-09-20 16:29:52 +01:00
2745e2c41a refactor slider mode binds 2023-09-20 16:29:42 +01:00
8716149eda fixes attribute error 2023-09-20 13:07:04 +01:00
dde940938f sync not required. using callbacks. 2023-09-20 11:34:06 +01:00
09f052b4a3 defines slider mode nav events 2023-09-20 10:40:09 +01:00
577f1fbdbb fixes limit resolution 2023-09-20 10:38:30 +01:00
f9614f44ac popups moved into popup.py 2023-09-20 10:01:48 +01:00
9b757b743b shortens the spoken feedback
for most of the controls.

needs more testing...
2023-09-19 23:19:39 +01:00
7f8f6f2b6c adds more navigation binds.
adds slider modes.
2023-09-19 22:22:44 +01:00
0c806b8e4c add guard clauses for nav binds 2023-09-18 23:07:09 +01:00
9 changed files with 629 additions and 409 deletions

View File

@@ -8,7 +8,7 @@ A remote control app for [Voicemeeter][voicemeeter], designed to be used with th
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">
<img src="./img/nvda-voicemeeter.png" width=960 alt="Image of Voicemeeter NVDA app settings tab">
## Requirements
@@ -57,7 +57,7 @@ import nvda_voicemeeter
KIND_ID = "potato"
with voicemeeterlib.api(KIND_ID, sync=True) as vm:
with voicemeeterlib.api(KIND_ID) as vm:
with nvda_voicemeeter.draw(KIND_ID, vm) as window:
window.run()
```
@@ -94,9 +94,19 @@ To adjust Patch Asio Inputs to Strips and Patch Insert values use `UP` and `DOWN
To access Advanced Settings you may press the Advanced Settings button or use `Control + A` when in the `Settings` tab.
#### `Strip/Bus`
#### `Physical Strip|Virtual Strip|Buses`
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.
You will find in each of these tabs two nested tabs,`Buttons` and `Sliders`. For each nested tab you will find the controls appropriate for the Voicemeeter kind and channel type.
All buttons may be triggered by pressing `SPACE` or `ENTER`.
All sliders may be controlled in three different ways:
- `Left|Right arrow` to move a slider by 1 step.
- `Shift + Left|Right arrow` to move a slider by 0.1 steps.
- `Control + Left|Right arrow` to move a slider by 3 steps.
To rename a strip/bus channel focus on the channel in question and press `F2`. Then enter the new channel name into the text input widget and press the `Ok` button.
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`.
@@ -114,6 +124,33 @@ The `Save Settings` option opens a popup window with two buttons, `Browse` and `
`Load Settings` and `Load on Startup` both open an Open dialog box immediately.
### `Quick access binds`
There are a number of quick binds available to assist with faster navigation and general use.
When focused on any one of "Physical Strip", "Virtual Strip" or "Buses" you may use `Control + Number` to skip to the corresponding channel.
When focused on any single channel (Strip or Bus), the following binds exist:
- `Alt + Number` will trigger the Bus output button corresponding to the number. For example `Alt + 3` will trigger the `A3` button
- `Control + O` will trigger the Mono button
- `Control + S` will trigger the Solo button
- `Control + M` will trigger the Mute button
You may also enter slider modes which allow for control of the channels sliders until the slider mode is exited. You may access the slider modes with the following binds:
- `Control + U` will enter Audibility mode
- `Control + G` will enter Gain mode
- `Control + T` will enter Gate mode
- `Control + L` will enter Limit mode
- `Control + B` will enter Bass mode
- `Control + I` will enter Mid mode
- `Control + R` will enter Treble mode
To exit any of the slider modes press `Escape`.
Once you are in a slider mode you may now control the slider that matches the slider mode. Slider mode binds are the same as the normal slider binds with the addition of the Alt keypress. For example, where you would normally use `Right Arrow` to shift a slider rightwards by 1 step, in slider mode you would now use `Alt + Right Arrow`.
### Issues
If you have any questions/suggestions feel free to raise an issue or open a new discussion.

View File

@@ -4,6 +4,6 @@ import nvda_voicemeeter
KIND_ID = "potato"
with voicemeeterlib.api(KIND_ID, sync=True) as vm:
with voicemeeterlib.api(KIND_ID) as vm:
with nvda_voicemeeter.draw(KIND_ID, vm) as window:
window.run()

BIN
img/nvda-voicemeeter.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 KiB

View File

@@ -1,6 +1,6 @@
[project]
name = "nvda_voicemeeter"
version = "0.2.2a1"
version = "0.4.0"
description = "A Voicemeeter app compatible with NVDA"
authors = [
{ name = "onyx-and-iris", email = "code@onyxandiris.online" },

View File

@@ -220,7 +220,9 @@ class Builder:
[
psg.Checkbox(
text=channel,
default=self.vm.patch.insert[util.get_insert_checkbox_index(self.kind, j, i)].on,
default=self.window.cache["insert"][
f"INSERT CHECKBOX||{util.get_insert_checkbox_index(self.kind, j, i)}"
],
enable_events=True,
key=f"INSERT CHECKBOX||IN{i} {j}",
)
@@ -233,7 +235,9 @@ class Builder:
[
psg.Checkbox(
text=channel,
default=self.vm.patch.insert[util.get_insert_checkbox_index(self.kind, j, i)].on,
default=self.window.cache["insert"][
f"INSERT CHECKBOX||{util.get_insert_checkbox_index(self.kind, j, i)}"
],
enable_events=True,
key=f"INSERT CHECKBOX||IN{i} {j}",
)
@@ -323,7 +327,7 @@ class Builder:
)
def add_param_sliders(layout):
layout.append([LabelSlider(self.window, i, param) for param in util.get_slider_params(i, self.vm)])
layout.append([LabelSlider(self.window, i, param) for param in util.get_slider_params(i, self.kind)])
def add_limit_slider(layout):
layout.append(
@@ -332,7 +336,7 @@ class Builder:
psg.Slider(
range=(-40, 12),
default_value=self.vm.strip[i].limit,
resolution=0.1,
resolution=1,
disable_number_display=True,
expand_x=True,
enable_events=True,
@@ -416,13 +420,13 @@ class Builder:
def add_param_sliders(layout):
if self.kind.name in ("basic", "banana"):
for param in util.get_slider_params(i, self.vm):
for param in util.get_slider_params(i, self.kind):
layout.append([LabelSlider(self.window, i, param, range_=(-12, 12))])
else:
layout.append(
[
LabelSlider(self.window, i, param, range_=(-12, 12))
for param in util.get_slider_params(i, self.vm)
for param in util.get_slider_params(i, self.kind)
]
)
@@ -433,7 +437,7 @@ class Builder:
psg.Slider(
range=(-40, 12),
default_value=self.vm.strip[i].limit,
resolution=0.1,
resolution=1,
disable_number_display=True,
expand_x=True,
enable_events=True,

View File

@@ -10,17 +10,13 @@ class LabelSlider(psg.Frame):
size = 7
else:
size = 4
if param == "LIMIT":
resolution = 1
else:
resolution = 0.1
layout = [
[
psg.Text(param.capitalize(), size=size),
psg.Slider(
range=range_,
default_value=self.default_value(i, param),
resolution=resolution,
resolution=0.1,
disable_number_display=True,
size=(12, 16),
expand_x=True,

View File

@@ -0,0 +1,157 @@
import logging
from pathlib import Path
import PySimpleGUI as psg
from . import util
logger = logging.getLogger(__name__)
class Popup:
def __init__(self, window):
self.window = window
self.kind = self.window.kind
self.logger = logger.getChild(type(self).__name__)
def save_as(self, message, title=None, initial_folder=None):
layout = [
[psg.Text(message)],
[
psg.FileSaveAs("Browse", initial_folder=str(initial_folder), file_types=(("XML", ".xml"),)),
psg.Button("Cancel"),
],
]
popup = psg.Window(title, layout, finalize=True)
popup["Browse"].bind("<FocusIn>", "||FOCUS IN")
popup["Browse"].bind("<Return>", "||KEY ENTER")
popup["Cancel"].bind("<FocusIn>", "||FOCUS IN")
popup["Cancel"].bind("<Return>", "||KEY ENTER")
filepath = None
while True:
event, values = popup.read()
self.logger.debug(f"event::{event}")
self.logger.debug(f"values::{values}")
if event in (psg.WIN_CLOSED, "Cancel"):
break
match parsed_cmd := self.window.parser.match.parseString(event):
case [[button], ["FOCUS", "IN"]]:
if values["Browse"]:
filepath = values["Browse"]
break
self.window.nvda.speak(button)
case [[button], ["KEY", "ENTER"]]:
popup.find_element_with_focus().click()
self.logger.debug(f"parsed::{parsed_cmd}")
popup.close()
if filepath:
return Path(filepath)
def rename(self, message, index, title=None, tab=None):
if "Strip" in tab:
if index < self.kind.phys_in:
title += f" Physical Strip {index + 1}"
else:
title += f" Virtual Strip {index - self.kind.phys_in + 1}"
else:
if index < self.kind.phys_out:
title += f" Physical Bus {index + 1}"
else:
title += f" Virtual Bus {index - self.kind.phys_out + 1}"
layout = [
[psg.Text(message)],
[
[
psg.Input(key="Edit"),
],
[psg.Button("Ok"), psg.Button("Cancel")],
],
]
popup = psg.Window(title, layout, finalize=True)
popup["Edit"].bind("<FocusIn>", "||FOCUS IN")
popup["Ok"].bind("<FocusIn>", "||FOCUS IN")
popup["Ok"].bind("<Return>", "||KEY ENTER")
popup["Cancel"].bind("<FocusIn>", "||FOCUS IN")
popup["Cancel"].bind("<Return>", "||KEY ENTER")
data = {}
while True:
event, values = popup.read()
self.logger.debug(f"event::{event}")
self.logger.debug(f"values::{values}")
if event in (psg.WIN_CLOSED, "Cancel"):
break
match parsed_cmd := self.window.parser.match.parseString(event):
case [[button], ["FOCUS", "IN"]]:
self.window.nvda.speak(button)
case [[button], ["KEY", "ENTER"]]:
popup.find_element_with_focus().click()
case ["Ok"]:
data = values
break
self.logger.debug(f"parsed::{parsed_cmd}")
popup.close()
return data
def advanced_settings(self, title):
def _make_buffering_frame() -> psg.Frame:
buffer = [
[
psg.ButtonMenu(
driver,
size=(14, 2),
menu_def=["", util.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))])
popup = psg.Window(title, layout, finalize=True)
buttonmenu_opts = {"takefocus": 1, "highlightthickness": 1}
for driver in ("MME", "WDM", "KS", "ASIO"):
popup[f"BUFFER {driver}"].Widget.config(**buttonmenu_opts)
popup[f"BUFFER {driver}"].bind("<FocusIn>", "||FOCUS IN")
popup[f"BUFFER {driver}"].bind("<space>", "||KEY SPACE", propagate=False)
popup[f"BUFFER {driver}"].bind("<Return>", "||KEY ENTER", propagate=False)
popup["Exit"].bind("<FocusIn>", "||FOCUS IN")
popup["Exit"].bind("<Return>", "||KEY ENTER")
while True:
event, values = popup.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.window.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.window.vm.set(f"option.buffer.{driver.lower()}", val)
self.window.TKroot.after(
200, self.window.nvda.speak, f"{driver} BUFFER {val if val else 'default'}"
)
case [["BUFFER", driver], ["FOCUS", "IN"]]:
val = int(self.window.vm.get(f"option.buffer.{driver.lower()}"))
self.window.nvda.speak(f"{driver} BUFFER {val if val else 'default'}")
case [["BUFFER", driver], ["KEY", "SPACE" | "ENTER"]]:
util.open_context_menu_for_buttonmenu(popup, f"BUFFER {driver}")
case [[button], ["FOCUS", "IN"]]:
self.window.nvda.speak(button)
case [[button], ["KEY", "ENTER"]]:
popup.find_element_with_focus().click()
self.logger.debug(f"parsed::{parsed_cmd}")
popup.close()

View File

@@ -141,12 +141,19 @@ def check_bounds(val, bounds: tuple) -> int | float:
return val
def get_slider_params(i, vm) -> Iterable:
if i < vm.kind.phys_in:
if vm.kind.name == "basic":
def get_slider_params(i, kind) -> Iterable:
if i < kind.phys_in:
if kind.name == "basic":
return ("AUDIBILITY",)
if vm.kind.name == "banana":
if kind.name == "banana":
return ("COMP", "GATE")
if vm.kind.name == "potato":
if kind.name == "potato":
return ("COMP", "GATE", "DENOISER")
return ("BASS", "MID", "TREBLE")
def get_full_slider_params(i, kind) -> Iterable:
params = list(get_slider_params(i, kind) + ("GAIN", "LIMIT"))
if kind.name == "basic":
params.remove("LIMIT")
return params

View File

@@ -8,6 +8,7 @@ from . import models, util
from .builder import Builder
from .nvda import Nvda
from .parser import Parser
from .popup import Popup
logger = logging.getLogger(__name__)
@@ -34,9 +35,10 @@ class NVDAVMWindow(psg.Window):
}
self.nvda = Nvda()
self.parser = Parser()
self.popup = Popup(self)
self.builder = Builder(self)
layout = self.builder.run()
super().__init__(title, layout, return_keyboard_events=True, finalize=True)
super().__init__(title, layout, return_keyboard_events=False, 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)
@@ -48,13 +50,17 @@ class NVDAVMWindow(psg.Window):
[self[f"PATCH COMPOSITE||PC{i + 1}"].Widget.config(**buttonmenu_opts) for i in range(self.kind.phys_out)]
slider_opts = {"takefocus": 1, "highlightthickness": 1}
for i in range(self.kind.num_strip):
for param in util.get_slider_params(i, self.vm):
for param in util.get_slider_params(i, self.kind):
self[f"STRIP {i}||SLIDER {param}"].Widget.config(**slider_opts)
self[f"STRIP {i}||SLIDER GAIN"].Widget.config(**slider_opts)
if self.kind.name != "basic":
self[f"STRIP {i}||SLIDER LIMIT"].Widget.config(**slider_opts)
for i in range(self.kind.num_bus):
self[f"BUS {i}||SLIDER GAIN"].Widget.config(**slider_opts)
if self.kind.name != "basic":
for i in range(self.kind.phys_out):
self[f"ASIO CHECKBOX||IN{i + 1} 0"].Widget.config(state="readonly")
self[f"ASIO CHECKBOX||IN{i + 1} 1"].Widget.config(state="readonly")
self.register_events()
self["tabgroup"].set_focus()
@@ -107,7 +113,7 @@ class NVDAVMWindow(psg.Window):
self[f"STRIP {i}||SLIDER GAIN"].update(value=self.vm.strip[i].gain)
if self.kind.name != "basic":
self[f"STRIP {i}||SLIDER LIMIT"].update(value=self.vm.strip[i].limit)
for param in util.get_slider_params(i, self.vm):
for param in util.get_slider_params(i, self.kind):
if param in ("AUDIBILITY", "BASS", "MID", "TREBLE"):
val = getattr(self.vm.strip[i], param.lower())
else:
@@ -136,9 +142,41 @@ class NVDAVMWindow(psg.Window):
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("<F2>", "F2")
# NAV
self.bind("<Control-a>", "CTRL-A")
for i in range(1, 10):
self.bind(f"<Control-Key-{i}>", f"CTRL-{i}")
for i in range(1, 10):
self.bind(f"<Alt-Key-{i}>", f"ALT-{i}")
self.bind("<Control-o>", "CTRL-O")
self.bind("<Control-s>", "CTRL-S")
self.bind("<Control-m>", "CTRL-M")
self.bind("<Control-g>", "GAIN MODE")
self.bind("<Control-b>", "BASS MODE")
self.bind("<Control-i>", "MID MODE")
self.bind("<Control-r>", "TREBLE MODE")
if self.kind.name == "basic":
self.bind("<Control-u>", "AUDIBILITY MODE")
elif self.kind.name == "banana":
self.bind("<Control-c>", "COMP MODE")
self.bind("<Control-t>", "GATE MODE")
self.bind("<Control-l>", "LIMIT MODE")
else:
self.bind("<Control-c>", "COMP MODE")
self.bind("<Control-t>", "GATE MODE")
self.bind("<Control-d>", "DENOISER MODE")
self.bind("<Control-l>", "LIMIT MODE")
self.bind("<Escape>", "ESCAPE")
for event in ("KeyPress", "KeyRelease"):
event_id = event.removeprefix("Key").upper()
for direction in ("Left", "Right", "Up", "Down"):
self.bind(f"<Alt-{event}-{direction}>", f"ALT {direction.upper()}||{event_id}")
self.bind(f"<Alt-Shift-{event}-{direction}>", f"ALT SHIFT {direction.upper()}||{event_id}")
self.bind(f"<Alt-Control-{event}-{direction}>", f"ALT CTRL {direction.upper()}||{event_id}")
# Hardware In
for i in range(self.vm.kind.phys_in):
@@ -175,8 +213,11 @@ class NVDAVMWindow(psg.Window):
if i < self.kind.phys_in:
self[f"INSERT CHECKBOX||IN{i + 1} 0"].bind("<FocusIn>", "||FOCUS IN")
self[f"INSERT CHECKBOX||IN{i + 1} 1"].bind("<FocusIn>", "||FOCUS IN")
self[f"INSERT CHECKBOX||IN{i + 1} 0"].bind("<Return>", "||KEY ENTER")
self[f"INSERT CHECKBOX||IN{i + 1} 1"].bind("<Return>", "||KEY ENTER")
else:
[self[f"INSERT CHECKBOX||IN{i + 1} {j}"].bind("<FocusIn>", "||FOCUS IN") for j in range(8)]
[self[f"INSERT CHECKBOX||IN{i + 1} {j}"].bind("<Return>", "||KEY ENTER") for j in range(8)]
# Advanced Settings
self["ADVANCED SETTINGS"].bind("<FocusIn>", "||FOCUS IN")
@@ -201,23 +242,21 @@ class NVDAVMWindow(psg.Window):
# Strip Sliders
for i in range(self.kind.num_strip):
for param in util.get_slider_params(i, self.vm) + ("GAIN", "LIMIT"):
if self.kind.name == "basic" and param == "LIMIT":
continue
for param in util.get_full_slider_params(i, self.kind):
self[f"STRIP {i}||SLIDER {param}"].bind("<FocusIn>", "||FOCUS IN")
self[f"STRIP {i}||SLIDER {param}"].bind("<FocusOut>", "||FOCUS OUT")
self[f"STRIP {i}||SLIDER {param}"].bind("<Left>", "||KEY LEFT")
self[f"STRIP {i}||SLIDER {param}"].bind("<Right>", "||KEY RIGHT")
self[f"STRIP {i}||SLIDER {param}"].bind("<Shift-KeyPress-Left>", "||KEY SHIFT LEFT")
self[f"STRIP {i}||SLIDER {param}"].bind("<Shift-KeyPress-Right>", "||KEY SHIFT RIGHT")
self[f"STRIP {i}||SLIDER {param}"].bind("<Control-KeyPress-Left>", "||KEY CTRL LEFT")
self[f"STRIP {i}||SLIDER {param}"].bind("<Control-KeyPress-Right>", "||KEY CTRL RIGHT")
self[f"STRIP {i}||SLIDER {param}"].bind("<Up>", "||KEY UP")
self[f"STRIP {i}||SLIDER {param}"].bind("<Down>", "||KEY DOWN")
self[f"STRIP {i}||SLIDER {param}"].bind("<Shift-KeyPress-Up>", "||KEY SHIFT UP")
self[f"STRIP {i}||SLIDER {param}"].bind("<Shift-KeyPress-Down>", "||KEY SHIFT DOWN")
self[f"STRIP {i}||SLIDER {param}"].bind("<Control-KeyPress-Up>", "||KEY CTRL UP")
self[f"STRIP {i}||SLIDER {param}"].bind("<Control-KeyPress-Down>", "||KEY CTRL DOWN")
for event in ("KeyPress", "KeyRelease"):
event_id = event.removeprefix("Key").upper()
for direction in ("Left", "Right", "Up", "Down"):
self[f"STRIP {i}||SLIDER {param}"].bind(
f"<{event}-{direction}>", f"||KEY {direction.upper()} {event_id}"
)
self[f"STRIP {i}||SLIDER {param}"].bind(
f"<Shift-{event}-{direction}>", f"||KEY SHIFT {direction.upper()} {event_id}"
)
self[f"STRIP {i}||SLIDER {param}"].bind(
f"<Control-{event}-{direction}>", f"||KEY CTRL {direction.upper()} {event_id}"
)
self[f"STRIP {i}||SLIDER {param}"].bind("<Control-Shift-KeyPress-R>", "||KEY CTRL SHIFT R")
# Bus Params
@@ -231,169 +270,19 @@ class NVDAVMWindow(psg.Window):
# 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")
self[f"BUS {i}||SLIDER GAIN"].bind("<Control-Shift-KeyPress-R>", "||KEY CTRL SHIFT R")
def popup_save_as(self, message, title=None, initial_folder=None):
layout = [
[psg.Text(message)],
[
psg.FileSaveAs("Browse", initial_folder=str(initial_folder), file_types=(("XML", ".xml"),)),
psg.Button("Cancel"),
],
]
window = psg.Window(title, layout, finalize=True)
window["Browse"].bind("<FocusIn>", "||FOCUS IN")
window["Browse"].bind("<Return>", "||KEY ENTER")
window["Cancel"].bind("<FocusIn>", "||FOCUS IN")
window["Cancel"].bind("<Return>", "||KEY ENTER")
filepath = None
while True:
event, values = window.read()
self.logger.debug(f"event::{event}")
self.logger.debug(f"values::{values}")
if event in (psg.WIN_CLOSED, "Cancel"):
break
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)
def popup_rename(self, message, title=None, tab=None):
if tab == "Physical Strip":
upper = self.kind.phys_in + 1
elif tab == "Virtual Strip":
upper = self.kind.virt_in + 1
elif tab == "Buses":
upper = self.kind.num_bus + 1
layout = [
[psg.Text(message)],
[
[
psg.Spin(
list(range(1, upper)), initial_value=1, size=2, enable_events=True, key=f"Index", readonly=True
),
psg.Input(key="Edit"),
],
[psg.Button("Ok"), psg.Button("Cancel")],
],
]
window = psg.Window(title, layout, finalize=True)
window["Index"].bind("<FocusIn>", "||FOCUS IN")
window["Edit"].bind("<FocusIn>", "||FOCUS IN")
window["Ok"].bind("<FocusIn>", "||FOCUS IN")
window["Ok"].bind("<Return>", "||KEY ENTER")
window["Cancel"].bind("<FocusIn>", "||FOCUS IN")
window["Cancel"].bind("<Return>", "||KEY ENTER")
data = {}
while True:
event, values = window.read()
self.logger.debug(f"event::{event}")
self.logger.debug(f"values::{values}")
if event in (psg.WIN_CLOSED, "Cancel"):
break
match parsed_cmd := self.parser.match.parseString(event):
case ["Index"]:
val = values["Index"]
self.nvda.speak(f"Index {val}")
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=["", util.get_asio_samples_list(driver)],
key=f"BUFFER {driver}",
for event in ("KeyPress", "KeyRelease"):
event_id = event.removeprefix("Key").upper()
for direction in ("Left", "Right", "Up", "Down"):
self[f"BUS {i}||SLIDER GAIN"].bind(
f"<{event}-{direction}>", f"||KEY {direction.upper()} {event_id}"
)
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"]]:
util.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()
self[f"BUS {i}||SLIDER GAIN"].bind(
f"<Shift-{event}-{direction}>", f"||KEY SHIFT {direction.upper()} {event_id}"
)
self[f"BUS {i}||SLIDER GAIN"].bind(
f"<Control-{event}-{direction}>", f"||KEY CTRL {direction.upper()} {event_id}"
)
self[f"BUS {i}||SLIDER GAIN"].bind("<Control-Shift-KeyPress-R>", "||KEY CTRL SHIFT R")
def run(self):
"""
@@ -401,6 +290,7 @@ class NVDAVMWindow(psg.Window):
Main thread will shutdown once a close or exit event occurs
"""
mode = None
while True:
event, values = self.read()
@@ -408,8 +298,28 @@ class NVDAVMWindow(psg.Window):
self.logger.debug(f"values::{values}")
if event in (psg.WIN_CLOSED, "Exit"):
break
elif event.endswith("MODE"):
mode = event
self.nvda.speak(f"{mode} enabled")
continue
elif event == "ESCAPE":
if mode:
self.nvda.speak(f"{mode} disabled")
mode = None
continue
match parsed_cmd := self.parser.match.parseString(event):
# Slide mode
case [["ALT", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction], ["PRESS" | "RELEASE" as e]]:
if mode:
self.write_event_value(f"SLIDER MODE {direction}||{e}", mode.split()[0])
case [
["ALT", "SHIFT" | "CTRL" as modifier, "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
["PRESS" | "RELEASE" as e],
]:
if mode:
self.write_event_value(f"SLIDER MODE {modifier} {direction}||{e}", mode.split()[0])
# Focus tabgroup
case ["CTRL-TAB"] | ["CTRL-SHIFT-TAB"]:
self["tabgroup"].set_focus()
@@ -420,6 +330,8 @@ class NVDAVMWindow(psg.Window):
key, index = bind.split("-")
match values["tabgroup"]:
case "tab||Physical Strip":
if int(index) > self.kind.phys_in:
continue
self[f"STRIP {int(index) - 1}||A1"].set_focus()
if (
self.find_element_with_focus() is None
@@ -437,39 +349,98 @@ class NVDAVMWindow(psg.Window):
):
self[f"STRIP {int(index) - 1}||SLIDER GAIN"].set_focus()
case "tab||Buses":
if int(index) > self.kind.num_bus:
continue
self[f"BUS {int(index) - 1}||MONO"].set_focus()
if (
self.find_element_with_focus() is None
or self.find_element_with_focus().Key != f"BUS {int(index) - 1}||MONO"
):
self[f"BUS {int(index) - 1}||SLIDER GAIN"].set_focus()
case ["ALT-1" | "ALT-2" | "ALT-3" | "ALT-4" | "ALT-5" | "ALT-6" | "ALT-7" | "ALT-8" as bind]:
if values["tabgroup"] not in ("tab||Physical Strip", "tab||Virtual Strip", "tab||Buses"):
continue
key, index = bind.split("-")
if int(index) > self.kind.phys_out + self.kind.virt_out:
continue
if focus := self.find_element_with_focus():
identifier, param = focus.Key.split("||")
if int(index) <= self.kind.phys_out:
self.write_event_value(f"{identifier}||A{int(index)}", None)
else:
self.write_event_value(f"{identifier}||B{int(index) - self.kind.phys_out}", None)
case ["CTRL-O"]:
if values["tabgroup"] not in ("tab||Physical Strip", "tab||Virtual Strip", "tab||Buses"):
continue
if focus := self.find_element_with_focus():
identifier, param = focus.Key.split("||")
self.write_event_value(f"{identifier}||MONO", None)
case ["CTRL-S"]:
if values["tabgroup"] not in ("tab||Physical Strip", "tab||Virtual Strip"):
continue
if focus := self.find_element_with_focus():
identifier, param = focus.Key.split("||")
self.write_event_value(f"{identifier}||SOLO", None)
case ["CTRL-M"]:
if values["tabgroup"] not in ("tab||Physical Strip", "tab||Virtual Strip", "tab||Buses"):
continue
if focus := self.find_element_with_focus():
identifier, param = focus.Key.split("||")
self.write_event_value(f"{identifier}||MUTE", None)
case [["SLIDER", "MODE", direction], ["PRESS" | "RELEASE" as e]]:
if values["tabgroup"] not in ("tab||Physical Strip", "tab||Virtual Strip", "tab||Buses"):
continue
param = values[event]
if focus := self.find_element_with_focus():
identifier, partial = focus.Key.split("||")
_, index = identifier.split()
if param in util.get_full_slider_params(int(index), self.kind):
if "SLIDER" not in partial:
self.write_event_value(f"{identifier}||SLIDER {param}||KEY {direction} {e}", None)
case [
["SLIDER", "MODE", "SHIFT" | "CTRL" as modifier, direction],
["PRESS" | "RELEASE" as e],
]:
if values["tabgroup"] not in ("tab||Physical Strip", "tab||Virtual Strip", "tab||Buses"):
continue
param = values[event]
if focus := self.find_element_with_focus():
identifier, partial = focus.Key.split("||")
_, index = identifier.split()
if param in util.get_full_slider_params(int(index), self.kind):
if "SLIDER" not in partial:
self.write_event_value(
f"{identifier}||SLIDER {param}||KEY {modifier} {direction} {e}", None
)
# Rename popups
case ["F2:113"]:
tab = values["tabgroup"]
case ["F2"]:
tab = values["tabgroup"].split("||")[1]
if tab in ("Physical Strip", "Virtual Strip", "Buses"):
data = self.popup_rename("Label", title=f"Rename {tab}", tab=tab)
if focus := self.find_element_with_focus():
identifier, partial = focus.Key.split("||")
_, index = identifier.split()
index = int(index)
data = self.popup.rename("Label", index, title=f"Rename", tab=tab)
if not data: # cancel was pressed
continue
index = int(data["Index"]) - 1
match tab:
case "Physical Strip":
label = data.get("Edit", f"Hardware Input {index + 1}")
self.vm.strip[index].label = label
label = data.get("Edit", f"Hardware Input {int(index) + 1}")
self.vm.strip[int(index)].label = label
self[f"STRIP {index}||LABEL"].update(value=label)
self.cache["labels"][f"STRIP {index}||LABEL"] = label
case "Virtual Strip":
index += self.kind.phys_in
label = data.get("Edit", f"Virtual Input {index - self.kind.phys_in + 1}")
self.vm.strip[index].label = label
label = data.get("Edit", f"Virtual Input {int(index) + 1}")
self.vm.strip[int(index)].label = label
self[f"STRIP {index}||LABEL"].update(value=label)
self.cache["labels"][f"STRIP {index}||LABEL"] = label
case "Buses":
if index < self.kind.phys_out:
label = data.get("Edit", f"Physical Bus {index + 1}")
label = data.get("Edit", f"Physical Bus {int(index) + 1}")
else:
label = data.get("Edit", f"Virtual Bus {index - self.kind.phys_out + 1}")
self.vm.bus[index].label = label
label = data.get("Edit", f"Virtual Bus {int(index) - self.kind.phys_out + 1}")
self.vm.bus[int(index)].label = label
self[f"BUS {index}||LABEL"].update(value=label)
self.cache["labels"][f"BUS {index}||LABEL"] = label
@@ -484,7 +455,7 @@ class NVDAVMWindow(psg.Window):
)
case [["Save", "Settings"], ["MENU"]]:
initial_folder = Path.home() / "Documents" / "Voicemeeter"
if filepath := self.popup_save_as(
if filepath := self.popup.save_as(
"Open the file browser", title="Save As", initial_folder=initial_folder
):
self.vm.set("command.save", str(filepath))
@@ -596,7 +567,7 @@ class NVDAVMWindow(psg.Window):
val = values[f"ASIO CHECKBOX||{in_num} {channel}"]
self.vm.patch.asio[index].set(val)
channel = ("left", "right")[int(channel)]
self.nvda.speak(f"Patch ASIO {in_num} {channel} set to {val}")
self.nvda.speak(str(val))
case [["ASIO", "CHECKBOX"], [in_num, channel], ["FOCUS", "IN"]]:
if self.find_element_with_focus() is not None:
val = values[f"ASIO CHECKBOX||{in_num} {channel}"]
@@ -630,9 +601,7 @@ class NVDAVMWindow(psg.Window):
)
val = values[f"INSERT CHECKBOX||{in_num} {channel}"]
self.vm.patch.insert[index].on = val
self.nvda.speak(
f"PATCH INSERT {in_num} {util._patch_insert_channels[int(channel)]} set to {'on' if val else 'off'}"
)
self.nvda.speak("on" if val else "off")
case [["INSERT", "CHECKBOX"], [in_num, channel], ["FOCUS", "IN"]]:
if self.find_element_with_focus() is not None:
index = util.get_insert_checkbox_index(
@@ -644,11 +613,14 @@ class NVDAVMWindow(psg.Window):
channel = util._patch_insert_channels[int(channel)]
num = int(in_num[-1])
self.nvda.speak(f"Patch INSERT IN#{num} {channel} {'on' if val else 'off'}")
case [["INSERT", "CHECKBOX"], [in_num, channel], ["KEY", "ENTER"]]:
val = not values[f"INSERT CHECKBOX||{in_num} {channel}"]
self.write_event_value(f"INSERT CHECKBOX||{in_num} {channel}", val)
# Advanced Settings
case ["ADVANCED SETTINGS"] | ["CTRL-A"]:
if values["tabgroup"] == "tab||Settings":
self.popup_advanced_settings(title="Advanced Settings")
self.popup.advanced_settings(title="Advanced Settings")
case [["ADVANCED", "SETTINGS"], ["FOCUS", "IN"]]:
self.nvda.speak("ADVANCED SETTINGS")
case [["ADVANCED", "SETTINGS"], ["KEY", "ENTER"]]:
@@ -672,19 +644,17 @@ class NVDAVMWindow(psg.Window):
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]}"
)
self.nvda.speak(["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'}")
self.nvda.speak("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'}")
self.nvda.speak("on" if val else "off")
case [["STRIP", index], [param], ["FOCUS", "IN"]]:
if self.find_element_with_focus() is not None:
val = self.cache["strip"][f"STRIP {index}||{param}"]
@@ -725,7 +695,6 @@ class NVDAVMWindow(psg.Window):
| "TREBLE" as param,
],
]:
label = self.cache["labels"][f"STRIP {index}||LABEL"]
val = values[event]
match param:
case "GAIN":
@@ -740,7 +709,6 @@ class NVDAVMWindow(psg.Window):
self.vm.strip[int(index)].limit = val
case "BASS" | "MID" | "TREBLE":
setattr(self.vm.strip[int(index)], param.lower(), val)
self.nvda.speak(f"{label} {param} slider {val}")
case [
["STRIP", index],
[
@@ -758,10 +726,9 @@ class NVDAVMWindow(psg.Window):
["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 {param}"]
self.nvda.speak(f"{label} {param} slider {int(val) if param == 'LIMIT' else val}")
label = self.cache["labels"][f"STRIP {index}||LABEL"]
self.nvda.speak(f"{label} {param} {int(val) if param == 'LIMIT' else val}")
case [
["STRIP", index],
[
@@ -770,7 +737,7 @@ class NVDAVMWindow(psg.Window):
],
["FOCUS", "OUT"],
]:
self.vm.event.pdirty = True
pass
case [
["STRIP", index],
[
@@ -785,8 +752,10 @@ class NVDAVMWindow(psg.Window):
| "MID"
| "TREBLE" as param,
],
["KEY", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
["KEY", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.vm.event.pdirty = False
match param:
case "GAIN":
val = self.vm.strip[int(index)].gain
@@ -808,20 +777,28 @@ class NVDAVMWindow(psg.Window):
match param:
case "GAIN":
self.vm.strip[int(index)].gain = util.check_bounds(val, (-60, 12))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-60, 12)))
val = util.check_bounds(val, (-60, 12))
self.vm.strip[int(index)].gain = val
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
case "COMP" | "GATE" | "DENOISER":
setattr(target, "knob", util.check_bounds(val, (0, 10)))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (0, 10)))
val = util.check_bounds(val, (0, 10))
setattr(target, "knob", val)
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
case "AUDIBILITY":
self.vm.strip[int(index)].audibility = util.check_bounds(val, (0, 10))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (0, 10)))
val = util.check_bounds(val, (0, 10))
self.vm.strip[int(index)].audibility = val
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
case "BASS" | "MID" | "TREBLE":
setattr(self.vm.strip[int(index)], param.lower(), util.check_bounds(val, (-12, 12)))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-12, 12)))
val = util.check_bounds(val, (-12, 12))
setattr(self.vm.strip[int(index)], param.lower(), val)
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
case "LIMIT":
self.vm.strip[int(index)].limit = util.check_bounds(val, (-40, 12))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-40, 12)))
val = util.check_bounds(val, (-40, 12))
self.vm.strip[int(index)].limit = val
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
self.nvda.speak(str(val))
else:
self.vm.event.pdirty = True
case [
["STRIP", index],
[
@@ -836,8 +813,10 @@ class NVDAVMWindow(psg.Window):
| "MID"
| "TREBLE" as param,
],
["KEY", "CTRL", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
["KEY", "CTRL", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.vm.event.pdirty = False
match param:
case "GAIN":
val = self.vm.strip[int(index)].gain
@@ -865,20 +844,28 @@ class NVDAVMWindow(psg.Window):
match param:
case "GAIN":
self.vm.strip[int(index)].gain = util.check_bounds(val, (-60, 12))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-60, 12)))
val = util.check_bounds(val, (-60, 12))
self.vm.strip[int(index)].gain = val
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
case "COMP" | "GATE" | "DENOISER":
setattr(target, "knob", util.check_bounds(val, (0, 10)))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (0, 10)))
val = util.check_bounds(val, (0, 10))
setattr(target, "knob", val)
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
case "AUDIBILITY":
self.vm.strip[int(index)].audibility = util.check_bounds(val, (0, 10))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (0, 10)))
val = util.check_bounds(val, (0, 10))
self.vm.strip[int(index)].audibility = val
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
case "BASS" | "MID" | "TREBLE":
setattr(self.vm.strip[int(index)], param.lower(), util.check_bounds(val, (-12, 12)))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-12, 12)))
val = util.check_bounds(val, (-12, 12))
setattr(self.vm.strip[int(index)], param.lower(), val)
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
case "LIMIT":
self.vm.strip[int(index)].limit = util.check_bounds(val, (-40, 12))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-40, 12)))
val = util.check_bounds(val, (-40, 12))
self.vm.strip[int(index)].limit = val
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
self.nvda.speak(f"{param} {val}")
else:
self.vm.event.pdirty = True
case [
["STRIP", index],
[
@@ -893,8 +880,10 @@ class NVDAVMWindow(psg.Window):
| "MID"
| "TREBLE" as param,
],
["KEY", "SHIFT", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
["KEY", "SHIFT", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.vm.event.pdirty = False
match param:
case "GAIN":
val = self.vm.strip[int(index)].gain
@@ -922,20 +911,28 @@ class NVDAVMWindow(psg.Window):
match param:
case "GAIN":
self.vm.strip[int(index)].gain = util.check_bounds(val, (-60, 12))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-60, 12)))
val = util.check_bounds(val, (-60, 12))
self.vm.strip[int(index)].gain = val
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
case "COMP" | "GATE" | "DENOISER":
setattr(target, "knob", util.check_bounds(val, (0, 10)))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (0, 10)))
val = util.check_bounds(val, (0, 10))
setattr(target, "knob", val)
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
case "AUDIBILITY":
self.vm.strip[int(index)].audibility = util.check_bounds(val, (0, 10))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (0, 10)))
val = util.check_bounds(val, (0, 10))
self.vm.strip[int(index)].audibility = val
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
case "BASS" | "MID" | "TREBLE":
setattr(self.vm.strip[int(index)], param.lower(), util.check_bounds(val, (-12, 12)))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-12, 12)))
val = util.check_bounds(val, (-12, 12))
setattr(self.vm.strip[int(index)], param.lower(), val)
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
case "LIMIT":
self.vm.strip[int(index)].limit = util.check_bounds(val, (-40, 12))
self[f"STRIP {index}||SLIDER {param}"].update(value=util.check_bounds(val, (-40, 12)))
val = util.check_bounds(val, (-40, 12))
self.vm.strip[int(index)].limit = val
self[f"STRIP {index}||SLIDER {param}"].update(value=val)
self.nvda.speak(f"{param} {val}")
else:
self.vm.event.pdirty = True
case [["STRIP", index], ["SLIDER", param], ["KEY", "CTRL", "SHIFT", "R"]]:
match param:
case "GAIN":
@@ -953,6 +950,7 @@ class NVDAVMWindow(psg.Window):
case "LIMIT":
self.vm.strip[int(index)].limit = 12
self[f"STRIP {index}||SLIDER {param}"].update(value=12)
self.nvda.speak(f"{param} {12 if param == 'LABEL' else 0}")
# Bus Params
case [["BUS", index], [param]]:
@@ -966,7 +964,7 @@ class NVDAVMWindow(psg.Window):
self.TKroot.after(
200,
self.nvda.speak,
f"{label} bus {param} {'on' if val else 'off'}",
"on" if val else "off",
)
case "MONO" | "MUTE":
val = not val
@@ -975,7 +973,7 @@ class NVDAVMWindow(psg.Window):
self.TKroot.after(
200,
self.nvda.speak,
f"{label} bus {param} {'on' if val else 'off'}",
"on" if val else "off",
)
case "MODE":
bus_modes = util.get_bus_modes(self.vm)
@@ -1000,7 +998,7 @@ class NVDAVMWindow(psg.Window):
self.TKroot.after(
200,
self.nvda.speak,
f"{label} bus mode {phonetic.get(next_bus, next_bus)}",
phonetic.get(next_bus, next_bus),
)
case [["BUS", index], [param], ["FOCUS", "IN"]]:
if self.find_element_with_focus() is not None:
@@ -1018,53 +1016,74 @@ class NVDAVMWindow(psg.Window):
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}")
self.nvda.speak(f"{label} gain {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]]:
pass
case [
["BUS", index],
["SLIDER", "GAIN"],
["KEY", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.vm.event.pdirty = False
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 = util.check_bounds(val, (-60, 12))
val = util.check_bounds(val, (-60, 12))
self.vm.bus[int(index)].gain = val
self[f"BUS {index}||SLIDER GAIN"].update(value=val)
self.nvda.speak(str(val))
else:
self.vm.event.pdirty = True
case [
["BUS", index],
["SLIDER", "GAIN"],
["KEY", "CTRL", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
["KEY", "CTRL", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.vm.event.pdirty = False
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 = util.check_bounds(val, (-60, 12))
val = util.check_bounds(val, (-60, 12))
self.vm.bus[int(index)].gain = val
self[f"BUS {index}||SLIDER GAIN"].update(value=val)
self.nvda.speak(str(val))
else:
self.vm.event.pdirty = True
case [
["BUS", index],
["SLIDER", "GAIN"],
["KEY", "SHIFT", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction],
["KEY", "SHIFT", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.vm.event.pdirty = False
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 = util.check_bounds(val, (-60, 12))
val = util.check_bounds(val, (-60, 12))
self.vm.bus[int(index)].gain = val
self[f"BUS {index}||SLIDER GAIN"].update(value=val)
self.nvda.speak(str(val))
else:
self.vm.event.pdirty = True
case [["BUS", index], ["SLIDER", "GAIN"], ["KEY", "CTRL", "SHIFT", "R"]]:
self.vm.bus[int(index)].gain = 0
self[f"BUS {index}||SLIDER GAIN"].update(value=0)
self.nvda.speak(str(val))
# Unknown
case _: