implements asio buffer

This commit is contained in:
onyx-and-iris 2023-08-26 21:55:39 +01:00
parent e1fb16c32b
commit a1c7f1358e
4 changed files with 90 additions and 20 deletions

View File

@ -2,6 +2,7 @@ import PySimpleGUI as psg
from .util import ( from .util import (
get_asio_checkbox_index, get_asio_checkbox_index,
get_asio_samples_list,
get_input_device_list, get_input_device_list,
get_insert_checkbox_index, get_insert_checkbox_index,
get_patch_composite_list, get_patch_composite_list,
@ -17,13 +18,19 @@ class Builder:
self.kind = self.vm.kind self.kind = self.vm.kind
def run(self) -> list: def run(self) -> list:
menu = self.make_menu() menu = [[self.make_menu()]]
layout0 = [] layout0 = []
if self.kind.name == "basic": if self.kind.name == "basic":
steps = (self.make_tab0_row0,) steps = (self.make_tab0_row0,)
else: else:
steps = (self.make_tab0_row0, self.make_tab0_row1, self.make_tab0_row2, self.make_tab0_row3) steps = (
self.make_tab0_row0,
self.make_tab0_row1,
self.make_tab0_row2,
self.make_tab0_row3,
self.make_tab0_row4,
)
for step in steps: for step in steps:
layout0.append([step()]) layout0.append([step()])
@ -59,7 +66,7 @@ class Builder:
], ],
], ],
] ]
return [[psg.Menu(menu_def, key="menus")]] return psg.Menu(menu_def, key="menus")
def make_tab0_row0(self) -> psg.Frame: def make_tab0_row0(self) -> psg.Frame:
"""row0 represents hardware outs""" """row0 represents hardware outs"""
@ -190,6 +197,26 @@ class Builder:
return psg.Frame("PATCH INSERT", asio_checkboxes) return psg.Frame("PATCH INSERT", asio_checkboxes)
def make_tab0_row4(self) -> psg.Frame:
"""row4 represents asio buffer"""
samples = get_asio_samples_list()
samples.append("Default")
return psg.Frame(
"ASIO BUFFER",
[
[
psg.ButtonMenu(
"ASIO BUFFER",
size=(12, 2),
menu_def=["", samples],
key="ASIO BUFFER",
)
]
],
)
def make_tab1_row(self, i) -> psg.Frame: def make_tab1_row(self, i) -> psg.Frame:
def add_strip_outputs(layout): def add_strip_outputs(layout):
layout.append( layout.append(

View File

@ -28,15 +28,3 @@ def _make_output_cache(vm) -> dict:
def _make_bus_mode_cache(vm) -> dict: def _make_bus_mode_cache(vm) -> dict:
return {**{f"BUS {i}||COMPOSITE": vm.bus[i].mode.get() for i in range(vm.kind.num_bus)}} return {**{f"BUS {i}||COMPOSITE": vm.bus[i].mode.get() for i in range(vm.kind.num_bus)}}
_patch_insert_channels = (
"left",
"right",
"center",
"low frequency effect",
"surround left",
"surround right",
"back left",
"back right",
)

View File

@ -1,10 +1,10 @@
def get_asio_checkbox_index(channel, num): def get_asio_checkbox_index(channel, num) -> int:
if channel == 0: if channel == 0:
return 2 * num - 2 return 2 * num - 2
return 2 * num - 1 return 2 * num - 1
def get_insert_checkbox_index(kind, channel, num): def get_insert_checkbox_index(kind, channel, num) -> int:
if num <= kind.phys_in: if num <= kind.phys_in:
if channel == 0: if channel == 0:
return 2 * num - 2 return 2 * num - 2
@ -13,11 +13,11 @@ def get_insert_checkbox_index(kind, channel, num):
return (2 * kind.phys_in) + (8 * (num - kind.phys_in - 1)) + channel return (2 * kind.phys_in) + (8 * (num - kind.phys_in - 1)) + channel
def get_input_device_list(vm): def get_input_device_list(vm) -> list:
return ["{type}: {name}".format(**vm.device.output(i)) for i in range(vm.device.outs)] return ["{type}: {name}".format(**vm.device.output(i)) for i in range(vm.device.outs)]
def get_patch_composite_list(kind): def get_patch_composite_list(kind) -> list:
temp = [] temp = []
for i in range(kind.phys_out): for i in range(kind.phys_out):
[temp.append(f"IN#{i + 1} {channel}") for channel in ("Left", "Right")] [temp.append(f"IN#{i + 1} {channel}") for channel in ("Left", "Right")]
@ -25,3 +25,43 @@ def get_patch_composite_list(kind):
[temp.append(f"IN#{i + 1} {channel}") for channel in ("Left", "Right", "Center", "LFE", "SL", "SR", "BL", "BR")] [temp.append(f"IN#{i + 1} {channel}") for channel in ("Left", "Right", "Center", "LFE", "SL", "SR", "BL", "BR")]
temp.append(f"BUS Channel") temp.append(f"BUS Channel")
return temp return temp
def get_patch_insert_channels() -> list:
return [
"left",
"right",
"center",
"low frequency effect",
"surround left",
"surround right",
"back left",
"back right",
]
_patch_insert_channels = get_patch_insert_channels()
def get_asio_samples_list() -> list:
return [
"1024",
"768",
"704",
"640",
"576",
"512",
"480",
"448",
"441",
"416",
"384",
"352",
"320",
"288",
"256",
"224",
"192",
"160",
"128",
]

View File

@ -3,10 +3,11 @@ import logging
import PySimpleGUI as psg import PySimpleGUI as psg
from .builder import Builder from .builder import Builder
from .models import _make_bus_mode_cache, _make_output_cache, _patch_insert_channels from .models import _make_bus_mode_cache, _make_output_cache
from .nvda import Nvda from .nvda import Nvda
from .parser import Parser from .parser import Parser
from .util import ( from .util import (
_patch_insert_channels,
get_asio_checkbox_index, get_asio_checkbox_index,
get_insert_checkbox_index, get_insert_checkbox_index,
get_patch_composite_list, get_patch_composite_list,
@ -33,6 +34,7 @@ class NVDAVMWindow(psg.Window):
[self[f"HARDWARE OUT||A{i + 1}"].Widget.config(takefocus=1) for i in range(self.kind.phys_out)] [self[f"HARDWARE OUT||A{i + 1}"].Widget.config(takefocus=1) for i in range(self.kind.phys_out)]
if self.kind.name != "basic": if self.kind.name != "basic":
[self[f"PATCH COMPOSITE||PC{i + 1}"].Widget.config(takefocus=1) for i in range(self.kind.phys_out)] [self[f"PATCH COMPOSITE||PC{i + 1}"].Widget.config(takefocus=1) for i in range(self.kind.phys_out)]
self["ASIO BUFFER"].Widget.config(takefocus=1)
self.register_events() self.register_events()
self.current_focus = None self.current_focus = None
@ -83,6 +85,9 @@ class NVDAVMWindow(psg.Window):
for j in range(self.kind.num_bus): for j in range(self.kind.num_bus):
self[f"BUS {i}||COMPOSITE"].bind("<FocusIn>", "||FOCUS IN") self[f"BUS {i}||COMPOSITE"].bind("<FocusIn>", "||FOCUS IN")
# ASIO Buffer
self[f"ASIO BUFFER"].bind("<FocusIn>", "||FOCUS IN")
def run(self): def run(self):
""" """
Parses the event string and matches it to events Parses the event string and matches it to events
@ -194,6 +199,16 @@ class NVDAVMWindow(psg.Window):
num = int(in_num[-1]) num = int(in_num[-1])
self.nvda.speak(f"Patch INSERT IN#{num} {channel} {'on' if val else 'off'}") self.nvda.speak(f"Patch INSERT IN#{num} {channel} {'on' if val else 'off'}")
# ASIO Buffer
case [["ASIO", "BUFFER"], ["FOCUS", "IN"]]:
self.nvda.speak(f"ASIO BUFFER")
case ["ASIO BUFFER"]:
if values[event] == "Default":
val = 0
else:
val = values[event]
self.vm.option.buffer("asio", val)
# Strip outputs # Strip outputs
case [["STRIP", index], [output]]: case [["STRIP", index], [output]]:
val = not self.cache["outputs"][f"STRIP {index}||{output}"] val = not self.cache["outputs"][f"STRIP {index}||{output}"]