From 42b2b09b9146e7fd74233b9529c398fa11dd1ab1 Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Wed, 3 Feb 2010 22:35:13 +0000 Subject: - fixed DC/Nyquist inclusion bug in xtract_spectrum() and refactored a bit --- examples/simpletest/simpletest.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'examples/simpletest/simpletest.c') diff --git a/examples/simpletest/simpletest.c b/examples/simpletest/simpletest.c index 3ead2d6..b17da16 100644 --- a/examples/simpletest/simpletest.c +++ b/examples/simpletest/simpletest.c @@ -23,12 +23,28 @@ int main(void) { - float mean = 0, vector[] = {1, 2, 3}; + float mean = 0, vector[] = {.1, .2, .3, .4, -.5, -.4, -.3, -.2, -.1}, + spectrum[10]; + int n, N = 9; + float argf[4]; + + argf[0] = 8000.f; + argf[1] = XTRACT_MAGNITUDE_SPECTRUM; + argf[2] = 0.f; + argf[3] = 0.f; - xtract[XTRACT_MEAN]((void *)&vector, 3, NULL, (void *)&mean); + xtract[XTRACT_MEAN]((void *)&vector, N, NULL, (void *)&mean); + xtract_init_fft(N, XTRACT_SPECTRUM); + xtract[XTRACT_SPECTRUM]((void *)&vector, N, &argf[0], (void *)&spectrum[0]); + + printf("\nThe mean of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] = %.1f\n\n", mean); + printf("\nResults of xtract_spectrum():\n"); + + for(n = 0; n < N; n++){ + printf("%.3f\t", spectrum[n]); + } + printf("\n"); - printf("\nThe mean of [1, 2, 3] = %.1f\n\n", mean); - return 0; } -- cgit v1.2.3