mirror of
https://github.com/onyx-and-iris/nvda-addon-voicemeeter.git
synced 2026-04-07 20:13:30 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c1b374cce7 | |||
| 6b57cfba57 | |||
| 0bd28be7b8 | |||
| f458fb8d0e | |||
| 4c34028194 | |||
| 84ee479bf1 |
@@ -38,8 +38,32 @@ class Binds:
|
|||||||
bind_set_parameter_float.restype = LONG
|
bind_set_parameter_float.restype = LONG
|
||||||
bind_set_parameter_float.argtypes = [ct.POINTER(CHAR), FLOAT]
|
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)
|
retval = fn(*args)
|
||||||
if retval not in ok:
|
if retval not in ok:
|
||||||
raise VMAddonCAPIError(fn.__name__, retval)
|
raise VMAddonCAPIError(fn.__name__, retval)
|
||||||
return 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)
|
||||||
|
|||||||
@@ -56,14 +56,27 @@ class CommandsMixin:
|
|||||||
def script_audibility_mode(self, _):
|
def script_audibility_mode(self, _):
|
||||||
self.__set_slider_mode('audibility')
|
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')
|
val = not self.controller.ctx.get_bool('mono')
|
||||||
self.controller.ctx.set_bool('mono', val)
|
self.controller.ctx.set_bool('mono', val)
|
||||||
ui.message('on' if val else 'off')
|
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, _):
|
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')
|
val = not self.controller.ctx.get_bool('solo')
|
||||||
self.controller.ctx.set_bool('solo', val)
|
self.controller.ctx.set_bool('solo', val)
|
||||||
ui.message('on' if val else 'off')
|
ui.message('on' if val else 'off')
|
||||||
@@ -74,19 +87,62 @@ class CommandsMixin:
|
|||||||
ui.message('on' if val else 'off')
|
ui.message('on' if val else 'off')
|
||||||
|
|
||||||
def script_toggle_mc(self, _):
|
def script_toggle_mc(self, _):
|
||||||
|
if not isinstance(self.controller.ctx.strategy, context.StripStrategy):
|
||||||
|
ui.message('MC only available for strips')
|
||||||
|
return
|
||||||
|
|
||||||
|
valid_indices_zero_based = [self.kind.phys_in]
|
||||||
|
match self.kind.name:
|
||||||
|
case 'potato':
|
||||||
|
valid_indices_zero_based.append(self.kind.phys_in + self.kind.virt_in - 1)
|
||||||
|
|
||||||
|
if self.controller.ctx.index not in valid_indices_zero_based:
|
||||||
|
valid_indices_display = [i + 1 for i in valid_indices_zero_based]
|
||||||
|
if len(valid_indices_display) == 1:
|
||||||
|
ui.message(f'MC only available for strip {valid_indices_display[0]} for Voicemeeter {self.kind}')
|
||||||
|
else:
|
||||||
|
ui.message(
|
||||||
|
f'MC only available for strips {valid_indices_display[0]} and {valid_indices_display[1]} for Voicemeeter {self.kind}'
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
val = not self.controller.ctx.get_bool('mc')
|
val = not self.controller.ctx.get_bool('mc')
|
||||||
self.controller.ctx.set_bool('mc', val)
|
self.controller.ctx.set_bool('mc', val)
|
||||||
ui.message('on' if val else 'off')
|
ui.message('on' if val else 'off')
|
||||||
|
|
||||||
def script_karaoke(self, _):
|
def script_karaoke(self, _):
|
||||||
|
if not isinstance(self.controller.ctx.strategy, context.StripStrategy):
|
||||||
|
ui.message('Karaoke mode only available for strips')
|
||||||
|
return
|
||||||
|
|
||||||
|
if self.kind.name not in ['banana', 'potato']:
|
||||||
|
ui.message(f'Karaoke mode not available for Voicemeeter {self.kind}')
|
||||||
|
return
|
||||||
|
|
||||||
|
valid_index_zero_based = None
|
||||||
|
match self.kind.name:
|
||||||
|
case 'banana':
|
||||||
|
valid_index_zero_based = self.kind.phys_in + self.kind.virt_in - 1
|
||||||
|
case 'potato':
|
||||||
|
valid_index_zero_based = self.kind.phys_in + self.kind.virt_in - 2
|
||||||
|
|
||||||
|
if self.controller.ctx.index != valid_index_zero_based:
|
||||||
|
ui.message(
|
||||||
|
f'Karaoke mode only available for strip {valid_index_zero_based + 1} for Voicemeeter {self.kind}'
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
opts = ['off', 'k m', 'k 1', 'k 2', 'k v']
|
opts = ['off', 'k m', 'k 1', 'k 2', 'k v']
|
||||||
val = self.controller.ctx.get_int('karaoke') + 1
|
val = self.controller.ctx.get_int('karaoke')
|
||||||
if val == len(opts):
|
new_val = (val + 1) % len(opts)
|
||||||
val = 0
|
self.controller.ctx.set_int('karaoke', new_val)
|
||||||
self.controller.ctx.set_int('karaoke', val)
|
ui.message(opts[new_val])
|
||||||
ui.message(opts[val])
|
|
||||||
|
|
||||||
def script_bus_assignment(self, gesture):
|
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])
|
proposed = int(gesture.displayName[-1])
|
||||||
if proposed - 1 < self.kind.phys_out:
|
if proposed - 1 < self.kind.phys_out:
|
||||||
output = f'A{proposed}'
|
output = f'A{proposed}'
|
||||||
|
|||||||
@@ -28,22 +28,22 @@ class Strategy(ABC):
|
|||||||
self._slider_mode = val
|
self._slider_mode = val
|
||||||
|
|
||||||
def get_bool(self, param: str) -> bool:
|
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):
|
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:
|
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):
|
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:
|
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):
|
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):
|
class StripStrategy(Strategy):
|
||||||
|
|||||||
@@ -9,30 +9,31 @@ from .context import Context, StripStrategy
|
|||||||
from .kinds import KindId
|
from .kinds import KindId
|
||||||
|
|
||||||
|
|
||||||
class Controller(Binds):
|
class Controller:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self._binds = Binds()
|
||||||
self.ctx = Context(StripStrategy(self, 0))
|
self.ctx = Context(StripStrategy(self, 0))
|
||||||
self.bits = config.get('bits', BITS)
|
self.bits = config.get('bits', BITS)
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
retval = self.call(self.bind_login, ok=(0, 1))
|
retval = self._binds.login()
|
||||||
log.info('INFO - logged into Voicemeeter Remote API')
|
log.info('INFO - logged into Voicemeeter Remote API')
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
def logout(self):
|
def logout(self):
|
||||||
self.call(self.bind_logout)
|
self._binds.logout()
|
||||||
log.info('NFO - logged out of Voicemeeter Remote API')
|
log.info('NFO - logged out of Voicemeeter Remote API')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def kind_id(self):
|
def kind_id(self):
|
||||||
c_type = ct.c_long()
|
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()
|
return KindId(c_type.value).name.lower()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def version(self):
|
def version(self):
|
||||||
ver = ct.c_long()
|
ver = ct.c_long()
|
||||||
self.call(self.bind_get_voicemeeter_version, ct.byref(ver))
|
self._binds.get_voicemeeter_version(ver)
|
||||||
return '{}.{}.{}.{}'.format(
|
return '{}.{}.{}.{}'.format(
|
||||||
(ver.value & 0xFF000000) >> 24,
|
(ver.value & 0xFF000000) >> 24,
|
||||||
(ver.value & 0x00FF0000) >> 16,
|
(ver.value & 0x00FF0000) >> 16,
|
||||||
@@ -44,17 +45,17 @@ class Controller(Binds):
|
|||||||
val = kind_id.value
|
val = kind_id.value
|
||||||
if self.bits == 64:
|
if self.bits == 64:
|
||||||
val += 3
|
val += 3
|
||||||
self.call(self.bind_run_voicemeeter, val)
|
self._binds.run_voicemeeter(val)
|
||||||
|
|
||||||
def __clear(self):
|
def __clear(self):
|
||||||
while self.call(self.bind_is_parameters_dirty, ok=(0, 1)) == 1:
|
while self._binds.is_parameters_dirty() == 1:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _get(self, param):
|
def get(self, param):
|
||||||
self.__clear()
|
self.__clear()
|
||||||
buf = ct.c_float()
|
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
|
return buf.value
|
||||||
|
|
||||||
def _set(self, param, val):
|
def set(self, param, val):
|
||||||
self.call(self.bind_set_parameter_float, param.encode(), ct.c_float(float(val)))
|
self._binds.set_parameter_float(param.encode(), ct.c_float(float(val)))
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ def _make_gestures(kind_id):
|
|||||||
'kb:NVDA+alt+a': 'audibility_mode',
|
'kb:NVDA+alt+a': 'audibility_mode',
|
||||||
'kb:NVDA+shift+q': 'announce_controller',
|
'kb:NVDA+shift+q': 'announce_controller',
|
||||||
'kb:NVDA+shift+v': 'announce_voicemeeter_version',
|
'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+s': 'toggle_solo',
|
||||||
'kb:NVDA+shift+m': 'toggle_mute',
|
'kb:NVDA+shift+m': 'toggle_mute',
|
||||||
'kb:NVDA+shift+c': 'toggle_mc',
|
'kb:NVDA+shift+c': 'toggle_mc',
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ addon_info = {
|
|||||||
The add-on requires Voicemeeter to be installed."""
|
The add-on requires Voicemeeter to be installed."""
|
||||||
),
|
),
|
||||||
# version
|
# version
|
||||||
'addon_version': '1.1.1',
|
'addon_version': '1.2.1',
|
||||||
# Author(s)
|
# Author(s)
|
||||||
'addon_author': 'onyx-and-iris <code@onyxandiris.online>',
|
'addon_author': 'onyx-and-iris <code@onyxandiris.online>',
|
||||||
# URL for the add-on documentation support
|
# URL for the add-on documentation support
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "nvda-addon-voicemeeter"
|
name = "nvda-addon-voicemeeter"
|
||||||
version = "1.1.1"
|
version = "1.2.1"
|
||||||
description = "A GUI-less NVDA Addon for Voicemeeter using the Remote API"
|
description = "A GUI-less NVDA Addon for Voicemeeter using the Remote API"
|
||||||
authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }]
|
authors = [{ name = "Onyx and Iris", email = "code@onyxandiris.online" }]
|
||||||
dependencies = []
|
dependencies = []
|
||||||
|
|||||||
Reference in New Issue
Block a user