refactor: cap waveform decode length + guard frombuffer + tighten test
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user