Repository navigation
Add --tags-only and a batch summary, speed up the analysis, and fix the chroma sample rate - #4
Merged
Merged
Conversation
…ch summary --tags-only uses only the loop points stored in the file's metadata tags, without analyzing the audio; files without valid loop tags are skipped. Batch runs now end with a summary of the processed files (with loop points from their tags or detected ones), and of the skipped and failed files grouped by reason.
The candidate search compares every pair of beats; it now does so with scalar loops over the beats' chroma and loudness instead of allocating temporary arrays for each comparison (about 60x faster, and much faster brute force). Only the loudest bin of each frame of the dB spectrogram was used, so only those are kept, the spectrograms are released as soon as they are no longer needed, and the tuning estimate of the chroma is computed over chunks of frames. The results are unchanged (bit-identical loop points and scores).
chroma_stft was not given the sample rate, so it assumed librosa's default of 22050 Hz: pitch classes were shifted by ~1.5 semitones for 48 kHz audio, and the chroma filter bank weighted the wrong octaves for 44.1 kHz audio. This is a correctness fix: it changes the best detected loop of some tracks, but compared on 151 real tracks it makes no measurable difference to the loop quality overall (one track clearly better, one worse, the rest unchanged or within noise). Beat tracking has the same default, which only scales the bpm used for the length of the scoring window; passing the real rate there gave no better loops, so it is documented and kept.
Adds an Unreleased section listing the changes since 3.6.0, regenerates the --help images (with --tags-only), and adds the trim command to CLI_README.md.
Xehanort88
force-pushed
the
analysis-performance
branch
from
September 27, 2026 11:52
6806a8d to
d28aebe
Compare
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
--tags-only: uses only the loop points stored in the files' metadata tags, skipping the loop analysis; files without valid loop tags are skipped instead of silently falling back to detected loop points. Available for all commands.-vstill logs them).chroma_stftassumed 22050 Hz, which shifted the pitch classes of 48 kHz audio by ~1.5 semitones. This is a correctness fix: it changes the best detected loop of some tracks, with no measurable effect on the loop quality overall.Analysis
The performance profiling, the verification that the optimizations give bit-identical results, and the evaluation of the sample rate fix on 151 tracks were done by Claude (Claude Code, Anthropic's Opus 5.5 model). There is no way I could have done this analysis myself to the same level of precision.
Performance (results unchanged)
The full loop pair lists (positions, order and scores) are bit-identical before and after, in normal,
--approx-loop-positionand--brute-forcemodes._find_candidate_pairscompares every pair of beats; it now uses scalar loops over the beats' chroma and loudness instead of allocating temporary arrays for each comparison (4.3 s → 0.07 s on the 19 min track; brute force benefits the most).Chroma sample rate
The old and new best loops were compared on 151 tracks, by how well the audio after the loop start matches the audio after the loop end (1.0 = identical). The fix corrects the analysis, but makes no measurable difference to the loop quality overall: one track is clearly better, one is worse, and the rest are unchanged or differ by noise.
48 further tracks (mostly non-looping film scores) had no loop found with either version.
Beat tracking has the same default sample rate, which only scales the bpm used for the length of the scoring window; passing the real sample rate there gave no better loops (and one clearly worse), so it is documented in the code and kept as-is.
Test plan
uv run pytest(145 tests, including new ones comparing the optimized computations with the original ones, and checking that an A4 tone is analyzed as A at 22.05, 44.1 and 48 kHz)--tags-onlybatch runs on real folders (214 and 41 files)