From 3ca9e14e96a07b470623c9c046658f5559a0753b Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 21 Sep 2023 09:33:22 +0100 Subject: [PATCH] adds bass, mid and treble slider modes patch bump --- README.md | 3 +++ pyproject.toml | 2 +- src/nvda_voicemeeter/builder.py | 6 +++--- src/nvda_voicemeeter/util.py | 17 ++++++++++++----- src/nvda_voicemeeter/window.py | 26 ++++++++++++++------------ 5 files changed, 33 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index d162921..a23e062 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,9 @@ You may also enter slider modes which allow for control of the channels sliders - `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`. diff --git a/pyproject.toml b/pyproject.toml index 311a5d9..490a367 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "nvda_voicemeeter" -version = "0.3.0b1" +version = "0.3.1" description = "A Voicemeeter app compatible with NVDA" authors = [ { name = "onyx-and-iris", email = "code@onyxandiris.online" }, diff --git a/src/nvda_voicemeeter/builder.py b/src/nvda_voicemeeter/builder.py index 0ca5b0a..a443cce 100644 --- a/src/nvda_voicemeeter/builder.py +++ b/src/nvda_voicemeeter/builder.py @@ -323,7 +323,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( @@ -416,13 +416,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) ] ) diff --git a/src/nvda_voicemeeter/util.py b/src/nvda_voicemeeter/util.py index 98cb1be..fc3d3d3 100644 --- a/src/nvda_voicemeeter/util.py +++ b/src/nvda_voicemeeter/util.py @@ -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 diff --git a/src/nvda_voicemeeter/window.py b/src/nvda_voicemeeter/window.py index 2145329..12b8222 100644 --- a/src/nvda_voicemeeter/window.py +++ b/src/nvda_voicemeeter/window.py @@ -50,7 +50,7 @@ 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": @@ -109,7 +109,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: @@ -148,16 +148,18 @@ class NVDAVMWindow(psg.Window): self.bind("", "CTRL-O") self.bind("", "CTRL-S") self.bind("", "CTRL-M") + + self.bind("", "GAIN MODE") + self.bind("", "BASS MODE") + self.bind("", "MID MODE") + self.bind("", "TREBLE MODE") if self.kind.name == "basic": self.bind("", "AUDIBILITY MODE") - self.bind("", "GAIN MODE") elif self.kind.name == "banana": - self.bind("", "GAIN MODE") self.bind("", "COMP MODE") self.bind("", "GATE MODE") self.bind("", "LIMIT MODE") else: - self.bind("", "GAIN MODE") self.bind("", "COMP MODE") self.bind("", "GATE MODE") self.bind("", "DENOISER MODE") @@ -231,9 +233,7 @@ 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("", "||FOCUS IN") self[f"STRIP {i}||SLIDER {param}"].bind("", "||FOCUS OUT") self[f"STRIP {i}||SLIDER {param}"].bind("", "||KEY LEFT") @@ -291,7 +291,7 @@ class NVDAVMWindow(psg.Window): self.logger.debug(f"values::{values}") if event in (psg.WIN_CLOSED, "Exit"): break - elif event in ("GAIN MODE", "COMP MODE", "GATE MODE", "DENOISER MODE", "LIMIT MODE"): + elif event.endswith("MODE"): mode = event self.nvda.speak(f"{mode} enabled") elif event == "Escape:27": @@ -385,9 +385,11 @@ class NVDAVMWindow(psg.Window): param = values[event] if focus := self.find_element_with_focus(): identifier, partial = focus.Key.split("||") - if "SLIDER" not in partial: - op = op.removeprefix("SLIDER-MODE-").split("-") - self.write_event_value(f"{identifier}||SLIDER {param}||KEY {' '.join(op)}", None) + _, index = identifier.split() + if param in util.get_full_slider_params(int(index), self.kind): + if "SLIDER" not in partial: + op = op.removeprefix("SLIDER-MODE-").split("-") + self.write_event_value(f"{identifier}||SLIDER {param}||KEY {' '.join(op)}", None) # Rename popups case ["F2:113"]: