Repository navigation
Measure spectrum bands over the whole file with ffmpeg - #128
Merged
Merged
Conversation
audio spectrum analyze read only the first ~2.7 s of a file and sampled each band at three Goertzel frequencies, with no 6-10 kHz band. An 80 Hz tone at -9 dBFS RMS read -27.7 dB, and a tone in the second half of a file read -inf. Each band is now the RMS level of the mono downmix over the whole file, cut brick-wall in the FFT domain by ffmpeg's afftfilt. The bands join from 20 Hz to 18 kHz with a new brilliance_6000_10000_hz band. The command now needs ffmpeg and fails with CONFIG_INVALID without it. Profile warnings now judge balance, not loudness: each band's level relative to the file's full-band level is compared with the profile's expected share. The old absolute baselines were tuned to the broken measurement; the new ones model a spectrum falling 1.5 dB per octave in energy per octave, with each profile's old character kept as offsets. A file with no signal reports `silent`. The ffmpeg runner and error moved to audio_analysis/ffmpeg.py, shared with ebur128. Tests use one fake_ffmpeg fixture and a real_ffmpeg fixture that skips without ffmpeg. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Stacked on #127 (it shares the ffmpeg runner and test fixtures). Merge #127 first; this PR's base then moves to
main.Summary
audio spectrum analyzedid not measure the spectrum:interleaved_mono(limit=min(sr*4, 131072))). On the Phase Trance render, that is just the intro.sub_hot,presence_lowandair_low.Change
afftfilt(8192-point window; a test tone reads within 0.3 dB). Biquad high/low-pass slopes were tried first; they sag 4–5 dB inside one-octave bands.brilliance_6000_10000_hzband.anime-club-balancedshape models a spectrum whose energy per octave falls 1.5 dB per octave around 1 kHz (−4.5 dB/oct on a per-Hz analyzer). The other profiles keep their old character as offsets from it.silent.CONFIG_INVALIDwithout it, like loudness.audio_analysis/ffmpeg.py, shared withebur128.py.interleaved_monowas only used here and is removed.docs/mastering.mddescribes the bands, the warnings and the ffmpeg requirement.Public contract impact
bands.brilliance_6000_10000_hzkey and a newsilentwarning code.CONFIG_INVALIDwithout ffmpeg (also forreference compare,remix mastering analyzeandsession capture --analyze).Tests
tests/test_audio_spectrum_bands.pywas written first and failed against the old code. It covers:-infon silenceCONFIG_INVALIDwithout ffmpegtests/conftest.pynow hasfake_ffmpeg, which fakes both loudness and spectrum, andreal_ffmpeg, which skips without ffmpeg. These replace the per-file skip markers.Validation
ruff check,ruff format --check,dev_checks: 1399 passedWarnings on real files:
sub_20_60_hz_lowsub_20_60_hz_lowbrilliance_hot,air_hotpresence_hot,brilliance_hot,air_hotKnown limits
audio reference comparestill compares absolute band deltas, so a level difference reads as a tonal one. Its true-peak check also compares a delta against −0.5 dB. Both are left for a follow-up.🤖 Generated with Claude Code