ref: 97886fac26f2f105871453d8dd8ae2c489c710dc
dir: /src/mfcc.c/
/* Copyright (C) 2006 Amaury Hazan Ported to aubio from LibXtract http://libxtract.sourceforge.net/ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "mffc.h" // Computation int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result){ aubio_mel_filter *f; int n, filter; f = (aubio_mel_filter *)argv; for(filter = 0; filter < f->n_filters; filter++){ result[filter] = 0.f; for(n = 0; n < N; n++){ result[filter] += data[n] * f->filters[filter][n]; } result[filter] = log(result[filter] < XTRACT_LOG_LIMIT ? XTRACT_LOG_LIMIT : result[filter]); } //TODO: check that zero padding for(n = filter + 1; n < N; n++) result[n] = 0; aubio_dct_do(result, f->n_filters, NULL, result); return XTRACT_SUCCESS; } int aubio_dct_do(const float *data, const int N, const void *argv, float *result){ //call aubio p_voc in dct setting //TODO: fvec as input? Remove data length, N? //compute mag spectrum aubio_pvoc_do (pv,data, fftgrain); int i; //extract real part of fft grain for(i=0; i<N ;i++){ result[i]= fftgrain->norm[i]*cos(fftgrain->phase[i]); } /* fftwf_plan plan; plan = fftwf_plan_r2r_1d(N, (float *) data, result, FFTW_REDFT00, FFTW_ESTIMATE); fftwf_execute(plan); fftwf_destroy_plan(plan);*/ return XTRACT_SUCCESS; }