Changeset 7a46bf6 for examples


Ignore:
Timestamp:
Sep 10, 2007, 7:29:32 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:
787f1f3, ef1c3b7
Parents:
7c6c806d (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

Location:
examples
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • examples/Makefile.am

    r7c6c806d r7a46bf6  
    1111        aubioonset \
    1212        aubiotrack \
    13         aubionotes
     13        aubionotes \
     14        aubiomfcc
    1415
    1516noinst_PROGRAMS = \
     
    2324aubiotrack_SOURCES = aubiotrack.c utils.c
    2425aubioquiet_SOURCES = aubioquiet.c utils.c
     26aubiomfcc_SOURCES = aubiomfcc.c utils.c
    2527
    2628aubioonset_LDADD = @JACK_LIBS@
     
    2830aubiotrack_LDADD = @JACK_LIBS@
    2931aubioquiet_LDADD = @JACK_LIBS@
     32aubiomfcc_LDADD = @JACK_LIBS@
  • examples/aubiomfcc.c

    r7c6c806d 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}
  • examples/tests/test-beattracking.c

    r7c6c806d r7a46bf6  
    1313        uint_t i = 0;
    1414
     15        smpl_t curtempo;
     16
    1517        while (i < 10) {
    1618          aubio_beattracking_do(tempo,in,out);
     19          curtempo = aubio_beattracking_get_bpm(tempo);
     20          if (curtempo != 0.) {
     21            fprintf(stdout,"%f\n",curtempo);
     22            return 1;
     23          }
    1724          i++;
    1825        };
  • examples/tests/test-tempo.c

    r7c6c806d r7a46bf6  
    1010        uint_t i = 0;
    1111
     12        smpl_t curtempo;
     13
    1214        while (i < 1000) {
    1315          aubio_tempo(o,in,out);
     16          curtempo = aubio_tempo_get_bpm(o);
     17          if (curtempo != 0.) {
     18            fprintf(stdout,"%f\n",curtempo);
     19          }
    1420          i++;
    1521        };
  • examples/utils.c

    r7c6c806d r7a46bf6  
    6060int isonset = 0;
    6161aubio_pickpeak_t * parms;
    62 
    63 /* mfcc objects */
    64 //parameters
    65 uint_t n_filters=20;
    66 uint_t nyquist= samplerate / 2.;
    67 smpl_t lowfreq=80.f;
    68 smpl_t highfreq=18000.f;
    69 // filterbank object
    70 aubio_mel_filter * mf;
    71 
    72 // DCT mfft and result storage
    73 aubio_mfft * fft_dct;
    74 cvec_t * fftgrain_dct;
    75 smpl_t mfcc_outbuf[11];
    76 
    7762
    7863/* pitch objects */
     
    315300  fftgrain  = new_cvec(buffer_size, channels);
    316301
    317   //init for mfcc process
    318   fftgrain_dct= new_cvec(n_filters, channels);
    319 
     302 
    320303  if (usepitch) {
    321304    pitchdet = new_aubio_pitchdetection(buffer_size*4,
     
    331314  pv = new_aubio_pvoc(buffer_size, overlap_size, channels);
    332315 
    333   // dct phase vocoder
    334   //TODO: check size
    335   fft_dct = new_aubio_mfft(n_filters, channels);
    336 
    337316  /* onsets */
    338317  parms = new_aubio_peakpicker(threshold);
     
    368347  del_fvec(onset);
    369348  del_fvec(woodblock);
    370  
    371   //mffc related
    372   del_aubio_mfft(fft_dct);
    373   del_cvec(fftgrain_dct);
    374349 
    375350  aubio_cleanup();
  • examples/utils.h

    r7c6c806d r7a46bf6  
    9898extern aubio_pickpeak_t * parms;
    9999
    100 /* mfcc objects */
    101 // params
    102 extern uint_t n_filters;
    103 extern uint_t nyquist;
    104 extern smpl_t lowfreq;
    105 extern smpl_t highfreq;
    106 // filterbank object
    107 extern aubio_mel_filter * mf;
    108 // DCT pvoc and result storage
    109 extern aubio_mfft_t * fft_dct;
    110 extern cvec_t * fftgrain_dct;
    111 extern smpl_t mfcc_outbuf[20];
    112 
    113100/* pitch objects */
    114101extern smpl_t pitch;
Note: See TracChangeset for help on using the changeset viewer.