Repository navigation
Measure tempo, key and energy from a track's sound - #47
Merged
Merged
Conversation
For the music whose tags say nothing. Plain numpy over ffmpeg-decoded PCM, no new dependency: - Tempo: autocorrelation of a spectral-flux onset curve, scored with its first four multiples and a log-normal prior at 110 BPM. - Key: pitch-class profile against the 24 Krumhansl-Kessler profiles. - Energy: loudness, brightness and drive, in three levels. Gated so talks and noise get nothing: a tempo needs a real beat, and a key without one needs a strong correlation. Fills blanks only, after tags, and is stamped "analysis" in field_provenance. Queued after every song-length audio upload, runnable per track from the Music tab, and library-wide from a new Settings panel, which also gives the existing tag harvest its first button. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DCL4jm6ogZBBhnjEfBBaXU
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.
This fills the music profile (davior/gam#46) for tracks whose tags say nothing, which is most music from free libraries. GAM measures tempo, key and energy from the audio itself, using plain numpy over ffmpeg-decoded PCM, with no new dependency.
What it measures (
app/ingest/audio_analysis.py)Not attempted:
Gates, so talks and noise get nothing:
How it's used
analysisinfield_provenance. That is a new fourth value beside human, ai and embedded. A tag or a hand edit always wins.POST /api/assets/{id}/analyze-music).POST /api/assets/analyze-music). The same panel gives the existing tag harvest (harvest_attribution) its first button; until now it could only be started through the API.Accuracy
I had no access to real music from the build environment, so this was checked against synthetic tracks with a known tempo and key:
Design notes are in
docs/music-profile.md.Testing
pytest -q: 1344 passed. The newtests/test_audio_analysis.pyuses seeded synthesised audio fromtests/music_synth.pyand covers:npm run format:check,npm run lint,npm test(418 passed, including the newLibraryScanPanel.test.tsxand Music tab button tests) andnpm run buildall clean.Generated by Claude Code