source: src/mfcc.c @ 7c6c806d

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

minor changes

  • Property mode set to 100644
File size: 2.3 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#include "aubio_priv.h"
24#include "sample.h"
25#include "fft.h"
26#include "mfcc.h"
27#include "math.h"
28
29/*
30new_aubio_mfcc
31aubio_mfcc_do
32del_aubio_mfcc
33*/
34
35// Computation
36// Added last two arguments to be able to pass from example
37
38
39
40int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t * fft_dct, cvec_t * fftgrain_dct){
41
42    aubio_mel_filter *f;
43    int n, filter;
44
45    f = (aubio_mel_filter *)argv;
46   
47    for(filter = 0; filter < f->n_filters; filter++){
48        result[filter] = 0.f;
49        for(n = 0; n < N; n++){
50            result[filter] += data[n] * f->filters[filter][n];
51        }
52        result[filter] = LOG(result[filter] < XTRACT_LOG_LIMIT ? XTRACT_LOG_LIMIT : result[filter]);
53    }
54
55    //TODO: check that zero padding
56    for(n = filter + 1; n < N; n++) result[n] = 0; 
57   
58    aubio_dct_do(result, f->n_filters, NULL, result, fft_dct, fftgrain_dct);
59   
60    return XTRACT_SUCCESS;
61}
62
63// Added last two arguments to be able to pass from example
64
65int aubio_dct_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t * fft_dct, cvec_t * fftgrain_dct){
66   
67   
68    //call aubio p_voc in dct setting
69
70    //TODO: fvec as input? Remove data length, N?
71
72    fvec_t * momo = new_fvec(20, 1);
73    momo->data = data;
74   
75    //compute mag spectrum
76    aubio_mfft_do (fft_dct, data, fftgrain_dct);
77
78    int i;
79    //extract real part of fft grain
80    for(i=0; i<N ;i++){
81      result[i]= fftgrain_dct->norm[0][i]*COS(fftgrain_dct->phas[0][i]);
82    }
83
84
85    return XTRACT_SUCCESS;
86}
Note: See TracBrowser for help on using the repository browser.