Compare commits

..

4 Commits

Author SHA1 Message Date
d54995dbf1 patch bump 2026-03-20 00:36:39 +00:00
bc0b25032a fixes deprecation warning 2026-03-20 00:29:50 +00:00
2a86c05bea add ServerState enum to give is_running return values meaning.
fail faster if nvda isn't running
2026-03-20 00:29:39 +00:00
aae62fa136 the platform check is mostly redundant since import winreg will already have failed on most python installations.
Instead wrap `import winreg` and raise NVDAVMError

switch to ct.WinDLL which is more appropriate for C APIs using the stdcall convention
2026-03-19 23:58:20 +00:00
5 changed files with 31 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
[project] [project]
name = "nvda-voicemeeter" name = "nvda-voicemeeter"
version = "1.1.0" version = "1.1.1"
description = "A Voicemeeter app compatible with NVDA" description = "A Voicemeeter app compatible with NVDA"
authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }] authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }]
dependencies = [ dependencies = [

View File

@@ -1,15 +1,21 @@
import ctypes as ct import ctypes as ct
import platform import platform
import winreg
from pathlib import Path from pathlib import Path
from .errors import NVDAVMError from .errors import NVDAVMError
BITS = 64 if ct.sizeof(ct.c_void_p) == 8 else 32 try:
import winreg
except ImportError as e:
ERR_MSG = 'winreg module not found, only Windows OS supported'
raise NVDAVMError(ERR_MSG) from e
# Defense against edge cases where winreg imports but we're not on Windows
if platform.system() != 'Windows': if platform.system() != 'Windows':
raise NVDAVMError('Only Windows OS supported') raise NVDAVMError('Only Windows OS supported')
BITS = 64 if ct.sizeof(ct.c_void_p) == 8 else 32
REG_KEY = '\\'.join( REG_KEY = '\\'.join(
filter( filter(
None, None,
@@ -43,4 +49,4 @@ if not controller_path.exists():
DLL_PATH = controller_path / f'x{64 if BITS == 64 else 86}' / 'nvdaControllerClient.dll' DLL_PATH = controller_path / f'x{64 if BITS == 64 else 86}' / 'nvdaControllerClient.dll'
libc = ct.CDLL(str(DLL_PATH)) libc = ct.WinDLL(str(DLL_PATH))

View File

@@ -1,7 +1,14 @@
from enum import IntEnum
from .cdll import libc from .cdll import libc
from .errors import NVDAVMCAPIError from .errors import NVDAVMCAPIError
class ServerState(IntEnum):
RUNNING = 0
UNAVAILABLE = 1722
class CBindings: class CBindings:
bind_test_if_running = libc.nvdaController_testIfRunning bind_test_if_running = libc.nvdaController_testIfRunning
bind_speak_text = libc.nvdaController_speakText bind_speak_text = libc.nvdaController_speakText
@@ -18,7 +25,10 @@ class CBindings:
class Nvda(CBindings): class Nvda(CBindings):
@property @property
def is_running(self): def is_running(self):
return self.call(self.bind_test_if_running) == 0 return (
self.call(self.bind_test_if_running, ok=(ServerState.RUNNING, ServerState.UNAVAILABLE))
== ServerState.RUNNING
)
def speak(self, text): def speak(self, text):
self.call(self.bind_speak_text, text) self.call(self.bind_speak_text, text)

View File

@@ -35,7 +35,7 @@ class Popup:
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
match parsed_cmd := self.window.parser.match.parseString(event): match parsed_cmd := self.window.parser.match.parse_string(event):
case [[button], ['FOCUS', 'IN']]: case [[button], ['FOCUS', 'IN']]:
if values['Browse']: if values['Browse']:
filepath = values['Browse'] filepath = values['Browse']
@@ -105,7 +105,7 @@ class Popup:
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
match parsed_cmd := self.window.parser.match.parseString(event): match parsed_cmd := self.window.parser.match.parse_string(event):
case [[button], ['FOCUS', 'IN']]: case [[button], ['FOCUS', 'IN']]:
self.window.nvda.speak(button) self.window.nvda.speak(button)
case [_, ['KEY', 'ENTER']]: case [_, ['KEY', 'ENTER']]:
@@ -227,7 +227,7 @@ class Popup:
self.logger.debug(f'values::{values}') self.logger.debug(f'values::{values}')
if event in (psg.WIN_CLOSED, 'Exit'): if event in (psg.WIN_CLOSED, 'Exit'):
break break
match parsed_cmd := self.window.parser.match.parseString(event): match parsed_cmd := self.window.parser.match.parse_string(event):
case [['ASIO', 'INPUT', 'SPINBOX'], [in_num, channel]]: case [['ASIO', 'INPUT', 'SPINBOX'], [in_num, channel]]:
index = util.get_asio_input_spinbox_index(int(channel), int(in_num[-1])) index = util.get_asio_input_spinbox_index(int(channel), int(in_num[-1]))
val = values[f'ASIO INPUT SPINBOX||{in_num} {channel}'] val = values[f'ASIO INPUT SPINBOX||{in_num} {channel}']
@@ -331,7 +331,7 @@ class Popup:
self.logger.debug(f'values::{values}') self.logger.debug(f'values::{values}')
if event in (psg.WIN_CLOSED, 'Exit'): if event in (psg.WIN_CLOSED, 'Exit'):
break break
match parsed_cmd := self.window.parser.match.parseString(event): match parsed_cmd := self.window.parser.match.parse_string(event):
case [['COMPRESSOR'], ['SLIDER', param]]: case [['COMPRESSOR'], ['SLIDER', param]]:
setattr(self.window.vm.strip[index].comp, param.lower(), values[event]) setattr(self.window.vm.strip[index].comp, param.lower(), values[event])
case [['COMPRESSOR'], ['SLIDER', param], ['FOCUS', 'IN']]: case [['COMPRESSOR'], ['SLIDER', param], ['FOCUS', 'IN']]:
@@ -661,7 +661,7 @@ class Popup:
self.logger.debug(f'values::{values}') self.logger.debug(f'values::{values}')
if event in (psg.WIN_CLOSED, 'Exit'): if event in (psg.WIN_CLOSED, 'Exit'):
break break
match parsed_cmd := self.window.parser.match.parseString(event): match parsed_cmd := self.window.parser.match.parse_string(event):
case [['GATE'], ['SLIDER', param]]: case [['GATE'], ['SLIDER', param]]:
setattr(self.window.vm.strip[index].gate, param.lower(), values[event]) setattr(self.window.vm.strip[index].gate, param.lower(), values[event])
case [['GATE'], ['SLIDER', param], ['FOCUS', 'IN']]: case [['GATE'], ['SLIDER', param], ['FOCUS', 'IN']]:

View File

@@ -6,6 +6,7 @@ import FreeSimpleGUI as psg
from . import configuration, models, util from . import configuration, models, util
from .builder import Builder from .builder import Builder
from .errors import NVDAVMError
from .nvda import Nvda from .nvda import Nvda
from .parser import Parser from .parser import Parser
from .popup import Popup from .popup import Popup
@@ -25,6 +26,10 @@ class NVDAVMWindow(psg.Window):
self.kind = self.vm.kind self.kind = self.vm.kind
self.logger = logger.getChild(type(self).__name__) self.logger = logger.getChild(type(self).__name__)
self.logger.debug(f'loaded with theme: {psg.theme()}') self.logger.debug(f'loaded with theme: {psg.theme()}')
self.nvda = Nvda()
if not self.nvda.is_running:
self.logger.error('NVDA is not running. Exiting...')
raise NVDAVMError('NVDA is not running')
self.cache = { self.cache = {
'hw_ins': models._make_hardware_ins_cache(self.vm), 'hw_ins': models._make_hardware_ins_cache(self.vm),
'hw_outs': models._make_hardware_outs_cache(self.vm), 'hw_outs': models._make_hardware_outs_cache(self.vm),
@@ -34,7 +39,6 @@ class NVDAVMWindow(psg.Window):
'asio': models._make_patch_asio_cache(self.vm), 'asio': models._make_patch_asio_cache(self.vm),
'insert': models._make_patch_insert_cache(self.vm), 'insert': models._make_patch_insert_cache(self.vm),
} }
self.nvda = Nvda()
self.parser = Parser() self.parser = Parser()
self.popup = Popup(self) self.popup = Popup(self)
self.builder = Builder(self) self.builder = Builder(self)