Skip to content

Interactive trim prompt and clean Ctrl+C exit on Windows - #2

Merged
Xehanort88 merged 2 commits into
masterfrom
add-test-suite
Sep 23, 2026
Merged

Xehanort88 merged 2 commits into
masterfrom
add-test-suite

Conversation

@Xehanort88

Copy link
Copy Markdown
Owner

Summary

  • Offer to trim after the loop end in interactive mode. After a loop is chosen, the export commands (tag, split-audio, extend, export-points) ask whether to losslessly trim the file after the loop end, and how many samples to keep (Enter = 100). The prompt only appears for formats that support lossless trimming (PCM/float WAV, FLAC, Ogg Vorbis), and not for trim itself.
    • With tag, a single copy is written that is both tagged and trimmed (name-tagged.ext), instead of separate tagged and trimmed files.
    • 100 samples (~2 ms at 44.1 kHz) is the default because some players/engines read slightly past the loop end (off-by-one or resampler lookahead).
    • Adds MusicLooper.supports_lossless_trim() and trim/keep_after options to MusicLooper.export_tags().
  • Exit cleanly on Ctrl+C at the interactive prompt on Windows. Ctrl+C at an input() prompt can surface as EOFError, with the real interrupt arriving moments later. This printed an empty ERROR line followed by a KeyboardInterrupt traceback from sounddevice's PortAudio cleanup at exit. Both are now handled, and further Ctrl+C is ignored while exiting.

Testing

  • uv run pytest: 105 passed, including new tests for the trim prompt (answers, invalid input, interrupts), the combined tag + trim output for FLAC and Ogg Vorbis, format support detection, and prompt skipping for unsupported formats and the trim command.
  • Ran pymusiclooper -s -i tag ... --tag-names LOOPSTART LOOPLENGTH end to end on a generated WAV: one tagged file was written, cut at the expected sample.

After the loop is chosen, export commands ask whether to trim WAV, FLAC and Ogg Vorbis files after the loop end, and how many samples to keep (100 by default). With tag, a single tagged and trimmed copy is written.
@Xehanort88
Xehanort88 merged commit 8943ebf into master Sep 23, 2026
8 checks passed
@Xehanort88
Xehanort88 deleted the add-test-suite branch September 27, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant