summaryrefslogtreecommitdiff
path: root/src/audio
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/gen.cc9
-rw-r--r--src/audio/synth.cc1
2 files changed, 9 insertions, 1 deletions
diff --git a/src/audio/gen.cc b/src/audio/gen.cc
index 5604457..74b468c 100644
--- a/src/audio/gen.cc
+++ b/src/audio/gen.cc
@@ -72,7 +72,14 @@ std::vector<float> generate_note_spectrogram(const NoteParams& params,
// 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
- const float scale_factor = sqrtf(DCT_SIZE / 2.0f);
+ //
+ // 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
+ const float scale_factor = sqrtf(DCT_SIZE / 2.0f) / 2.5f;
// Copy to buffer with scaling
for (int i = 0; i < DCT_SIZE; ++i) {
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 <atomic>
#include <math.h>