mirror of
https://github.com/onyx-and-iris/nvda-voicemeeter.git
synced 2024-11-22 10:00:46 +00:00
save,load and load on startup implemented
This commit is contained in:
parent
2de1b379f5
commit
50d2fa3de8
3
.gitignore
vendored
3
.gitignore
vendored
@ -170,5 +170,8 @@ basic.py
|
|||||||
banana.py
|
banana.py
|
||||||
potato.py
|
potato.py
|
||||||
|
|
||||||
|
# persistent storage
|
||||||
|
default.bin
|
||||||
|
|
||||||
# quick test
|
# quick test
|
||||||
quick.py
|
quick.py
|
@ -63,6 +63,9 @@ class Builder:
|
|||||||
"&Voicemeeter",
|
"&Voicemeeter",
|
||||||
[
|
[
|
||||||
"Restart Audio Engine::MENU",
|
"Restart Audio Engine::MENU",
|
||||||
|
"Save Settings::MENU",
|
||||||
|
"Load Settings::MENU",
|
||||||
|
"Load Settings on Startup ::MENU",
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
@ -209,7 +212,7 @@ class Builder:
|
|||||||
[
|
[
|
||||||
psg.ButtonMenu(
|
psg.ButtonMenu(
|
||||||
"ASIO BUFFER",
|
"ASIO BUFFER",
|
||||||
size=(12, 2),
|
size=(14, 2),
|
||||||
menu_def=["", samples],
|
menu_def=["", samples],
|
||||||
key="ASIO BUFFER",
|
key="ASIO BUFFER",
|
||||||
)
|
)
|
||||||
@ -271,7 +274,7 @@ class Builder:
|
|||||||
"""tab3 row represents bus composite toggle"""
|
"""tab3 row represents bus composite toggle"""
|
||||||
|
|
||||||
def add_strip_outputs(layout):
|
def add_strip_outputs(layout):
|
||||||
layout.append([psg.Button(f"BUSMODE", size=(16, 2), key=f"BUS {i}||MODE")])
|
layout.append([psg.Button(f"BUSMODE", size=(12, 2), key=f"BUS {i}||MODE")])
|
||||||
|
|
||||||
buses = list()
|
buses = list()
|
||||||
[step(buses) for step in (add_strip_outputs,)]
|
[step(buses) for step in (add_strip_outputs,)]
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import pickle
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import PySimpleGUI as psg
|
import PySimpleGUI as psg
|
||||||
|
|
||||||
@ -22,6 +24,8 @@ psg.theme("Dark Blue 3")
|
|||||||
class NVDAVMWindow(psg.Window):
|
class NVDAVMWindow(psg.Window):
|
||||||
"""Represents the main window of the Voicemeeter NVDA application"""
|
"""Represents the main window of the Voicemeeter NVDA application"""
|
||||||
|
|
||||||
|
DEFAULT_BIN = "default.bin"
|
||||||
|
|
||||||
def __init__(self, title, vm):
|
def __init__(self, title, vm):
|
||||||
self.vm = vm
|
self.vm = vm
|
||||||
self.kind = self.vm.kind
|
self.kind = self.vm.kind
|
||||||
@ -41,6 +45,21 @@ class NVDAVMWindow(psg.Window):
|
|||||||
self.register_events()
|
self.register_events()
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
|
default_config = Path.cwd() / self.DEFAULT_BIN
|
||||||
|
if default_config.exists():
|
||||||
|
try:
|
||||||
|
with open(default_config, "rb") as f:
|
||||||
|
if config := pickle.load(f):
|
||||||
|
self.vm.set("command.load", config)
|
||||||
|
self.logger.debug(f"config {config} loaded")
|
||||||
|
self.TKroot.after(
|
||||||
|
200,
|
||||||
|
self.nvda.speak,
|
||||||
|
f"config {Path(config).stem} has been loaded",
|
||||||
|
)
|
||||||
|
except EOFError:
|
||||||
|
self.logger.debug("no data in default bin. silently continuing...")
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
@ -129,8 +148,46 @@ class NVDAVMWindow(psg.Window):
|
|||||||
self.TKroot.after(
|
self.TKroot.after(
|
||||||
200,
|
200,
|
||||||
self.nvda.speak,
|
self.nvda.speak,
|
||||||
f"Audio Engine restarted",
|
"Audio Engine restarted",
|
||||||
)
|
)
|
||||||
|
case [["Save", "Settings"], ["MENU"]]:
|
||||||
|
filename = psg.popup_get_text("Filename", title="Save As")
|
||||||
|
if filename:
|
||||||
|
configpath = Path.home() / "Documents" / "Voicemeeter" / f"{filename.removesuffix('xml')}.xml"
|
||||||
|
self.vm.set("command.save", str(configpath))
|
||||||
|
self.logger.debug(f"saving config file to {configpath}")
|
||||||
|
self.TKroot.after(
|
||||||
|
200,
|
||||||
|
self.nvda.speak,
|
||||||
|
f"config file {filename} has been saved",
|
||||||
|
)
|
||||||
|
case [["Load", "Settings"], ["MENU"]]:
|
||||||
|
configpath = Path.home() / "Documents" / "Voicemeeter"
|
||||||
|
filename = psg.popup_get_file("Load Settings", default_path=str(configpath))
|
||||||
|
if filename:
|
||||||
|
configpath = configpath / filename
|
||||||
|
self.vm.set("command.load", str(configpath))
|
||||||
|
self.logger.debug(f"loading config file from {configpath}")
|
||||||
|
self.TKroot.after(
|
||||||
|
200,
|
||||||
|
self.nvda.speak,
|
||||||
|
f"config file {Path(filename).stem} has been loaded",
|
||||||
|
)
|
||||||
|
case [["Load", "Settings", "on", "Startup"], ["MENU"]]:
|
||||||
|
filename = psg.popup_get_text("Filename", title="Load on startup")
|
||||||
|
if filename:
|
||||||
|
configpath = Path.home() / "Documents" / "Voicemeeter" / f"{filename.removesuffix('xml')}.xml"
|
||||||
|
with open(self.DEFAULT_BIN, "wb") as f:
|
||||||
|
pickle.dump(str(configpath), f)
|
||||||
|
self.TKroot.after(
|
||||||
|
200,
|
||||||
|
self.nvda.speak,
|
||||||
|
f"config {filename} set as default on startup",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
with open(self.DEFAULT_BIN, "wb") as f:
|
||||||
|
f.truncate()
|
||||||
|
self.logger.debug("default bin was truncated")
|
||||||
|
|
||||||
# Tabs
|
# Tabs
|
||||||
case [["tabs"], ["FOCUS", "IN"]]:
|
case [["tabs"], ["FOCUS", "IN"]]:
|
||||||
|
Loading…
Reference in New Issue
Block a user