summaryrefslogtreecommitdiff
path: root/src/audio/window.cc
blob: b68c74715f4c0a41b95c65a15899354d76a7f29b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// This file is part of the 64k demo project.
// It implements the Hamming window function for spectral processing.
// Used to reduce spectral leakage during DCT operations.

#include "window.h"
#include <math.h>

void hamming_window_512(float* window) {
  const float PI = 3.14159265358979323846f;
  for (int i = 0; i < WINDOW_SIZE; ++i) {
    window[i] =
        0.54f - 0.46f * cosf(2.0f * PI * (float)i / (float)(WINDOW_SIZE - 1));
  }
}