mirror of
https://github.com/onyx-and-iris/nvda-voicemeeter.git
synced 2024-11-22 18:00:50 +00:00
implements advanced settings popup
gives access to driver buffer settings. may open by button or ctrl-a
This commit is contained in:
parent
5069db97da
commit
14c6b937d1
@ -228,24 +228,20 @@ class Builder:
|
|||||||
return psg.Frame("PATCH INSERT", asio_checkboxes)
|
return psg.Frame("PATCH INSERT", asio_checkboxes)
|
||||||
|
|
||||||
def make_tab0_row5(self) -> psg.Frame:
|
def make_tab0_row5(self) -> psg.Frame:
|
||||||
"""tab0 row5 represents asio buffer"""
|
"""tab0 row5 represents advanced settings"""
|
||||||
|
|
||||||
samples = get_asio_samples_list()
|
|
||||||
samples.append("Default")
|
|
||||||
|
|
||||||
return psg.Frame(
|
return psg.Frame(
|
||||||
"ASIO BUFFER",
|
"ADVANCED SETTINGS",
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
psg.ButtonMenu(
|
psg.Button(
|
||||||
"ASIO BUFFER",
|
"ADVANCED SETTINGS",
|
||||||
size=(14, 2),
|
size=(20, 2),
|
||||||
menu_def=["", samples],
|
key="ADVANCED SETTINGS",
|
||||||
key="ASIO BUFFER",
|
|
||||||
)
|
)
|
||||||
]
|
],
|
||||||
],
|
],
|
||||||
key="ASIO BUFFER FRAME",
|
key="ADVANCED SETTINGS FRAME",
|
||||||
)
|
)
|
||||||
|
|
||||||
def make_tab1_row(self, i) -> psg.Frame:
|
def make_tab1_row(self, i) -> psg.Frame:
|
||||||
|
@ -47,28 +47,20 @@ def get_patch_insert_channels() -> list:
|
|||||||
_patch_insert_channels = get_patch_insert_channels()
|
_patch_insert_channels = get_patch_insert_channels()
|
||||||
|
|
||||||
|
|
||||||
def get_asio_samples_list() -> list:
|
def get_asio_samples_list(driver) -> list:
|
||||||
return [
|
if driver == "MME":
|
||||||
"1024",
|
samples = ["2048", "1536", "1024", "896", "768", "704", "640", "576", "512", "480", "441"]
|
||||||
"768",
|
else:
|
||||||
"704",
|
# fmt: off
|
||||||
"640",
|
samples = [
|
||||||
"576",
|
"2048", "1536", "1024", "768", "704", "640", "576", "512", "480", "448", "441", "416", "384",
|
||||||
"512",
|
"352", "320", "288", "256", "224", "192", "160", "128"
|
||||||
"480",
|
]
|
||||||
"448",
|
# fmt: on
|
||||||
"441",
|
if driver == "ASIO":
|
||||||
"416",
|
samples = [x for x in samples if x not in ("2048", "1536")]
|
||||||
"384",
|
samples.append("Default")
|
||||||
"352",
|
return samples
|
||||||
"320",
|
|
||||||
"288",
|
|
||||||
"256",
|
|
||||||
"224",
|
|
||||||
"192",
|
|
||||||
"160",
|
|
||||||
"128",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def get_tabs_labels() -> list:
|
def get_tabs_labels() -> list:
|
||||||
|
@ -18,6 +18,7 @@ from .parser import Parser
|
|||||||
from .util import (
|
from .util import (
|
||||||
_patch_insert_channels,
|
_patch_insert_channels,
|
||||||
get_asio_checkbox_index,
|
get_asio_checkbox_index,
|
||||||
|
get_asio_samples_list,
|
||||||
get_bus_modes,
|
get_bus_modes,
|
||||||
get_channel_identifier_list,
|
get_channel_identifier_list,
|
||||||
get_insert_checkbox_index,
|
get_insert_checkbox_index,
|
||||||
@ -62,10 +63,7 @@ class NVDAVMWindow(psg.Window):
|
|||||||
self[f"HARDWARE OUT||A2"].Widget.config(**buttonmenu_opts)
|
self[f"HARDWARE OUT||A2"].Widget.config(**buttonmenu_opts)
|
||||||
if self.kind.name != "basic":
|
if self.kind.name != "basic":
|
||||||
[self[f"PATCH COMPOSITE||PC{i + 1}"].Widget.config(**buttonmenu_opts) for i in range(self.kind.phys_out)]
|
[self[f"PATCH COMPOSITE||PC{i + 1}"].Widget.config(**buttonmenu_opts) for i in range(self.kind.phys_out)]
|
||||||
self["ASIO BUFFER"].Widget.config(**buttonmenu_opts)
|
|
||||||
if self.kind.name != "basic":
|
|
||||||
self["ASIO BUFFER FRAME"].update(visible=False)
|
|
||||||
self["ASIO BUFFER FRAME"].hide_row()
|
|
||||||
self.register_events()
|
self.register_events()
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
@ -128,6 +126,7 @@ class NVDAVMWindow(psg.Window):
|
|||||||
self["tabs"].bind("<FocusIn>", "||FOCUS IN")
|
self["tabs"].bind("<FocusIn>", "||FOCUS IN")
|
||||||
self.bind("<Control-KeyPress-Tab>", "CTRL-TAB")
|
self.bind("<Control-KeyPress-Tab>", "CTRL-TAB")
|
||||||
self.bind("<Control-Shift-KeyPress-Tab>", "CTRL-SHIFT-TAB")
|
self.bind("<Control-Shift-KeyPress-Tab>", "CTRL-SHIFT-TAB")
|
||||||
|
self.bind("<Control-a>", "CTRL-A")
|
||||||
|
|
||||||
# Hardware In
|
# Hardware In
|
||||||
for i in range(self.vm.kind.phys_in):
|
for i in range(self.vm.kind.phys_in):
|
||||||
@ -167,6 +166,10 @@ class NVDAVMWindow(psg.Window):
|
|||||||
else:
|
else:
|
||||||
[self[f"INSERT CHECKBOX||IN{i + 1} {j}"].bind("<FocusIn>", "||FOCUS IN") for j in range(8)]
|
[self[f"INSERT CHECKBOX||IN{i + 1} {j}"].bind("<FocusIn>", "||FOCUS IN") for j in range(8)]
|
||||||
|
|
||||||
|
# Advanced Settings
|
||||||
|
if self.kind.name != "basic":
|
||||||
|
self["ADVANCED SETTINGS"].bind("<Return>", "||KEY ENTER")
|
||||||
|
|
||||||
# Strip Params
|
# Strip Params
|
||||||
for i in range(self.kind.num_strip):
|
for i in range(self.kind.num_strip):
|
||||||
for j in range(self.kind.phys_out):
|
for j in range(self.kind.phys_out):
|
||||||
@ -193,12 +196,6 @@ class NVDAVMWindow(psg.Window):
|
|||||||
self[f"BUS {i}||{param}"].bind("<FocusIn>", "||FOCUS IN")
|
self[f"BUS {i}||{param}"].bind("<FocusIn>", "||FOCUS IN")
|
||||||
self[f"BUS {i}||{param}"].bind("<Return>", "||KEY ENTER")
|
self[f"BUS {i}||{param}"].bind("<Return>", "||KEY ENTER")
|
||||||
|
|
||||||
# ASIO Buffer
|
|
||||||
if self.kind.name != "basic":
|
|
||||||
self["ASIO BUFFER"].bind("<FocusIn>", "||FOCUS IN")
|
|
||||||
self["ASIO BUFFER"].bind("<space>", "||KEY SPACE", propagate=False)
|
|
||||||
self["ASIO BUFFER"].bind("<Return>", "||KEY ENTER", propagate=False)
|
|
||||||
|
|
||||||
def popup_save_as(self, message, title=None, initial_folder=None):
|
def popup_save_as(self, message, title=None, initial_folder=None):
|
||||||
layout = [
|
layout = [
|
||||||
[psg.Text(message)],
|
[psg.Text(message)],
|
||||||
@ -219,18 +216,15 @@ class NVDAVMWindow(psg.Window):
|
|||||||
self.logger.debug(f"values::{values}")
|
self.logger.debug(f"values::{values}")
|
||||||
if event in (psg.WIN_CLOSED, "Cancel"):
|
if event in (psg.WIN_CLOSED, "Cancel"):
|
||||||
break
|
break
|
||||||
elif event.endswith("||FOCUS IN"):
|
match parsed_cmd := self.parser.match.parseString(event):
|
||||||
if values["Browse"]:
|
case [[button], ["FOCUS", "IN"]]:
|
||||||
filepath = values["Browse"]
|
if values["Browse"]:
|
||||||
break
|
filepath = values["Browse"]
|
||||||
label = event.split("||")[0]
|
break
|
||||||
self.TKroot.after(
|
self.nvda.speak(button)
|
||||||
200 if label == "Edit" else 1,
|
case [[button], ["KEY", "ENTER"]]:
|
||||||
self.nvda.speak,
|
window.find_element_with_focus().click()
|
||||||
label,
|
self.logger.debug(f"parsed::{parsed_cmd}")
|
||||||
)
|
|
||||||
elif event.endswith("||KEY ENTER"):
|
|
||||||
window.find_element_with_focus().click()
|
|
||||||
window.close()
|
window.close()
|
||||||
if filepath:
|
if filepath:
|
||||||
return Path(filepath)
|
return Path(filepath)
|
||||||
@ -269,24 +263,79 @@ class NVDAVMWindow(psg.Window):
|
|||||||
self.logger.debug(f"values::{values}")
|
self.logger.debug(f"values::{values}")
|
||||||
if event in (psg.WIN_CLOSED, "Cancel"):
|
if event in (psg.WIN_CLOSED, "Cancel"):
|
||||||
break
|
break
|
||||||
elif event.endswith("||KEY ENTER"):
|
match parsed_cmd := self.parser.match.parseString(event):
|
||||||
window.find_element_with_focus().click()
|
case ["Index"]:
|
||||||
elif event == "Index":
|
|
||||||
val = values["Index"]
|
|
||||||
self.nvda.speak(f"Index {val}")
|
|
||||||
elif event.endswith("||FOCUS IN"):
|
|
||||||
if event.startswith("Index"):
|
|
||||||
val = values["Index"]
|
val = values["Index"]
|
||||||
self.nvda.speak(f"Index {val}")
|
self.nvda.speak(f"Index {val}")
|
||||||
else:
|
case [[button], ["FOCUS", "IN"]]:
|
||||||
self.nvda.speak(event.split("||")[0])
|
if button == "Index":
|
||||||
elif event == "Ok":
|
val = values["Index"]
|
||||||
data = values
|
self.nvda.speak(f"Index {val}")
|
||||||
break
|
else:
|
||||||
|
self.nvda.speak(button)
|
||||||
|
case [[button], ["KEY", "ENTER"]]:
|
||||||
|
window.find_element_with_focus().click()
|
||||||
|
case ["Ok"]:
|
||||||
|
data = values
|
||||||
|
break
|
||||||
|
self.logger.debug(f"parsed::{parsed_cmd}")
|
||||||
window.close()
|
window.close()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def popup_advanced_settings(self, title):
|
||||||
|
def _make_buffering_frame() -> psg.Frame:
|
||||||
|
buffer = [
|
||||||
|
[
|
||||||
|
psg.ButtonMenu(
|
||||||
|
driver,
|
||||||
|
size=(14, 2),
|
||||||
|
menu_def=["", get_asio_samples_list(driver)],
|
||||||
|
key=f"BUFFER {driver}",
|
||||||
|
)
|
||||||
|
for driver in ("MME", "WDM", "KS", "ASIO")
|
||||||
|
],
|
||||||
|
]
|
||||||
|
return psg.Frame("BUFFERING", buffer)
|
||||||
|
|
||||||
|
buffer_frame = _make_buffering_frame()
|
||||||
|
layout = [[buffer_frame], [psg.Button("Exit")]]
|
||||||
|
|
||||||
|
window = psg.Window(title, layout, finalize=True)
|
||||||
|
buttonmenu_opts = {"takefocus": 1, "highlightthickness": 1}
|
||||||
|
for driver in ("MME", "WDM", "KS", "ASIO"):
|
||||||
|
window[f"BUFFER {driver}"].Widget.config(**buttonmenu_opts)
|
||||||
|
window[f"BUFFER {driver}"].bind("<FocusIn>", "||FOCUS IN")
|
||||||
|
window[f"BUFFER {driver}"].bind("<space>", "||KEY SPACE", propagate=False)
|
||||||
|
window[f"BUFFER {driver}"].bind("<Return>", "||KEY ENTER", propagate=False)
|
||||||
|
window["Exit"].bind("<FocusIn>", "||FOCUS IN")
|
||||||
|
window["Exit"].bind("<Return>", "||KEY ENTER")
|
||||||
|
while True:
|
||||||
|
event, values = window.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.parser.match.parseString(event):
|
||||||
|
case ["BUFFER MME" | "BUFFER WDM" | "BUFFER KS" | "BUFFER ASIO"]:
|
||||||
|
if values[event] == "Default":
|
||||||
|
val = 0
|
||||||
|
else:
|
||||||
|
val = int(values[event])
|
||||||
|
driver = event.split()[1]
|
||||||
|
self.vm.set(f"option.buffer.{driver.lower()}", val)
|
||||||
|
self.TKroot.after(200, self.nvda.speak, f"{driver} BUFFER {val if val else 'default'}")
|
||||||
|
case [["BUFFER", driver], ["FOCUS", "IN"]]:
|
||||||
|
val = int(self.vm.get(f"option.buffer.{driver.lower()}"))
|
||||||
|
self.nvda.speak(f"{driver} BUFFER {val if val else 'default'}")
|
||||||
|
case [["BUFFER", driver], ["KEY", "SPACE" | "ENTER"]]:
|
||||||
|
open_context_menu_for_buttonmenu(window, f"BUFFER {driver}")
|
||||||
|
case [[button], ["FOCUS", "IN"]]:
|
||||||
|
self.nvda.speak(button)
|
||||||
|
case [[button], ["KEY", "ENTER"]]:
|
||||||
|
window.find_element_with_focus().click()
|
||||||
|
self.logger.debug(f"parsed::{parsed_cmd}")
|
||||||
|
window.close()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""
|
"""
|
||||||
Parses the event string and matches it to events
|
Parses the event string and matches it to events
|
||||||
@ -495,19 +544,11 @@ class NVDAVMWindow(psg.Window):
|
|||||||
num = int(in_num[-1])
|
num = int(in_num[-1])
|
||||||
self.nvda.speak(f"Patch INSERT IN#{num} {channel} {'on' if val else 'off'}")
|
self.nvda.speak(f"Patch INSERT IN#{num} {channel} {'on' if val else 'off'}")
|
||||||
|
|
||||||
# ASIO Buffer
|
# Advanced Settings
|
||||||
case ["ASIO BUFFER"]:
|
case ["ADVANCED SETTINGS"] | ["CTRL-A"]:
|
||||||
if values[event] == "Default":
|
self.popup_advanced_settings(title="Advanced Settings")
|
||||||
val = 0
|
case [["ADVANCED", "SETTINGS"], ["KEY", "ENTER"]]:
|
||||||
else:
|
self.find_element_with_focus().click()
|
||||||
val = values[event]
|
|
||||||
self.vm.option.buffer("asio", val)
|
|
||||||
self.TKroot.after(200, self.nvda.speak, f"ASIO BUFFER {val if val else 'default'}")
|
|
||||||
case [["ASIO", "BUFFER"], ["FOCUS", "IN"]]:
|
|
||||||
val = int(self.vm.get("option.buffer.asio"))
|
|
||||||
self.nvda.speak(f"ASIO BUFFER {val if val else 'default'}")
|
|
||||||
case [["ASIO", "BUFFER"], ["KEY", "SPACE" | "ENTER"]]:
|
|
||||||
open_context_menu_for_buttonmenu(self, "ASIO BUFFER")
|
|
||||||
|
|
||||||
# Strip Params
|
# Strip Params
|
||||||
case [["STRIP", index], [param]]:
|
case [["STRIP", index], [param]]:
|
||||||
|
Loading…
Reference in New Issue
Block a user