mirror of
https://github.com/onyx-and-iris/nvda-addon-voicemeeter.git
synced 2024-11-15 15:00:47 +00:00
slider mode binds implemented
bump to version 0.2
This commit is contained in:
parent
c9ae271cf4
commit
1b2608801f
@ -14,17 +14,24 @@ def _make_gestures():
|
||||
defaults = {
|
||||
"kb:NVDA+alt+s": "strip_mode",
|
||||
"kb:NVDA+alt+b": "bus_mode",
|
||||
"kb:NVDA+alt+g": "slider_mode",
|
||||
"kb:NVDA+alt+c": "slider_mode",
|
||||
"kb:NVDA+alt+t": "slider_mode",
|
||||
"kb:NVDA+alt+d": "slider_mode",
|
||||
"kb:NVDA+alt+a": "slider_mode",
|
||||
"kb:NVDA+shift+q": "announce_controller",
|
||||
"kb:NVDA+shift+a": "announce_voicemeeter_version",
|
||||
"kb:NVDA+shift+o": "toggle_mono",
|
||||
"kb:NVDA+shift+s": "toggle_solo",
|
||||
"kb:NVDA+shift+m": "toggle_mute",
|
||||
"kb:NVDA+shift+upArrow": "increase_gain",
|
||||
"kb:NVDA+shift+downArrow": "decrease_gain",
|
||||
"kb:NVDA+shift+alt+upArrow": "increase_gain",
|
||||
"kb:NVDA+shift+alt+downArrow": "decrease_gain",
|
||||
"kb:NVDA+shift+control+upArrow": "increase_gain",
|
||||
"kb:NVDA+shift+control+downArrow": "decrease_gain",
|
||||
"kb:NVDA+shift+c": "toggle_mc",
|
||||
"kb:NVDA+shift+k": "karaoke",
|
||||
"kb:NVDA+shift+upArrow": "slider_increase",
|
||||
"kb:NVDA+shift+downArrow": "slider_decrease",
|
||||
"kb:NVDA+shift+alt+upArrow": "slider_increase",
|
||||
"kb:NVDA+shift+alt+downArrow": "slider_decrease",
|
||||
"kb:NVDA+shift+control+upArrow": "slider_increase",
|
||||
"kb:NVDA+shift+control+downArrow": "slider_decrease",
|
||||
}
|
||||
|
||||
overrides = None
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ui
|
||||
from logHandler import log
|
||||
|
||||
from . import context
|
||||
from . import context, util
|
||||
|
||||
|
||||
class CommandsMixin:
|
||||
@ -37,7 +37,20 @@ class CommandsMixin:
|
||||
ui.message(f"Controller for {self.controller.ctx.strategy} {self.controller.ctx.index + 1}")
|
||||
log.info(f"INFO - {self.controller.ctx.strategy} {self.controller.ctx.index} mode")
|
||||
|
||||
### BOOLEAN PARMETERS ###
|
||||
def script_slider_mode(self, gesture):
|
||||
if gesture.displayName.endswith("g"):
|
||||
self.controller.ctx.slider_mode = "gain"
|
||||
elif gesture.displayName.endswith("c"):
|
||||
self.controller.ctx.slider_mode = "comp"
|
||||
elif gesture.displayName.endswith("t"):
|
||||
self.controller.ctx.slider_mode = "gate"
|
||||
elif gesture.displayName.endswith("d"):
|
||||
self.controller.ctx.slider_mode = "denoiser"
|
||||
elif gesture.displayName.endswith("a"):
|
||||
self.controller.ctx.slider_mode = "audibility"
|
||||
ui.message(f"{self.controller.ctx.slider_mode} mode enabled")
|
||||
|
||||
### BOOLEAN PARAMETERS ###
|
||||
|
||||
def script_toggle_mono(self, _):
|
||||
val = not self.controller.ctx.get_bool("mono")
|
||||
@ -54,6 +67,18 @@ class CommandsMixin:
|
||||
self.controller.ctx.set_bool("mute", val)
|
||||
ui.message("on" if val else "off")
|
||||
|
||||
def script_toggle_mc(self, _):
|
||||
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, _):
|
||||
val = self.controller.ctx.get_int("karaoke") + 1
|
||||
if val == 5:
|
||||
val = 0
|
||||
self.controller.ctx.set_int("karaoke", val)
|
||||
ui.message(val)
|
||||
|
||||
def script_bus_assignment(self, gesture):
|
||||
proposed = int(gesture.displayName[-1])
|
||||
if proposed - 1 < self.kind.phys_out:
|
||||
@ -63,3 +88,29 @@ class CommandsMixin:
|
||||
val = not self.controller.ctx.get_bool(output)
|
||||
self.controller.ctx.set_bool(output, val)
|
||||
ui.message("on" if val else "off")
|
||||
|
||||
### SLIDER MODES ###
|
||||
|
||||
def script_slider_increase(self, gesture):
|
||||
op = util.remove_prefix(gesture.displayName, "kb:NVDA+shift+")
|
||||
if op.startswith("alt"):
|
||||
offset = 0.1
|
||||
elif op.startswith("ctrl"):
|
||||
offset = 3
|
||||
else:
|
||||
offset = 1
|
||||
val = self.controller.ctx.get_float(self.controller.ctx.slider_mode) + offset
|
||||
self.controller.ctx.set_float(self.controller.ctx.slider_mode, val)
|
||||
ui.message(str(round(val, 1)))
|
||||
|
||||
def script_slider_decrease(self, gesture):
|
||||
op = util.remove_prefix(gesture.displayName, "kb:NVDA+shift+")
|
||||
if op.startswith("alt"):
|
||||
offset = 0.1
|
||||
elif op.startswith("ctrl"):
|
||||
offset = 3
|
||||
else:
|
||||
offset = 1
|
||||
val = self.controller.ctx.get_float(self.controller.ctx.slider_mode) - offset
|
||||
self.controller.ctx.set_float(self.controller.ctx.slider_mode, val)
|
||||
ui.message(str(round(val, 1)))
|
||||
|
@ -5,6 +5,15 @@ class Strategy(ABC):
|
||||
def __init__(self, controller, index):
|
||||
self._controller = controller
|
||||
self._index = index
|
||||
self._slider_mode = "gain"
|
||||
|
||||
@abstractmethod
|
||||
def __str__(self):
|
||||
pass
|
||||
|
||||
@property
|
||||
def identifier(self):
|
||||
return f"{self}[{self._index}]"
|
||||
|
||||
@property
|
||||
def index(self):
|
||||
@ -14,30 +23,42 @@ class Strategy(ABC):
|
||||
def index(self, val):
|
||||
self._index = val
|
||||
|
||||
@property
|
||||
def slider_mode(self):
|
||||
return self._slider_mode
|
||||
|
||||
@slider_mode.setter
|
||||
def slider_mode(self, val):
|
||||
self._slider_mode = val
|
||||
|
||||
def get_bool(self, param: str) -> bool:
|
||||
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)
|
||||
|
||||
def get_float(self, param: str) -> float:
|
||||
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)
|
||||
|
||||
def get_int(self, param: str) -> int:
|
||||
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)
|
||||
|
||||
|
||||
class StripStrategy(Strategy):
|
||||
def __str__(self):
|
||||
return "Strip"
|
||||
|
||||
@property
|
||||
def identifier(self):
|
||||
return f"strip[{self._index}]"
|
||||
|
||||
|
||||
class BusStrategy(Strategy):
|
||||
def __str__(self):
|
||||
return "Bus"
|
||||
|
||||
@property
|
||||
def identifier(self):
|
||||
return f"bus[{self._index}]"
|
||||
|
||||
|
||||
class Context:
|
||||
def __init__(self, strategy: Strategy) -> None:
|
||||
@ -59,8 +80,28 @@ class Context:
|
||||
def index(self, val):
|
||||
self._strategy._index = val
|
||||
|
||||
def get_bool(self, *args):
|
||||
@property
|
||||
def slider_mode(self):
|
||||
return self._strategy._slider_mode
|
||||
|
||||
@slider_mode.setter
|
||||
def slider_mode(self, val):
|
||||
self._strategy._slider_mode = val
|
||||
|
||||
def get_bool(self, *args) -> bool:
|
||||
return self._strategy.get_bool(*args)
|
||||
|
||||
def set_bool(self, *args):
|
||||
self._strategy.set_bool(*args)
|
||||
|
||||
def get_float(self, *args) -> float:
|
||||
return self._strategy.get_float(*args)
|
||||
|
||||
def set_float(self, *args):
|
||||
self._strategy.set_float(*args)
|
||||
|
||||
def get_int(self, *args) -> int:
|
||||
return self._strategy.get_int(*args)
|
||||
|
||||
def set_int(self, *args):
|
||||
self._strategy.set_int(*args)
|
||||
|
10
addon/globalPlugins/voicemeeter/util.py
Normal file
10
addon/globalPlugins/voicemeeter/util.py
Normal file
@ -0,0 +1,10 @@
|
||||
def remove_prefix(input_string, prefix):
|
||||
if prefix and input_string.startswith(prefix):
|
||||
return input_string[len(prefix) :]
|
||||
return input_string
|
||||
|
||||
|
||||
def remove_suffix(input_string, suffix):
|
||||
if suffix and input_string.endswith(suffix):
|
||||
return input_string[: -len(suffix)]
|
||||
return input_string
|
@ -28,7 +28,7 @@ addon_info = {
|
||||
The add-on requires Voicemeeter to be installed."""
|
||||
),
|
||||
# version
|
||||
"addon_version": "0.1",
|
||||
"addon_version": "0.2",
|
||||
# Author(s)
|
||||
"addon_author": "onyx-and-iris <code@onyxandiris.online>",
|
||||
# URL for the add-on documentation support
|
||||
|
Loading…
Reference in New Issue
Block a user