Add stereo options to GUI

pull/357/head
nyanpasu64 2019-01-22 22:12:35 -08:00
rodzic b2a228ea53
commit 4b394ab465
3 zmienionych plików z 64 dodań i 9 usunięć

Wyświetl plik

@ -1,10 +1,9 @@
import functools
import os
import sys
import traceback
from pathlib import Path
from types import MethodType
from typing import Type, Optional, List, Any, Tuple, Callable, Union
from typing import Type, Optional, List, Any, Tuple, Callable, Union, Dict
import PyQt5.QtCore as qc
import PyQt5.QtWidgets as qw
@ -26,6 +25,7 @@ from corrscope.gui.data_bind import (
behead,
rgetattr,
rsetattr,
Symbol,
)
from corrscope.gui.history_file_dlg import (
get_open_file_name,
@ -37,6 +37,7 @@ from corrscope.outputs import IOutputConfig, FFplayOutputConfig, FFmpegOutputCon
from corrscope.settings import paths
from corrscope.triggers import CorrelationTriggerConfig, ITriggerConfig
from corrscope.util import obj_name
from corrscope.wave import Flatten
FILTER_WAV_FILES = ["WAV files (*.wav)"]
@ -627,13 +628,32 @@ def path_fix_property(path: str) -> property:
return property(getter, setter)
flatten_modes = {
Flatten.SumAvg: "Average: (L+R)/2",
Flatten.DiffAvg: "DiffAvg: (L-R)/2",
Flatten.Sum: "Sum: (L+R)",
Flatten.Diff: "Difference: (L-R)",
Flatten.Stereo: "Stereo (broken)",
}
assert set(flatten_modes.keys()) == set(Flatten.modes)
flatten_symbols = list(flatten_modes.keys())
flatten_text = list(flatten_modes.values())
class ConfigModel(PresentationModel):
cfg: Config
combo_symbols = {}
combo_text = {}
combo_symbols: Dict[str, List[Symbol]] = {}
combo_text: Dict[str, List[str]] = {}
master_audio = path_fix_property("master_audio")
# Stereo flattening
for path in ["trigger_stereo", "render_stereo"]:
combo_symbols[path] = flatten_symbols
combo_text[path] = flatten_text
del path
render__bg_color = color2hex_property("render__bg_color")
render__init_line_color = color2hex_property("render__init_line_color")
render__grid_color = color2hex_maybe_property("render__grid_color")

Wyświetl plik

@ -1,6 +1,6 @@
import functools
import operator
from typing import Optional, List, Callable, Dict, Any, ClassVar, TYPE_CHECKING
from typing import Optional, List, Callable, Dict, Any, ClassVar, TYPE_CHECKING, Union
from PyQt5 import QtWidgets as qw, QtCore as qc
from PyQt5.QtCore import pyqtSlot
@ -13,6 +13,9 @@ from corrscope.util import obj_name, perr
if TYPE_CHECKING:
from corrscope.gui import MainWindow
from enum import Enum
assert Enum
__all__ = ["PresentationModel", "map_gui", "behead", "rgetattr", "rsetattr"]
@ -20,6 +23,9 @@ __all__ = ["PresentationModel", "map_gui", "behead", "rgetattr", "rsetattr"]
WidgetUpdater = Callable[[], None]
Symbol = Union[str, "Enum"]
class PresentationModel(qc.QObject):
""" Key-value MVP presentation-model.
@ -30,7 +36,7 @@ class PresentationModel(qc.QObject):
# These fields are specific to each subclass, and assigned there.
# Although less explicit, these can be assigned using __init_subclass__.
combo_symbols: Dict[str, List[str]]
combo_symbols: Dict[str, List[Symbol]]
combo_text: Dict[str, List[str]]
edited = qc.pyqtSignal()
@ -202,8 +208,8 @@ class BoundDoubleSpinBox(qw.QDoubleSpinBox, BoundWidget):
class BoundComboBox(qw.QComboBox, BoundWidget):
combo_symbols: List[str]
symbol2idx: Dict[str, int]
combo_symbols: List[Symbol]
symbol2idx: Dict[Symbol, int]
# noinspection PyAttributeOutsideInit
def bind_widget(self, model: PresentationModel, path: str) -> None:
@ -222,7 +228,7 @@ class BoundComboBox(qw.QComboBox, BoundWidget):
BoundWidget.bind_widget(self, model, path)
# combobox.index = pmodel.attr
def set_gui(self, symbol: str):
def set_gui(self, symbol: Symbol):
combo_index = self.symbol2idx[symbol]
self.setCurrentIndex(combo_index)

Wyświetl plik

@ -245,6 +245,35 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="optionStereo">
<property name="title">
<string>Stereo Downmixing</string>
</property>
<layout class="QFormLayout" name="formLayout_6">
<item row="0" column="0">
<widget class="QLabel" name="trigger_stereoL">
<property name="text">
<string>Trigger Stereo</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="BoundComboBox" name="trigger_stereo"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="render_stereoL">
<property name="text">
<string>Render Stereo</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="BoundComboBox" name="render_stereo"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">