Compare commits

..

33 Commits

Author SHA1 Message Date
876de55ad2 Advanced Comp|Gate sliders implemented
bump to 0.5.0

closes #14
2023-09-27 23:34:07 +01:00
eab4b1c6a9 fixes unboundlocalerror 2023-09-27 13:36:48 +01:00
0aeb33608f implements reset binds
Advanced Comp|Gate section added to README.

bump to version 0.5.0b1
2023-09-26 23:51:34 +01:00
5befe72ca1 adds pdirty events for advanced comp/gate 2023-09-26 19:38:55 +01:00
abab560281 +10, +50 step binds added for gate
bump to version 0.5.0a2
Initial gate slider implementation
for Issue #14
2023-09-26 17:20:15 +01:00
6882adb47b gate as no Knee parameter 2023-09-26 15:56:12 +01:00
af602e087d GateSlider added to compound
Advanced Gate slider layout and events defined
needs more testing.
2023-09-26 15:53:43 +01:00
01e80dc4f6 replace flake8 with ruff
add tool.ruff to pyproject

update lint dependencies

removes settings.json

ruff badge added to readme

bump to version 0.4.2.a1
Initial compressor slider implementation
for Issue #14
2023-09-26 14:37:41 +01:00
7262af4bcf disable default keyboard/mouse events
for gain sliders
2023-09-26 13:33:13 +01:00
ef10b224d7 remove redundant if statement 2023-09-25 18:24:43 +01:00
89d0253591 add advanced comproessor slider events
voicemeeter-api version bumped

some of the spoken feedback for sliders corrected.
2023-09-25 18:22:17 +01:00
85527e0749 defines layout for compressor popup 2023-09-25 12:14:29 +01:00
9d8ea5f747 fixes regression, bus focus in/out readded
patch bump
2023-09-23 17:04:33 +01:00
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
645361c731 bump to pre-release a1 2023-09-18 09:38:37 +01:00
6baa0000c8 Merge remote-tracking branch 'origin/dev' into add-nav-binds 2023-09-18 09:18:44 +01:00
c94d763569 adds some quick navigation binds 2023-09-18 00:07:35 +01:00
11 changed files with 1584 additions and 471 deletions

View File

@@ -1,5 +0,0 @@
{
"black-formatter.args": [
"--line-length=120"
]
}

View File

