blob: ad9549689105286876b22c6a1b2a5018ff3d0c91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 <math.h>
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 / (float)DCT_SIZE * ((float)n + 0.5f) * (float)k);
}
output[k] = sum;
}
}
|