jamie@86
|
1 /* libxtract feature extraction library
|
jamie@86
|
2 *
|
jamie@86
|
3 * Copyright (C) 2006 Jamie Bullock
|
jamie@86
|
4 *
|
jamie@86
|
5 * This program is free software; you can redistribute it and/or modify
|
jamie@86
|
6 * it under the terms of the GNU General Public License as published by
|
jamie@86
|
7 * the Free Software Foundation; either version 2 of the License, or
|
jamie@86
|
8 * (at your option) any later version.
|
jamie@86
|
9 *
|
jamie@86
|
10 * This program is distributed in the hope that it will be useful,
|
jamie@86
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
jamie@86
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
jamie@86
|
13 * GNU General Public License for more details.
|
jamie@86
|
14 *
|
jamie@86
|
15 * You should have received a copy of the GNU General Public License
|
jamie@86
|
16 * along with this program; if not, write to the Free Software
|
jamie@86
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
jamie@86
|
18 * USA.
|
jamie@86
|
19 */
|
jamie@29
|
20
|
jamie@29
|
21 #include "xtract/libxtract.h"
|
jamie@29
|
22 #include <stdio.h>
|
jamie@29
|
23
|
jamie@86
|
24 int main(void) {
|
jamie@29
|
25
|
jamie@120
|
26 float mean = 0, vector[] = {.1, .2, .3, .4, -.5, -.4, -.3, -.2, -.1},
|
jamie@120
|
27 spectrum[10];
|
jamie@120
|
28 int n, N = 9;
|
jamie@120
|
29 float argf[4];
|
jamie@120
|
30
|
jamie@120
|
31 argf[0] = 8000.f;
|
jamie@120
|
32 argf[1] = XTRACT_MAGNITUDE_SPECTRUM;
|
jamie@120
|
33 argf[2] = 0.f;
|
jamie@120
|
34 argf[3] = 0.f;
|
jamie@29
|
35
|
jamie@120
|
36 xtract[XTRACT_MEAN]((void *)&vector, N, NULL, (void *)&mean);
|
jamie@120
|
37 xtract_init_fft(N, XTRACT_SPECTRUM);
|
jamie@120
|
38 xtract[XTRACT_SPECTRUM]((void *)&vector, N, &argf[0], (void *)&spectrum[0]);
|
jamie@29
|
39
|
jamie@121
|
40 printf("\nThe mean of [.1, .2, .3, .4, -.5, -.4, -.3, -.2, -.1] = %.1f\n\n", mean);
|
jamie@120
|
41 printf("\nResults of xtract_spectrum():\n");
|
jamie@120
|
42
|
jamie@120
|
43 for(n = 0; n < N; n++){
|
jamie@120
|
44 printf("%.3f\t", spectrum[n]);
|
jamie@120
|
45 }
|
jamie@120
|
46 printf("\n");
|
jamie@120
|
47
|
jamie@29
|
48 return 0;
|
jamie@29
|
49
|
jamie@29
|
50 }
|