added default volume

This commit is contained in:
Hannes committed 2026-09-14 00:47:15 +02:00
1 parent 05d6c6539b
commit c06c7fbc69
2 files changed
+11 -9

No files matched your search

+8 -7
View File
@@ -79,11 +79,12 @@ def decimate_with_peak(arr: np.ndarray, peak_idx: int, max_pts: int = 200_000) -
return out, idx_out
def find_wavs_from_config(cfg: dict) -> tuple[str, str, int, float, float]:
def find_wavs_from_config(cfg: dict) -> tuple[str, str, int, float, float, int]:
audio_cfg = cfg.get("audio", {})
extract_cfg = cfg.get("extract", {})
sync_cfg = cfg.get("sync", {})
sr = int(audio_cfg.get("sample_rate", 48000))
volume = int(audio_cfg.get("volume"))
# priority: explicit wav paths else derived from extracted dir
a_wav = audio_cfg.get("file_a_wav")
b_wav = audio_cfg.get("file_b_wav")
@@ -109,12 +110,12 @@ def find_wavs_from_config(cfg: dict) -> tuple[str, str, int, float, float]:
duration = extract_cfg.get("duration", 90)
start = float(extract_cfg.get("start", 0.0))
# duration_sec comment: only duration needed is off the extract — we respect that
return a_wav, b_wav, sr, float(start), float(duration)
return a_wav, b_wav, sr, float(start), float(duration), volume
class SyncWindow(QtWidgets.QMainWindow):
def __init__(self, a_path: str, b_path: str, sr: int = 48000, method: str = "phat", device: str = "auto",
video_a: str = "", video_b: str = "", out_dir: str = "output"):
video_a: str = "", video_b: str = "", out_dir: str = "output", volume: int = 30):
super().__init__()
self.setWindowTitle(f"movie_sync — audio sync test — {device_info()}")
self.resize(1400, 900)
@@ -253,10 +254,10 @@ class SyncWindow(QtWidgets.QMainWindow):
ctr2.addWidget(QtWidgets.QLabel("Volume:"))
self.vol = QtWidgets.QSlider(QtCore.Qt.Orientation.Horizontal)
self.vol.setRange(0, 100)
self.vol.setValue(70)
self.vol.setValue(volume)
self.vol.setMaximumWidth(200)
ctr2.addWidget(self.vol)
self.vol_label = QtWidgets.QLabel("70%")
self.vol_label = QtWidgets.QLabel(f"{volume}%")
ctr2.addWidget(self.vol_label)
self.btn_play_a = QtWidgets.QPushButton("Play A")
@@ -507,7 +508,7 @@ def main():
args = ap.parse_args()
cfg = load_config(args.config)
cfg_a, cfg_b, sr, _, _ = find_wavs_from_config(cfg)
cfg_a, cfg_b, sr, _, _, volume = find_wavs_from_config(cfg)
a_path = args.a or cfg_a
b_path = args.b or cfg_b
method = args.method or cfg.get("sync", {}).get("method", "phat")
@@ -554,7 +555,7 @@ def main():
app.setPalette(dark)
pg.setConfigOptions(antialias=True, background="#1e1e1e", foreground="#ddd")
w = SyncWindow(a_path, b_path, sr=sr, method=method, device=device,
video_a=video_a, video_b=video_b, out_dir=out_dir)
video_a=video_a, video_b=video_b, out_dir=out_dir, volume=volume)
w.show()
sys.exit(app.exec())