jamie@107: /* libxtract feature extraction library jamie@107: * jamie@107: * Copyright (C) 2006 Jamie Bullock jamie@107: * jamie@107: * This program is free software; you can redistribute it and/or modify jamie@107: * it under the terms of the GNU General Public License as published by jamie@107: * the Free Software Foundation; either version 2 of the License, or jamie@107: * (at your option) any later version. jamie@107: * jamie@107: * This program is distributed in the hope that it will be useful, jamie@107: * but WITHOUT ANY WARRANTY; without even the implied warranty of jamie@107: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jamie@107: * GNU General Public License for more details. jamie@107: * jamie@107: * You should have received a copy of the GNU General Public License jamie@107: * along with this program; if not, write to the Free Software jamie@107: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, jamie@107: * USA. jamie@107: */ jamie@107: jamie@107: jamie@107: /* helper.c: helper functions. */ jamie@107: jamie@107: #include "xtract/libxtract.h" jamie@107: jamie@107: int xtract_windowed(const float *data, const int N, const void *argv, float *result){ jamie@107: jamie@107: int n; jamie@107: const float *window; jamie@107: jamie@107: n = N; jamie@107: window = (const float *)argv; jamie@107: jamie@107: while(n--) jamie@107: result[n] = data[n] * window[n]; jamie@107: jamie@107: return XTRACT_SUCCESS; jamie@107: jamie@107: } jamie@107: jamie@107: int xtract_features_from_subframes(const float *data, const int N, const int feature, const void *argv, float *result){ jamie@107: jamie@107: const float *frame1, jamie@107: *frame2; jamie@107: float *result1, jamie@107: *result2; jamie@107: jamie@107: int n, jamie@107: rv; jamie@107: jamie@107: n = N >> 1; jamie@107: jamie@107: frame1 = data; jamie@107: frame2 = data + n; jamie@107: result1 = result; jamie@107: result2 = result + n; jamie@107: jamie@107: rv = xtract[feature](frame1, n, argv, result1); jamie@107: jamie@107: if(rv == XTRACT_SUCCESS) jamie@107: rv = xtract[feature](frame2, n, argv, result2); jamie@107: jamie@107: return rv; jamie@107: jamie@107: }