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