summaryrefslogtreecommitdiff
path: root/src/audio/fdct.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/fdct.cc')
-rw-r--r--src/audio/fdct.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/audio/fdct.cc b/src/audio/fdct.cc
index 5cf0211..ad95496 100644
--- a/src/audio/fdct.cc
+++ b/src/audio/fdct.cc
@@ -1,17 +1,17 @@
+// This file is part of the 64k demo project.
+// It implements the 512-point Forward Discrete Cosine Transform.
+// Used for analyzing audio files into spectrograms.
+
#include "dct.h"
-#include "util/math.h"
#include <math.h>
-void fdct_512(const float input[DCT_SIZE], float output[DCT_SIZE]) {
- float scale_k0 = sqrtf(1.0f / DCT_SIZE);
- float scale_kn = sqrtf(2.0f / DCT_SIZE);
-
+void fdct_512(const float *input, float *output) {
+ const float PI = 3.14159265358979323846f;
for (int k = 0; k < DCT_SIZE; ++k) {
float sum = 0.0f;
for (int n = 0; n < DCT_SIZE; ++n) {
- sum += input[n] * cosf((PI / DCT_SIZE) * (n + 0.5f) * k);
+ sum += input[n] * cosf(PI / (float)DCT_SIZE * ((float)n + 0.5f) * (float)k);
}
- float scale = (k == 0) ? scale_k0 : scale_kn;
- output[k] = sum * scale;
+ output[k] = sum;
}
-}
+} \ No newline at end of file