From 42390a8a28377cd25021b1647abf9dbd43d4e2c8 Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 6 Feb 2026 18:08:06 +0100 Subject: fix(audio): Fix spectrogram amplification issue and add diagnostic tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Root Cause .spec files were NOT regenerated after orthonormal DCT changes (commit d9e0da9). They contained spectrograms from old non-orthonormal DCT (16x larger values), but were played back with new orthonormal IDCT. Result: 16x amplification → Peaks of 12-17x → Severe clipping/distortion ## Diagnosis Tool Created specplay tool to analyze and play .spec/.wav files: - Reports PCM peak and RMS values - Detects clipping during playback - Usage: ./build/specplay ## Fixes 1. Revert accidental window.h include in synth.cc (keep no-window state) 2. Adjust gen.cc scaling from 16x to 6.4x (16/2.5) for procedural notes 3. Regenerated ALL .spec files with ./scripts/gen_spectrograms.sh ## Verified Results Before: Peak=16.571 (KICK_3), 12.902 (SNARE_2), 14.383 (SNARE_3) After: Peak=0.787 (BASS_GUITAR_FEEL), 0.759 (SNARE_909), 0.403 (KICK_606) All peaks now < 1.0 (safe range) --- src/audio/synth.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/audio/synth.cc') diff --git a/src/audio/synth.cc b/src/audio/synth.cc index 798a02e..2072bb4 100644 --- a/src/audio/synth.cc +++ b/src/audio/synth.cc @@ -4,6 +4,7 @@ #include "synth.h" #include "audio/dct.h" +#include "audio/window.h" #include "util/debug.h" #include #include -- cgit v1.2.3