4 Commits

Author SHA1 Message Date
0bd28be7b8 fix regression, login should allow a return value of 1. 2026-03-19 05:42:35 +00:00
f458fb8d0e minor bump 2026-03-19 05:33:25 +00:00
4c34028194 improve the feedback for some of the binds:
- solo + mc will give error warning if not currently using a Strip controller.
- karaoke and mc will give error warning if the Strip controller doesn't have the correct index.
- bus assignments will give error warning if not on a Strip controller.

mono now toggles for the Strip controller but rotates through modes for the Bus controller.
2026-03-19 05:33:16 +00:00
84ee479bf1 Controller no longer subclasses Binds.
add some wrapper methods to binds
2026-03-19 05:26:19 +00:00
7 changed files with 100 additions and 31 deletions

View File

@@ -38,8 +38,32 @@ class Binds:
bind_set_parameter_float.restype = LONG
bind_set_parameter_float.argtypes = [ct.POINTER(CHAR), FLOAT]
def call(self, fn, *args, ok=(0,)):
def _call(self, fn, *args, ok=(0,)):
retval = fn(*args)
if retval not in ok:
raise VMAddonCAPIError(fn.__name__, retval)
return retval
def login(self):
return self._call(self.bind_login, ok=(0, 1))
def logout(self):
return self._call(self.bind_logout)
def run_voicemeeter(self, kind_val):
return self._call(self.bind_run_voicemeeter, kind_val)
def get_voicemeeter_type(self, c_type):
return self._call(self.bind_get_voicemeeter_type, ct.byref(c_type))
def get_voicemeeter_version(self, ver):
return self._call(self.bind_get_voicemeeter_version, ct.byref(ver))
def is_parameters_dirty(self):
return self._call(self.bind_is_parameters_dirty, ok=(0, 1))
def get_parameter_float(self, param, buf):
return self._call(self.bind_get_parameter_float, param, ct.byref(buf))
def set_parameter_float(self, param, val):
return self._call(self.bind_set_parameter_float, param, val)

View File

@@ -56,14 +56,27 @@ class CommandsMixin:
def script_audibility_mode(self, _):
self.__set_slider_mode('audibility')
### BOOLEAN PARAMETERS ###
# Mono is a special case because the parameter is a boolean for strips and an int for buses
def script_toggle_mono(self, _):
def script_rotate_mono(self, _):
if isinstance(self.controller.ctx.strategy, context.StripStrategy):
val = not self.controller.ctx.get_bool('mono')
self.controller.ctx.set_bool('mono', val)
ui.message('on' if val else 'off')
else:
opts = ['off', 'on', 'stereo reverse']
val = self.controller.ctx.get_int('mono')
new_val = (val + 1) % len(opts)
self.controller.ctx.set_int('mono', new_val)
ui.message(opts[new_val])
### BOOLEAN PARAMETERS ###
def script_toggle_solo(self, _):
if not isinstance(self.controller.ctx.strategy, context.StripStrategy):
ui.message('Solo only available for strips')
return
val = not self.controller.ctx.get_bool('solo')
self.controller.ctx.set_bool('solo', val)
ui.message('on' if val else 'off')
@@ -74,19 +87,50 @@ class CommandsMixin:
ui.message('on' if val else 'off')
def script_toggle_mc(self, _):
if not isinstance(self.controller.ctx.strategy, context.StripStrategy):
ui.message('MC only available for strips')
return
valid_indices = [self.kind.phys_in + 1]
match self.kind.name:
case 'potato':
valid_indices.append(self.kind.phys_in + self.kind.virt_in)
if self.controller.ctx.index + 1 not in valid_indices:
if len(valid_indices) == 1:
ui.message(f'MC only available for strip {valid_indices[0]} for Voicemeeter {self.kind}')
else:
ui.message(
f'MC only available for strips {valid_indices[0]} and {valid_indices[1]} for Voicemeeter {self.kind}'
)
return
val = not self.controller.ctx.get_bool('mc')
self.controller.ctx.set_bool('mc', val)
ui.message('on' if val else 'off')
def script_karaoke(self, _):
if not isinstance(self.controller.ctx.strategy, context.StripStrategy):
ui.message('Karaoke mode only available for strips')
return
valid_index = self.kind.phys_in + self.kind.virt_in - 1
# controller index is 0 based and the gesture display is 1 based, so subtract 1 from valid_index
if self.controller.ctx.index != valid_index - 1:
ui.message(f'Karaoke mode only available for strip {valid_index} for Voicemeeter {self.kind}')
return
opts = ['off', 'k m', 'k 1', 'k 2', 'k v']
val = self.controller.ctx.get_int('karaoke') + 1
if val == len(opts):
val = 0
self.controller.ctx.set_int('karaoke', val)
ui.message(opts[val])
val = self.controller.ctx.get_int('karaoke')
new_val = (val + 1) % len(opts)
self.controller.ctx.set_int('karaoke', new_val)
ui.message(opts[new_val])
def script_bus_assignment(self, gesture):
if not isinstance(self.controller.ctx.strategy, context.StripStrategy):
ui.message('Bus assignment only available for strips')
return
proposed = int(gesture.displayName[-1])
if proposed - 1 < self.kind.phys_out:
output = f'A{proposed}'

