Ignore:
Timestamp:
Sep 10, 2007, 7:29:32 PM (13 years ago)
Author:
Amaury Hazan <mahmoudax@gmail.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
787f1f3, ef1c3b7
Parents:
7c6c806 (diff), 45134c5 (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 piem, corrected mffcs coefs/filter number
added some scripts to visualize filterbank and mfccs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/aubiomfcc.c

    r7c6c806 r7a46bf6  
    11/*
    2    Copyright (C) 2007 Amaury Hazan
     2   Copyright (C) 2007 Amaury Hazan <ahazan@iua.upf.edu>
     3                  and Paul Brossier <piem@piem.org>
    34
    45   This program is free software; you can redistribute it and/or modify
     
    1819
    1920#include "utils.h"
     21
     22/* mfcc objects */
     23fvec_t * mfcc_out;
     24aubio_mfcc_t * mfcc;
     25
     26uint_t n_filters = 20;
     27uint_t n_coefs = 11;
    2028
    2129unsigned int pos = 0; /*frames%dspblocksize*/
     
    4351      aubio_pvoc_do (pv,ibuf, fftgrain);
    4452     
    45       uint_t n_coefs= n_filters/2 +1;
    46       uint_t coef_cnt;
    47        
    48 
    49       for (coef_cnt=0; coef_cnt<n_coefs ; coef_cnt++)
    50         mfcc_outbuf[coef_cnt]=0.f;
    51        
    5253      //compute mfccs
    53       aubio_mffc_do(fftgrain->norm, nframes, mf, mfcc_outbuf, fft_dct, fftgrain_dct);
    54      
    55       for (coef_cnt=0; coef_cnt<n_coefs ; coef_cnt++)
    56         outmsg("%f ",mfcc_outbuf[coef_cnt]);
    57       outmsg("\n");
    58      
    59      
     54      aubio_mfcc_do(mfcc, fftgrain, mfcc_out);
    6055
    6156      /* end of block loop */
     
    7368      */
    7469     
     70      uint_t coef_cnt;
    7571      if (output_filename == NULL) {
    76         if(frames >= 4) {
    77           outmsg("%f\n",(frames-4)*overlap_size/(float)samplerate);
    78         } else if (frames < 4) {
    79           outmsg("%f\n",0.);
     72//         if(frames >= 4) {
     73//           outmsg("%f\t",(frames-4)*overlap_size/(float)samplerate);
     74//         }
     75//         else if (frames < 4) {
     76//           outmsg("%f\t",0.);
     77//         }
     78        //outmsg("%f ",mfcc_out->data[0][0]);
     79       
     80        /*for (coef_cnt = 0; coef_cnt < n_coefs; coef_cnt++) {
     81          outmsg("%f ",mfcc_out->data[0][coef_cnt]);
    8082        }
     83        outmsg("\n");/*/
    8184      }
    8285}
    8386
    8487int main(int argc, char **argv) {
     88  // params
     89  //uint_t n_filters = 40;
     90  //uint_t n_coefs = 15;
     91
    8592  examples_common_init(argc,argv);
    86  
    87   //allocate and initialize mel filter bank
    88  
    89 
    90   //allocating global mf (in utils.c)
    91   uint_t banksize = (uint) ( sizeof(aubio_mel_filter));
    92   mf = (aubio_mel_filter *)getbytes(banksize);
    93 
    94   mf->n_filters = 20;
    95   mf->filters = (smpl_t **)getbytes(mf->n_filters * sizeof(smpl_t *));
    96   for(n = 0; n < mf->n_filters; n++)
    97     mf->filters[n] = (smpl_t *)getbytes((buffer_size/2+1) * sizeof(smpl_t));
     93  smpl_t lowfreq = 133.333f;
     94  smpl_t highfreq = 44100.f;
     95  mfcc_out = new_fvec(n_coefs,channels);
    9896 
    9997  //populating the filter
    100   aubio_mfcc_init(buffer_size, nyquist, XTRACT_EQUAL_GAIN, lowfreq, highfreq, mf->n_filters, mf->filters);
     98  mfcc = new_aubio_mfcc(buffer_size, samplerate, n_filters, n_coefs , lowfreq, highfreq, channels);
    10199
    102100  //process
    103101  examples_common_process(aubio_process,process_print);
     102 
     103  //destroying mfcc
     104  del_aubio_mfcc(mfcc);
     105  del_fvec(mfcc_out);
     106
    104107  examples_common_del();
    105108  debug("End of program.\n");
    106109  fflush(stderr);
    107110 
    108   //destroying filterbank
    109   free(mf);
    110  
    111111  return 0;
    112112}
Note: See TracChangeset for help on using the changeset viewer.