Compare commits

..

3 Commits

Author SHA1 Message Date
c385476cc4 adjust cache to match strip layout
event keys updated

_get_bus_assignments added to util.py

patch bump
2023-09-29 20:08:18 +01:00
1c09556c61 adds missing karaoke mode k v
patch bump
2023-09-29 18:30:53 +01:00
421688eff8 resizes the patch composite buttons
fixes possible (but unlikely) index out of range.

patch bump
2023-09-29 13:38:40 +01:00
5 changed files with 46 additions and 48 deletions

View File

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

View File

@@ -202,7 +202,7 @@ class Builder:
[
psg.ButtonMenu(
f"PC{i + 1}",
size=(6, 2),
size=(5, 2),
menu_def=["", outputs],
key=f"PATCH COMPOSITE||PC{i + 1}",
)
@@ -381,7 +381,7 @@ class Builder:
if i == self.kind.phys_in + 1:
layout.append(
[
psg.Button("K", size=(6, 2), key=f"STRIP {i}||MONO"),
psg.Button("K", size=(6, 2), key=f"STRIP {i}||KARAOKE"),
psg.Button("Solo", size=(6, 2), key=f"STRIP {i}||SOLO"),
psg.Button("Mute", size=(6, 2), key=f"STRIP {i}||MUTE"),
],
@@ -389,7 +389,7 @@ class Builder:
else:
layout.append(
[
psg.Button("MC", size=(6, 2), key=f"STRIP {i}||MONO"),
psg.Button("MC", size=(6, 2), key=f"STRIP {i}||MC"),
psg.Button("Solo", size=(6, 2), key=f"STRIP {i}||SOLO"),
psg.Button("Mute", size=(6, 2), key=f"STRIP {i}||MUTE"),
],

View File

@@ -38,10 +38,15 @@ def _make_param_cache(vm, channel_type) -> dict:
**{f"STRIP {i}||B3": vm.strip[i].B3 for i in range(vm.kind.num_strip)},
}
params |= {
**{f"STRIP {i}||MONO": vm.strip[i].mono for i in range(vm.kind.num_strip)},
**{f"STRIP {i}||MONO": vm.strip[i].mono for i in range(vm.kind.phys_in)},
**{f"STRIP {i}||SOLO": vm.strip[i].solo for i in range(vm.kind.num_strip)},
**{f"STRIP {i}||MUTE": vm.strip[i].mute for i in range(vm.kind.num_strip)},
}
for i in range(vm.kind.phys_in, vm.kind.phys_in + vm.kind.virt_in):
if i == vm.kind.phys_in + 1:
params[f"STRIP {i}||KARAOKE"] = vm.strip[i].k
else:
params[f"STRIP {i}||MC"] = vm.strip[i].mc
else:
params |= {
**{f"BUS {i}||MONO": vm.bus[i].mono for i in range(vm.kind.num_bus)},

View File

@@ -192,3 +192,7 @@ def get_slider_modes() -> Iterable:
"DENOISER MODE",
"LIMIT MODE",
)
def _get_bus_assignments(kind) -> list:
return [f"A{i}" for i in range(1, kind.phys_out + 1)] + [f"B{i}" for i in range(1, kind.virt_out + 1)]

View File

@@ -237,9 +237,14 @@ class NVDAVMWindow(psg.Window):
self[f"STRIP {i}||{param}"].bind("<FocusIn>", "||FOCUS IN")
self[f"STRIP {i}||{param}"].bind("<Return>", "||KEY ENTER")
else:
for param in ("MONO", "SOLO", "MUTE"):
self[f"STRIP {i}||{param}"].bind("<FocusIn>", "||FOCUS IN")
self[f"STRIP {i}||{param}"].bind("<Return>", "||KEY ENTER")
if i == self.kind.phys_in + 1:
for param in ("KARAOKE", "SOLO", "MUTE"):
self[f"STRIP {i}||{param}"].bind("<FocusIn>", "||FOCUS IN")
self[f"STRIP {i}||{param}"].bind("<Return>", "||KEY ENTER")
else:
for param in ("MC", "SOLO", "MUTE"):
self[f"STRIP {i}||{param}"].bind("<FocusIn>", "||FOCUS IN")
self[f"STRIP {i}||{param}"].bind("<Return>", "||KEY ENTER")
# Strip Sliders
for i in range(self.kind.num_strip):
@@ -613,10 +618,12 @@ class NVDAVMWindow(psg.Window):
else:
index = int(key[-1]) - 1
comp_index = self.vm.patch.composite[index].get()
if self.kind.name == "banana":
if comp_index == 64: # bus channel
comp_index = 0
val = util.get_patch_composite_list(self.kind)[comp_index - 1]
comp_list = util.get_patch_composite_list(self.kind)
try:
val = comp_list[comp_index - 1]
except IndexError as e:
val = comp_list[-1]
self.logger.error(f"{type(e).__name__}: {e}")
self.nvda.speak(f"Patch COMPOSITE {key[-1]} {val}")
case [["PATCH", "COMPOSITE"], [key], ["KEY", "SPACE" | "ENTER"]]:
util.open_context_menu_for_buttonmenu(self, f"PATCH COMPOSITE||{key}")
@@ -657,54 +664,36 @@ class NVDAVMWindow(psg.Window):
# Strip Params
case [["STRIP", index], [param]]:
label = self.cache["labels"][f"STRIP {index}||LABEL"]
match param:
case "MONO":
if int(index) < self.kind.phys_in:
actual = param.lower()
elif int(index) == self.kind.phys_in + 1:
actual = "k"
else:
actual = "mc"
phonetic = {"k": "karaoke"}
if actual == "k":
next_val = self.vm.strip[int(index)].k + 1
if next_val == 4:
next_val = 0
setattr(self.vm.strip[int(index)], actual, next_val)
self.cache["strip"][f"STRIP {index}||{param}"] = 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("on" if val else "off")
case "KARAOKE":
opts = ["off", "k m", "k 1", "k 2", "k v"]
next_val = self.vm.strip[int(index)].k + 1
if next_val == len(opts):
next_val = 0
self.vm.strip[int(index)].k = next_val
self.cache["strip"][f"STRIP {index}||{param}"] = next_val
self.nvda.speak(opts[next_val])
case output if param in util._get_bus_assignments(self.kind):
val = not self.cache["strip"][f"STRIP {index}||{output}"]
setattr(self.vm.strip[int(index)], output, val)
self.cache["strip"][f"STRIP {index}||{output}"] = val
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)
setattr(self.vm.strip[int(index)], param.lower(), val)
self.cache["strip"][f"STRIP {index}||{param}"] = val
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}"]
match param:
case "MONO":
if int(index) < self.kind.phys_in:
actual = param.lower()
elif int(index) == self.kind.phys_in + 1:
actual = "k"
else:
actual = "mc"
case _:
actual = param
phonetic = {"k": "karaoke"}
phonetic = {"KARAOKE": "karaoke"}
label = self.cache["labels"][f"STRIP {index}||LABEL"]
if actual == "k":
if param == "KARAOKE":
self.nvda.speak(
f"{label} {phonetic.get(actual, actual)} {['off', 'k m', 'k 1', 'k 2'][self.cache['strip'][f'STRIP {int(index)}||{param}']]}"
f"{label} {phonetic.get(param, param)} {['off', 'k m', 'k 1', 'k 2', 'k v'][self.cache['strip'][f'STRIP {int(index)}||{param}']]}"
)
else:
self.nvda.speak(f"{label} {phonetic.get(actual, actual)} {'on' if val else 'off'}")
self.nvda.speak(f"{label} {phonetic.get(param, param)} {'on' if val else 'off'}")
case [["STRIP", index], [param], ["KEY", "ENTER"]]:
self.find_element_with_focus().click()