View File

@@ -28,22 +28,22 @@ class Strategy(ABC):
self._slider_mode = val
def get_bool(self, param: str) -> bool:
return self._controller._get(f'{self.identifier}.{param}') == 1
return self._controller.get(f'{self.identifier}.{param}') == 1
def set_bool(self, param: str, val: bool):
self._controller._set(f'{self.identifier}.{param}', 1 if val else 0)
self._controller.set(f'{self.identifier}.{param}', 1 if val else 0)
def get_float(self, param: str) -> float:
return round(self._controller._get(f'{self.identifier}.{param}'), 1)
return round(self._controller.get(f'{self.identifier}.{param}'), 1)
def set_float(self, param: str, val: float):
self._controller._set(f'{self.identifier}.{param}', val)
self._controller.set(f'{self.identifier}.{param}', val)
def get_int(self, param: str) -> int:
return int(self._controller._get(f'{self.identifier}.{param}'))
return int(self._controller.get(f'{self.identifier}.{param}'))
def set_int(self, param: str, val: int):
self._controller._set(f'{self.identifier}.{param}', val)
self._controller.set(f'{self.identifier}.{param}', val)
class StripStrategy(Strategy):

View File

@@ -9,30 +9,31 @@ from .context import Context, StripStrategy
from .kinds import KindId
class Controller(Binds):
class Controller:
def __init__(self):
self._binds = Binds()
self.ctx = Context(StripStrategy(self, 0))
self.bits = config.get('bits', BITS)
def login(self):
retval = self.call(self.bind_login, ok=(0, 1))
retval = self._binds.login()
log.info('INFO - logged into Voicemeeter Remote API')
return retval
def logout(self):
self.call(self.bind_logout)
self._binds.logout()
log.info('NFO - logged out of Voicemeeter Remote API')
@property
def kind_id(self):
c_type = ct.c_long()
self.call(self.bind_get_voicemeeter_type, ct.byref(c_type))
self._binds.get_voicemeeter_type(c_type)
return KindId(c_type.value).name.lower()
@property
def version(self):
ver = ct.c_long()
self.call(self.bind_get_voicemeeter_version, ct.byref(ver))
self._binds.get_voicemeeter_version(ver)
return '{}.{}.{}.{}'.format(
(ver.value & 0xFF000000) >> 24,
(ver.value & 0x00FF0000) >> 16,
@@ -44,17 +45,17 @@ class Controller(Binds):
val = kind_id.value
if self.bits == 64:
val += 3
self.call(self.bind_run_voicemeeter, val)
self._binds.run_voicemeeter(val)
def __clear(self):
while self.call(self.bind_is_parameters_dirty, ok=(0, 1)) == 1:
while self._binds.is_parameters_dirty() == 1:
pass
def _get(self, param):
def get(self, param):
self.__clear()
buf = ct.c_float()
self.call(self.bind_get_parameter_float, param.encode(), ct.byref(buf))
self._binds.get_parameter_float(param.encode(), buf)
return buf.value
def _set(self, param, val):
self.call(self.bind_set_parameter_float, param.encode(), ct.c_float(float(val)))
def set(self, param, val):
self._binds.set_parameter_float(param.encode(), ct.c_float(float(val)))

View File

@@ -26,7 +26,7 @@ def _make_gestures(kind_id):
'kb:NVDA+alt+a': 'audibility_mode',
'kb:NVDA+shift+q': 'announce_controller',
'kb:NVDA+shift+v': 'announce_voicemeeter_version',
'kb:NVDA+shift+o': 'toggle_mono',
'kb:NVDA+shift+o': 'rotate_mono',
'kb:NVDA+shift+s': 'toggle_solo',
'kb:NVDA+shift+m': 'toggle_mute',
'kb:NVDA+shift+c': 'toggle_mc',

View File

@@ -28,7 +28,7 @@ addon_info = {
The add-on requires Voicemeeter to be installed."""
),
# version
'addon_version': '1.1.1',
'addon_version': '1.2.0',
# Author(s)
'addon_author': 'onyx-and-iris <code@onyxandiris.online>',
# URL for the add-on documentation support

View File

@@ -1,6 +1,6 @@
[project]
name = "nvda-addon-voicemeeter"
version = "1.1.1"
version = "1.2.0"
description = "A GUI-less NVDA Addon for Voicemeeter using the Remote API"
authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }]
dependencies = []