refactor: cap waveform decode length + guard frombuffer + tighten test

This commit is contained in:
2026-07-02 15:00:34 +02:00
parent 12eaa944a7
commit 7501c4729b
3 changed files with 11 additions and 2 deletions
+6 -1
View File
@@ -6511,12 +6511,17 @@ class MainWindow(QMainWindow):
from core.waveform import load_region_samples, peaks
start = self._cursor
dur = self._spn_audio_len.value()
preview = min(dur, 120.0) # cap decode; the strip is 128 bars regardless
QApplication.setOverrideCursor(Qt.CursorShape.WaitCursor)
try:
samples = load_region_samples(self._file_path, start, dur)
samples = load_region_samples(self._file_path, start, preview)
finally:
QApplication.restoreOverrideCursor()
self._wave.set_peaks(peaks(samples))
if samples.size == 0:
self._show_status("Waveform: no audio decoded", 3000)
elif preview < dur:
self._show_status(f"Waveform shows first {preview:.0f}s of {dur:.0f}s", 4000)
def _on_extract_audio(self) -> None:
"""Extract an exact-length audio slice starting at the playhead and