From 719328c6de4a49aaa73c47cf3da69c6bb05027f1 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Fri, 15 Sep 2023 23:01:26 +0100 Subject: [PATCH] adds check bounds. bump pre-release a3 --- pyproject.toml | 2 +- src/nvda_voicemeeter/util.py | 9 +++++++++ src/nvda_voicemeeter/window.py | 13 +++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 035b571..2f908e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "nvda_voicemeeter" -version = "0.2.1a2" +version = "0.2.1a3" description = "A Voicemeeter app compatible with NVDA" authors = [ { name = "onyx-and-iris", email = "code@onyxandiris.online" }, diff --git a/src/nvda_voicemeeter/util.py b/src/nvda_voicemeeter/util.py index 82c7ee8..f93247b 100644 --- a/src/nvda_voicemeeter/util.py +++ b/src/nvda_voicemeeter/util.py @@ -128,3 +128,12 @@ def get_bus_modes(vm) -> list: "lfeonly", "rearonly", ] + + +def check_bounds(val, bounds): + lower, upper = bounds + if val > upper: + val = upper + elif val < lower: + val = lower + return val diff --git a/src/nvda_voicemeeter/window.py b/src/nvda_voicemeeter/window.py index 8aceb18..c9d5ff3 100644 --- a/src/nvda_voicemeeter/window.py +++ b/src/nvda_voicemeeter/window.py @@ -17,6 +17,7 @@ from .nvda import Nvda from .parser import Parser from .util import ( _patch_insert_channels, + check_bounds, get_asio_checkbox_index, get_asio_samples_list, get_bus_modes, @@ -697,7 +698,7 @@ class NVDAVMWindow(psg.Window): val += 1 case "LEFT" | "DOWN": val -= 1 - self.vm.strip[int(index)].gain = val + self.vm.strip[int(index)].gain = check_bounds(val, (-60, 12)) self[f"STRIP {index}||SLIDER GAIN"].update(value=val) case [ ["STRIP", index], @@ -710,7 +711,7 @@ class NVDAVMWindow(psg.Window): val += 3 case "LEFT" | "DOWN": val -= 3 - self.vm.strip[int(index)].gain = val + self.vm.strip[int(index)].gain = check_bounds(val, (-60, 12)) self[f"STRIP {index}||SLIDER GAIN"].update(value=val) case [ ["STRIP", index], @@ -723,7 +724,7 @@ class NVDAVMWindow(psg.Window): val += 0.1 case "LEFT" | "DOWN": val -= 0.1 - self.vm.strip[int(index)].gain = val + self.vm.strip[int(index)].gain = check_bounds(val, (-60, 12)) self[f"STRIP {index}||SLIDER GAIN"].update(value=val) # Bus Params @@ -806,7 +807,7 @@ class NVDAVMWindow(psg.Window): val += 1 case "LEFT" | "DOWN": val -= 1 - self.vm.bus[int(index)].gain = val + self.vm.bus[int(index)].gain = check_bounds(val, (-60, 12)) self[f"BUS {index}||SLIDER GAIN"].update(value=val) case [ ["BUS", index], @@ -819,7 +820,7 @@ class NVDAVMWindow(psg.Window): val += 3 case "LEFT" | "DOWN": val -= 3 - self.vm.bus[int(index)].gain = val + self.vm.bus[int(index)].gain = check_bounds(val, (-60, 12)) self[f"BUS {index}||SLIDER GAIN"].update(value=val) case [ ["BUS", index], @@ -832,7 +833,7 @@ class NVDAVMWindow(psg.Window): val += 0.1 case "LEFT" | "DOWN": val -= 0.1 - self.vm.bus[int(index)].gain = val + self.vm.bus[int(index)].gain = check_bounds(val, (-60, 12)) self[f"BUS {index}||SLIDER GAIN"].update(value=val) # Unknown