summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-06 18:31:14 +0100
committerskal <pascal.massimino@gmail.com>2026-02-06 18:31:14 +0100
commit69fd884aaec5523871696149cd39aff6b10c9397 (patch)
treef76401c7fbea84910e19fdc17be363eb35115a7f /scripts
parent819394afe35a754f8408a98dc3f42e58ef5f69f9 (diff)
feat(audio): Add RMS normalization to spectool for consistent sample loudness
IMPLEMENTATION: - Added --normalize flag to spectool analyze command - Default target RMS: 0.15 (customizable via --normalize [rms]) - Two-pass processing: load all PCM → calculate RMS/peak → normalize → DCT - Peak-limiting safety: prevents clipping by limiting scale factor if peak > 1.0 - Updated gen_spectrograms.sh to use --normalize by default ALGORITHM: 1. Calculate original RMS and peak of input audio 2. Compute scale factor to reach target RMS (default 0.15) 3. Check if scaled peak would exceed 1.0 (after windowing + IDCT) 4. If yes, reduce scale factor to keep peak ≤ 1.0 (prevents clipping) 5. Apply scale factor to all PCM samples before windowing/DCT RESULTS: Before normalization: - RMS range: 0.054 - 0.248 (4.6x variation, ~13 dB) - Some peaks > 1.0 (clipping) After normalization: - RMS range: 0.049 - 0.097 (2.0x variation, ~6 dB) ✅ 2.3x improvement - All peaks < 1.0 (no clipping) ✅ SAMPLES REGENERATED: - All 14 .spec files regenerated with normalization - High dynamic range samples (SNARE_808, CRASH_DMX, HIHAT_CLOSED_DMX) were peak-limited to prevent clipping - Consistent loudness across all drum and bass samples GITIGNORE CHANGE: - Removed *.spec from .gitignore to track normalized spectrograms - This ensures reproducibility and prevents drift from source files handoff(Claude): RMS normalization implemented and working. All samples now have consistent loudness with no clipping.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gen_spectrograms.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/gen_spectrograms.sh b/scripts/gen_spectrograms.sh
index 7eb6bdc..a5c1510 100755
--- a/scripts/gen_spectrograms.sh
+++ b/scripts/gen_spectrograms.sh
@@ -49,7 +49,7 @@ process_file() {
fi
echo "Generating spectrogram: ${base_name} -> ${output_name}.spec"
- "${SPECTOOL_PATH}" analyze "$file_to_process" "$spec_file"
+ "${SPECTOOL_PATH}" analyze "$file_to_process" "$spec_file" --normalize
}
# Find and process all audio files