mirror of
https://github.com/onyx-and-iris/nvda-addon-voicemeeter.git
synced 2026-04-07 20:13:30 +00:00
Compare commits
20 Commits
add-slider
...
v.0.6
| Author | SHA1 | Date | |
|---|---|---|---|
| 26de3d90b9 | |||
| e14ea5f23c | |||
| e9b9295a46 | |||
| 2db268551c | |||
| 0be7919f12 | |||
| ab728f0a32 | |||
| 050e0336b8 | |||
| f49b04d4f6 | |||
| c9781ff92a | |||
| bfccc323f1 | |||
| 86dbe0b335 | |||
| 82f32643d6 | |||
| 51ccd76c2a | |||
| 149ed73605 | |||
| ecca4c65c8 | |||
| 770a7742a2 | |||
| 2ca201af3a | |||
| 15a1747921 | |||
| bac1fb09ec | |||
| f24ef8442e |
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -1,8 +1,5 @@
|
|||||||
{
|
{
|
||||||
"python.analysis.diagnosticSeverityOverrides": {
|
"python.analysis.diagnosticSeverityOverrides": {
|
||||||
"reportMissingImports": "none"
|
"reportMissingImports": "none"
|
||||||
},
|
}
|
||||||
"black-formatter.args": [
|
|
||||||
"--line-length=120"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
119
README.md
119
README.md
@@ -1,3 +1,120 @@
|
|||||||
# NVDA Addon Voicemeeter
|
# NVDA Addon Voicemeeter
|
||||||
|
|
||||||
Control Voicemeeter GUI with customisable hotkeys.
|
Control Voicemeeter with global hotkeys.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
This addon can be installed through the Add-on store, `Install from external source`. Simply download the [latest Release](https://github.com/onyx-and-iris/nvda-addon-voicemeeter/releases) and load it with NVDA.
|
||||||
|
|
||||||
|
## Default Keybinds
|
||||||
|
|
||||||
|
### Controllers
|
||||||
|
|
||||||
|
- `NVDA+alt+s`: Enable strip mode
|
||||||
|
- `NVDA+alt+b`: Enable bus mode.
|
||||||
|
|
||||||
|
- `NVDA+alt+1`: Enable controller for channel 1 (strip|bus)
|
||||||
|
- `NVDA+alt+2`: Enable controller for channel 2 (strip|bus)
|
||||||
|
- `NVDA+alt+3`: Enable controller for channel 3 (strip|bus)
|
||||||
|
- `NVDA+alt+4`: Enable controller for channel 4 (strip|bus)
|
||||||
|
- `NVDA+alt+5`: Enable controller for channel 5 (strip|bus)
|
||||||
|
- `NVDA+alt+6`: Enable controller for channel 6 (strip|bus)
|
||||||
|
- `NVDA+alt+7`: Enable controller for channel 7 (strip|bus)
|
||||||
|
- `NVDA+alt+8`: Enable controller for channel 8 (strip|bus)
|
||||||
|
|
||||||
|
### Slider Modes
|
||||||
|
|
||||||
|
- `NVDA+alt+g`: Enable gain slider mode.
|
||||||
|
- `NVDA+alt+c`: Enable comp slider mode.
|
||||||
|
- `NVDA+alt+t`: Enable gate slider mode.
|
||||||
|
- `NVDA+alt+d`: Enable denoiser slider mode.
|
||||||
|
- `NVDA+alt+a`: Enable audibility slider mode.
|
||||||
|
|
||||||
|
### Sliders
|
||||||
|
|
||||||
|
- `NVDA+shift+upArrow`: Move slider up by 1 step
|
||||||
|
- `NVDA+shift+downArrow`: Move slider down by 1 step
|
||||||
|
- `NVDA+shift+alt+upArrow`: Move slider up by 0.1 step
|
||||||
|
- `NVDA+shift+alt+downArrow`: Move slider down by 0.1 step
|
||||||
|
- `NVDA+shift+control+upArrow`: Move slider up by 3 steps
|
||||||
|
- `NVDA+shift+control+downArrow`: Move slider down by 3 steps
|
||||||
|
|
||||||
|
### Channel Parameters
|
||||||
|
|
||||||
|
- `NVDA+shift+o`: Mono
|
||||||
|
- `NVDA+shift+s`: Solo
|
||||||
|
- `NVDA+shift+m`: Mute
|
||||||
|
- `NVDA+shift+c`: MC
|
||||||
|
- `NVDA+shift+k`: Karaoke
|
||||||
|
|
||||||
|
### Bus Assignments (A1-A5|B1-B3)
|
||||||
|
|
||||||
|
- `NVDA+shift+1`: Toggle BUS assignment 1 for a strip
|
||||||
|
- `NVDA+shift+2`: Toggle BUS assignment 2 for a strip
|
||||||
|
- `NVDA+shift+3`: Toggle BUS assignment 3 for a strip
|
||||||
|
- `NVDA+shift+4`: Toggle BUS assignment 4 for a strip
|
||||||
|
- `NVDA+shift+5`: Toggle BUS assignment 5 for a strip
|
||||||
|
- `NVDA+shift+6`: Toggle BUS assignment 6 for a strip
|
||||||
|
- `NVDA+shift+7`: Toggle BUS assignment 7 for a strip
|
||||||
|
- `NVDA+shift+8`: Toggle BUS assignment 8 for a strip
|
||||||
|
|
||||||
|
### Announcements
|
||||||
|
|
||||||
|
- `NVDA+shift+q`: Announce current controller.
|
||||||
|
- `NVDA+shift+a`: Announce Voicemeeter kind.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
By placing a file named `nvda_settings.json` in `User Home Directory / Documents / Voicemeeter` (the same place as your Voicemeeter xml profiles) you can change most of the default keybinds.
|
||||||
|
|
||||||
|
The `voicemeeter` key can take one of three values:
|
||||||
|
|
||||||
|
- `basic`
|
||||||
|
- `banana`
|
||||||
|
- `potato`
|
||||||
|
|
||||||
|
example:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"voicemeeter": "banana",
|
||||||
|
"keybinds": {
|
||||||
|
"NVDA+alt+k": "strip_mode",
|
||||||
|
"NVDA+alt+l": "bus_mode",
|
||||||
|
"NVDA+alt+g": "gain_mode",
|
||||||
|
"NVDA+alt+c": "comp_mode",
|
||||||
|
"NVDA+alt+t": "gate_mode",
|
||||||
|
"NVDA+alt+d": "denoiser_mode",
|
||||||
|
"NVDA+alt+a": "audibility_mode",
|
||||||
|
"NVDA+shift+q": "announce_controller",
|
||||||
|
"NVDA+shift+z": "announce_voicemeeter_version",
|
||||||
|
"NVDA+shift+s": "toggle_solo",
|
||||||
|
"NVDA+shift+m": "toggle_mute",
|
||||||
|
"NVDA+shift+c": "toggle_mc",
|
||||||
|
"NVDA+shift+k": "karaoke",
|
||||||
|
"NVDA+shift+upArrow": "slider_increase_by_point_one",
|
||||||
|
"NVDA+shift+downArrow": "slider_decrease_by_point_one",
|
||||||
|
"NVDA+shift+alt+upArrow": "slider_increase_by_one",
|
||||||
|
"NVDA+shift+alt+downArrow": "slider_decrease_by_one",
|
||||||
|
"NVDA+shift+control+upArrow": "slider_increase_by_three",
|
||||||
|
"NVDA+shift+control+downArrow": "slider_decrease_by_three",
|
||||||
|
"NVDA+control+1": "bus_assignment",
|
||||||
|
"NVDA+control+2": "bus_assignment",
|
||||||
|
"NVDA+control+3": "bus_assignment",
|
||||||
|
"NVDA+control+4": "bus_assignment",
|
||||||
|
"NVDA+control+5": "bus_assignment",
|
||||||
|
"NVDA+control+6": "bus_assignment",
|
||||||
|
"NVDA+control+7": "bus_assignment",
|
||||||
|
"NVDA+control+8": "bus_assignment"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Would make the following changes:
|
||||||
|
|
||||||
|
- load the plugin in `banana` mode (default is potato)
|
||||||
|
- change the `strip_mode` and `bus_mode` binds to `NVDA+alt+k` and `NVDA+alt+l` respectively
|
||||||
|
- change the `announce_voicemeeter_version` bind to `NVDA+shift+z`
|
||||||
|
- changes the bus assignment binds to `NVDA+control+number`
|
||||||
|
|
||||||
|
All other binds would then be defaults.
|
||||||
|
|||||||
@@ -1,63 +1,16 @@
|
|||||||
import json
|
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import globalPluginHandler
|
import globalPluginHandler
|
||||||
from logHandler import log
|
|
||||||
|
|
||||||
|
from . import config, util
|
||||||
from .commands import CommandsMixin
|
from .commands import CommandsMixin
|
||||||
from .controller import Controller
|
from .controller import Controller
|
||||||
from .kinds import KindId, request_kind_map
|
from .kinds import KindId, request_kind_map
|
||||||
|
|
||||||
|
|
||||||
def _make_gestures():
|
class GlobalPlugin(CommandsMixin, globalPluginHandler.GlobalPlugin):
|
||||||
defaults = {
|
__kind_id = config.get("voicemeeter", "potato")
|
||||||
"kb:NVDA+alt+s": "strip_mode",
|
__gestures = util._make_gestures(__kind_id)
|
||||||
"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+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
|
|
||||||
pn = Path.home() / "Documents" / "Voicemeeter" / "keybinds.json"
|
|
||||||
if pn.exists():
|
|
||||||
with open(pn, "r") as f:
|
|
||||||
data = json.load(f)
|
|
||||||
overrides = {f"kb:{v}": k for k, v in data.items()}
|
|
||||||
log.info("INFO - loading settings from keybinds.json")
|
|
||||||
if overrides:
|
|
||||||
return {**defaults, **overrides}
|
|
||||||
return defaults
|
|
||||||
|
|
||||||
|
|
||||||
def _get_kind_id():
|
|
||||||
pn = Path.home() / "Documents" / "Voicemeeter" / "settings.json"
|
|
||||||
if pn.exists():
|
|
||||||
with open(pn, "r") as f:
|
|
||||||
data = json.load(f)
|
|
||||||
return data["voicemeeter"]
|
|
||||||
return "potato"
|
|
||||||
|
|
||||||
|
|
||||||
class GlobalPlugin(globalPluginHandler.GlobalPlugin, CommandsMixin):
|
|
||||||
__gestures = _make_gestures()
|
|
||||||
__kind_id = _get_kind_id()
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
@@ -65,12 +18,7 @@ class GlobalPlugin(globalPluginHandler.GlobalPlugin, CommandsMixin):
|
|||||||
if self.controller.login() == 1:
|
if self.controller.login() == 1:
|
||||||
self.controller.run_voicemeeter(KindId[self.__kind_id.upper()])
|
self.controller.run_voicemeeter(KindId[self.__kind_id.upper()])
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.kind = request_kind_map(self.controller.kind_id)
|
self.kind = request_kind_map(self.__kind_id)
|
||||||
|
|
||||||
for i in range(1, self.kind.num_strip + 1):
|
|
||||||
self.bindGesture(f"kb:NVDA+alt+{i}", "index")
|
|
||||||
for i in range(1, self.kind.phys_out + self.kind.virt_out + 1):
|
|
||||||
self.bindGesture(f"kb:NVDA+shift+{i}", "bus_assignment")
|
|
||||||
|
|
||||||
def terminate(self, *args, **kwargs):
|
def terminate(self, *args, **kwargs):
|
||||||
super().terminate(*args, **kwargs)
|
super().terminate(*args, **kwargs)
|
||||||
|
|||||||
@@ -1,51 +1,45 @@
|
|||||||
import ctypes as ct
|
import ctypes as ct
|
||||||
import winreg
|
from ctypes.wintypes import CHAR, FLOAT, LONG
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from .error import VMError
|
from .cdll import libc
|
||||||
|
from .error import VMCAPIError
|
||||||
|
|
||||||
|
|
||||||
class Binds:
|
class Binds:
|
||||||
VM_KEY = "VB:Voicemeeter {17359A74-1236-5467}"
|
bind_login = libc.VBVMR_Login
|
||||||
BITS = 64 if ct.sizeof(ct.c_voidp) == 8 else 32
|
bind_login.restype = LONG
|
||||||
|
bind_login.argtypes = None
|
||||||
|
|
||||||
def __init__(self):
|
bind_logout = libc.VBVMR_Logout
|
||||||
dll_path = Path(self.__vmpath()).parent.joinpath(
|
bind_logout.restype = LONG
|
||||||
f'VoicemeeterRemote{"64" if self.BITS == 64 else ""}.dll'
|
bind_logout.argtypes = None
|
||||||
)
|
|
||||||
if self.BITS == 64:
|
|
||||||
self.libc = ct.CDLL(str(dll_path))
|
|
||||||
else:
|
|
||||||
self.libc = ct.WinDLL(str(dll_path))
|
|
||||||
|
|
||||||
def __vmpath(self):
|
bind_run_voicemeeter = libc.VBVMR_RunVoicemeeter
|
||||||
with winreg.OpenKey(
|
bind_run_voicemeeter.restype = LONG
|
||||||
winreg.HKEY_LOCAL_MACHINE,
|
bind_run_voicemeeter.argtypes = [LONG]
|
||||||
r"{}".format(
|
|
||||||
"\\".join(
|
bind_get_voicemeeter_type = libc.VBVMR_GetVoicemeeterType
|
||||||
(
|
bind_get_voicemeeter_type.restype = LONG
|
||||||
"\\".join(
|
bind_get_voicemeeter_type.argtypes = [ct.POINTER(LONG)]
|
||||||
filter(
|
|
||||||
None,
|
bind_get_voicemeeter_version = libc.VBVMR_GetVoicemeeterVersion
|
||||||
(
|
bind_get_voicemeeter_version.restype = LONG
|
||||||
"SOFTWARE",
|
bind_get_voicemeeter_version.argtypes = [ct.POINTER(LONG)]
|
||||||
"WOW6432Node" if self.BITS == 64 else "",
|
|
||||||
"Microsoft",
|
bind_is_parameters_dirty = libc.VBVMR_IsParametersDirty
|
||||||
"Windows",
|
bind_is_parameters_dirty.restype = LONG
|
||||||
"CurrentVersion",
|
bind_is_parameters_dirty.argtypes = None
|
||||||
"Uninstall",
|
|
||||||
),
|
bind_get_parameter_float = libc.VBVMR_GetParameterFloat
|
||||||
)
|
bind_get_parameter_float.restype = LONG
|
||||||
),
|
bind_get_parameter_float.argtypes = [ct.POINTER(CHAR), ct.POINTER(FLOAT)]
|
||||||
self.VM_KEY,
|
|
||||||
)
|
bind_set_parameter_float = libc.VBVMR_SetParameterFloat
|
||||||
)
|
bind_set_parameter_float.restype = LONG
|
||||||
),
|
bind_set_parameter_float.argtypes = [ct.POINTER(CHAR), FLOAT]
|
||||||
) as vm_key:
|
|
||||||
return winreg.QueryValueEx(vm_key, r"UninstallString")[0]
|
|
||||||
|
|
||||||
def call(self, fn, *args, ok=(0,)):
|
def call(self, fn, *args, ok=(0,)):
|
||||||
retval = getattr(self.libc, fn)(*args)
|
retval = fn(*args)
|
||||||
if retval not in ok:
|
if retval not in ok:
|
||||||
raise VMError(f"{fn} returned {retval}")
|
raise VMCAPIError(fn.__name__, retval)
|
||||||
return retval
|
return retval
|
||||||
|
|||||||
49
addon/globalPlugins/voicemeeter/cdll.py
Normal file
49
addon/globalPlugins/voicemeeter/cdll.py
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import ctypes as ct
|
||||||
|
import platform
|
||||||
|
import winreg
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from .error import VMError
|
||||||
|
|
||||||
|
BITS = 64 if ct.sizeof(ct.c_voidp) == 8 else 32
|
||||||
|
|
||||||
|
if platform.system() != "Windows":
|
||||||
|
raise VMError("Only Windows OS supported")
|
||||||
|
|
||||||
|
|
||||||
|
VM_KEY = "VB:Voicemeeter {17359A74-1236-5467}"
|
||||||
|
REG_KEY = "\\".join(
|
||||||
|
filter(
|
||||||
|
None,
|
||||||
|
(
|
||||||
|
"SOFTWARE",
|
||||||
|
"WOW6432Node" if BITS == 64 else "",
|
||||||
|
"Microsoft",
|
||||||
|
"Windows",
|
||||||
|
"CurrentVersion",
|
||||||
|
"Uninstall",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_vmpath():
|
||||||
|
with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"{}".format("\\".join((REG_KEY, VM_KEY)))) as vm_key:
|
||||||
|
return winreg.QueryValueEx(vm_key, r"UninstallString")[0]
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
vm_parent = Path(get_vmpath()).parent
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
raise VMError("Unable to fetch DLL path from the registry") from e
|
||||||
|
|
||||||
|
DLL_NAME = f'VoicemeeterRemote{"64" if BITS == 64 else ""}.dll'
|
||||||
|
|
||||||
|
dll_path = vm_parent.joinpath(DLL_NAME)
|
||||||
|
if not dll_path.is_file():
|
||||||
|
raise VMError(f"Could not find {dll_path}")
|
||||||
|
|
||||||
|
if BITS == 64:
|
||||||
|
libc = ct.CDLL(str(dll_path))
|
||||||
|
else:
|
||||||
|
libc = ct.WinDLL(str(dll_path))
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
import ui
|
import ui
|
||||||
from logHandler import log
|
from logHandler import log
|
||||||
|
|
||||||
from . import context, util
|
from . import context
|
||||||
|
|
||||||
|
|
||||||
class CommandsMixin:
|
class CommandsMixin:
|
||||||
### ANNOUNCEMENTS ###
|
### ANNOUNCEMENTS ###
|
||||||
|
|
||||||
def script_announce_voicemeeter_version(self, _):
|
def script_announce_voicemeeter_version(self, _):
|
||||||
ui.message(f"Running Voicemeeter {self.kind}")
|
ui.message(f"Running Voicemeeter {self.kind} {self.controller.version}")
|
||||||
|
|
||||||
def script_announce_controller(self, _):
|
def script_announce_controller(self, _):
|
||||||
ui.message(f"Controller for {self.controller.ctx.strategy} {self.controller.ctx.index + 1}")
|
ui.message(f"Controller for {self.controller.ctx.strategy} {self.controller.ctx.index + 1}")
|
||||||
@@ -37,18 +37,24 @@ class CommandsMixin:
|
|||||||
ui.message(f"Controller for {self.controller.ctx.strategy} {self.controller.ctx.index + 1}")
|
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")
|
log.info(f"INFO - {self.controller.ctx.strategy} {self.controller.ctx.index} mode")
|
||||||
|
|
||||||
def script_slider_mode(self, gesture):
|
def __set_slider_mode(self, mode):
|
||||||
if gesture.displayName.endswith("g"):
|
self.controller.ctx.slider_mode = mode
|
||||||
self.controller.ctx.slider_mode = "gain"
|
ui.message(f"{mode} mode enabled")
|
||||||
elif gesture.displayName.endswith("c"):
|
|
||||||
self.controller.ctx.slider_mode = "comp"
|
def script_gain_mode(self, _):
|
||||||
elif gesture.displayName.endswith("t"):
|
self.__set_slider_mode("gain")
|
||||||
self.controller.ctx.slider_mode = "gate"
|
|
||||||
elif gesture.displayName.endswith("d"):
|
def script_comp_mode(self, _):
|
||||||
self.controller.ctx.slider_mode = "denoiser"
|
self.__set_slider_mode("comp")
|
||||||
elif gesture.displayName.endswith("a"):
|
|
||||||
self.controller.ctx.slider_mode = "audibility"
|
def script_gate_mode(self, _):
|
||||||
ui.message(f"{self.controller.ctx.slider_mode} mode enabled")
|
self.__set_slider_mode("gate")
|
||||||
|
|
||||||
|
def script_denoiser_mode(self, _):
|
||||||
|
self.__set_slider_mode("denoiser")
|
||||||
|
|
||||||
|
def script_audibility_mode(self, _):
|
||||||
|
self.__set_slider_mode("audibility")
|
||||||
|
|
||||||
### BOOLEAN PARAMETERS ###
|
### BOOLEAN PARAMETERS ###
|
||||||
|
|
||||||
@@ -73,11 +79,12 @@ class CommandsMixin:
|
|||||||
ui.message("on" if val else "off")
|
ui.message("on" if val else "off")
|
||||||
|
|
||||||
def script_karaoke(self, _):
|
def script_karaoke(self, _):
|
||||||
|
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") + 1
|
||||||
if val == 5:
|
if val == len(opts):
|
||||||
val = 0
|
val = 0
|
||||||
self.controller.ctx.set_int("karaoke", val)
|
self.controller.ctx.set_int("karaoke", val)
|
||||||
ui.message(val)
|
ui.message(opts[val])
|
||||||
|
|
||||||
def script_bus_assignment(self, gesture):
|
def script_bus_assignment(self, gesture):
|
||||||
proposed = int(gesture.displayName[-1])
|
proposed = int(gesture.displayName[-1])
|
||||||
@@ -89,28 +96,34 @@ class CommandsMixin:
|
|||||||
self.controller.ctx.set_bool(output, val)
|
self.controller.ctx.set_bool(output, val)
|
||||||
ui.message("on" if val else "off")
|
ui.message("on" if val else "off")
|
||||||
|
|
||||||
### SLIDER MODES ###
|
### CONTROL SLIDERS ###
|
||||||
|
|
||||||
def script_slider_increase(self, gesture):
|
def script_slider_increase_by_point_one(self, gesture):
|
||||||
op = util.remove_prefix(gesture.displayName, "kb:NVDA+shift+")
|
val = self.controller.ctx.get_float(self.controller.ctx.slider_mode) + 0.1
|
||||||
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)
|
self.controller.ctx.set_float(self.controller.ctx.slider_mode, val)
|
||||||
ui.message(str(round(val, 1)))
|
ui.message(str(round(val, 1)))
|
||||||
|
|
||||||
def script_slider_decrease(self, gesture):
|
def script_slider_decrease_by_point_one(self, gesture):
|
||||||
op = util.remove_prefix(gesture.displayName, "kb:NVDA+shift+")
|
val = self.controller.ctx.get_float(self.controller.ctx.slider_mode) - 0.1
|
||||||
if op.startswith("alt"):
|
self.controller.ctx.set_float(self.controller.ctx.slider_mode, val)
|
||||||
offset = 0.1
|
ui.message(str(round(val, 1)))
|
||||||
elif op.startswith("ctrl"):
|
|
||||||
offset = 3
|
def script_slider_increase_by_one(self, gesture):
|
||||||
else:
|
val = self.controller.ctx.get_float(self.controller.ctx.slider_mode) + 1
|
||||||
offset = 1
|
self.controller.ctx.set_float(self.controller.ctx.slider_mode, val)
|
||||||
val = self.controller.ctx.get_float(self.controller.ctx.slider_mode) - offset
|
ui.message(str(round(val, 1)))
|
||||||
|
|
||||||
|
def script_slider_decrease_by_one(self, gesture):
|
||||||
|
val = self.controller.ctx.get_float(self.controller.ctx.slider_mode) - 1
|
||||||
|
self.controller.ctx.set_float(self.controller.ctx.slider_mode, val)
|
||||||
|
ui.message(str(round(val, 1)))
|
||||||
|
|
||||||
|
def script_slider_increase_by_three(self, gesture):
|
||||||
|
val = self.controller.ctx.get_float(self.controller.ctx.slider_mode) + 3
|
||||||
|
self.controller.ctx.set_float(self.controller.ctx.slider_mode, val)
|
||||||
|
ui.message(str(round(val, 1)))
|
||||||
|
|
||||||
|
def script_slider_decrease_by_three(self, gesture):
|
||||||
|
val = self.controller.ctx.get_float(self.controller.ctx.slider_mode) - 3
|
||||||
self.controller.ctx.set_float(self.controller.ctx.slider_mode, val)
|
self.controller.ctx.set_float(self.controller.ctx.slider_mode, val)
|
||||||
ui.message(str(round(val, 1)))
|
ui.message(str(round(val, 1)))
|
||||||
|
|||||||
20
addon/globalPlugins/voicemeeter/config.py
Normal file
20
addon/globalPlugins/voicemeeter/config.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def config_from_json():
|
||||||
|
pn = Path.home() / "Documents" / "Voicemeeter" / "nvda_settings.json"
|
||||||
|
data = None
|
||||||
|
if pn.exists():
|
||||||
|
with open(pn, "r") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
return data or {}
|
||||||
|
|
||||||
|
|
||||||
|
__config = config_from_json()
|
||||||
|
|
||||||
|
|
||||||
|
def get(name, default=None):
|
||||||
|
if name in __config:
|
||||||
|
return __config[name]
|
||||||
|
return default
|
||||||
@@ -8,12 +8,8 @@ class Strategy(ABC):
|
|||||||
self._slider_mode = "gain"
|
self._slider_mode = "gain"
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def __str__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
@property
|
|
||||||
def identifier(self):
|
def identifier(self):
|
||||||
return f"{self}[{self._index}]"
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def index(self):
|
def index(self):
|
||||||
@@ -54,11 +50,19 @@ class StripStrategy(Strategy):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Strip"
|
return "Strip"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def identifier(self):
|
||||||
|
return f"{self}[{self._index}]"
|
||||||
|
|
||||||
|
|
||||||
class BusStrategy(Strategy):
|
class BusStrategy(Strategy):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Bus"
|
return "Bus"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def identifier(self):
|
||||||
|
return f"{self}[{self._index}]"
|
||||||
|
|
||||||
|
|
||||||
class Context:
|
class Context:
|
||||||
def __init__(self, strategy: Strategy) -> None:
|
def __init__(self, strategy: Strategy) -> None:
|
||||||
|
|||||||
@@ -3,45 +3,56 @@ import ctypes as ct
|
|||||||
from logHandler import log
|
from logHandler import log
|
||||||
|
|
||||||
from .binds import Binds
|
from .binds import Binds
|
||||||
|
from .cdll import BITS
|
||||||
from .context import Context, StripStrategy
|
from .context import Context, StripStrategy
|
||||||
from .kinds import KindId
|
from .kinds import KindId
|
||||||
|
|
||||||
|
|
||||||
class Controller:
|
class Controller(Binds):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.binds = Binds()
|
|
||||||
self.ctx = Context(StripStrategy(self, 0))
|
self.ctx = Context(StripStrategy(self, 0))
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
retval = self.binds.call("VBVMR_Login", ok=(0, 1))
|
retval = self.call(self.bind_login, ok=(0, 1))
|
||||||
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.binds.call("VBVMR_Logout")
|
self.call(self.bind_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.binds.call("VBVMR_GetVoicemeeterType", ct.byref(c_type))
|
self.call(self.bind_get_voicemeeter_type, ct.byref(c_type))
|
||||||
return KindId(c_type.value).name.lower()
|
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))
|
||||||
|
return "{}.{}.{}.{}".format(
|
||||||
|
(ver.value & 0xFF000000) >> 24,
|
||||||
|
(ver.value & 0x00FF0000) >> 16,
|
||||||
|
(ver.value & 0x0000FF00) >> 8,
|
||||||
|
ver.value & 0x000000FF,
|
||||||
|
)
|
||||||
|
|
||||||
def run_voicemeeter(self, kind_id):
|
def run_voicemeeter(self, kind_id):
|
||||||
val = kind_id.value
|
val = kind_id.value
|
||||||
if val == 3 and Binds.BITS == 64:
|
if val == 3 and BITS == 64:
|
||||||
val = 6
|
val = 6
|
||||||
self.binds.call("VBVMR_RunVoicemeeter", val)
|
self.call(self.bind_run_voicemeeter, val)
|
||||||
|
|
||||||
def __clear(self):
|
def __clear(self):
|
||||||
while self.binds.call("VBVMR_IsParametersDirty", ok=(0, 1)) == 1:
|
while self.call(self.bind_is_parameters_dirty, ok=(0, 1)) == 1:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _get(self, param):
|
def _get(self, param):
|
||||||
self.__clear()
|
self.__clear()
|
||||||
buf = ct.c_float()
|
buf = ct.c_float()
|
||||||
self.binds.call("VBVMR_GetParameterFloat", param.encode(), ct.byref(buf))
|
self.call(self.bind_get_parameter_float, param.encode(), ct.byref(buf))
|
||||||
return buf.value
|
return buf.value
|
||||||
|
|
||||||
def _set(self, param, val):
|
def _set(self, param, val):
|
||||||
self.binds.call("VBVMR_SetParameterFloat", param.encode(), ct.c_float(float(val)))
|
self.call(self.bind_set_parameter_float, param.encode(), ct.c_float(float(val)))
|
||||||
|
|||||||
@@ -1,2 +1,11 @@
|
|||||||
class VMError(Exception):
|
class VMError(Exception):
|
||||||
"""Base VMError class"""
|
"""Base voicemeeterlib exception class"""
|
||||||
|
|
||||||
|
|
||||||
|
class VMCAPIError(VMError):
|
||||||
|
"""Exception raised when the C-API returns an error code"""
|
||||||
|
|
||||||
|
def __init__(self, fn_name, code):
|
||||||
|
self.fn_name = fn_name
|
||||||
|
self.code = code
|
||||||
|
super().__init__(f"{self.fn_name} returned {self.code}")
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
from . import config
|
||||||
|
from .kinds import request_kind_map
|
||||||
|
|
||||||
|
|
||||||
def remove_prefix(input_string, prefix):
|
def remove_prefix(input_string, prefix):
|
||||||
if prefix and input_string.startswith(prefix):
|
if prefix and input_string.startswith(prefix):
|
||||||
return input_string[len(prefix) :]
|
return input_string[len(prefix) :]
|
||||||
@@ -8,3 +12,40 @@ def remove_suffix(input_string, suffix):
|
|||||||
if suffix and input_string.endswith(suffix):
|
if suffix and input_string.endswith(suffix):
|
||||||
return input_string[: -len(suffix)]
|
return input_string[: -len(suffix)]
|
||||||
return input_string
|
return input_string
|
||||||
|
|
||||||
|
|
||||||
|
def _make_gestures(kind_id):
|
||||||
|
kind = request_kind_map(kind_id)
|
||||||
|
defaults = {
|
||||||
|
"kb:NVDA+alt+s": "strip_mode",
|
||||||
|
"kb:NVDA+alt+b": "bus_mode",
|
||||||
|
"kb:NVDA+alt+g": "gain_mode",
|
||||||
|
"kb:NVDA+alt+c": "comp_mode",
|
||||||
|
"kb:NVDA+alt+t": "gate_mode",
|
||||||
|
"kb:NVDA+alt+d": "denoiser_mode",
|
||||||
|
"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+s": "toggle_solo",
|
||||||
|
"kb:NVDA+shift+m": "toggle_mute",
|
||||||
|
"kb:NVDA+shift+c": "toggle_mc",
|
||||||
|
"kb:NVDA+shift+k": "karaoke",
|
||||||
|
"kb:NVDA+shift+upArrow": "slider_increase_by_point_one",
|
||||||
|
"kb:NVDA+shift+downArrow": "slider_decrease_by_point_one",
|
||||||
|
"kb:NVDA+shift+alt+upArrow": "slider_increase_by_one",
|
||||||
|
"kb:NVDA+shift+alt+downArrow": "slider_decrease_by_one",
|
||||||
|
"kb:NVDA+shift+control+upArrow": "slider_increase_by_three",
|
||||||
|
"kb:NVDA+shift+control+downArrow": "slider_decrease_by_three",
|
||||||
|
}
|
||||||
|
for i in range(1, kind.num_strip + 1):
|
||||||
|
defaults[f"kb:NVDA+alt+{i}"] = "index"
|
||||||
|
for i in range(1, kind.phys_out + kind.virt_out + 1):
|
||||||
|
defaults[f"kb:NVDA+shift+{i}"] = "bus_assignment"
|
||||||
|
abc = config.get("keybinds")
|
||||||
|
if abc:
|
||||||
|
overrides = {f"kb:{remove_prefix(k, 'kb:')}": v for k, v in abc.items()}
|
||||||
|
matching_values = set(defaults.values()).intersection(set(overrides.values()))
|
||||||
|
defaults = {k: v for k, v in defaults.items() if v not in matching_values}
|
||||||
|
return {**defaults, **overrides}
|
||||||
|
return defaults
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ param(
|
|||||||
|
|
||||||
function Copy-FilestoScratchpad {
|
function Copy-FilestoScratchpad {
|
||||||
$source = Join-Path $PSScriptRoot "addon" "globalPlugins" "voicemeeter"
|
$source = Join-Path $PSScriptRoot "addon" "globalPlugins" "voicemeeter"
|
||||||
$target = Join-Path $env:appdata "nvda" "scratchpad" "globalPlugins"
|
$target = Join-Path $env:appdata "nvda" "scratchpad" "globalPlugins" "voicemeeter"
|
||||||
Copy-Item -Path $source -Destination $target -Recurse -Force
|
Robocopy $source $target | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
function main {
|
function main {
|
||||||
|
|||||||
@@ -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": "0.2",
|
"addon_version": "0.6",
|
||||||
# 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
|
||||||
|
|||||||
46
pyproject.toml
Normal file
46
pyproject.toml
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
[tool.black]
|
||||||
|
line-length = 119
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
|
||||||
|
select = ["E", "F"]
|
||||||
|
# Avoid enforcing line-length violations (`E501`). Let Black deal with this.
|
||||||
|
ignore = ["E501"]
|
||||||
|
# Allow autofix for all enabled rules (when `--fix`) is provided.
|
||||||
|
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
|
||||||
|
unfixable = []
|
||||||
|
# Exclude a variety of commonly ignored directories.
|
||||||
|
exclude = [
|
||||||
|
".bzr",
|
||||||
|
".direnv",
|
||||||
|
".eggs",
|
||||||
|
".git",
|
||||||
|
".git-rewrite",
|
||||||
|
".hg",
|
||||||
|
".mypy_cache",
|
||||||
|
".nox",
|
||||||
|
".pants.d",
|
||||||
|
".pytype",
|
||||||
|
".ruff_cache",
|
||||||
|
".svn",
|
||||||
|
".tox",
|
||||||
|
".venv",
|
||||||
|
"__pypackages__",
|
||||||
|
"_build",
|
||||||
|
"buck-out",
|
||||||
|
"build",
|
||||||
|
"dist",
|
||||||
|
"node_modules",
|
||||||
|
"venv",
|
||||||
|
]
|
||||||
|
# Same as Black.
|
||||||
|
line-length = 119
|
||||||
|
# Allow unused variables when underscore-prefixed.
|
||||||
|
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
||||||
|
# Assume Python 3.7
|
||||||
|
target-version = "py37"
|
||||||
|
[tool.ruff.mccabe]
|
||||||
|
# Unlike Flake8, default to a complexity level of 10.
|
||||||
|
max-complexity = 10
|
||||||
|
[tool.ruff.per-file-ignores]
|
||||||
|
"__init__.py" = ["E402", "F401"] # Ignore unused import and variable not accessed violations
|
||||||
Reference in New Issue
Block a user