jamie@107
|
1 /* libxtract feature extraction library
|
jamie@107
|
2 *
|
jamie@107
|
3 * Copyright (C) 2006 Jamie Bullock
|
jamie@107
|
4 *
|
jamie@107
|
5 * This program is free software; you can redistribute it and/or modify
|
jamie@107
|
6 * it under the terms of the GNU General Public License as published by
|
jamie@107
|
7 * the Free Software Foundation; either version 2 of the License, or
|
jamie@107
|
8 * (at your option) any later version.
|
jamie@107
|
9 *
|
jamie@107
|
10 * This program is distributed in the hope that it will be useful,
|
jamie@107
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
jamie@107
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
jamie@107
|
13 * GNU General Public License for more details.
|
jamie@107
|
14 *
|
jamie@107
|
15 * You should have received a copy of the GNU General Public License
|
jamie@107
|
16 * along with this program; if not, write to the Free Software
|
jamie@107
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
jamie@107
|
18 * USA.
|
jamie@107
|
19 */
|
jamie@107
|
20
|
jamie@107
|
21
|
jamie@107
|
22 /* helper.c: helper functions. */
|
jamie@107
|
23
|
jamie@107
|
24 #include "xtract/libxtract.h"
|
jamie@107
|
25
|
jamie@107
|
26 int xtract_windowed(const float *data, const int N, const void *argv, float *result){
|
jamie@107
|
27
|
jamie@107
|
28 int n;
|
jamie@107
|
29 const float *window;
|
jamie@107
|
30
|
jamie@107
|
31 n = N;
|
jamie@107
|
32 window = (const float *)argv;
|
jamie@107
|
33
|
jamie@107
|
34 while(n--)
|
jamie@107
|
35 result[n] = data[n] * window[n];
|
jamie@107
|
36
|
jamie@107
|
37 return XTRACT_SUCCESS;
|
jamie@107
|
38
|
jamie@107
|
39 }
|
jamie@107
|
40
|
jamie@107
|
41 int xtract_features_from_subframes(const float *data, const int N, const int feature, const void *argv, float *result){
|
jamie@107
|
42
|
jamie@107
|
43 const float *frame1,
|
jamie@107
|
44 *frame2;
|
jamie@107
|
45 float *result1,
|
jamie@107
|
46 *result2;
|
jamie@107
|
47
|
jamie@107
|
48 int n,
|
jamie@107
|
49 rv;
|
jamie@107
|
50
|
jamie@107
|
51 n = N >> 1;
|
jamie@107
|
52
|
jamie@107
|
53 frame1 = data;
|
jamie@107
|
54 frame2 = data + n;
|
jamie@107
|
55 result1 = result;
|
jamie@107
|
56 result2 = result + n;
|
jamie@107
|
57
|
jamie@107
|
58 rv = xtract[feature](frame1, n, argv, result1);
|
jamie@107
|
59
|
jamie@107
|
60 if(rv == XTRACT_SUCCESS)
|
jamie@107
|
61 rv = xtract[feature](frame2, n, argv, result2);
|
jamie@107
|
62
|
jamie@107
|
63 return rv;
|
jamie@107
|
64
|
jamie@107
|
65 }
|