@@ -1,6 +1,7 @@
[![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/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
# NVDA Voicemeeter
@@ -8,7 +9,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 +58,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,14 +95,42 @@ 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 reset a slider back to its default value you may use `Control + Shift + R`.
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`.
Pressing `Cancel` will close the popup window with no affect on the label.
#### `Advanced Compressor|Gate`
For potato version only, you may access advanced Compressor and Gate sliders. Simply focus any Gate or Compressor slider and press `Control + A`. This will open a popup window where you can navigate between the different sliders with `TAB`. Move the sliders with the same binds you would for normal sliders. However, there are a couple of extra binds for certain controls.
For Compressor Release you may use:
- `Alt + Left|Right arrow` to move the slider by 10 steps.
- `Alt + Control + Left|Right arrow` to move the slider by 50 steps.
For Gate BP Sidechain, Attack, Hold, Release you may use:
- `Alt + Left|Right arrow` to move the slider by 10 steps.
- `Alt + Control + Left|Right arrow` to move the slider by 50 steps.
To reset a slider back to its default value you may use `Control + Shift + R`.
#### `Menu`
A single menu item `Voicemeeter` can be opened using `Alt` and then `v`. The menu allows you to:
@@ -114,6 +143,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

78
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:ba53368b628b713c9cf4eb54e6f5c5c4af207c8e247d473417e4c2a4b47f645d"
content_hash = "sha256:680eff1b532e55860290380d4e2f331dc29af6fb898a0df16fdb033843bf15a4"
[[package]]
name = "altgraph"
@@ -63,21 +63,6 @@ files = [
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"},
]
[[package]]
name = "flake8"
version = "6.1.0"
requires_python = ">=3.8.1"
summary = "the modular source code checker: pep8 pyflakes and co"
dependencies = [
"mccabe<0.8.0,>=0.7.0",
"pycodestyle<2.12.0,>=2.11.0",
"pyflakes<3.2.0,>=3.1.0",
]
files = [
{file = "flake8-6.1.0-py2.py3-none-any.whl", hash = "sha256:ffdfce58ea94c6580c77888a86506937f9a1a227dfcd15f245d694ae20a6b6e5"},
{file = "flake8-6.1.0.tar.gz", hash = "sha256:d5b3857f07c030bdb5bf41c7f53799571d75c4491748a3adcd47de929e34cd23"},
]
[[package]]
name = "macholib"
version = "1.16.2"
@@ -90,16 +75,6 @@ files = [
{file = "macholib-1.16.2.tar.gz", hash = "sha256:557bbfa1bb255c20e9abafe7ed6cd8046b48d9525db2f9b77d3122a63a2a8bf8"},
]
[[package]]
name = "mccabe"
version = "0.7.0"
requires_python = ">=3.6"
summary = "McCabe checker, plugin for flake8"
files = [
{file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"},
{file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"},
]
[[package]]
name = "mypy-extensions"
version = "1.0.0"
@@ -162,26 +137,6 @@ files = [
{file = "psgdemos-1.12.1.tar.gz", hash = "sha256:4108af795477531a9b1c8675b9aa9b6628c109e660f6954baf8ba2dc3b5806e9"},
]
[[package]]
name = "pycodestyle"
version = "2.11.0"
requires_python = ">=3.8"
summary = "Python style guide checker"
files = [
{file = "pycodestyle-2.11.0-py2.py3-none-any.whl", hash = "sha256:5d1013ba8dc7895b548be5afb05740ca82454fd899971563d2ef625d090326f8"},
{file = "pycodestyle-2.11.0.tar.gz", hash = "sha256:259bcc17857d8a8b3b4a2327324b79e5f020a13c16074670f9c8c8f872ea76d0"},
]
[[package]]
name = "pyflakes"
version = "3.1.0"
requires_python = ">=3.8"
summary = "passive checker of Python programs"
files = [
{file = "pyflakes-3.1.0-py2.py3-none-any.whl", hash = "sha256:4132f6d49cb4dae6819e5379898f2b8cce3c5f23994194c24b77d5da2e36f774"},
{file = "pyflakes-3.1.0.tar.gz", hash = "sha256:a0aae034c444db0071aa077972ba4768d40c830d9539fd45bf4cd3f8f6992efc"},
]
[[package]]
name = "pyinstaller"
version = "5.13.0"
@@ -249,6 +204,31 @@ files = [
{file = "pywin32_ctypes-0.2.2-py3-none-any.whl", hash = "sha256:bf490a1a709baf35d688fe0ecf980ed4de11d2b3e37b51e5442587a75d9957e7"},
]
[[package]]
name = "ruff"
version = "0.0.291"
requires_python = ">=3.7"
summary = "An extremely fast Python linter, written in Rust."
files = [
{file = "ruff-0.0.291-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:b97d0d7c136a85badbc7fd8397fdbb336e9409b01c07027622f28dcd7db366f2"},
{file = "ruff-0.0.291-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:6ab44ea607967171e18aa5c80335237be12f3a1523375fa0cede83c5cf77feb4"},
{file = "ruff-0.0.291-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a04b384f2d36f00d5fb55313d52a7d66236531195ef08157a09c4728090f2ef0"},
{file = "ruff-0.0.291-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b727c219b43f903875b7503a76c86237a00d1a39579bb3e21ce027eec9534051"},
{file = "ruff-0.0.291-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:87671e33175ae949702774071b35ed4937da06f11851af75cd087e1b5a488ac4"},
{file = "ruff-0.0.291-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:b75f5801547f79b7541d72a211949754c21dc0705c70eddf7f21c88a64de8b97"},
{file = "ruff-0.0.291-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b09b94efdcd162fe32b472b2dd5bf1c969fcc15b8ff52f478b048f41d4590e09"},
{file = "ruff-0.0.291-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8d5b56bc3a2f83a7a1d7f4447c54d8d3db52021f726fdd55d549ca87bca5d747"},
{file = "ruff-0.0.291-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13f0d88e5f367b2dc8c7d90a8afdcfff9dd7d174e324fd3ed8e0b5cb5dc9b7f6"},
{file = "ruff-0.0.291-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:b3eeee1b1a45a247758ecdc3ab26c307336d157aafc61edb98b825cadb153df3"},
{file = "ruff-0.0.291-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:6c06006350c3bb689765d71f810128c9cdf4a1121fd01afc655c87bab4fb4f83"},
{file = "ruff-0.0.291-py3-none-musllinux_1_2_i686.whl", hash = "sha256:fd17220611047de247b635596e3174f3d7f2becf63bd56301fc758778df9b629"},
{file = "ruff-0.0.291-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:5383ba67ad360caf6060d09012f1fb2ab8bd605ab766d10ca4427a28ab106e0b"},
{file = "ruff-0.0.291-py3-none-win32.whl", hash = "sha256:1d5f0616ae4cdc7a938b493b6a1a71c8a47d0300c0d65f6e41c281c2f7490ad3"},
{file = "ruff-0.0.291-py3-none-win_amd64.whl", hash = "sha256:8a69bfbde72db8ca1c43ee3570f59daad155196c3fbe357047cd9b77de65f15b"},
{file = "ruff-0.0.291-py3-none-win_arm64.whl", hash = "sha256:d867384a4615b7f30b223a849b52104214442b5ba79b473d7edd18da3cde22d6"},
{file = "ruff-0.0.291.tar.gz", hash = "sha256:c61109661dde9db73469d14a82b42a88c7164f731e6a3b0042e71394c1c7ceed"},
]
[[package]]
name = "setuptools"
version = "68.1.2"
@@ -271,13 +251,13 @@ files = [
[[package]]
name = "voicemeeter-api"
version = "2.4.9"
version = "2.4.10"
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.9-py3-none-any.whl", hash = "sha256:a09fd07fe3799cd5c880d491048da81d94e49aa97ec753aa1f9289acd27be965"},
{file = "voicemeeter_api-2.4.9.tar.gz", hash = "sha256:47ad614a8b9ccb0b4e47acf65666ce0f0537a0890fffda9949e995bea70e679c"},
{file = "voicemeeter_api-2.4.10-py3-none-any.whl", hash = "sha256:2f75acb7b472e56b6bd8d4f1141f32d948c55ef9b30d5a08e085a1c8e76e2464"},
{file = "voicemeeter_api-2.4.10.tar.gz", hash = "sha256:1d8dfc1e8922179f8b97c90b90b9ed051082018c6af5feb1d48250140a02d40c"},
]

View File

@@ -1,6 +1,6 @@
[project]
name = "nvda_voicemeeter"
version = "0.2.2"
version = "0.5.0"
description = "A Voicemeeter app compatible with NVDA"
authors = [
{ name = "onyx-and-iris", email = "code@onyxandiris.online" },
@@ -8,7 +8,7 @@ authors = [
dependencies = [
"pysimplegui>=4.60.5",
"pyparsing>=3.1.1",
"voicemeeter-api>=2.4.9",
"voicemeeter-api>=2.4.10",
]
requires-python = ">=3.10,<3.12"
readme = "README.md"
@@ -22,7 +22,7 @@ build = [
]
lint = [
"black>=23.7.0",
"flake8>=6.1.0",
"ruff>=0.0.291",
]
test = [
"psgdemos>=1.12.1",
@@ -30,3 +30,97 @@ test = [
[tool.pdm.scripts.build]
shell = "build.ps1"
[tool.black]
line-length = 119
[tool.ruff]
select = [
"E",
"F",
]
ignore = [
"E501",
]
fixable = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"I",
"N",
"Q",
"S",
"T",
"W",
"ANN",
"ARG",
"BLE",
"COM",
"DJ",
"DTZ",
"EM",
"ERA",
"EXE",
"FBT",
"ICN",
"INP",
"ISC",
"NPY",
"PD",
"PGH",
"PIE",
"PL",
"PT",
"PTH",
"PYI",
"RET",
"RSE",
"RUF",
"SIM",
"SLF",
"TCH",
"TID",
"TRY",
"UP",
"YTT",
]
unfixable = []
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]
line-length = 119
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
target-version = "py310"
[tool.ruff.mccabe]
max-complexity = 10
[tool.ruff.per-file-ignores]
"__init__.py" = [
"E402",
"F401",
]

View File

@@ -161,7 +161,9 @@ class Builder:
[
psg.Spin(
nums,
initial_value=self.window.cache["asio"][f"ASIO CHECKBOX||{util.get_asio_checkbox_index(0, i)}"],
initial_value=self.window.cache["asio"][
f"ASIO CHECKBOX||{util.get_asio_checkbox_index(0, i)}"
],
size=2,
enable_events=True,
key=f"ASIO CHECKBOX||IN{i} 0",
@@ -172,7 +174,9 @@ class Builder:
[
psg.Spin(
nums,
initial_value=self.window.cache["asio"][f"ASIO CHECKBOX||{util.get_asio_checkbox_index(1, i)}"],
initial_value=self.window.cache["asio"][
f"ASIO CHECKBOX||{util.get_asio_checkbox_index(1, i)}"
],
size=2,
enable_events=True,
key=f"ASIO CHECKBOX||IN{i} 1",
@@ -220,7 +224,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 +239,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}",
)
@@ -316,6 +324,7 @@ class Builder:
disable_number_display=True,
expand_x=True,
enable_events=True,
disabled=True,
orientation="horizontal",
key=f"STRIP {i}||SLIDER GAIN",
),
@@ -323,7 +332,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 +341,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,
@@ -388,7 +397,11 @@ class Builder:
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")
return psg.Frame(
self.window.cache["labels"][f"STRIP {i}||LABEL"],
outputs,
key=f"STRIP {i}||LABEL",
)
def make_tab2_button_rows(self) -> psg.Frame:
layout = [
@@ -408,6 +421,7 @@ class Builder:
disable_number_display=True,
expand_x=True,
enable_events=True,
disabled=True,
orientation="horizontal",
key=f"STRIP {i}||SLIDER GAIN",
),
@@ -416,13 +430,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 +447,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,
@@ -448,7 +462,11 @@ class Builder:
if self.kind.name in ("banana", "potato"):
steps += (add_limit_slider,)
[step(layout) for step in steps]
return psg.Frame(self.window.cache["labels"][f"STRIP {i}||LABEL"], layout, key=f"STRIP {i}||LABEL||SLIDER")
return psg.Frame(
self.window.cache["labels"][f"STRIP {i}||LABEL"],
layout,
key=f"STRIP {i}||LABEL||SLIDER",
)
def make_tab2_slider_rows(self) -> psg.Frame:
layout = [
@@ -477,7 +495,11 @@ class Builder:
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")
return psg.Frame(
self.window.cache["labels"][f"BUS {i}||LABEL"],
outputs,
key=f"BUS {i}||LABEL",
)
def make_tab3_button_rows(self) -> psg.Frame:
layout = [[self.make_tab3_button_row(i)] for i in range(self.kind.num_bus)]
@@ -487,6 +509,7 @@ class Builder:
def add_gain_slider(layout):
layout.append(
[
psg.Text("Gain"),
psg.Slider(
range=(-60, 12),
default_value=self.vm.bus[i].gain,
@@ -494,9 +517,10 @@ class Builder:
disable_number_display=True,
expand_x=True,
enable_events=True,
disabled=True,
orientation="horizontal",
key=f"BUS {i}||SLIDER GAIN",
)
),
]
)

View File

@@ -1,8 +1,12 @@
from typing import Union
import PySimpleGUI as psg
from . import util
class LabelSlider(psg.Frame):
"""Compound Label Slider element"""
"""Compound Label Slider Strip element"""
def __init__(self, parent, i, param, range_=(0, 10), *args, **kwargs):
self.parent = parent
@@ -10,17 +14,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,
@@ -37,3 +37,169 @@ class LabelSlider(psg.Frame):
if param in ("COMP", "GATE", "DENOISER"):
return target.knob
return target
class CompSlider(psg.Slider):
"""Compressor Slider element"""
def __init__(self, vm, index, param):
self.vm = vm
self.index = index
super().__init__(
disable_number_display=True,
expand_x=True,
enable_events=True,
orientation="horizontal",
key=f"COMPRESSOR||SLIDER {param}",
**self.default_params(param),
)
def default_params(self, param):
match param:
case "INPUT GAIN":
return {
"range": (-24, 24),
"default_value": self.vm.strip[self.index].comp.gainin,
"resolution": 0.1,
"disabled": True,
}
case "RATIO":
return {
"range": (1, 8),
"default_value": self.vm.strip[self.index].comp.ratio,
"resolution": 0.1,
}
case "THRESHOLD":
return {
"range": (-40, -3),
"default_value": self.vm.strip[self.index].comp.threshold,
"resolution": 0.1,
}
case "ATTACK":
return {
"range": (0, 200),
"default_value": self.vm.strip[self.index].comp.attack,
"resolution": 0.1,
}
case "RELEASE":
return {
"range": (0, 5000),
"default_value": self.vm.strip[self.index].comp.release,
"resolution": 0.1,
}
case "KNEE":
return {
"range": (0, 1),
"default_value": self.vm.strip[self.index].comp.knee,
"resolution": 0.01,
}
case "OUTPUT GAIN":
return {
"range": (-24, 24),
"default_value": self.vm.strip[self.index].comp.gainout,
"resolution": 0.01,
"disabled": True,
}
@staticmethod
def check_bounds(param, val):
match param:
case "RATIO":
val = util.check_bounds(val, (1, 8))
case "THRESHOLD":
val = util.check_bounds(val, (-40, -3))
case "ATTACK":
val = util.check_bounds(val, (0, 200))
case "RELEASE":
val = util.check_bounds(val, (0, 5000))
case "KNEE":
val = util.check_bounds(val, (0, 1))
return val
class GateSlider(psg.Slider):
def __init__(self, vm, index, param):
self.vm = vm
self.index = index
super().__init__(
disable_number_display=True,
expand_x=True,
enable_events=True,
orientation="horizontal",
key=f"GATE||SLIDER {param}",
**self.default_params(param),
)
def default_params(self, param):
match param:
case "THRESHOLD":
return {
"range": (-60, -10),
"default_value": self.vm.strip[self.index].gate.threshold,
"resolution": 0.1,
}
case "DAMPING":
return {
"range": (-60, -10),
"default_value": self.vm.strip[self.index].gate.damping,
"resolution": 0.1,
}
case "BPSIDECHAIN":
return {
"range": (100, 4000),
"default_value": self.vm.strip[self.index].gate.bpsidechain,
"resolution": 1,
}
case "ATTACK":
return {
"range": (0, 1000),
"default_value": self.vm.strip[self.index].gate.attack,
"resolution": 0.1,
}
case "HOLD":
return {
"range": (0, 5000),
"default_value": self.vm.strip[self.index].gate.hold,
"resolution": 0.1,
}
case "RELEASE":
return {
"range": (0, 5000),
"default_value": self.vm.strip[self.index].gate.release,
"resolution": 0.1,
}
@staticmethod
def check_bounds(param, val):
match param:
case "THRESHOLD":
val = util.check_bounds(val, (-60, -10))
case "DAMPING MAX":
val = util.check_bounds(val, (-60, -10))
case "BPSIDECHAIN":
val = util.check_bounds(val, (100, 4000))
case "ATTACK":
val = util.check_bounds(val, (0, 1000))
case "HOLD":
val = util.check_bounds(val, (0, 5000))
case "RELEASE":
val = util.check_bounds(val, (0, 5000))
return val
class LabelSliderAdvanced(psg.Frame):
"""Compound Label Slider element for Advanced Comp|Gate"""
def __init__(self, parent, index, param, slider_cls: Union[CompSlider, GateSlider], *args, **kwargs):
label_map = {
"DAMPING": "Damping Max",
"BPSIDECHAIN": "BP Sidechain",
}
layout = [
[
psg.Text(label_map.get(param, param.title()), size=10),
slider_cls(parent.vm, index, param),
]
]
super().__init__(None, layout=layout, border_width=0, pad=0, *args, **kwargs)

View File

@@ -0,0 +1,715 @@
import logging
from pathlib import Path
import PySimpleGUI as psg
from . import util
from .compound import CompSlider, GateSlider, LabelSliderAdvanced
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 [_, ["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 [_, ["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 [_, ["KEY", "ENTER"]]:
popup.find_element_with_focus().click()
self.logger.debug(f"parsed::{parsed_cmd}")
popup.close()
def on_pdirty(self):
if self.popup.Title == "Advanced Compressor":
for param in ("RATIO", "THRESHOLD", "ATTACK", "RELEASE", "KNEE"):
self.popup[f"COMPRESSOR||SLIDER {param}"].update(
value=getattr(self.window.vm.strip[self.index].comp, param.lower())
)
self.popup["COMPRESSOR||SLIDER INPUT GAIN"].update(value=self.window.vm.strip[self.index].comp.gainin)
self.popup["COMPRESSOR||SLIDER OUTPUT GAIN"].update(value=self.window.vm.strip[self.index].comp.gainout)
elif self.popup.Title == "Advanced Gate":
for param in ("THRESHOLD", "DAMPING", "BPSIDECHAIN", "ATTACK", "HOLD", "RELEASE"):
self.popup[f"GATE||SLIDER {param}"].update(
value=getattr(self.window.vm.strip[self.index].gate, param.lower())
)
def compressor(self, index, title=None):
self.index = index
def _make_comp_frame() -> psg.Frame:
comp_layout = [
[LabelSliderAdvanced(self.window, index, param, CompSlider)]
for param in ("INPUT GAIN", "RATIO", "THRESHOLD", "ATTACK", "RELEASE", "KNEE", "OUTPUT GAIN")
]
return psg.Frame("ADVANCED COMPRESSOR", comp_layout)
layout = []
steps = (_make_comp_frame,)
for step in steps:
layout.append([step()])
layout.append([psg.Button("MAKEUP", size=(12, 1)), psg.Button("Exit", size=(8, 1))])
self.popup = psg.Window(title, layout, return_keyboard_events=False, finalize=True)
buttonmenu_opts = {"takefocus": 1, "highlightthickness": 1}
for param in ("INPUT GAIN", "RATIO", "THRESHOLD", "ATTACK", "RELEASE", "KNEE", "OUTPUT GAIN"):
self.popup[f"COMPRESSOR||SLIDER {param}"].Widget.config(**buttonmenu_opts)
self.popup[f"COMPRESSOR||SLIDER {param}"].bind("<FocusIn>", "||FOCUS IN")
self.popup[f"COMPRESSOR||SLIDER {param}"].bind("<FocusOut>", "||FOCUS OUT")
for event in ("KeyPress", "KeyRelease"):
event_id = event.removeprefix("Key").upper()
for direction in ("Left", "Right", "Up", "Down"):
self.popup[f"COMPRESSOR||SLIDER {param}"].bind(
f"<{event}-{direction}>", f"||KEY {direction.upper()} {event_id}"
)
self.popup[f"COMPRESSOR||SLIDER {param}"].bind(
f"<Shift-{event}-{direction}>", f"||KEY SHIFT {direction.upper()} {event_id}"
)
self.popup[f"COMPRESSOR||SLIDER {param}"].bind(
f"<Control-{event}-{direction}>", f"||KEY CTRL {direction.upper()} {event_id}"
)
if param == "RELEASE":
self.popup[f"COMPRESSOR||SLIDER {param}"].bind(
f"<Alt-{event}-{direction}>", f"||KEY ALT {direction.upper()} {event_id}"
)
self.popup[f"COMPRESSOR||SLIDER {param}"].bind(
f"<Control-Alt-{event}-{direction}>", f"||KEY CTRL ALT {direction.upper()} {event_id}"
)
self.popup[f"COMPRESSOR||SLIDER {param}"].bind("<Control-Shift-KeyPress-R>", "||KEY CTRL SHIFT R")
self.popup["MAKEUP"].bind("<FocusIn>", "||FOCUS IN")
self.popup["MAKEUP"].bind("<Return>", "||KEY ENTER")
self.popup["Exit"].bind("<FocusIn>", "||FOCUS IN")
self.popup["Exit"].bind("<Return>", "||KEY ENTER")
self.window.vm.observer.add(self.on_pdirty)
while True:
event, values = self.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 [["COMPRESSOR"], ["SLIDER", param]]:
setattr(self.window.vm.strip[index].comp, param.lower(), values[event])
case [["COMPRESSOR"], ["SLIDER", param], ["FOCUS", "IN"]]:
self.window.nvda.speak(f"{param} {values[f'COMPRESSOR||SLIDER {param}']}")
case [
["COMPRESSOR"],
["SLIDER", param],
["KEY", "LEFT" | "RIGHT" | "UP" | "DOWN" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
val = getattr(self.window.vm.strip[index].comp, param.lower())
match input_direction:
case "RIGHT" | "UP":
if param == "KNEE":
val += 0.1
else:
val += 1
case "LEFT" | "DOWN":
if param == "KNEE":
val -= 0.1
else:
val -= 1
val = CompSlider.check_bounds(param, val)
setattr(self.window.vm.strip[index].comp, param.lower(), val)
self.popup[f"COMPRESSOR||SLIDER {param}"].update(value=val)
if param == "KNEE":
self.window.nvda.speak(str(round(val, 2)))
else:
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [
["COMPRESSOR"],
["SLIDER", param],
["KEY", "CTRL", "LEFT" | "RIGHT" | "UP" | "DOWN" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
val = getattr(self.window.vm.strip[index].comp, param.lower())
match input_direction:
case "RIGHT" | "UP":
if param == "KNEE":
val += 0.3
elif param == "RELEASE":
val += 5
else:
val += 3
case "LEFT" | "DOWN":
if param == "KNEE":
val -= 0.3
elif param == "RELEASE":
val -= 5
else:
val -= 3
val = CompSlider.check_bounds(param, val)
setattr(self.window.vm.strip[index].comp, param.lower(), val)
self.popup[f"COMPRESSOR||SLIDER {param}"].update(value=val)
if param == "KNEE":
self.window.nvda.speak(str(round(val, 2)))
else:
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [
["COMPRESSOR"],
["SLIDER", param],
["KEY", "SHIFT", "LEFT" | "RIGHT" | "UP" | "DOWN" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
val = getattr(self.window.vm.strip[index].comp, param.lower())
match input_direction:
case "RIGHT" | "UP":
if param == "KNEE":
val += 0.01
else:
val += 0.1
case "LEFT" | "DOWN":
if param == "KNEE":
val -= 0.01
else:
val -= 0.1
val = CompSlider.check_bounds(param, val)
setattr(self.window.vm.strip[index].comp, param.lower(), val)
self.popup[f"COMPRESSOR||SLIDER {param}"].update(value=val)
if param == "KNEE":
self.window.nvda.speak(str(round(val, 2)))
else:
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [
["COMPRESSOR"],
["SLIDER", "RELEASE"],
["KEY", "ALT", "LEFT" | "RIGHT" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
val = self.window.vm.strip[index].comp.release
match input_direction:
case "RIGHT" | "UP":
val += 10
case "LEFT" | "DOWN":
val -= 10
val = util.check_bounds(val, (0, 5000))
self.window.vm.strip[index].comp.release = val
self.popup[f"COMPRESSOR||SLIDER {param}"].update(value=val)
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [
["COMPRESSOR"],
["SLIDER", "RELEASE"],
["KEY", "CTRL", "ALT", "LEFT" | "RIGHT" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
val = self.window.vm.strip[index].comp.release
match input_direction:
case "RIGHT" | "UP":
val += 50
case "LEFT" | "DOWN":
val -= 50
val = util.check_bounds(val, (0, 5000))
self.window.vm.strip[index].comp.release = val
self.popup[f"COMPRESSOR||SLIDER {param}"].update(value=val)
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [["COMPRESSOR"], ["SLIDER", "INPUT" | "OUTPUT" as direction, "GAIN"]]:
if direction == "INPUT":
self.window.vm.strip[index].comp.gainin = values[event]
else:
self.window.vm.strip[index].comp.gainout = values[event]
case [["COMPRESSOR"], ["SLIDER", "INPUT" | "OUTPUT" as direction, "GAIN"], ["FOCUS", "IN"]]:
label = f"{direction} GAIN"
self.window.nvda.speak(f"{label} {values[f'COMPRESSOR||SLIDER {label}']}")
case [
["COMPRESSOR"],
["SLIDER", "INPUT" | "OUTPUT" as direction, "GAIN"],
["KEY", "LEFT" | "RIGHT" | "UP" | "DOWN" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
if direction == "INPUT":
val = self.window.vm.strip[index].comp.gainin
else:
val = self.window.vm.strip[index].comp.gainout
match input_direction:
case "RIGHT" | "UP":
val += 1
case "LEFT" | "DOWN":
val -= 1
val = util.check_bounds(val, (-24, 24))
if direction == "INPUT":
self.window.vm.strip[index].comp.gainin = val
else:
self.window.vm.strip[index].comp.gainout = val
self.popup[f"COMPRESSOR||SLIDER {direction} GAIN"].update(value=val)
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [
["COMPRESSOR"],
["SLIDER", "INPUT" | "OUTPUT" as direction, "GAIN"],
["KEY", "CTRL", "LEFT" | "RIGHT" | "UP" | "DOWN" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
if direction == "INPUT":
val = self.window.vm.strip[index].comp.gainin
else:
val = self.window.vm.strip[index].comp.gainout
match input_direction:
case "RIGHT" | "UP":
val += 3
case "LEFT" | "DOWN":
val -= 3
val = util.check_bounds(val, (-24, 24))
if direction == "INPUT":
self.window.vm.strip[index].comp.gainin = val
else:
self.window.vm.strip[index].comp.gainout = val
self.popup[f"COMPRESSOR||SLIDER {direction} GAIN"].update(value=val)
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [
["COMPRESSOR"],
["SLIDER", "INPUT" | "OUTPUT" as direction, "GAIN"],
["KEY", "SHIFT", "LEFT" | "RIGHT" | "UP" | "DOWN" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
if direction == "INPUT":
val = self.window.vm.strip[index].comp.gainin
else:
val = self.window.vm.strip[index].comp.gainout
match input_direction:
case "RIGHT" | "UP":
val += 0.1
case "LEFT" | "DOWN":
val -= 0.1
val = util.check_bounds(val, (-24, 24))
if direction == "INPUT":
self.window.vm.strip[index].comp.gainin = val
else:
self.window.vm.strip[index].comp.gainout = val
self.popup[f"COMPRESSOR||SLIDER {direction} GAIN"].update(value=val)
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [
["COMPRESSOR"],
["SLIDER", "INPUT" | "OUTPUT" as direction, "GAIN"],
["KEY", "CTRL", "SHIFT", "R"],
]:
if direction == "INPUT":
self.window.vm.strip[index].comp.gainin = 0
else:
self.window.vm.strip[index].comp.gainout = 0
self.popup[f"COMPRESSOR||SLIDER {direction} GAIN"].update(value=0)
self.window.nvda.speak(str(0))
case [["COMPRESSOR"], ["SLIDER", param], ["KEY", "CTRL", "SHIFT", "R"]]:
match param:
case "RATIO":
val = 1
case "THRESHOLD":
val = -20
case "ATTACK":
val = 10
case "RELEASE":
val = 50
case "KNEE":
val = 0.5
setattr(self.window.vm.strip[index].comp, param.lower(), val)
self.popup[f"COMPRESSOR||SLIDER {param}"].update(value=val)
self.window.nvda.speak(str(round(val, 1)))
case ["MAKEUP"]:
val = not self.window.vm.strip[index].comp.makeup
self.window.vm.strip[index].comp.makeup = val
self.window.nvda.speak("on" if val else "off")
case [[button], ["FOCUS", "IN"]]:
if button == "MAKEUP":
self.window.nvda.speak(
f"{button} {'on' if self.window.vm.strip[index].comp.makeup else 'off'}"
)
else:
self.window.nvda.speak(button)
case [_, ["KEY", "ENTER"]]:
self.popup.find_element_with_focus().click()
self.logger.debug(f"parsed::{parsed_cmd}")
self.window.vm.observer.remove(self.on_pdirty)
self.popup.close()
def gate(self, index, title=None):
self.index = index
def _make_gate_frame() -> psg.Frame:
gate_layout = [
[LabelSliderAdvanced(self.window, index, param, GateSlider)]
for param in ("THRESHOLD", "DAMPING", "BPSIDECHAIN", "ATTACK", "HOLD", "RELEASE")
]
return psg.Frame("ADVANCED GATE", gate_layout)
layout = []
steps = (_make_gate_frame,)
for step in steps:
layout.append([step()])
layout.append([psg.Button("Exit", size=(8, 1))])
self.popup = psg.Window(title, layout, return_keyboard_events=False, finalize=True)
buttonmenu_opts = {"takefocus": 1, "highlightthickness": 1}
for param in ("THRESHOLD", "DAMPING", "BPSIDECHAIN", "ATTACK", "HOLD", "RELEASE"):
self.popup[f"GATE||SLIDER {param}"].Widget.config(**buttonmenu_opts)
self.popup[f"GATE||SLIDER {param}"].bind("<FocusIn>", "||FOCUS IN")
self.popup[f"GATE||SLIDER {param}"].bind("<FocusOut>", "||FOCUS OUT")
for event in ("KeyPress", "KeyRelease"):
event_id = event.removeprefix("Key").upper()
for direction in ("Left", "Right", "Up", "Down"):
self.popup[f"GATE||SLIDER {param}"].bind(
f"<{event}-{direction}>", f"||KEY {direction.upper()} {event_id}"
)
self.popup[f"GATE||SLIDER {param}"].bind(
f"<Shift-{event}-{direction}>", f"||KEY SHIFT {direction.upper()} {event_id}"
)
self.popup[f"GATE||SLIDER {param}"].bind(
f"<Control-{event}-{direction}>", f"||KEY CTRL {direction.upper()} {event_id}"
)
if param in ("BPSIDECHAIN", "ATTACK", "HOLD", "RELEASE"):
self.popup[f"GATE||SLIDER {param}"].bind(
f"<Alt-{event}-{direction}>", f"||KEY ALT {direction.upper()} {event_id}"
)
self.popup[f"GATE||SLIDER {param}"].bind(
f"<Control-Alt-{event}-{direction}>", f"||KEY CTRL ALT {direction.upper()} {event_id}"
)
self.popup[f"GATE||SLIDER {param}"].bind("<Control-Shift-KeyPress-R>", "||KEY CTRL SHIFT R")
self.popup["Exit"].bind("<FocusIn>", "||FOCUS IN")
self.popup["Exit"].bind("<Return>", "||KEY ENTER")
self.window.vm.observer.add(self.on_pdirty)
while True:
event, values = self.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 [["GATE"], ["SLIDER", param]]:
setattr(self.window.vm.strip[index].gate, param.lower(), values[event])
case [["GATE"], ["SLIDER", param], ["FOCUS", "IN"]]:
label_map = {
"DAMPING": "Damping Max",
"BPSIDECHAIN": "BP Sidechain",
}
self.window.nvda.speak(f"{label_map.get(param, param)} {values[f'GATE||SLIDER {param}']}")
case [
["GATE"],
["SLIDER", param],
["KEY", "LEFT" | "RIGHT" | "UP" | "DOWN" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
val = getattr(self.window.vm.strip[index].gate, param.lower())
match input_direction:
case "RIGHT" | "UP":
val += 1
case "LEFT" | "DOWN":
val -= 1
val = GateSlider.check_bounds(param, val)
setattr(self.window.vm.strip[index].gate, param.lower(), val)
self.popup[f"GATE||SLIDER {param}"].update(value=val)
if param == "BPSIDECHAIN":
self.window.nvda.speak(str(int(val)))
else:
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [
["GATE"],
["SLIDER", param],
["KEY", "CTRL", "LEFT" | "RIGHT" | "UP" | "DOWN" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
val = getattr(self.window.vm.strip[index].gate, param.lower())
match input_direction:
case "RIGHT" | "UP":
val += 3
case "LEFT" | "DOWN":
val -= 3
val = GateSlider.check_bounds(param, val)
setattr(self.window.vm.strip[index].gate, param.lower(), val)
self.popup[f"GATE||SLIDER {param}"].update(value=val)
if param == "BPSIDECHAIN":
self.window.nvda.speak(str(int(val)))
else:
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [
["GATE"],
["SLIDER", param],
["KEY", "SHIFT", "LEFT" | "RIGHT" | "UP" | "DOWN" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
val = getattr(self.window.vm.strip[index].gate, param.lower())
match input_direction:
case "RIGHT" | "UP":
val += 0.1
case "LEFT" | "DOWN":
val -= 0.1
val = GateSlider.check_bounds(param, val)
setattr(self.window.vm.strip[index].gate, param.lower(), val)
self.popup[f"GATE||SLIDER {param}"].update(value=val)
if param == "BPSIDECHAIN":
self.window.nvda.speak(str(int(val)))
else:
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [
["GATE"],
["SLIDER", "BPSIDECHAIN" | "ATTACK" | "HOLD" | "RELEASE" as param],
["KEY", "ALT", "LEFT" | "RIGHT" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
val = getattr(self.window.vm.strip[index].gate, param.lower())
match input_direction:
case "RIGHT" | "UP":
val += 10
case "LEFT" | "DOWN":
val -= 10
val = GateSlider.check_bounds(param, val)
setattr(self.window.vm.strip[index].gate, param.lower(), val)
self.popup[f"GATE||SLIDER {param}"].update(value=val)
if param == "BPSIDECHAIN":
self.window.nvda.speak(str(int(val)))
else:
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [
["GATE"],
["SLIDER", "BPSIDECHAIN" | "ATTACK" | "HOLD" | "RELEASE" as param],
["KEY", "CTRL", "ALT", "LEFT" | "RIGHT" as input_direction, "PRESS" | "RELEASE" as e],
]:
if e == "PRESS":
self.window.vm.event.pdirty = False
val = getattr(self.window.vm.strip[index].gate, param.lower())
match input_direction:
case "RIGHT" | "UP":
val += 50
case "LEFT" | "DOWN":
val -= 50
val = GateSlider.check_bounds(param, val)
setattr(self.window.vm.strip[index].gate, param.lower(), val)
self.popup[f"GATE||SLIDER {param}"].update(value=val)
if param == "BPSIDECHAIN":
self.window.nvda.speak(str(int(val)))
else:
self.window.nvda.speak(str(round(val, 1)))
else:
self.window.vm.event.pdirty = True
case [["GATE"], ["SLIDER", param], ["KEY", "CTRL", "SHIFT", "R"]]:
match param:
case "THRESHOLD":
val = -60
case "DAMPING":
val = -60
case "BPSIDECHAIN":
val = 100
case "ATTACK":
val = 0
case "HOLD":
val = 500
case "RELEASE":
val = 1000
setattr(self.window.vm.strip[index].gate, param.lower(), val)
self.popup[f"GATE||SLIDER {param}"].update(value=val)
self.window.nvda.speak(str(round(val, 1)))
case [[button], ["FOCUS", "IN"]]:
self.window.nvda.speak(button)
case [_, ["KEY", "ENTER"]]:
self.popup.find_element_with_focus().click()
self.logger.debug(f"parsed::{parsed_cmd}")
self.window.vm.observer.remove(self.on_pdirty)
self.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,7 +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):
@@ -173,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")
@@ -199,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,167 +272,19 @@ class NVDAVMWindow(psg.Window):
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):
"""
@@ -399,6 +292,7 @@ class NVDAVMWindow(psg.Window):
Main thread will shutdown once a close or exit event occurs
"""
mode = None
while True:
event, values = self.read()
@@ -406,42 +300,169 @@ 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):
# Slider 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()
self.nvda.speak(f"{values['tabgroup']}")
# Quick Navigation
case ["CTRL-1" | "CTRL-2" | "CTRL-3" | "CTRL-4" | "CTRL-5" | "CTRL-6" | "CTRL-7" | "CTRL-8" as bind]:
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
or self.find_element_with_focus().Key != f"STRIP {int(index) - 1}||A1"
):
self[f"STRIP {int(index) - 1}||SLIDER GAIN"].set_focus()
case "tab||Virtual Strip":
index = int(index) + self.kind.phys_in
if index > self.kind.num_strip:
continue
self[f"STRIP {index - 1}||A1"].set_focus()
if (
self.find_element_with_focus() is None
or self.find_element_with_focus().Key != f"STRIP {int(index) - 1}||A1"
):
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
# Advanced popups (settings, comp, gate)
case ["CTRL-A"]:
match values["tabgroup"]:
case "tab||Settings":
self.write_event_value("ADVANCED SETTINGS", None)
case "tab||Physical Strip":
if values["tabgroup||Physical Strip"] == "tab||Physical Strip||sliders":
if focus := self.find_element_with_focus():
identifier, partial = focus.key.split("||")
_, index = identifier.split()
match self.kind.name:
case "potato":
if "SLIDER COMP" in partial:
self.popup.compressor(int(index), title="Advanced Compressor")
elif "SLIDER GATE" in partial:
self.popup.gate(int(index), title="Advanced Gate")
# Menus
case [["Restart", "Audio", "Engine"], ["MENU"]]:
self.perform_long_operation(self.vm.command.restart, "ENGINE RESTART||END")
@@ -453,7 +474,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))
@@ -565,7 +586,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}"]
@@ -599,9 +620,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(
@@ -613,11 +632,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"]:
case ["ADVANCED SETTINGS"]:
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"]]:
@@ -641,19 +663,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}"]
@@ -694,7 +714,6 @@ class NVDAVMWindow(psg.Window):
| "TREBLE" as param,
],
]:
label = self.cache["labels"][f"STRIP {index}||LABEL"]
val = values[event]
match param:
case "GAIN":
@@ -709,7 +728,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],
[
@@ -727,10 +745,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],
[
@@ -739,7 +756,7 @@ class NVDAVMWindow(psg.Window):
],
["FOCUS", "OUT"],
]:
self.vm.event.pdirty = True
pass
case [
["STRIP", index],
[
@@ -754,8 +771,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
@@ -777,20 +796,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(round(val, 1)))
else:
self.vm.event.pdirty = True
case [
["STRIP", index],
[
@@ -805,8 +832,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
@@ -834,20 +863,31 @@ 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)
if param == "LIMIT":
self.nvda.speak(str(int(val)))
else:
self.nvda.speak(str(round(val, 1)))
else:
self.vm.event.pdirty = True
case [
["STRIP", index],
[
@@ -862,8 +902,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
@@ -891,26 +933,38 @@ 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)
if param == "LIMIT":
self.nvda.speak(str(int(val)))
else:
self.nvda.speak(str(round(val, 1)))
else:
self.vm.event.pdirty = True
case [["STRIP", index], ["SLIDER", param], ["KEY", "CTRL", "SHIFT", "R"]]:
match param:
case "GAIN":
self.vm.strip[int(index)].gain = 0
self[f"STRIP {index}||SLIDER {param}"].update(value=0)
case "COMP" | "GATE" | "DENOISER":
target = getattr(self.vm.strip[int(index)], param.lower())
setattr(target, "knob", 0)
self[f"STRIP {index}||SLIDER {param}"].update(value=0)
case "AUDIBILITY":
@@ -922,6 +976,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"{12 if param == 'LIMIT' else 0}")
# Bus Params
case [["BUS", index], [param]]:
@@ -935,7 +990,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
@@ -944,7 +999,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)
@@ -969,7 +1024,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:
@@ -987,53 +1042,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(round(val, 1)))
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(round(val, 1)))
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(round(val, 1)))
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(0))
# Unknown
case _: