blob: 3ab46112e3baf9582b2cdc1f93048c859076e8da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
// 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 <math.h>
void idct_512(const float *input, float *output) {
const float PI = 3.14159265358979323846f;
for (int n = 0; n < DCT_SIZE; ++n) {
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 * (2.0f / (float)DCT_SIZE);
}
}
|