25 Commits

Author SHA1 Message Date
5ab1fd7102 add loader to handle userprofiles in vm-compact
ensure we reload user profiles into memory
when rebuilding the config menu

patch bump
2023-06-26 16:08:58 +01:00
d896193ade md fix 2023-06-26 14:18:23 +01:00
8c0c31dc0d 1.7.0 section added 2023-06-26 14:17:24 +01:00
c8b3e9fc33 dependencies updated.
minor version bump
2023-06-26 13:58:22 +01:00
d4358bf7d3 update comp, gate, eq settings in example.toml 2023-06-26 13:57:39 +01:00
194b95d67b use subject class to notify of busmix update
update messageboxes
2023-06-26 13:57:08 +01:00
0f734e87b7 upd docstring 2023-06-26 13:56:06 +01:00
944ef9ca1c updates to events, callbacks 2023-06-26 13:55:50 +01:00
fc20bb0c1e configpaths added to configurations 2023-06-26 13:53:38 +01:00
5ccc2a6dab error class renamed
doc string expanded
2023-06-26 13:52:42 +01:00
cfc1279f6c module level loggers added 2023-06-26 13:52:24 +01:00
d4df11f62d optimizations to reduce the number of api calls
comp, gate, eq parameter calls updated.
2023-06-26 13:51:21 +01:00
onyx-and-iris
3b6e1f61a4 patch ver bump 2022-10-19 14:54:25 +01:00
onyx-and-iris
3f306ddf62 now using event property setters. 2022-10-19 14:54:00 +01:00
onyx-and-iris
732368a65b fix math error in level updates 2022-10-05 23:39:51 +01:00
onyx-and-iris
d7df79b798 upd vban-cmd ver
patch bump
2022-10-05 23:12:25 +01:00
onyx-and-iris
0906f3343b upd dependencies
patch bump
2022-10-05 23:03:46 +01:00
onyx-and-iris
294dfe7d03 changes to progressbar level udpates 2022-10-05 23:03:27 +01:00
onyx-and-iris
4db7be172b bump dep versions
minor version bump
2022-10-04 16:06:47 +01:00
onyx-and-iris
35775f5024 logger.info logs added
voicemeeter-api, vban-cmd dependency ver updated

changelog updated to reflect changes

minor version bump
2022-09-29 13:45:06 +01:00
onyx-and-iris
d4b2b90fc0 run vban.logout() to cleanup threads/sockets.
bump vban-cmd dependency ver.

patch bump
2022-09-24 08:04:59 +01:00
onyx-and-iris
6de79977cc show messagebox on connection timeout
patch bump
2022-09-23 20:23:55 +01:00
onyx-and-iris
2c290e2632 now using event toggles when dragging sliders
patch bump
2022-09-16 09:44:47 +01:00
onyx-and-iris
d08299a88d minor bump 2022-09-12 02:08:49 +01:00
onyx-and-iris
4507358215 update sv-ttk dependency version 2022-09-12 02:04:32 +01:00
18 changed files with 402 additions and 183 deletions

4
.gitignore vendored
View File

@@ -1,5 +1,5 @@
# quick test
z_*.py
quick.py
# Byte-compiled / optimized / DLL files
__pycache__/
@@ -131,3 +131,5 @@ dmypy.json
# Pyre type checker
.pyre/
.vscode/

View File

@@ -7,13 +7,57 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- [ ] Add support for forest theme (should be coming soon)
- [ ] Add support for forest theme (if rbende adds it to pypi)
## [1.4.0] - 2022-09-03
## [1.7.0] - 2023-06-26
### Changed
- There are changes to how some parameters must be set in user toml configs.
- use `comp.knob` to set a strip comp slider.
- use `gate.knob` to set a strip gate slider.
- use `eq.on` to set a bus eq.on button.
- use `eq.ab` to set a bus eq.ab button.
Check example configs.
- `configs` directory may now be located in one of the following locations:
- \<current working directory>/configs/
- \<user home directory>/.configs/vm-compact/configs/
- \<user home directory>/Documents/Voicemeeter/configs/
- dependency updates:
- sv_ttk updated to v2.4.5.
- voicemeeter-api updated to v2.0.1.
- vban-cmd updated to v2.0.0.
### Fixed
- A number of changes that reduce the amount of api calls being made.
## [1.6.0] - 2022-09-29
### Added
- Logging module used in place of print statements across the interface.
## [1.5.1] - 2022-09-16
### Added
- 1.5.1 binary to releases
### Changed
- sv_ttk updated to v2.0.
- event toggles used to pause updates when dragging sliders.
## [1.4.2] - 2022-09-03
### Added
- tomli/tomllib compatibility layer to support python 3.10
- 1.4.2 binary to releases
## [1.3.0] - 2022-07-14

View File

@@ -2,12 +2,12 @@
label = "PhysStrip0"
A1 = true
gain = -8.8
comp = 3.2
comp.knob = 3.2
[strip-1]
label = "PhysStrip1"
B1 = true
gate = 4.1
gate.knob = 4.1
[strip-2]
label = "PhysStrip2"
@@ -34,12 +34,12 @@ mono = true
[bus-2]
label = "PhysBus2"
eq = true
eq.on = true
mode = "composite"
[bus-3]
label = "VirtBus0"
eq_ab = true
eq.ab = true
mode = "upmix61"
[bus-4]

