Compare commits

...

5 Commits

Author SHA1 Message Date
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
8 changed files with 555 additions and 75 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) [![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) [![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/) [![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 # NVDA Voicemeeter

78
pdm.lock generated
View File

@@ -6,7 +6,7 @@ groups = ["default", "build", "lint", "test"]
cross_platform = true cross_platform = true
static_urls = false static_urls = false
lock_version = "4.3" lock_version = "4.3"
content_hash = "sha256:ba53368b628b713c9cf4eb54e6f5c5c4af207c8e247d473417e4c2a4b47f645d" content_hash = "sha256:680eff1b532e55860290380d4e2f331dc29af6fb898a0df16fdb033843bf15a4"
[[package]] [[package]]
name = "altgraph" name = "altgraph"
@@ -63,21 +63,6 @@ files = [
{file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, {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]] [[package]]
name = "macholib" name = "macholib"
version = "1.16.2" version = "1.16.2"
@@ -90,16 +75,6 @@ files = [
{file = "macholib-1.16.2.tar.gz", hash = "sha256:557bbfa1bb255c20e9abafe7ed6cd8046b48d9525db2f9b77d3122a63a2a8bf8"}, {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]] [[package]]
name = "mypy-extensions" name = "mypy-extensions"
version = "1.0.0" version = "1.0.0"
@@ -162,26 +137,6 @@ files = [
{file = "psgdemos-1.12.1.tar.gz", hash = "sha256:4108af795477531a9b1c8675b9aa9b6628c109e660f6954baf8ba2dc3b5806e9"}, {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]] [[package]]
name = "pyinstaller" name = "pyinstaller"
version = "5.13.0" version = "5.13.0"
@@ -249,6 +204,31 @@ files = [
{file = "pywin32_ctypes-0.2.2-py3-none-any.whl", hash = "sha256:bf490a1a709baf35d688fe0ecf980ed4de11d2b3e37b51e5442587a75d9957e7"}, {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]] [[package]]
name = "setuptools" name = "setuptools"
version = "68.1.2" version = "68.1.2"
@@ -271,13 +251,13 @@ files = [
[[package]] [[package]]
name = "voicemeeter-api" name = "voicemeeter-api"
version = "2.4.9" version = "2.4.10"
requires_python = ">=3.10,<4.0" requires_python = ">=3.10,<4.0"
summary = "A Python wrapper for the Voiceemeter API" summary = "A Python wrapper for the Voiceemeter API"
dependencies = [ dependencies = [
"tomli<3.0.0,>=2.0.1; python_version < \"3.11\"", "tomli<3.0.0,>=2.0.1; python_version < \"3.11\"",
] ]
files = [ files = [
{file = "voicemeeter_api-2.4.9-py3-none-any.whl", hash = "sha256:a09fd07fe3799cd5c880d491048da81d94e49aa97ec753aa1f9289acd27be965"}, {file = "voicemeeter_api-2.4.10-py3-none-any.whl", hash = "sha256:2f75acb7b472e56b6bd8d4f1141f32d948c55ef9b30d5a08e085a1c8e76e2464"},
{file = "voicemeeter_api-2.4.9.tar.gz", hash = "sha256:47ad614a8b9ccb0b4e47acf65666ce0f0537a0890fffda9949e995bea70e679c"}, {file = "voicemeeter_api-2.4.10.tar.gz", hash = "sha256:1d8dfc1e8922179f8b97c90b90b9ed051082018c6af5feb1d48250140a02d40c"},
] ]

View File

@@ -1,6 +1,6 @@
[project] [project]
name = "nvda_voicemeeter" name = "nvda_voicemeeter"
version = "0.4.1" version = "0.4.2a1"
description = "A Voicemeeter app compatible with NVDA" description = "A Voicemeeter app compatible with NVDA"
authors = [ authors = [
{ name = "onyx-and-iris", email = "code@onyxandiris.online" }, { name = "onyx-and-iris", email = "code@onyxandiris.online" },
@@ -8,7 +8,7 @@ authors = [
dependencies = [ dependencies = [
"pysimplegui>=4.60.5", "pysimplegui>=4.60.5",
"pyparsing>=3.1.1", "pyparsing>=3.1.1",
"voicemeeter-api>=2.4.9", "voicemeeter-api>=2.4.10",
] ]
requires-python = ">=3.10,<3.12" requires-python = ">=3.10,<3.12"
readme = "README.md" readme = "README.md"
@@ -22,7 +22,7 @@ build = [
] ]
lint = [ lint = [
"black>=23.7.0", "black>=23.7.0",
"flake8>=6.1.0", "ruff>=0.0.291",
] ]
test = [ test = [
"psgdemos>=1.12.1", "psgdemos>=1.12.1",
@@ -30,3 +30,57 @@ test = [
[tool.pdm.scripts.build] [tool.pdm.scripts.build]
shell = "build.ps1" shell = "build.ps1"
[tool.black]
line-length = 119
[tool.ruff]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
select = ["E", "F"]
# Avoid enforcing line-length violations (`E501`). Let Black deal with this.
ignore = ["E501"]
# Allow autofix for all enabled rules (when `--fix`) is provided.
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 a variety of commonly ignored directories.
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",
]
# Same as Black.
line-length = 119
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
# Assume Python 3.10
target-version = "py310"
[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10
[tool.ruff.per-file-ignores]
"__init__.py" = ["E402", "F401"] # Ignore unused import and variable not accessed violations

View File

@@ -161,7 +161,9 @@ class Builder:
[ [
psg.Spin( psg.Spin(
nums, 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, size=2,
enable_events=True, enable_events=True,
key=f"ASIO CHECKBOX||IN{i} 0", key=f"ASIO CHECKBOX||IN{i} 0",
@@ -172,7 +174,9 @@ class Builder:
[ [
psg.Spin( psg.Spin(
nums, 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, size=2,
enable_events=True, enable_events=True,
key=f"ASIO CHECKBOX||IN{i} 1", key=f"ASIO CHECKBOX||IN{i} 1",
@@ -320,6 +324,7 @@ class Builder:
disable_number_display=True, disable_number_display=True,
expand_x=True, expand_x=True,
enable_events=True, enable_events=True,
disabled=True,
orientation="horizontal", orientation="horizontal",
key=f"STRIP {i}||SLIDER GAIN", key=f"STRIP {i}||SLIDER GAIN",
), ),
@@ -392,7 +397,11 @@ class Builder:
outputs = [] outputs = []
[step(outputs) for step in (add_strip_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: def make_tab2_button_rows(self) -> psg.Frame:
layout = [ layout = [
@@ -412,6 +421,7 @@ class Builder:
disable_number_display=True, disable_number_display=True,
expand_x=True, expand_x=True,
enable_events=True, enable_events=True,
disabled=True,
orientation="horizontal", orientation="horizontal",
key=f"STRIP {i}||SLIDER GAIN", key=f"STRIP {i}||SLIDER GAIN",
), ),
@@ -452,7 +462,11 @@ class Builder:
if self.kind.name in ("banana", "potato"): if self.kind.name in ("banana", "potato"):
steps += (add_limit_slider,) steps += (add_limit_slider,)
[step(layout) for step in steps] [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: def make_tab2_slider_rows(self) -> psg.Frame:
layout = [ layout = [
@@ -481,7 +495,11 @@ class Builder:
outputs = [] outputs = []
[step(outputs) for step in (add_strip_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: def make_tab3_button_rows(self) -> psg.Frame:
layout = [[self.make_tab3_button_row(i)] for i in range(self.kind.num_bus)] layout = [[self.make_tab3_button_row(i)] for i in range(self.kind.num_bus)]
@@ -491,6 +509,7 @@ class Builder:
def add_gain_slider(layout): def add_gain_slider(layout):
layout.append( layout.append(
[ [
psg.Text("Gain"),
psg.Slider( psg.Slider(
range=(-60, 12), range=(-60, 12),
default_value=self.vm.bus[i].gain, default_value=self.vm.bus[i].gain,
@@ -498,9 +517,10 @@ class Builder:
disable_number_display=True, disable_number_display=True,
expand_x=True, expand_x=True,
enable_events=True, enable_events=True,
disabled=True,
orientation="horizontal", orientation="horizontal",
key=f"BUS {i}||SLIDER GAIN", key=f"BUS {i}||SLIDER GAIN",
) ),
] ]
) )

View File

@@ -2,7 +2,7 @@ import PySimpleGUI as psg
class LabelSlider(psg.Frame): class LabelSlider(psg.Frame):
"""Compound Label Slider element""" """Compound Label Slider Strip element"""
def __init__(self, parent, i, param, range_=(0, 10), *args, **kwargs): def __init__(self, parent, i, param, range_=(0, 10), *args, **kwargs):
self.parent = parent self.parent = parent
@@ -33,3 +33,85 @@ class LabelSlider(psg.Frame):
if param in ("COMP", "GATE", "DENOISER"): if param in ("COMP", "GATE", "DENOISER"):
return target.knob return target.knob
return target 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",
**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,
"key": f"COMPRESSOR||SLIDER {param}",
}
case "RATIO":
return {
"range": (1, 8),
"default_value": self.vm.strip[self.index].comp.ratio,
"resolution": 0.1,
"key": f"COMPRESSOR||SLIDER {param}",
}
case "THRESHOLD":
return {
"range": (-40, -3),
"default_value": self.vm.strip[self.index].comp.threshold,
"resolution": 0.1,
"key": f"COMPRESSOR||SLIDER {param}",
}
case "ATTACK":
return {
"range": (0, 200),
"default_value": self.vm.strip[self.index].comp.attack,
"resolution": 0.1,
"key": f"COMPRESSOR||SLIDER {param}",
}
case "RELEASE":
return {
"range": (0, 5000),
"default_value": self.vm.strip[self.index].comp.release,
"resolution": 0.1,
"key": f"COMPRESSOR||SLIDER {param}",
}
case "KNEE":
return {
"range": (0, 1),
"default_value": self.vm.strip[self.index].comp.knee,
"resolution": 0.01,
"key": f"COMPRESSOR||SLIDER {param}",
}
case "OUTPUT GAIN":
return {
"range": (-24, 24),
"default_value": self.vm.strip[self.index].comp.gainout,
"resolution": 0.01,
"disabled": True,
"key": f"COMPRESSOR||SLIDER {param}",
}
class LabelSliderCompressor(psg.Frame):
"""Compound Label Slider Compressor element"""
def __init__(self, parent, index, param, *args, **kwargs):
layout = [
[
psg.Text(param.capitalize(), size=8),
CompSlider(parent.vm, index, param),
]
]
super().__init__(None, layout=layout, border_width=0, pad=0, *args, **kwargs)

View File

@@ -4,6 +4,7 @@ from pathlib import Path
import PySimpleGUI as psg import PySimpleGUI as psg
from . import util from . import util
from .compound import LabelSliderCompressor
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -40,7 +41,7 @@ class Popup:
filepath = values["Browse"] filepath = values["Browse"]
break break
self.window.nvda.speak(button) self.window.nvda.speak(button)
case [[button], ["KEY", "ENTER"]]: case [_, ["KEY", "ENTER"]]:
popup.find_element_with_focus().click() popup.find_element_with_focus().click()
self.logger.debug(f"parsed::{parsed_cmd}") self.logger.debug(f"parsed::{parsed_cmd}")
popup.close() popup.close()
@@ -83,7 +84,7 @@ class Popup:
match parsed_cmd := self.window.parser.match.parseString(event): match parsed_cmd := self.window.parser.match.parseString(event):
case [[button], ["FOCUS", "IN"]]: case [[button], ["FOCUS", "IN"]]:
self.window.nvda.speak(button) self.window.nvda.speak(button)
case [[button], ["KEY", "ENTER"]]: case [_, ["KEY", "ENTER"]]:
popup.find_element_with_focus().click() popup.find_element_with_focus().click()
case ["Ok"]: case ["Ok"]:
data = values data = values
@@ -151,7 +152,335 @@ class Popup:
util.open_context_menu_for_buttonmenu(popup, f"BUFFER {driver}") util.open_context_menu_for_buttonmenu(popup, f"BUFFER {driver}")
case [[button], ["FOCUS", "IN"]]: case [[button], ["FOCUS", "IN"]]:
self.window.nvda.speak(button) self.window.nvda.speak(button)
case [[button], ["KEY", "ENTER"]]: case [_, ["KEY", "ENTER"]]:
popup.find_element_with_focus().click()
self.logger.debug(f"parsed::{parsed_cmd}")
popup.close()
def compressor(self, index, title=None):
def _make_comp_frame() -> psg.Frame:
comp_layout = [
[LabelSliderCompressor(self.window, index, param)]
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))])
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"):
popup[f"COMPRESSOR||SLIDER {param}"].Widget.config(**buttonmenu_opts)
popup[f"COMPRESSOR||SLIDER {param}"].bind("<FocusIn>", "||FOCUS IN")
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"):
popup[f"COMPRESSOR||SLIDER {param}"].bind(
f"<{event}-{direction}>", f"||KEY {direction.upper()} {event_id}"
)
popup[f"COMPRESSOR||SLIDER {param}"].bind(
f"<Shift-{event}-{direction}>", f"||KEY SHIFT {direction.upper()} {event_id}"
)
popup[f"COMPRESSOR||SLIDER {param}"].bind(
f"<Control-{event}-{direction}>", f"||KEY CTRL {direction.upper()} {event_id}"
)
if param == "RELEASE":
popup[f"COMPRESSOR||SLIDER {param}"].bind(
f"<Alt-{event}-{direction}>", f"||KEY ALT {direction.upper()} {event_id}"
)
popup[f"COMPRESSOR||SLIDER {param}"].bind(
f"<Control-Alt-{event}-{direction}>", f"||KEY CTRL ALT {direction.upper()} {event_id}"
)
popup["MAKEUP"].bind("<FocusIn>", "||FOCUS IN")
popup["MAKEUP"].bind("<Return>", "||KEY ENTER")
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 [["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
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))
setattr(self.window.vm.strip[index].comp, param.lower(), val)
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
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))
setattr(self.window.vm.strip[index].comp, param.lower(), val)
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
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))
setattr(self.window.vm.strip[index].comp, param.lower(), val)
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
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
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
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
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
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 ["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"]]:
popup.find_element_with_focus().click() popup.find_element_with_focus().click()
self.logger.debug(f"parsed::{parsed_cmd}") self.logger.debug(f"parsed::{parsed_cmd}")
popup.close() popup.close()

View File

@@ -311,7 +311,7 @@ class NVDAVMWindow(psg.Window):
continue continue
match parsed_cmd := self.parser.match.parseString(event): match parsed_cmd := self.parser.match.parseString(event):
# Slide mode # Slider mode
case [["ALT", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction], ["PRESS" | "RELEASE" as e]]: case [["ALT", "LEFT" | "RIGHT" | "UP" | "DOWN" as direction], ["PRESS" | "RELEASE" as e]]:
if mode: if mode:
self.write_event_value(f"SLIDER MODE {direction}||{e}", mode.split()[0]) self.write_event_value(f"SLIDER MODE {direction}||{e}", mode.split()[0])
@@ -446,6 +446,19 @@ class NVDAVMWindow(psg.Window):
self[f"BUS {index}||LABEL"].update(value=label) self[f"BUS {index}||LABEL"].update(value=label)
self.cache["labels"][f"BUS {index}||LABEL"] = 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()
if "SLIDER COMP" in partial:
self.popup.compressor(int(index), title="Advanced Compressor")
# Menus # Menus
case [["Restart", "Audio", "Engine"], ["MENU"]]: case [["Restart", "Audio", "Engine"], ["MENU"]]:
self.perform_long_operation(self.vm.command.restart, "ENGINE RESTART||END") self.perform_long_operation(self.vm.command.restart, "ENGINE RESTART||END")
@@ -620,7 +633,7 @@ class NVDAVMWindow(psg.Window):
self.write_event_value(f"INSERT CHECKBOX||{in_num} {channel}", val) self.write_event_value(f"INSERT CHECKBOX||{in_num} {channel}", val)
# Advanced Settings # Advanced Settings
case ["ADVANCED SETTINGS"] | ["CTRL-A"]: case ["ADVANCED SETTINGS"]:
if values["tabgroup"] == "tab||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"]]: case [["ADVANCED", "SETTINGS"], ["FOCUS", "IN"]]:
@@ -798,7 +811,7 @@ class NVDAVMWindow(psg.Window):
val = util.check_bounds(val, (-40, 12)) val = util.check_bounds(val, (-40, 12))
self.vm.strip[int(index)].limit = val self.vm.strip[int(index)].limit = val
self[f"STRIP {index}||SLIDER {param}"].update(value=val) self[f"STRIP {index}||SLIDER {param}"].update(value=val)
self.nvda.speak(str(val)) self.nvda.speak(str(round(val, 1)))
else: else:
self.vm.event.pdirty = True self.vm.event.pdirty = True
case [ case [
@@ -865,7 +878,10 @@ class NVDAVMWindow(psg.Window):
val = util.check_bounds(val, (-40, 12)) val = util.check_bounds(val, (-40, 12))
self.vm.strip[int(index)].limit = val self.vm.strip[int(index)].limit = val
self[f"STRIP {index}||SLIDER {param}"].update(value=val) self[f"STRIP {index}||SLIDER {param}"].update(value=val)
self.nvda.speak(f"{param} {val}") if param == "LIMIT":
self.nvda.speak(str(int(val)))
else:
self.nvda.speak(str(round(val, 1)))
else: else:
self.vm.event.pdirty = True self.vm.event.pdirty = True
case [ case [
@@ -932,7 +948,10 @@ class NVDAVMWindow(psg.Window):
val = util.check_bounds(val, (-40, 12)) val = util.check_bounds(val, (-40, 12))
self.vm.strip[int(index)].limit = val self.vm.strip[int(index)].limit = val
self[f"STRIP {index}||SLIDER {param}"].update(value=val) self[f"STRIP {index}||SLIDER {param}"].update(value=val)
self.nvda.speak(f"{param} {val}") if param == "LIMIT":
self.nvda.speak(str(int(val)))
else:
self.nvda.speak(str(round(val, 1)))
else: else:
self.vm.event.pdirty = True self.vm.event.pdirty = True
case [["STRIP", index], ["SLIDER", param], ["KEY", "CTRL", "SHIFT", "R"]]: case [["STRIP", index], ["SLIDER", param], ["KEY", "CTRL", "SHIFT", "R"]]:
@@ -1041,7 +1060,7 @@ class NVDAVMWindow(psg.Window):
val = util.check_bounds(val, (-60, 12)) val = util.check_bounds(val, (-60, 12))
self.vm.bus[int(index)].gain = val self.vm.bus[int(index)].gain = val
self[f"BUS {index}||SLIDER GAIN"].update(value=val) self[f"BUS {index}||SLIDER GAIN"].update(value=val)
self.nvda.speak(str(val)) self.nvda.speak(str(round(val, 1)))
else: else:
self.vm.event.pdirty = True self.vm.event.pdirty = True
case [ case [
@@ -1060,7 +1079,7 @@ class NVDAVMWindow(psg.Window):
val = util.check_bounds(val, (-60, 12)) val = util.check_bounds(val, (-60, 12))
self.vm.bus[int(index)].gain = val self.vm.bus[int(index)].gain = val
self[f"BUS {index}||SLIDER GAIN"].update(value=val) self[f"BUS {index}||SLIDER GAIN"].update(value=val)
self.nvda.speak(str(val)) self.nvda.speak(str(round(val, 1)))
else: else:
self.vm.event.pdirty = True self.vm.event.pdirty = True
case [ case [
@@ -1079,7 +1098,7 @@ class NVDAVMWindow(psg.Window):
val = util.check_bounds(val, (-60, 12)) val = util.check_bounds(val, (-60, 12))
self.vm.bus[int(index)].gain = val self.vm.bus[int(index)].gain = val
self[f"BUS {index}||SLIDER GAIN"].update(value=val) self[f"BUS {index}||SLIDER GAIN"].update(value=val)
self.nvda.speak(str(val)) self.nvda.speak(str(round(val, 1)))
else: else:
self.vm.event.pdirty = True self.vm.event.pdirty = True
case [["BUS", index], ["SLIDER", "GAIN"], ["KEY", "CTRL", "SHIFT", "R"]]: case [["BUS", index], ["SLIDER", "GAIN"], ["KEY", "CTRL", "SHIFT", "R"]]: