summaryrefslogtreecommitdiff
path: root/src/audio/gen.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/gen.cc')
-rw-r--r--src/audio/gen.cc16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/audio/gen.cc b/src/audio/gen.cc
index 0757b4d..cd36d54 100644
--- a/src/audio/gen.cc
+++ b/src/audio/gen.cc
@@ -70,15 +70,17 @@ std::vector<float> generate_note_spectrogram(const NoteParams& params,
fdct_512(pcm_chunk, dct_chunk);
// Scale up to compensate for orthonormal normalization
- // Old non-orthonormal DCT had no sqrt scaling, so output was ~sqrt(N/2) larger
- // Scale factor: sqrt(DCT_SIZE / 2) = sqrt(256) = 16
+ // Old non-orthonormal DCT had no sqrt scaling, so output was ~sqrt(N/2)
+ // larger Scale factor: sqrt(DCT_SIZE / 2) = sqrt(256) = 16
//
- // HOWEVER: After removing synthesis windowing (commit f998bfc), audio is louder.
- // The old synthesis incorrectly applied Hamming window to spectrum (reducing energy by 0.63x).
- // New synthesis is correct (no window), but procedural notes with 16x scaling are too loud.
+ // HOWEVER: After removing synthesis windowing (commit f998bfc), audio is
+ // louder. The old synthesis incorrectly applied Hamming window to spectrum
+ // (reducing energy by 0.63x). New synthesis is correct (no window), but
+ // procedural notes with 16x scaling are too loud.
//
- // Analysis applies Hamming window (0.63x energy). With 16x scaling: 0.63 × 16 ≈ 10x.
- // Divide by 2.5 to match the relative loudness increase: 16 / 2.5 = 6.4
+ // Analysis applies Hamming window (0.63x energy). With 16x scaling: 0.63 ×
+ // 16 ≈ 10x. Divide by 2.5 to match the relative loudness increase: 16 / 2.5
+ // = 6.4
const float scale_factor = sqrtf(DCT_SIZE / 2.0f) / 2.5f;
// Copy to buffer with scaling