View File

@@ -2,12 +2,12 @@
label = "PhysStrip0"
A1 = true
gain = -8.8
comp = 3.2
comp.knob = 3.2
[strip-1]
label = "PhysStrip1"
B1 = true
gate = 4.1
gate.knob = 4.1
[strip-2]
label = "PhysStrip2"
@@ -50,7 +50,7 @@ mono = true
[bus-2]
label = "PhysBus2"
eq = true
eq.on = true
[bus-3]
label = "PhysBus3"
@@ -62,7 +62,7 @@ mode = "composite"
[bus-5]
label = "VirtBus0"
eq_ab = true
eq.ab = true
[bus-6]
label = "VirtBus1"

View File

@@ -4,10 +4,10 @@
# kind = 'banana'
# ip = '<ip address 1>'
# streamname = 'Command1'
# port = 6990
# port = 6980
# [connection-2]
# kind = 'potato'
# ip = '<ip address 2>'
# streamname = 'Command1'
# port = 6990
# port = 6980

59
poetry.lock generated
View File

@@ -1,10 +1,10 @@
[[package]]
name = "black"
version = "22.8.0"
version = "22.10.0"
description = "The uncompromising code formatter."
category = "dev"
optional = false
python-versions = ">=3.6.2"
python-versions = ">=3.7"
[package.dependencies]
click = ">=8.0.0"
@@ -38,6 +38,20 @@ category = "dev"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
[[package]]
name = "isort"
version = "5.12.0"
description = "A Python utility / library to sort Python imports."
category = "dev"
optional = false
python-versions = ">=3.8.0"
[package.extras]
colors = ["colorama (>=0.4.3)"]
requirements-deprecated-finder = ["pip-api", "pipreqs"]
pipfile-deprecated-finder = ["pip-shims (>=0.5.2)", "pipreqs", "requirementslib"]
plugins = ["setuptools"]
[[package]]
name = "mypy-extensions"
version = "0.4.3"
@@ -68,8 +82,8 @@ test = ["appdirs (==1.4.4)", "pytest-cov (>=2.7)", "pytest-mock (>=3.6)", "pytes
[[package]]
name = "sv-ttk"
version = "0.1"
description = "Python module to easily use the Sun Valley ttk theme"
version = "2.4.5"
description = "A gorgeous theme for Tkinter, based on Windows 11's UI"
category = "main"
optional = false
python-versions = ">=3.4"
@@ -84,7 +98,7 @@ python-versions = ">=3.7"
[[package]]
name = "vban-cmd"
version = "1.4.2"
version = "2.0.0"
description = "Python interface for the VBAN RT Packet Service (Sendtext)"
category = "main"
optional = false
@@ -95,7 +109,7 @@ tomli = {version = ">=2.0.1,<3.0.0", markers = "python_version < \"3.11\""}
[[package]]
name = "voicemeeter-api"
version = "0.7.0"
version = "2.0.1"
description = "A Python wrapper for the Voiceemeter API"
category = "main"
optional = false
@@ -107,34 +121,17 @@ tomli = {version = ">=2.0.1,<3.0.0", markers = "python_version < \"3.11\""}
[metadata]
lock-version = "1.1"
python-versions = "^3.10"
content-hash = "b1536b0935a1bd7b0d87a97924ba6714c753ff4e59e6863abd7765642cb0a0d1"
content-hash = "ffb9af7ef7aa87ac08a09293de5e99487155faaa459cd49964ac95589deb69fa"
[metadata.files]
black = []
click = [
{file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"},
{file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"},
]
colorama = [
{file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"},
{file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"},
]
mypy-extensions = [
{file = "mypy_extensions-0.4.3-py2.py3-none-any.whl", hash = "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d"},
{file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"},
]
click = []
colorama = []
isort = []
mypy-extensions = []
pathspec = []
platformdirs = [
{file = "platformdirs-2.5.2-py3-none-any.whl", hash = "sha256:027d8e83a2d7de06bbac4e5ef7e023c02b863d7ea5d079477e722bb41ab25788"},
{file = "platformdirs-2.5.2.tar.gz", hash = "sha256:58c8abb07dcb441e6ee4b11d8df0ac856038f944ab98b7be6b27b2a3c7feef19"},
]
sv-ttk = [
{file = "sv_ttk-0.1-py3-none-any.whl", hash = "sha256:c47ab1c70aad0333bc7f5063ab55e8a16b562e700e89e7853e577a1e2fdaa091"},
{file = "sv_ttk-0.1.tar.gz", hash = "sha256:342754618292b6d224060307eccaa35b6f6c284b34b4da1d0cf0484b652ffb0f"},
]
tomli = [
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
]
platformdirs = []
sv-ttk = []
tomli = []
vban-cmd = []
voicemeeter-api = []

View File

@@ -1,26 +1,25 @@
[tool.poetry]
name = "voicemeeter-compact"
version = "1.4.2"
version = "1.7.1"
description = "A Compact Voicemeeter Remote App"
authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/onyx-and-iris/voicemeeter-compact"
packages = [
{ include = "vmcompact" },
]
packages = [{ include = "vmcompact" }]
include = ["vmcompact/img/cat.ico"]
[tool.poetry.dependencies]
python = "^3.10"
sv-ttk = "^0.1"
sv-ttk = "^2.4.5"
tomli = { version = "^2.0.1", python = "<3.11" }
voicemeeter-api = "^0.7.0"
vban-cmd = "1.4.2"
voicemeeter-api = "^2.0.1"
vban-cmd = "^2.0.0"
[tool.poetry.dev-dependencies]
black = {version = "^22.6.0", allow-prereleases = true}
black = { version = "^22.6.0", allow-prereleases = true }
isort = "^5.12.0"
[build-system]
requires = ["poetry-core>=1.0.0"]

View File

@@ -1,11 +1,13 @@
import tkinter as tk
from functools import cached_property
from pathlib import Path
from tkinter import ttk
from typing import NamedTuple
from .builders import MainFrameBuilder
from .configurations import loader
from .data import _base_values, _configuration, _kinds_all
from .errors import VMCompactErrors
from .errors import VMCompactError
from .menu import Menus
from .subject import Subject
@@ -34,12 +36,14 @@ class App(tk.Tk):
super().__init__()
self._vmr = vmr
self._vmr.event.add("ldirty")
self._vmr.event.add(["pdirty", "ldirty"])
self._vmr.init_thread()
icon_path = Path(__file__).parent.resolve() / "img" / "cat.ico"
if icon_path.is_file():
self.iconbitmap(str(icon_path))
self.minsize(275, False)
self.subject = Subject()
self._configs = None
self["menu"] = Menus(self, vmr)
self.styletable = ttk.Style()
if _configuration.config:
@@ -50,6 +54,9 @@ class App(tk.Tk):
self.drag_id = ""
self.bind("<Configure>", self.dragging)
def __str__(self):
return f"{type(self).__name__}App"
@property
def target(self):
"""returns the current interface"""
@@ -74,8 +81,8 @@ class App(tk.Tk):
if kind:
self.kind = kind
# register app as observer
self.target.subject.add(self)
# register event callbacks
self.target.subject.add([self.on_pdirty, self.on_ldirty])
self.bus_frame = None
self.submix_frame = None
@@ -90,14 +97,13 @@ class App(tk.Tk):
if self.kind.name == "potato":
self.builder.create_banner()
def on_update(self, subject):
"""called whenever notified of update"""
def on_pdirty(self):
if _base_values.run_update:
self.after(1, self.subject.notify, "pdirty")
if not _base_values.in_scale_button_1:
if subject == "pdirty":
self.after(1, self.subject.notify, "pdirty")
elif subject == "ldirty" and not _base_values.dragging:
self.after(1, self.subject.notify, "ldirty")
def on_ldirty(self):
if not _base_values.dragging:
self.after(1, self.subject.notify, "ldirty")
def _destroy_top_level_frames(self):
"""
@@ -118,16 +124,19 @@ class App(tk.Tk):
def dragging(self, event, *args):
if event.widget is self:
if self.drag_id == "":
_base_values.in_scale_button_1 = True
_base_values.dragging = True
else:
self.after_cancel(self.drag_id)
self.drag_id = self.after(100, self.stop_drag)
def stop_drag(self):
_base_values.dragging = False
_base_values.in_scale_button_1 = False
self.drag_id = ""
_base_values.dragging = False
@cached_property
def userconfigs(self):
self._configs = loader(self.kind.name)
return self._configs
_apps = {kind.name: App.make(kind) for kind in _kinds_all}
@@ -139,5 +148,5 @@ def connect(kind_id: str, vmr) -> App:
try:
VMMIN_cls = _apps[kind_id]
except KeyError:
raise VMCompactErrors(f"Invalid kind: {kind_id}")
raise VMCompactError(f"Invalid kind: {kind_id}")
return VMMIN_cls(vmr)

View File

@@ -1,15 +1,19 @@
import logging
import tkinter as tk
from tkinter import ttk
from .data import _base_values, _configuration
logger = logging.getLogger(__name__)
class Banner(ttk.Frame):
def __init__(self, parent):
super().__init__()
self.parent = parent
self.submix = tk.StringVar()
self.submix.set(self.target.bus[_configuration.submixes].label)
self.parent.subject.add(self)
self.logger = logger.getChild(self.__class__.__name__)
self.submix = tk.StringVar(value=self.target.bus[_configuration.submixes].label)
self.label = ttk.Label(
self,
@@ -17,19 +21,15 @@ class Banner(ttk.Frame):
)
self.label.grid(column=0, row=0, sticky=(tk.N, tk.S, tk.W, tk.E))
self.upd_submix()
@property
def target(self):
"""returns the current interface"""
return self.parent.target
def upd_submix(self):
self.after(1, self.upd_submix_step)
def upd_submix_step(self):
if not _base_values.dragging:
self.submix.set(self.target.bus[_configuration.submixes].label)
self.label["text"] = f"SUBMIX: {self.submix.get().upper()}"
self.after(100, self.upd_submix_step)
def on_update(self, subject):
if subject == "submix":
if not _base_values.dragging:
self.logger.debug("checking submix for banner")
self.submix.set(self.target.bus[_configuration.submixes].label)
self.label["text"] = f"SUBMIX: {self.submix.get().upper()}"

View File

@@ -1,4 +1,5 @@
import abc
import logging
import tkinter as tk
from functools import partial
from tkinter import ttk
@@ -11,6 +12,8 @@ from .config import BusConfig, StripConfig
from .data import _base_values, _configuration
from .navigation import Navigation
logger = logging.getLogger(__name__)
class AbstractBuilder(abc.ABC):
@abc.abstractmethod
@@ -30,6 +33,7 @@ class MainFrameBuilder(AbstractBuilder):
def __init__(self, app):
self.kind = app.kind
self.app = app
self.logger = logger.getChild(self.__class__.__name__)
def setup(self):
self.app.title(
@@ -39,21 +43,26 @@ class MainFrameBuilder(AbstractBuilder):
if _configuration.themes_enabled:
if sv_ttk.get_theme() not in ("light", "dark"):
sv_ttk.set_theme(_configuration.theme_mode)
print(f"Sunvalley {sv_ttk.get_theme().capitalize()} Theme applied")
self.logger.info(
f"Sunvalley {sv_ttk.get_theme().capitalize()} Theme applied"
)
def create_channelframe(self, type_):
if type_ == "strip":
self.app.strip_frame = _make_channelframe(self.app, type_)
else:
self.app.bus_frame = _make_channelframe(self.app, type_)
self.logger.info(f"Finished building channelframe type {type_}")
def create_separator(self):
self.app.sep = ttk.Separator(self.app, orient="vertical")
self.app.sep.grid(row=0, column=1, sticky=(tk.N, tk.S))
self.app.columnconfigure(1, minsize=15)
self.logger.info(f"Finished building separator")
def create_navframe(self):
self.app.nav_frame = Navigation(self.app)
self.logger.info(f"Finished building navframe")
def create_configframe(self, type_, index, id):
if type_ == "strip":
@@ -99,6 +108,7 @@ class MainFrameBuilder(AbstractBuilder):
)
for _, frame in enumerate(self.app.bus_frame.labelframes)
]
self.logger.info(f"Finished building configframe for {type_}[{index}]")
self.app.after(5, self.reset_config_frames)
def reset_config_frames(self):
@@ -111,6 +121,7 @@ class MainFrameBuilder(AbstractBuilder):
def create_banner(self):
self.app.banner = Banner(self.app)
self.app.banner.grid(row=4, column=0, columnspan=3)
self.logger.info(f"Finished building banner")
def teardown(self):
pass
@@ -216,7 +227,7 @@ class ChannelLabelFrameBuilder(AbstractBuilder):
"""Adds a progress bar widget to a single label frame"""
self.labelframe.pb = ttk.Progressbar(
self.labelframe,
maximum=100,
maximum=72,
orient="vertical",
mode="determinate",
variable=self.labelframe.level,
@@ -326,7 +337,7 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder):
self.configframe.slider_params = ("audibility",)
self.configframe.slider_vars = (tk.DoubleVar(),)
else:
self.configframe.slider_params = ("comp", "gate", "limit")
self.configframe.slider_params = ("comp.knob", "gate.knob", "limit")
self.configframe.slider_vars = [
tk.DoubleVar() for _ in self.configframe.slider_params
]
@@ -383,16 +394,16 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder):
orient="horizontal",
length=_configuration.level_width,
variable=self.configframe.slider_vars[
self.configframe.slider_params.index("comp")
self.configframe.slider_params.index("comp.knob")
],
command=partial(self.configframe.scale_callback, "comp"),
command=partial(self.configframe.scale_callback, "comp.knob"),
)
comp_scale.bind(
"<Double-Button-1>", partial(self.configframe.reset_scale, "comp", 0)
"<Double-Button-1>", partial(self.configframe.reset_scale, "comp.knob", 0)
)
comp_scale.bind("<Button-1>", self.configframe.scale_press)
comp_scale.bind("<ButtonRelease-1>", self.configframe.scale_release)
comp_scale.bind("<Enter>", partial(self.configframe.scale_enter, "comp"))
comp_scale.bind("<Enter>", partial(self.configframe.scale_enter, "comp.knob"))
comp_scale.bind("<Leave>", self.configframe.scale_leave)
comp_label.grid(column=0, row=0)
@@ -407,16 +418,16 @@ class StripConfigFrameBuilder(ChannelConfigFrameBuilder):
orient="horizontal",
length=_configuration.level_width,
variable=self.configframe.slider_vars[
self.configframe.slider_params.index("gate")
self.configframe.slider_params.index("gate.knob")
],
command=partial(self.configframe.scale_callback, "gate"),
command=partial(self.configframe.scale_callback, "gate.knob"),
)
gate_scale.bind(
"<Double-Button-1>", partial(self.configframe.reset_scale, "gate", 0)
"<Double-Button-1>", partial(self.configframe.reset_scale, "gate.knob", 0)
)
gate_scale.bind("<Button-1>", self.configframe.scale_press)
gate_scale.bind("<ButtonRelease-1>", self.configframe.scale_release)
gate_scale.bind("<Enter>", partial(self.configframe.scale_enter, "gate"))
gate_scale.bind("<Enter>", partial(self.configframe.scale_enter, "gate.knob"))
gate_scale.bind("<Leave>", self.configframe.scale_leave)
gate_label.grid(column=2, row=0)
@@ -553,7 +564,7 @@ class BusConfigFrameBuilder(ChannelConfigFrameBuilder):
}
self.configframe.bus_modes = list(self.configframe.bus_mode_map.keys())
# fmt: on
self.configframe.params = ("mono", "eq", "eq_ab")
self.configframe.params = ("mono", "eq.on", "eq.ab")
self.configframe.param_vars = [tk.BooleanVar() for _ in self.configframe.params]
self.configframe.bus_mode_label_text = tk.StringVar(
value=self.configframe.bus_mode_map[self.configframe.current_bus_mode()]

View File

@@ -1,10 +1,12 @@
import logging
import tkinter as tk
from math import log
from tkinter import ttk
from . import builders
from .data import _base_values, _configuration
logger = logging.getLogger(__name__)
class ChannelLabelFrame(ttk.LabelFrame):
"""Base class for a single channel"""
@@ -14,6 +16,7 @@ class ChannelLabelFrame(ttk.LabelFrame):
self.parent = parent
self.index = index
self.id = id
self.logger = logger.getChild(self.__class__.__name__)
self.styletable = self.parent.parent.styletable
self.builder = builders.ChannelLabelFrameBuilder(self, index, id)
@@ -40,18 +43,21 @@ class ChannelLabelFrame(ttk.LabelFrame):
return self.parent.target
def getter(self, param):
if hasattr(self.target, param):
try:
return getattr(self.target, param)
except AttributeError as e:
self.logger(f"{type(e).__name__}: {e}")
def setter(self, param, value):
if hasattr(self.target, param):
if param in dir(self.target): # avoid calling getattr (with hasattr)
setattr(self.target, param, value)
def scale_callback(self, *args):
"""callback function for scale widget"""
self.setter("gain", self.gain.get())
self.gainlabel.set(round(self.gain.get(), 1))
val = round(self.gain.get(), 1)
self.setter("gain", val)
self.gainlabel.set(val)
def toggle_mute(self, *args):
self.target.mute = self.mute.get()
@@ -64,15 +70,29 @@ class ChannelLabelFrame(ttk.LabelFrame):
def reset_gain(self, *args):
self.setter("gain", 0)
self.gain.set(0)
self.gainlabel.set(self.gain.get())
def scale_press(self, *args):
_base_values.in_scale_button_1 = True
self.after(1, self.remove_events)
def remove_events(self):
self.parent.target.event.remove("pdirty")
self.parent.target.event.remove("ldirty")
def scale_release(self, *args):
_base_values.in_scale_button_1 = False
_base_values.run_update = False
self.after(1, self.add_events)
def add_events(self):
self.parent.target.event.add("pdirty")
self.parent.target.event.add("ldirty")
self.after(500, self.resume_updates)
def resume_updates(self):
_base_values.run_update = True
def _on_mousewheel(self, event):
_base_values.in_scale_button_1 = True
_base_values.run_update = False
self.gain.set(
self.gain.get()
+ (
@@ -86,7 +106,7 @@ class ChannelLabelFrame(ttk.LabelFrame):
elif self.gain.get() < -60:
self.gain.set(-60)
self.setter("gain", self.gain.get())
_base_values.in_scale_button_1 = False
self.after(1, self.resume_updates)
def open_config(self):
if self.conf.get():
@@ -172,7 +192,7 @@ class Strip(ChannelLabelFrame):
if self.target.levels.is_updated:
val = max(self.target.levels.prefader)
self.level.set(
(0 if self.mute.get() else 100 + val - 18 + self.gain.get())
(0 if self.mute.get() else 72 + val - 12 + self.gain.get())
)
@@ -194,7 +214,7 @@ class Bus(ChannelLabelFrame):
if self.index < self.parent.parent.kind.num_bus:
if self.target.levels.is_updated or self.level.get() != -118:
val = max(self.target.levels.all)
self.level.set((0 if self.mute.get() else 100 + val - 18))
self.level.set((0 if self.mute.get() else 72 + val - 12))
class ChannelFrame(ttk.Frame):

View File

@@ -1,10 +1,11 @@
import tkinter as tk
from functools import partial
import logging
from tkinter import ttk
from . import builders
from .data import _base_values, _configuration
logger = logging.getLogger(__name__)
class Config(ttk.Frame):
def __init__(self, parent, index, _id):
@@ -12,6 +13,7 @@ class Config(ttk.Frame):
self.parent = parent
self.index = index
self.id = _id
self.logger = logger.getChild(self.__class__.__name__)
self.styletable = parent.styletable
self.phys_in, self.virt_in = parent.kind.ins
self.phys_out, self.virt_out = parent.kind.outs
@@ -29,18 +31,45 @@ class Config(ttk.Frame):
return self.parent.target
def getter(self, param):
if hasattr(self.target, param):
return getattr(self.target, param)
param = param.split(".")
try:
if len(param) == 2:
target = getattr(self.target, param[0])
return getattr(target, param[1])
else:
return getattr(self.target, param[0])
except AttributeError as e:
self.logger.error(f"{type(e).__name__}: {e}")
def setter(self, param, value):
if hasattr(self.target, param):
setattr(self.target, param, value)
param = param.split(".")
try:
if len(param) == 2:
target = getattr(self.target, param[0])
setattr(target, param[1], value)
else:
setattr(self.target, param[0], value)
except AttributeError as e:
self.logger(f"{type(e).__name__}: {e}")
def scale_press(self, *args):
_base_values.in_scale_button_1 = True
self.after(1, self.remove_events)
def remove_events(self):
self.parent.target.event.remove("pdirty")
self.parent.target.event.remove("ldirty")
def scale_release(self, *args):
_base_values.in_scale_button_1 = False
_base_values.run_update = False
self.after(1, self.add_events)
def add_events(self):
self.parent.target.event.add("pdirty")
self.parent.target.event.add("ldirty")
self.after(350, self.resume_updates)
def resume_updates(self):
_base_values.run_update = True
def scale_enter(self, param, *args):
val = self.slider_vars[self.slider_params.index(param)].get()
@@ -53,7 +82,7 @@ class Config(ttk.Frame):
"""callback function for scale widget"""
val = self.slider_vars[self.slider_params.index(param)].get()
self.setter(param, val)
self.setter(param, round(val, 1))
self.parent.nav_frame.info_text.set(round(val, 1))
def reset_scale(self, param, val, *args):
@@ -85,6 +114,7 @@ class StripConfig(Config):
self.make_row_2()
self.builder.grid_configure()
self.parent.target.clear_dirty()
self.sync()
@property
@@ -142,6 +172,12 @@ class StripConfig(Config):
self.param_vars[i].set(self.getter(param))
for i, param in enumerate(self.params)
]
if not _base_values.vban_connected: # slider vars not defined in RT Packet
[
self.slider_vars[i].set(self.getter(param))
for i, param in enumerate(self.slider_params)
if self.index < self.phys_in
]
if not _configuration.themes_enabled:
[
@@ -180,6 +216,7 @@ class BusConfig(Config):
self.make_row_1()
self.builder.grid_configure()
self.parent.target.clear_dirty()
self.sync()
@property

View File

@@ -1,3 +1,4 @@
import logging
from pathlib import Path
try:
@@ -5,24 +6,32 @@ try:
except ModuleNotFoundError:
import tomli as tomllib
logger = logging.getLogger(__name__)
configuration = {}
config_path = [Path.cwd() / "configs"]
for path in config_path:
if path.is_dir():
filenames = list(path.glob("*.toml"))
configs = {}
for filename in filenames:
name = filename.with_suffix("").stem
try:
with open(filename, "rb") as f:
configs[name] = tomllib.load(f)
except tomllib.TOMLDecodeError:
print(f"Invalid TOML config: configs/{filename.stem}")
configpaths = [
Path.cwd() / "configs",
Path.home() / ".config" / "vm-compact" / "configs",
Path.home() / "Documents" / "Voicemeeter" / "configs",
]
for configpath in configpaths:
if configpath.is_dir():
filepaths = list(configpath.glob("*.toml"))
if any(f.stem in ("app", "vban") for f in filepaths):
configs = {}
for filepath in filepaths:
filename = filepath.with_suffix("").stem
if filename in ("app", "vban"):
try:
with open(filepath, "rb") as f:
configs[filename] = tomllib.load(f)
logger.info(f"configuration: {filename} loaded into memory")
except tomllib.TOMLDecodeError:
logger.error(f"Invalid TOML config: configs/{filename.stem}")
for name, cfg in configs.items():
print(f"Loaded configuration configs/{name}")
configuration[name] = cfg
configuration |= configs
break
_defaults = {
"configs": {
@@ -57,3 +66,19 @@ else:
def get_configuration(key):
if key in configuration:
return configuration[key]
def loader(kind_id):
configs = {}
userconfigpath = Path.home() / ".config" / "vm-compact" / "configs" / kind_id
if userconfigpath.exists():
filepaths = list(userconfigpath.glob("*.toml"))
for filepath in filepaths:
identifier = filepath.with_suffix("").stem
try:
with open(filepath, "rb") as f:
configs[identifier] = tomllib.load(f)
logger.info(f"loader: {identifier} loaded into memory")
except tomllib.TOMLDecodeError:
logger.error(f"Invalid TOML config: configs/{filename.stem}")
return configs

View File

@@ -45,8 +45,8 @@ class Configurations(metaclass=SingletonMeta):
@dataclass
class BaseValues(metaclass=SingletonMeta):
# are we dragging a scale with mouse 1
in_scale_button_1: bool = False
# pause updates after releasing scale
run_update: bool = True
# are we dragging main window with mouse 1
dragging: bool = False
# a vban connection established

View File

@@ -1,4 +1,2 @@
class VMCompactErrors(Exception):
"""Base classs for VMCompact Errors"""
pass
class VMCompactError(Exception):
"""Exception raised when general errors occur"""

View File

@@ -1,5 +1,4 @@
import tkinter as tk
from math import log
from tkinter import ttk
from . import builders
@@ -42,31 +41,48 @@ class GainLayer(ttk.LabelFrame):
return "gainlayer"
def getter(self, param):
if hasattr(self.target, param):
try:
return getattr(self.target, param)
except AttributeError as e:
self.logger(f"{type(e).__name__}: {e}")
def setter(self, param, value):
if hasattr(self.target, param):
if param in dir(self.target): # avoid calling getattr (with hasattr)
setattr(self.target, param, value)
def reset_gain(self, *args):
self.setter("gain", 0)
self.gain.set(0)
self.gainlabel.set(0)
self.gainlabel.set(self.gain.get())
def scale_callback(self, *args):
"""callback function for scale widget"""
self.setter("gain", self.gain.get())
self.gainlabel.set(round(self.gain.get(), 1))
val = round(self.gain.get(), 1)
self.setter("gain", val)
self.gainlabel.set(val)
def scale_press(self, *args):
_base_values.in_scale_button_1 = True
self.after(1, self.remove_events)
def remove_events(self):
self.parent.target.event.remove("pdirty")
self.parent.target.event.remove("ldirty")
def scale_release(self, *args):
_base_values.in_scale_button_1 = False
_base_values.run_update = False
self.after(1, self.add_events)
def add_events(self):
self.parent.target.event.add("pdirty")
self.parent.target.event.add("ldirty")
self.after(500, self.resume_updates)
def resume_updates(self):
_base_values.run_update = True
def _on_mousewheel(self, event):
_base_values.run_update = False
self.gain.set(
self.gain.get()
+ (
@@ -80,6 +96,7 @@ class GainLayer(ttk.LabelFrame):
elif self.gain.get() < -60:
self.gain.set(-60)
self.setter("gain", self.gain.get())
self.after(1, self.resume_updates)
def set_on(self):
"""enables a gainlayer. sets its button colour"""
@@ -142,8 +159,9 @@ class GainLayer(ttk.LabelFrame):
self.level.set(
(
0
if self.parent.target.strip[self.index].mute or not self.on.get()
else 100 + val - 18 + self.gain.get()
if self.parent.parent.strip_frame.strips[self.index].mute.get()
or not self.on.get()
else 72 + val - 12 + self.gain.get()
)
)

View File

@@ -1,19 +1,24 @@
import logging
import tkinter as tk
import webbrowser
from functools import partial
from tkinter import messagebox, ttk
from tkinter import messagebox
import sv_ttk
import vban_cmd
from vban_cmd.error import VBANCMDConnectionError
from .data import _base_values, _configuration, get_configuration, kind_get
logger = logging.getLogger(__name__)
class Menus(tk.Menu):
def __init__(self, parent, vmr):
super().__init__()
self.parent = parent
self.vmr = vmr
self.logger = logger.getChild(self.__class__.__name__)
self.vban_config = get_configuration("vban")
self.app_config = get_configuration("app")
self._is_topmost = tk.BooleanVar()
@@ -88,6 +93,14 @@ class Menus(tk.Menu):
for profile in self.target.configs.keys()
if profile not in self.config_defaults
]
elif self.parent.userconfigs:
[
self.menu_configs_load.add_command(
label=name, command=partial(self.load_custom_profile, data)
)
for name, data in self.parent.userconfigs.items()
if name not in self.config_defaults
]
else:
self.menu_configs.entryconfig(0, state="disabled")
self.menu_configs.add_command(
@@ -208,15 +221,24 @@ class Menus(tk.Menu):
self._unlock.set(not self._lock.get())
setattr(self.target.command, cmd, val)
def load_custom_profile(self, profile):
self.logger.info(f"loading user profile {profile}")
self.target.apply(profile)
def load_profile(self, profile):
self.logger.info(f"loading user profile {profile}")
self.target.apply_config(profile)
def load_defaults(self):
resp = messagebox.askyesno(
message="Are you sure you want to Reset values to defaults?\nPhysical strips B1, Virtual strips A1\nMono, Solo, Mute, EQ all OFF"
msg = (
"Are you sure you want to Reset values to defaults?",
"Physical strips B1, Virtual strips A1",
"Mono, Solo, Mute, EQ all OFF",
"Gain sliders for Strip/Bus at 0.0",
)
resp = messagebox.askyesno(message="\n".join(msg))
if resp:
self.target.apply_config("reset")
self.load_profile("reset")
def always_on_top(self):
self.parent.attributes("-topmost", self._is_topmost.get())
@@ -238,6 +260,7 @@ class Menus(tk.Menu):
self.parent.nav_frame.show_submix()
for j, var in enumerate(self._selected_bus):
var.set(i == j)
self.parent.subject.notify("submix")
def load_theme(self, theme):
sv_ttk.set_theme(theme)
@@ -267,12 +290,20 @@ class Menus(tk.Menu):
for menu in self.menu_layout.winfo_children()
if isinstance(menu, tk.Menu)
]
self.logger.info(
f"Finished loading theme Sunvalley {sv_ttk.get_theme().capitalize()} theme"
)
def vban_connect(self, i):
def menu_teardown(self, i):
# remove config load menus
[
self.menu_configs_load.delete(key)
for key in self.vmr.configs.keys()
for key in self.target.configs.keys()
if key not in self.config_defaults
]
[
self.menu_configs_load.delete(key)
for key in self.parent.userconfigs.keys()
if key not in self.config_defaults
]
@@ -282,13 +313,50 @@ class Menus(tk.Menu):
if j != i
]
def menu_setup(self):
if len(self.target.configs) > len(self.config_defaults) and all(
key in self.target.configs for key in self.config_defaults
):
[
self.menu_configs_load.add_command(
label=profile, command=partial(self.load_profile, profile)
)
for profile in self.target.configs.keys()
if profile not in self.config_defaults
]
elif self.parent.userconfigs:
[
self.menu_configs_load.add_command(
label=name, command=partial(self.load_custom_profile, data)
)
for name, data in self.parent.userconfigs.items()
if name not in self.config_defaults
]
else:
self.menu_configs.entryconfig(0, state="disabled")
def vban_connect(self, i):
opts = {}
opts |= self.vban_config[f"connection-{i+1}"]
kind_id = opts.pop("kind")
self.vban = vban_cmd.api(kind_id, **opts)
# login to vban interface
self.vban.login()
self.vban.event.add("ldirty")
try:
self.logger.info(f"Attempting vban connection to {opts.get('ip')}")
self.vban.login()
except VBANCMDConnectionError as e:
self.vban.logout()
msg = (
f"Timeout attempting to establish connection to {opts.get('ip')}",
f"Please check your connection settings",
)
messagebox.showerror("Connection Error", "\n".join(msg))
msg = (str(e), f"resuming local connection")
self.logger.error(", ".join(msg))
self.after(1, self.enable_vban_menus)
return
self.menu_teardown(i)
self.vban.event.add(["pdirty", "ldirty"])
# destroy the current App frames
self.parent._destroy_top_level_frames()
_base_values.vban_connected = True
@@ -303,27 +371,15 @@ class Menus(tk.Menu):
self.menu_layout.entryconfig(
0, state=f"{'normal' if kind.name == 'potato' else 'disabled'}"
)
# rebuild config load menus
if len(self.target.configs) > len(self.config_defaults) and all(
key in self.target.configs for key in self.config_defaults
):
[
self.menu_configs_load.add_command(
label=profile, command=partial(self.load_profile, profile)
)
for profile in self.target.configs.keys()
if profile not in self.config_defaults
]
else:
self.menu_configs.entryconfig(0, state="disabled")
# ensure the configs are reloaded into memory
if "config" in self.parent.target.__dict__:
del self.parent.target.__dict__["config"]
if "userconfigs" in self.parent.__dict__:
del self.parent.__dict__["userconfigs"]
self.menu_setup()
def vban_disconnect(self, i):
# remove config load menus
[
self.menu_configs_load.delete(key)
for key in self.vban.configs.keys()
if key not in self.config_defaults
]
self.menu_teardown(i)
# destroy the current App frames
self.parent._destroy_top_level_frames()
@@ -340,19 +396,12 @@ class Menus(tk.Menu):
self.menu_layout.entryconfig(
0, state=f"{'normal' if kind.name == 'potato' else 'disabled'}"
)
# rebuild config load menus
if len(self.target.configs) > len(self.config_defaults) and all(
key in self.target.configs for key in self.config_defaults
):
[
self.menu_configs_load.add_command(
label=profile, command=partial(self.load_profile, profile)
)
for profile in self.target.configs.keys()
if profile not in self.config_defaults
]
else:
self.menu_configs.entryconfig(0, state="disabled")
# ensure the configs are reloaded into memory
if "config" in self.parent.target.__dict__:
del self.parent.target.__dict__["config"]
if "userconfigs" in self.parent.__dict__:
del self.parent.__dict__["userconfigs"]
self.menu_setup()
self.after(15000, self.enable_vban_menus)

View File

@@ -1,3 +1,4 @@
import logging
import tkinter as tk
from tkinter import ttk
@@ -5,11 +6,14 @@ from . import builders
from .data import _configuration
from .gainlayer import SubMixFrame
logger = logging.getLogger(__name__)
class Navigation(ttk.Frame):
def __init__(self, parent):
super().__init__(parent)
self.parent = parent
self.logger = logger.getChild(self.__class__.__name__)
self.grid(row=0, column=3, padx=(0, 2), pady=(5, 5), sticky=(tk.W, tk.E))
self.styletable = self.parent.styletable
@@ -26,6 +30,9 @@ class Navigation(ttk.Frame):
def show_submix(self):
if self.submix.get():
self.parent.submix_frame = SubMixFrame(self.parent)
self.logger.info(
f"Finished building submixframe for submix {_configuration.submixes}"
)
else:
if _configuration.extends_horizontal:
self.parent.submix_frame.teardown()
@@ -39,6 +46,9 @@ class Navigation(ttk.Frame):
self.parent.bus_frame.grid()
else:
self.parent.rowconfigure(2, weight=0, minsize=0)
self.logger.info(
f"Finished tearing down submixframe for submix {_configuration.submixes}"
)
if not _configuration.themes_enabled:
self.styletable.configure(
@@ -84,4 +94,4 @@ class Navigation(ttk.Frame):
background=f'{"purple" if self.submix.get() else "white"}',
)
self.extend_text.set("REDUCE" if self.extend.get() else "EXTEND")
self.extend_text.set("REDUCE" if self.extend.get() else "EXTEND")