source: src/mfcc.c @ 71d3bf0

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 71d3bf0 was 71d3bf0, checked in by Amaury Hazan <mahmoudax@gmail.com>, 17 years ago

small adds

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2   Copyright (C) 2006 Amaury Hazan
3   Ported to aubio from LibXtract
4   http://libxtract.sourceforge.net/
5   
6
7   This program is free software; you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation; either version 2 of the License, or
10   (at your option) any later version.
11
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with this program; if not, write to the Free Software
19   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21*/
22
23
24#include "mffc.h"
25
26// Computation
27
28int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result){
29
30    aubio_mel_filter *f;
31    int n, filter;
32
33    f = (aubio_mel_filter *)argv;
34   
35    for(filter = 0; filter < f->n_filters; filter++){
36        result[filter] = 0.f;
37        for(n = 0; n < N; n++){
38            result[filter] += data[n] * f->filters[filter][n];
39        }
40        result[filter] = log(result[filter] < XTRACT_LOG_LIMIT ? XTRACT_LOG_LIMIT : result[filter]);
41    }
42
43    for(n = filter + 1; n < N; n++) result[n] = 0; 
44   
45    aubio_dct_do(result, f->n_filters, NULL, result);
46   
47    return XTRACT_SUCCESS;
48}
49
50int aubio_dct_do(const float *data, const int N, const void *argv, float *result){
51   
52    fftwf_plan plan;
53   
54    plan = 
55        fftwf_plan_r2r_1d(N, (float *) data, result, FFTW_REDFT00, FFTW_ESTIMATE);
56   
57    fftwf_execute(plan);
58    fftwf_destroy_plan(plan);
59
60    return XTRACT_SUCCESS;
61}
Note: See TracBrowser for help on using the repository browser.