summaryrefslogtreecommitdiff
path: root/src/tests/test_window.cc
blob: 1d2d76f0271df08661e2e5908bd5f9e7399d1bde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// This file is part of the 64k demo project.
// It validates the mathematical properties of the Hamming window.
// Ensures the window peaks at the center and has correct symmetry.

#include "audio/window.h"
#include <assert.h>
#include <math.h>
#include <stdio.h>

int main() {
  printf("Running HammingWindow tests...\n");

  float window[WINDOW_SIZE];
  hamming_window_512(window);

  // Check symmetry
  for (int i = 0; i < WINDOW_SIZE / 2; ++i) {
    assert(fabsf(window[i] - window[WINDOW_SIZE - 1 - i]) < 1e-6f);
  }

  // Check peak (should be at the center for even size, it's actually split
  // between 255 and 256)
  assert(window[255] > 0.99f);
  assert(window[256] > 0.99f);

  printf("HammingWindow tests PASSED\n");
  return 0;
}