summaryrefslogtreecommitdiff
path: root/src/audio/idct.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-01-28 09:31:13 +0100
committerskal <pascal.massimino@gmail.com>2026-01-28 09:31:13 +0100
commit302d883f34864bc66a5e04532ae27d7e89fd94e8 (patch)
tree8f813865d5dc5b70ee8bf9ee4866546116859825 /src/audio/idct.cc
parentf804dcb9740540b3735628ebf8c006235cc56fca (diff)
style: Add 3-line descriptive headers to all source files
This commit applies a new project-wide rule that every source file must begin with a concise 3-line comment header describing its purpose. - Updated CONTRIBUTING.md with the new rule. - Applied headers to all .cc and .h files in src/ and tools/. - Fixed various minor compilation errors and missing includes discovered during the header update process.
Diffstat (limited to 'src/audio/idct.cc')
-rw-r--r--src/audio/idct.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/audio/idct.cc b/src/audio/idct.cc
index 5d6bde0..97fc224 100644
--- a/src/audio/idct.cc
+++ b/src/audio/idct.cc
@@ -1,17 +1,17 @@
+// This file is part of the 64k demo project.
+// It implements the 512-point Inverse Discrete Cosine Transform.
+// Used for real-time synthesis of audio from spectral data.
+
#include "dct.h"
-#include "util/math.h"
#include <math.h>
-void idct_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 idct_512(const float *input, float *output) {
+ const float PI = 3.14159265358979323846f;
for (int n = 0; n < DCT_SIZE; ++n) {
- float sum = 0.0f;
- for (int k = 0; k < DCT_SIZE; ++k) {
- float scale = (k == 0) ? scale_k0 : scale_kn;
- sum += scale * input[k] * cosf((PI / DCT_SIZE) * (n + 0.5f) * k);
+ float sum = input[0] / 2.0f;
+ for (int k = 1; k < DCT_SIZE; ++k) {
+ sum += input[k] * cosf(PI / (float)DCT_SIZE * (float)k * ((float)n + 0.5f));
}
- output[n] = sum;
+ output[n] = sum * (2.0f / (float)DCT_SIZE);
}
-}
+} \ No newline at end of file