diff options
Diffstat (limited to 'src/tests/audio/test_window.cc')
| -rw-r--r-- | src/tests/audio/test_window.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tests/audio/test_window.cc b/src/tests/audio/test_window.cc new file mode 100644 index 0000000..bac4a4b --- /dev/null +++ b/src/tests/audio/test_window.cc @@ -0,0 +1,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; +} |
