Initial commit
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
# Copyright (C) 2026 Seth Hillbrand
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
"""Audio settings section."""
|
||||
|
||||
from PySide6.QtCore import Signal
|
||||
from PySide6.QtWidgets import QWidget, QHBoxLayout, QLabel, QComboBox
|
||||
|
||||
from ..widgets import CollapsibleSection, ParamSlider, ToggleSwitch
|
||||
|
||||
NOISE_LEVELS = ["Close", "Weak", "Middle", "Strong"]
|
||||
REVERB_LEVELS = ["Close", "Weak", "Middle", "Strong"]
|
||||
|
||||
|
||||
class AudioSection(CollapsibleSection):
|
||||
"""Collapsible panel for audio settings."""
|
||||
|
||||
param_changed = Signal(str, object)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__("Audio Settings", parent)
|
||||
|
||||
self.volume_slider = ParamSlider("Volume", min_val=0, max_val=100, default=50, step=1)
|
||||
self.volume_slider.value_changed.connect(lambda v: self.param_changed.emit("au-volume", v))
|
||||
self.add_widget(self.volume_slider)
|
||||
|
||||
self.noise_combo = QComboBox()
|
||||
self.noise_combo.addItems(NOISE_LEVELS)
|
||||
self.noise_combo.setCurrentIndex(2)
|
||||
self.noise_combo.currentIndexChanged.connect(
|
||||
lambda idx: self.param_changed.emit("au-denoise", idx)
|
||||
)
|
||||
self.add_widget(self._labeled("Noise Reduction", self.noise_combo))
|
||||
|
||||
self.delay_slider = ParamSlider("Audio Delay", min_val=0, max_val=400, default=0, step=1, suffix="ms")
|
||||
self.delay_slider.value_changed.connect(lambda v: self.param_changed.emit("au-delay", v))
|
||||
self.add_widget(self.delay_slider)
|
||||
|
||||
self.auto_gain_toggle = ToggleSwitch(checked=True)
|
||||
self.auto_gain_toggle.toggled.connect(lambda v: self.param_changed.emit("au-gain", v))
|
||||
self._auto_gain_row = self._toggle_row("Auto Gain", self.auto_gain_toggle)
|
||||
self.add_widget(self._auto_gain_row)
|
||||
|
||||
self.reverb_combo = QComboBox()
|
||||
self.reverb_combo.addItems(REVERB_LEVELS)
|
||||
self.reverb_combo.currentIndexChanged.connect(
|
||||
lambda idx: self.param_changed.emit("au-reverb", idx)
|
||||
)
|
||||
self.add_widget(self._labeled("Reverb", self.reverb_combo))
|
||||
|
||||
@staticmethod
|
||||
def _labeled(text: str, widget: QWidget) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(110)
|
||||
layout.addWidget(lbl)
|
||||
layout.addWidget(widget)
|
||||
layout.addStretch()
|
||||
return row
|
||||
|
||||
@staticmethod
|
||||
def _toggle_row(text: str, toggle: ToggleSwitch) -> QWidget:
|
||||
row = QWidget()
|
||||
layout = QHBoxLayout(row)
|
||||
layout.setContentsMargins(0, 2, 0, 2)
|
||||
layout.setSpacing(8)
|
||||
lbl = QLabel(text)
|
||||
lbl.setFixedWidth(170)
|
||||
layout.addWidget(lbl)
|
||||
layout.addStretch()
|
||||
layout.addWidget(toggle)
|
||||
return row
|
||||
|
||||
def set_volume(self, value: int):
|
||||
self.volume_slider.set_value(float(value), emit=False)
|
||||
|
||||
def set_noise_reduction(self, value: int):
|
||||
self.noise_combo.blockSignals(True)
|
||||
self.noise_combo.setCurrentIndex(value)
|
||||
self.noise_combo.blockSignals(False)
|
||||
|
||||
def set_delay(self, value: int):
|
||||
self.delay_slider.set_value(float(value), emit=False)
|
||||
|
||||
def set_auto_gain(self, enabled: bool):
|
||||
self.auto_gain_toggle.set_checked(enabled, emit=False)
|
||||
|
||||
def set_reverb(self, value: int):
|
||||
self.reverb_combo.blockSignals(True)
|
||||
self.reverb_combo.setCurrentIndex(value)
|
||||
self.reverb_combo.blockSignals(False)
|
||||
Reference in New Issue
Block a user