Changeset 71b1b4b


Ignore:
Timestamp:
Sep 6, 2007, 3:52:19 PM (17 years ago)
Author:
Amaury Hazan <mahmoudax@gmail.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
7c6c806d
Parents:
dcc649c (diff), 97886fa (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merged from laptop

Files:
5 edited
2 moved

Legend:

Unmodified
Added
Removed
  • examples/aubiomfcc.c

    rdcc649c r71b1b4b  
    4646      //compute mag spectrum
    4747      aubio_pvoc_do (pv,ibuf, fftgrain);
     48     
     49      uint_t coef_cnt;
     50      uint_t n_filters=20;
     51      smpl_t outbuf[20];
     52
     53      for (coef_cnt=0; coef_cnt<n_filters ; coef_cnt++)
     54        outbuf[coef_cnt]=0.f;
     55       
     56      //compute mfccs
     57      aubio_mffc_do(fftgrain->norm, nframes, mf, outbuf);
    4858     
    49       //TODO: extract Magnitude buffer f_fvec from fftgrain cvec
    50 
    51       //compute mfccs
    52       aubio_mffc_do (magbuf, nframes, filterbank, outbuf);
     59      for (coef_cnt=0; coef_cnt<n_filters ; coef_cnt++)
     60        outmsg("%f ",outbuf[coef_cnt]);
     61      outmsg("\n");
    5362     
    5463     
     
    7988int main(int argc, char **argv) {
    8089  examples_common_init(argc,argv);
     90 
     91  //allocate and initialize mel filter bank
     92  uint_t n_filters=20;
     93  uint_t nyquist= samplerate / 2.;
     94  smpl_t lowfreq=80.f;
     95  smpl_t highfreq=18000.f;
     96
     97  uint_t banksize = (uint) ( sizeof(aubio_mel_filter));
     98  aubio_mel_filter * mf = (aubio_mel_filter *)getbytes(banksize);
     99
     100  mf->n_filters = 20;
     101  mf->filters = (smpl_t **)getbytes(mf->n_filters * sizeof(smpl_t *));
     102  for(n = 0; n < mf->n_filters; n++)
     103    mf->filters[n] = (smpl_t *)getbytes((buffer_size/2+1) * sizeof(smpl_t));
     104 
     105  //populating the filter
     106  aubio_mfcc_init(buffer_size, nyquist, XTRACT_EQUAL_GAIN, lowfreq, highfreq, mf->n_filters, mf->filters);
     107
     108  //process
    81109  examples_common_process(aubio_process,process_print);
    82110  examples_common_del();
    83111  debug("End of program.\n");
    84112  fflush(stderr);
     113 
     114  //destroying filterbank
     115  free(mf);
     116 
    85117  return 0;
    86118}
  • src/Makefile.am

    rdcc649c r71b1b4b  
    2222        onset.h \
    2323        tempo.h \
    24         filter.h
     24        filter.h
     25
    2526nodist_pkginclude_HEADERS = config.h
    2627
     
    6970        tempo.h \
    7071        filter.c \
    71         filter.h
     72        filter.h \
    7273
    7374AM_CFLAGS = @AUBIO_CFLAGS@ @FFTWLIB_CFLAGS@ @SAMPLERATE_CFLAGS@
  • src/aubio.h

    rdcc649c r71b1b4b  
    8080#include "onset.h"
    8181#include "tempo.h"
     82#include "mfcc.h"
    8283
    8384#ifdef __cplusplus
  • src/filterbank.c

    rdcc649c r71b1b4b  
    2121*/
    2222
    23 #include "aubiofilterbank.h"
     23#include "filterbank.h"
    2424
    2525// Initialization
    2626
    27 int aubio_mfcc_init(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, float **fft_tables){
     27int aubio_mfcc_init(int N, smpl_t nyquist, int style, smpl_t freq_min, smpl_t freq_max, int freq_bands, smpl_t **fft_tables){
    2828
    2929    int n, i, k, *fft_peak, M, next_peak;
    30     float norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val,
     30    smpl_t norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val,
    3131        freq_bw_mel, *mel_peak, *height_norm, *lin_peak;
    3232
     
    3939    freq_bw_mel = (mel_freq_max - mel_freq_min) / freq_bands;
    4040
    41     mel_peak = (float *)malloc((freq_bands + 2) * sizeof(float));
     41    mel_peak = (smpl_t *)malloc((freq_bands + 2) * sizeof(smpl_t));
    4242    /* +2 for zeros at start and end */
    43     lin_peak = (float *)malloc((freq_bands + 2) * sizeof(float));
     43    lin_peak = (smpl_t *)malloc((freq_bands + 2) * sizeof(smpl_t));
    4444    fft_peak = (int *)malloc((freq_bands + 2) * sizeof(int));
    45     height_norm = (float *)malloc(freq_bands * sizeof(float));
     45    height_norm = (smpl_t *)malloc(freq_bands * sizeof(smpl_t));
    4646
    4747    if(mel_peak == NULL || height_norm == NULL ||
  • src/filterbank.h

    rdcc649c r71b1b4b  
    1818   along with this program; if not, write to the Free Software
    1919   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20 
    2120*/
    2221
    2322#ifndef AUBIOFILTERBANK_H
    24 #include AUBIOFILTERBANK_H
     23#define AUBIOFILTERBANK_H
    2524
    26 #define NYQUIST 22050.f
    2725
    2826// Struct Declaration
     
    3129typedef struct aubio_mel_filter_ {
    3230    int n_filters;
    33     float **filters;
     31    smpl_t **filters;
    3432} aubio_mel_filter;
    3533
     
    4038 * It is up to the caller to pass in a pointer to memory allocated for freq_bands arrays of length N. This function populates these arrays with magnitude coefficients representing the mel filterbank on a linear scale
    4139 */
    42 int aubio_mfcc_init(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, float **fft_tables);
     40int aubio_mfcc_init(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, smpl_t ** fft_tables);
    4341
    4442#endif
  • src/mfcc.c

    rdcc649c r71b1b4b  
    2323
    2424#include "mffc.h"
    25 #include "aubiofilterbank.h"
    2625
    2726// Computation
     
    4241    }
    4342
     43    //TODO: check that zero padding
    4444    for(n = filter + 1; n < N; n++) result[n] = 0;
    4545   
     
    5151int aubio_dct_do(const float *data, const int N, const void *argv, float *result){
    5252   
     53   
     54    //call aubio p_voc in dct setting
     55
     56    //TODO: fvec as input? Remove data length, N?
     57
     58    //compute mag spectrum
     59    aubio_pvoc_do (pv,data, fftgrain);
     60
     61    int i;
     62    //extract real part of fft grain
     63    for(i=0; i<N ;i++){
     64      result[i]= fftgrain->norm[i]*cos(fftgrain->phase[i]);
     65    }
     66   
     67    /*
    5368    fftwf_plan plan;
    5469   
     
    5772   
    5873    fftwf_execute(plan);
    59     fftwf_destroy_plan(plan);
     74    fftwf_destroy_plan(plan);*/
    6075
    6176    return XTRACT_SUCCESS;
  • src/mfcc.h

    rdcc649c r71b1b4b  
    2424#define MFCC_H
    2525
     26#include "filterbank.h"
    2627
    2728//libXtract enums
Note: See TracChangeset for help on using the changeset viewer.