Compare commits

..

No commits in common. "3ca9e14e96a07b470623c9c046658f5559a0753b" and "a19aab393624479298f91de6c40b421ab43fc5fa" have entirely different histories.

6 changed files with 67 additions and 74 deletions

View File

@ -106,7 +106,7 @@ All sliders may be controlled in three different ways:
- `Shift + Left|Right arrow` to move a slider by 0.1 steps.
- `Control + Left|Right arrow` to move a slider by 3 steps.
To rename a strip/bus channel focus on the channel in question and press `F2`. Then enter the new channel name into the text input widget and press the `Ok` button.
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.
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`.
@ -143,9 +143,6 @@ 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`.

View File

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

View File

@ -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.kind)])
layout.append([LabelSlider(self.window, i, param) for param in util.get_slider_params(i, self.vm)])
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.kind):
for param in util.get_slider_params(i, self.vm):
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.kind)
for param in util.get_slider_params(i, self.vm)
]
)

View File

@ -11,7 +11,6 @@ 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):
@ -47,27 +46,28 @@ class Popup:
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}"
def rename(self, message, title=None, tab=None):
if tab == "Physical Strip":
upper = self.window.kind.phys_in + 1
elif tab == "Virtual Strip":
upper = self.window.kind.virt_in + 1
elif tab == "Buses":
upper = self.window.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")],
],
]
popup = psg.Window(title, layout, finalize=True)
popup["Index"].bind("<FocusIn>", "||FOCUS IN")
popup["Edit"].bind("<FocusIn>", "||FOCUS IN")
popup["Ok"].bind("<FocusIn>", "||FOCUS IN")
popup["Ok"].bind("<Return>", "||KEY ENTER")
@ -81,8 +81,15 @@ class Popup:
if event in (psg.WIN_CLOSED, "Cancel"):
break
match parsed_cmd := self.window.parser.match.parseString(event):
case ["Index"]:
val = values["Index"]
self.window.nvda.speak(f"Index {val}")
case [[button], ["FOCUS", "IN"]]:
self.window.nvda.speak(button)
if button == "Index":
val = values["Index"]
self.window.nvda.speak(f"Index {val}")
else:
self.window.nvda.speak(button)
case [[button], ["KEY", "ENTER"]]:
popup.find_element_with_focus().click()
case ["Ok"]:

View File

@ -141,19 +141,12 @@ def check_bounds(val, bounds: tuple) -> int | float:
return val
def get_slider_params(i, kind) -> Iterable:
if i < kind.phys_in:
if kind.name == "basic":
def get_slider_params(i, vm) -> Iterable:
if i < vm.kind.phys_in:
if vm.kind.name == "basic":
return ("AUDIBILITY",)
if kind.name == "banana":
if vm.kind.name == "banana":
return ("COMP", "GATE")
if kind.name == "potato":
if vm.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

@ -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.kind):
for param in util.get_slider_params(i, self.vm):
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.kind):
for param in util.get_slider_params(i, self.vm):
if param in ("AUDIBILITY", "BASS", "MID", "TREBLE"):
val = getattr(self.vm.strip[i], param.lower())
else:
@ -148,18 +148,16 @@ class NVDAVMWindow(psg.Window):
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")
self.bind("<Control-g>", "GAIN MODE")
elif self.kind.name == "banana":
self.bind("<Control-g>", "GAIN MODE")
self.bind("<Control-c>", "COMP MODE")
self.bind("<Control-t>", "GATE MODE")
self.bind("<Control-l>", "LIMIT MODE")
else:
self.bind("<Control-g>", "GAIN MODE")
self.bind("<Control-c>", "COMP MODE")
self.bind("<Control-t>", "GATE MODE")
self.bind("<Control-d>", "DENOISER MODE")
@ -233,7 +231,9 @@ class NVDAVMWindow(psg.Window):
# Strip Sliders
for i in range(self.kind.num_strip):
for param in util.get_full_slider_params(i, self.kind):
for param in util.get_slider_params(i, self.vm) + ("GAIN", "LIMIT"):
if self.kind.name == "basic" and param == "LIMIT":
continue
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")
@ -291,12 +291,12 @@ class NVDAVMWindow(psg.Window):
self.logger.debug(f"values::{values}")
if event in (psg.WIN_CLOSED, "Exit"):
break
elif event.endswith("MODE"):
elif event in ("GAIN MODE", "COMP MODE", "GATE MODE", "DENOISER MODE", "LIMIT MODE"):
mode = event
self.nvda.speak(f"{mode} enabled")
elif event == "Escape:27":
if mode:
self.nvda.speak(f"{mode} disabled")
self.nvda.speak(f"{mode.split()[0]} mode disabled")
mode = None
if mode:
@ -380,47 +380,43 @@ class NVDAVMWindow(psg.Window):
| "SLIDER-MODE-CTRL-LEFT"
| "SLIDER-MODE-CTRL-RIGHT" as op
]:
op = op.removeprefix("SLIDER-MODE-").split("-")
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:
op = op.removeprefix("SLIDER-MODE-").split("-")
self.write_event_value(f"{identifier}||SLIDER {param}||KEY {' '.join(op)}", None)
if "SLIDER" not in partial:
self.write_event_value(f"{identifier}||SLIDER {param}||KEY {' '.join(op)}", None)
# Rename popups
case ["F2:113"]:
tab = values["tabgroup"].split("||")[1]
if tab in ("Physical Strip", "Virtual Strip", "Buses"):
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
match tab:
case "Physical Strip":
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":
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 {int(index) + 1}")
else:
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
data = self.popup.rename("Label", title=f"Rename {tab}", 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
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
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}")
else:
label = data.get("Edit", f"Virtual Bus {index - self.kind.phys_out + 1}")
self.vm.bus[index].label = label
self[f"BUS {index}||LABEL"].update(value=label)
self.cache["labels"][f"BUS {index}||LABEL"] = label
# Menus
case [["Restart", "Audio", "Engine"], ["MENU"]]: