Repository navigation
Preserve metadata when trimming, support WAV smpl loops, and trim/tag fixes - #3
Merged
Merged
Conversation
…rt offset - Trim WAV files at the chunk level: every chunk is copied verbatim (tags, sampler loops, cue points, bext, the exact format chunk), only the data chunk is shortened and the fact sample count updated. - Restore the source's FLAC metadata blocks (tags, cover art, application blocks, padding, surrounding ID3 tags) onto the re-encoded audio, dropping only the seek table and cue sheet, which point into the old audio. - Log a warning instead of silently ignoring failures to copy tags. - Trim Ogg Vorbis streams whose granule positions start past 0 at the right sample, as decoders number samples from the stream's start granule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QTLaHUDYw58dcfrK65spTz
…pe embedded loops - Read loop points from a WAV file's sampler (smpl) chunk when it has no loop tags (tag names auto-detected), so they are used as the first loop choice and by play-tagged; write them to the smpl chunk when tagging WAV files, keeping any existing sampler data and other loops. - Parse WAV chunks from their headers with seeks, so looking for the smpl chunk does not read the whole file. - Do not offer to trim when export-points only prints to the console. - Leave out detected loops within 5 ms of the embedded loop points, which would otherwise be listed twice. - Default `trim --keep-after` to the same 100 samples as the interactive prompt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QTLaHUDYw58dcfrK65spTz
Xehanort88
added a commit
that referenced
this pull request
Sep 26, 2026
Preserve metadata when trimming, support WAV smpl loops, and trim/tag fixes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Trimming keeps all metadata
smplsampler loops,cuepoints,bext, the exactfmtchunk). Only thedatachunk is shortened, and thefactsample count is updated. The audio is no longer rewritten. Adatasize left as a placeholder (0 or past the end of the file) by an interrupted writer is handled.trimandextend) are now logged as warnings instead of being silently ignored.WAV
smplloop pointssmplloop used as the embedded loop: it is the first choice for all commands, and is used byplay-taggedwhen no tag names are given. Text tags take precedence, and explicitly named tags never fall back tosmpl.tagon WAV files also writes the loop to thesmplchunk (as a forward loop with an inclusive end, repeating forever). An existing chunk keeps its header, its other loops and its sampler-specific data.smplloop doesn't load the whole file.Other fixes
export-pointsonly prints to the console.trim --keep-afternow defaults to 100 samples, the same as the interactive prompt (one shared constant). The Python API'sMusicLooper.trim()still defaults to 0.Behaviour change
Running
trimwithout--keep-afternow keeps 100 samples after the loop end instead of 0. Pass--keep-after 0to cut exactly at the loop end.Testing
trimandtagwere run on WAV files that have tags and asmplchunk.