- Timestamp:
- Sep 10, 2007, 7:29:32 PM (17 years ago)
- 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. - Location:
- src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.am
r7c6c806d r7a46bf6 23 23 tempo.h \ 24 24 filter.h \ 25 filterbank.h \ 25 26 mfcc.h 26 27 … … 72 73 filter.c \ 73 74 filter.h \ 75 filterbank.c \ 76 filterbank.h \ 74 77 mfcc.h \ 75 78 mfcc.c -
src/aubio.h
r7c6c806d r7a46bf6 80 80 #include "onset.h" 81 81 #include "tempo.h" 82 #include "filterbank.h" 82 83 #include "mfcc.h" 83 84 -
src/beattracking.c
r7c6c806d r7a46bf6 453 453 454 454 } 455 456 smpl_t aubio_beattracking_get_bpm(aubio_beattracking_t * bt) { 457 if (bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) { 458 return 5168. / (smpl_t)bt->gp; 459 } else { 460 return 0.; 461 } 462 } -
src/beattracking.h
r7c6c806d r7a46bf6 60 60 */ 61 61 void aubio_beattracking_do(aubio_beattracking_t * bt, fvec_t * dfframes, fvec_t * out); 62 /** get current tempo in bpm 63 64 \param bt beat tracking object 65 66 Returns the currently observed tempo, in beats per minutes, or 0 if no 67 consistent value is found. 68 69 */ 70 smpl_t aubio_beattracking_get_bpm(aubio_beattracking_t * bt); 62 71 /** delete beat tracking object 63 72 -
src/filterbank.c
r7c6c806d r7a46bf6 1 1 /* 2 Copyright (C) 2007 Amaury Hazan 3 Ported to aubio from LibXtract 4 http://libxtract.sourceforge.net/ 5 2 Copyright (C) 2007 Amaury Hazan <ahazan@iua.upf.edu> 3 and Paul Brossier <piem@piem.org> 6 4 7 5 This program is free software; you can redistribute it and/or modify … … 21 19 */ 22 20 21 /* part of this mfcc implementation were inspired from LibXtract 22 http://libxtract.sourceforge.net/ 23 */ 24 23 25 #include "aubio_priv.h" 26 #include "sample.h" 24 27 #include "filterbank.h" 25 28 26 27 // Struct Declaration 28 29 /** \brief A structure to store a set of n_filters Mel filters */ 30 typedef struct aubio_mel_filter_ { 31 int n_filters; 32 smpl_t **filters; 29 #include "stdio.h" 30 31 #define USE_EQUAL_GAIN 1 32 #define VERY_SMALL_NUMBER 2e-42 33 34 /** \brief A structure to store a set of n_filters filters of lenghts win_s */ 35 struct aubio_filterbank_t_ { 36 uint_t win_s; 37 uint_t n_filters; 38 fvec_t **filters; 33 39 }; 34 40 35 // Initialization 36 37 int 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){ 38 39 int n, i, k, *fft_peak, M, next_peak; 40 smpl_t norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val, 41 freq_bw_mel, *mel_peak, *height_norm, *lin_peak; 42 43 mel_peak = height_norm = lin_peak = NULL; 44 fft_peak = NULL; 45 norm = 1; 46 47 mel_freq_max = 1127 * log(1 + freq_max / 700); 48 mel_freq_min = 1127 * log(1 + freq_min / 700); 49 freq_bw_mel = (mel_freq_max - mel_freq_min) / freq_bands; 50 51 mel_peak = (smpl_t *)malloc((freq_bands + 2) * sizeof(smpl_t)); 52 /* +2 for zeros at start and end */ 53 lin_peak = (smpl_t *)malloc((freq_bands + 2) * sizeof(smpl_t)); 54 fft_peak = (int *)malloc((freq_bands + 2) * sizeof(int)); 55 height_norm = (smpl_t *)malloc(freq_bands * sizeof(smpl_t)); 56 57 if(mel_peak == NULL || height_norm == NULL || 58 lin_peak == NULL || fft_peak == NULL) 59 return XTRACT_MALLOC_FAILED; 60 61 M = N >> 1; 62 63 mel_peak[0] = mel_freq_min; 64 lin_peak[0] = 700 * (exp(mel_peak[0] / 1127) - 1); 65 fft_peak[0] = lin_peak[0] / nyquist * M; 66 67 68 for (n = 1; n <= freq_bands; n++){ 41 aubio_filterbank_t * new_aubio_filterbank(uint_t n_filters, uint_t win_s){ 42 /** allocating space for filterbank object */ 43 aubio_filterbank_t * fb = AUBIO_NEW(aubio_filterbank_t); 44 uint_t filter_cnt; 45 fb->win_s=win_s; 46 fb->n_filters=n_filters; 47 48 /** allocating filter tables */ 49 fb->filters=AUBIO_ARRAY(fvec_t*,n_filters); 50 for (filter_cnt=0; filter_cnt<n_filters; filter_cnt++) 51 /* considering one-channel filters */ 52 fb->filters[filter_cnt]=new_fvec(win_s, 1); 53 54 return fb; 55 } 56 57 aubio_filterbank_t * new_aubio_filterbank_mfcc(uint_t n_filters, uint_t win_s, smpl_t samplerate, smpl_t freq_min, smpl_t freq_max){ 58 59 uint_t writelog=1; 60 61 FILE * mlog; 62 if(writelog==1) mlog=fopen("filterbank.txt","w"); 63 64 65 smpl_t nyquist = samplerate/2.; 66 uint_t style = 1; 67 aubio_filterbank_t * fb = new_aubio_filterbank(n_filters, win_s); 68 69 uint_t n, i, k, *fft_peak, M, next_peak; 70 smpl_t norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val, 71 freq_bw_mel, *mel_peak, *height_norm, *lin_peak; 72 73 mel_peak = height_norm = lin_peak = NULL; 74 fft_peak = NULL; 75 norm = 1; 76 77 mel_freq_max = 1127 * log(1 + freq_max / 700); 78 mel_freq_min = 1127 * log(1 + freq_min / 700); 79 freq_bw_mel = (mel_freq_max - mel_freq_min) / fb->n_filters; 80 81 mel_peak = (smpl_t *)malloc((fb->n_filters + 2) * sizeof(smpl_t)); 82 /* +2 for zeros at start and end */ 83 lin_peak = (smpl_t *)malloc((fb->n_filters + 2) * sizeof(smpl_t)); 84 fft_peak = (uint_t *)malloc((fb->n_filters + 2) * sizeof(uint_t)); 85 height_norm = (smpl_t *)malloc(fb->n_filters * sizeof(smpl_t)); 86 87 if(mel_peak == NULL || height_norm == NULL || 88 lin_peak == NULL || fft_peak == NULL) 89 return NULL; 90 91 M = fb->win_s >> 1; 92 93 mel_peak[0] = mel_freq_min; 94 lin_peak[0] = 700 * (exp(mel_peak[0] / 1127) - 1); 95 fft_peak[0] = lin_peak[0] / nyquist * M; 96 97 for (n = 1; n <= fb->n_filters; n++){ 69 98 /*roll out peak locations - mel, linear and linear on fft window scale */ 70 mel_peak[n] = mel_peak[n - 1] + freq_bw_mel; 71 lin_peak[n] = 700 * (exp(mel_peak[n] / 1127) -1); 72 fft_peak[n] = lin_peak[n] / nyquist * M; 73 } 74 75 for (n = 0; n < freq_bands; n++){ 76 /*roll out normalised gain of each peak*/ 77 if (style == XTRACT_EQUAL_GAIN){ 78 height = 1; 79 norm_fact = norm; 80 } 81 else{ 82 height = 2 / (lin_peak[n + 2] - lin_peak[n]); 83 norm_fact = norm / (2 / (lin_peak[2] - lin_peak[0])); 84 } 85 height_norm[n] = height * norm_fact; 86 } 87 88 i = 0; 89 90 for(n = 0; n < freq_bands; n++){ 91 92 /*calculate the rise increment*/ 93 if(n > 0) 94 inc = height_norm[n] / (fft_peak[n] - fft_peak[n - 1]); 95 else 96 inc = height_norm[n] / fft_peak[n]; 97 val = 0; 98 99 /*zero the start of the array*/ 100 for(k = 0; k < i; k++) 101 fft_tables[n][k] = 0.f; 102 103 /*fill in the rise */ 104 for(; i <= fft_peak[n]; i++){ 105 fft_tables[n][i] = val; 106 val += inc; 107 } 108 109 /*calculate the fall increment */ 110 inc = height_norm[n] / (fft_peak[n + 1] - fft_peak[n]); 111 112 val = 0; 113 next_peak = fft_peak[n + 1]; 114 115 /*reverse fill the 'fall' */ 116 for(i = next_peak; i > fft_peak[n]; i--){ 117 fft_tables[n][i] = val; 118 val += inc; 119 } 120 121 /*zero the rest of the array*/ 122 for(k = next_peak + 1; k < N; k++) 123 fft_tables[n][k] = 0.f; 124 } 125 126 free(mel_peak); 127 free(lin_peak); 128 free(height_norm); 129 free(fft_peak); 130 131 return XTRACT_SUCCESS; 132 133 } 99 mel_peak[n] = mel_peak[n - 1] + freq_bw_mel; 100 lin_peak[n] = 700 * (exp(mel_peak[n] / 1127) -1); 101 fft_peak[n] = lin_peak[n] / nyquist * M; 102 } 103 104 for (n = 0; n < fb->n_filters; n++){ 105 /*roll out normalised gain of each peak*/ 106 if (style == USE_EQUAL_GAIN){ 107 height = 1; 108 norm_fact = norm; 109 } 110 else{ 111 height = 2 / (lin_peak[n + 2] - lin_peak[n]); 112 norm_fact = norm / (2 / (lin_peak[2] - lin_peak[0])); 113 } 114 height_norm[n] = height * norm_fact; 115 } 116 117 i = 0; 118 119 for(n = 0; n < fb->n_filters; n++){ 120 121 /*calculate the rise increment*/ 122 if(n > 0) 123 inc = height_norm[n] / (fft_peak[n] - fft_peak[n - 1]); 124 else 125 inc = height_norm[n] / fft_peak[n]; 126 val = 0; 127 128 /*zero the start of the array*/ 129 for(k = 0; k < i; k++) 130 fb->filters[n]->data[0][k]=0.f; 131 132 /*fill in the rise */ 133 for(; i <= fft_peak[n]; i++){ 134 fb->filters[n]->data[0][k]=val; 135 val += inc; 136 } 137 138 /*calculate the fall increment */ 139 inc = height_norm[n] / (fft_peak[n + 1] - fft_peak[n]); 140 141 val = 0; 142 next_peak = fft_peak[n + 1]; 143 144 /*reverse fill the 'fall' */ 145 for(i = next_peak; i > fft_peak[n]; i--){ 146 fb->filters[n]->data[0][k]=val; 147 val += inc; 148 } 149 150 /*zero the rest of the array*/ 151 for(k = next_peak + 1; k < fb->win_s; k++) 152 fb->filters[n]->data[0][k]=0.f; 153 154 if(writelog){ 155 //dumping filter values 156 smpl_t area_tmp=0.f; 157 for(k = 0; k < fb->win_s; k++){ 158 fprintf(mlog,"%f ",fb->filters[n]->data[0][k]); 159 } 160 fprintf(mlog,"\n"); 161 } 162 163 } 164 165 free(mel_peak); 166 free(lin_peak); 167 free(height_norm); 168 free(fft_peak); 169 170 if(mlog) fclose(mlog); 171 172 return fb; 173 174 } 175 176 177 void del_aubio_filterbank(aubio_filterbank_t * fb){ 178 uint_t filter_cnt; 179 /** deleting filter tables first */ 180 for (filter_cnt=0; filter_cnt<fb->n_filters; filter_cnt++) 181 del_fvec(fb->filters[filter_cnt]); 182 AUBIO_FREE(fb->filters); 183 AUBIO_FREE(fb); 184 } 185 186 void aubio_filterbank_do(aubio_filterbank_t * f, cvec_t * in, fvec_t *out) { 187 uint_t n, filter_cnt; 188 for(filter_cnt = 0; (filter_cnt < f->n_filters) 189 && (filter_cnt < out->length); filter_cnt++){ 190 out->data[0][filter_cnt] = 0.f; 191 for(n = 0; n < in->length; n++){ 192 out->data[0][filter_cnt] += in->norm[0][n] 193 * f->filters[filter_cnt]->data[0][n]; 194 } 195 out->data[0][filter_cnt] = 196 LOG(out->data[0][filter_cnt] < VERY_SMALL_NUMBER ? 197 VERY_SMALL_NUMBER : out->data[0][filter_cnt]); 198 } 199 200 return; 201 } -
src/filterbank.h
r7c6c806d r7a46bf6 1 1 /* 2 Copyright (C) 2007 Amaury Hazan 3 Ported to aubio from LibXtract 4 http://libxtract.sourceforge.net/ 5 2 Copyright (C) 2007 Amaury Hazan <ahazan@iua.upf.edu> 3 and Paul Brossier <piem@piem.org> 6 4 7 5 This program is free software; you can redistribute it and/or modify … … 20 18 */ 21 19 22 #ifndef AUBIOFILTERBANK_H 23 #define AUBIOFILTERBANK_H 20 /** \file 21 22 Filterbank object 23 24 General-purpose spectral filterbank object. Comes with mel-filter initialization function. 25 26 */ 27 28 #ifndef FILTERBANK_H 29 #define FILTERBANK_H 24 30 25 31 #ifdef __cplusplus … … 27 33 #endif 28 34 35 typedef struct aubio_filterbank_t_ aubio_filterbank_t; 36 37 /** create filterbank object 38 39 \param win_s size of analysis buffer (and length the FFT transform) 40 \param n_filters number of filters to create 41 42 */ 43 44 aubio_filterbank_t * new_aubio_filterbank(uint_t n_filters, uint_t win_s); 45 46 /** filterbank initialization for mel filters 47 48 \param nyquist nyquist frequency, i.e. half of the sampling rate 49 \param style libxtract style 50 \param freqmin lowest filter frequency 51 \param freqmax highest filter frequency 52 53 */ 54 aubio_filterbank_t * new_aubio_filterbank_mfcc(uint_t n_filters, uint_t win_s, smpl_t samplerate, smpl_t freq_min, smpl_t freq_max); 29 55 30 56 31 typedef struct aubio_mel_filter_ aubio_mel_filter; 57 /** destroy filterbank object 32 58 33 // Initialization 59 \param fb filterbank, as returned by new_aubio_filterbank method 34 60 35 /** \brief A function to initialise a mel filter bank 36 * 37 * 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 38 */ 39 int 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); 61 */ 62 void del_aubio_filterbank(aubio_filterbank_t * fb); 63 64 /** compute filterbank 65 66 */ 67 void aubio_filterbank_do(aubio_filterbank_t * fb, cvec_t * in, fvec_t *out); 40 68 41 69 #ifdef __cplusplus … … 43 71 #endif 44 72 45 #endif 73 #endif // FILTERBANK_H -
src/mfcc.c
r7c6c806d r7a46bf6 24 24 #include "sample.h" 25 25 #include "fft.h" 26 #include "filterbank.h" 26 27 #include "mfcc.h" 27 28 #include "math.h" 28 29 29 /* 30 new_aubio_mfcc 31 aubio_mfcc_do 32 del_aubio_mfcc 33 */ 30 /** Internal structure for mfcc object **/ 34 31 35 // Computation 36 // Added last two arguments to be able to pass from example 32 struct aubio_mfcc_t_{ 33 uint_t win_s; /** grain length */ 34 uint_t samplerate; /** sample rate (needed?) */ 35 uint_t channels; /** number of channels */ 36 uint_t n_filters; /** number of *filters */ 37 uint_t n_coefs; /** number of coefficients (<= n_filters/2 +1) */ 38 smpl_t lowfreq; /** lowest frequency for filters */ 39 smpl_t highfreq; /** highest frequency for filters */ 40 aubio_filterbank_t * fb; /** filter bank */ 41 fvec_t * in_dct; /** input buffer for dct * [fb->n_filters] */ 42 aubio_mfft_t * fft_dct; /** fft object for dct */ 43 cvec_t * fftgrain_dct; /** output buffer for dct */ 44 }; 37 45 38 46 47 aubio_mfcc_t * new_aubio_mfcc (uint_t win_s, uint_t samplerate, uint_t n_filters, uint_t n_coefs, smpl_t lowfreq, smpl_t highfreq, uint_t channels){ 48 /** allocating space for mfcc object */ 49 aubio_mfcc_t * mfcc = AUBIO_NEW(aubio_mfcc_t); 39 50 40 int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t * fft_dct, cvec_t * fftgrain_dct){ 51 //we need (n_coefs-1)*2 filters to obtain n_coefs coefficients after dct 52 //uint_t n_filters = (n_coefs-1)*2; 53 54 mfcc->win_s=win_s; 55 mfcc->samplerate=samplerate; 56 mfcc->channels=channels; 57 mfcc->n_filters=n_filters; 58 mfcc->n_coefs=n_coefs; 59 mfcc->lowfreq=lowfreq; 60 mfcc->highfreq=highfreq; 41 61 42 aubio_mel_filter *f;43 int n, filter;62 /** filterbank allocation */ 63 mfcc->fb = new_aubio_filterbank_mfcc(n_filters, mfcc->win_s, samplerate, lowfreq, highfreq); 44 64 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 } 65 /** allocating space for fft object (used for dct) */ 66 mfcc->fft_dct=new_aubio_mfft(n_filters, 1); 54 67 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; 68 /** allocating buffers */ 69 mfcc->in_dct=new_fvec(mfcc->win_s, 1); 70 71 mfcc->fftgrain_dct=new_cvec(n_filters, 1); 72 73 return mfcc; 74 }; 75 76 void del_aubio_mfcc(aubio_mfcc_t *mf){ 77 /** deleting filterbank */ 78 del_aubio_filterbank(mf->fb); 79 /** deleting mfft object */ 80 del_aubio_mfft(mf->fft_dct); 81 /** deleting buffers */ 82 del_fvec(mf->in_dct); 83 del_cvec(mf->fftgrain_dct); 84 85 /** deleting mfcc object */ 86 AUBIO_FREE(mf); 61 87 } 62 88 63 // Added last two arguments to be able to pass from example 89 void aubio_mfcc_do(aubio_mfcc_t * mf, cvec_t *in, fvec_t *out){ 90 // compute filterbank 91 aubio_filterbank_do(mf->fb, in, mf->in_dct); 92 //TODO: check that zero padding 93 // the following line seems useless since the in_dct buffer has the correct size 94 //for(n = filter + 1; n < N; n++) result[n] = 0; 95 96 aubio_dct_do(mf, mf->in_dct, out); 64 97 65 int 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 98 return; 99 } 69 100 70 //TODO: fvec as input? Remove data length, N? 101 void aubio_dct_do(aubio_mfcc_t * mf, fvec_t *in, fvec_t *out){ 102 uint_t i; 103 //compute mag spectrum 104 aubio_mfft_do (mf->fft_dct, in, mf->fftgrain_dct); 105 //extract real part of fft grain 106 for(i=0; i<mf->n_coefs ;i++){ 107 //for(i=0; i<out->length;i++){ 108 out->data[0][i]= mf->fftgrain_dct->norm[0][i] 109 *COS(mf->fftgrain_dct->phas[0][i]); 110 } 111 return; 112 } 71 113 72 fvec_t * momo = new_fvec(20, 1);73 momo->data = data;74 75 //compute mag spectrum76 aubio_mfft_do (fft_dct, data, fftgrain_dct);77 78 int i;79 //extract real part of fft grain80 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 } -
src/mfcc.h
r7c6c806d r7a46bf6 1 1 /* 2 Copyright (C) 2006 Amaury Hazan 3 Ported to aubio from LibXtract 4 http://libxtract.sourceforge.net/ 5 2 Copyright (C) 2007 Amaury Hazan <ahazan@iua.upf.edu> 3 and Paul Brossier <piem@piem.org> 6 4 7 5 This program is free software; you can redistribute it and/or modify … … 21 19 */ 22 20 21 /* part of this mfcc implementation were inspired from LibXtract 22 http://libxtract.sourceforge.net/ 23 */ 24 23 25 #ifndef MFCC_H 24 26 #define MFCC_H … … 28 30 #endif 29 31 32 #include "sample.h" 30 33 #include "filterbank.h" 31 34 32 //libXtract constants and enums 33 // TODO: remove them 35 typedef struct aubio_mfcc_t_ aubio_mfcc_t; 34 36 35 #define XTRACT_SQ(a) ((a) * (a)) 36 #define XTRACT_MIN(a, b) ((a) < (b) ? (a) : (b)) 37 #define XTRACT_MAX(a, b) ((a) > (b) ? (a) : (b)) 38 #define XTRACT_NEEDS_FFTW printf("LibXtract must be compiled with fftw support to use this function.\n") 39 #define XTRACT_VERY_SMALL_NUMBER 2e-42 40 #define XTRACT_LOG_LIMIT XTRACT_VERY_SMALL_NUMBER 41 #define XTRACT_LOG_LIMIT_DB -96.0 42 #define XTRACT_DB_SCALE_OFFSET 96.0 43 #define XTRACT_VERY_BIG_NUMBER 2e42 44 #define XTRACT_SR_UPPER_LIMIT 192000.0 45 #define XTRACT_SR_LOWER_LIMIT 22050.0 46 #define XTRACT_SR_DEFAULT 44100.0 47 #define XTRACT_FUNDAMENTAL_DEFAULT 440.0 48 #define XTRACT_CHECK_nyquist if(!nyquist) nyquist = XTRACT_SR_DEFAULT / 2 49 #define XTRACT_CHECK_q if(!q) q = XTRACT_SR_DEFAULT / N 50 #define XTRACT_IS_ODD(x) (x % 2 != 0 ? 1 : 0) 51 #define XTRACT_SR_LIMIT SR_UPPER_LIMIT 52 #define XTRACT_FFT_BANDS_MIN 16 53 #define XTRACT_FFT_BANDS_MAX 65536 54 #define XTRACT_FFT_BANDS_DEF 1024 55 #define XTRACT_SPEC_BW_MIN 0.168 /* Minimum spectral bandwidth \ 56 (= SR_LOWER_LIMIT / FFT_BANDS_MAX*/ 57 #define XTRACT_SPEC_BW_MAX 12000.0 /* SR_UPPER_LIMIT / FFT_BANDS_MIN */ 58 #define XTRACT_SPEC_BW_DEF 43.066 /* SR_DEFAULT / FFT_BANDS_DEF */ 37 /** create mfcc object 59 38 60 /** \brief Enumeration of feature initialisation functions */ 61 enum xtract_feature_init_ { 62 XTRACT_INIT_MFCC = 100, 63 XTRACT_INIT_BARK 64 }; 39 \param win_s size of analysis buffer (and length the FFT transform) 40 \param samplerate 41 \param n_coefs: number of desired coefs 42 \param lowfreq: lowest frequency to use in filterbank 43 \param highfreq highest frequency to use in filterbank 44 \param channels number of channels 65 45 66 /** \brief Enumeration of feature types */ 67 enum xtract_feature_types_ { 68 XTRACT_SCALAR, 69 XTRACT_VECTOR, 70 XTRACT_DELTA 71 }; 46 */ 47 aubio_mfcc_t * new_aubio_mfcc (uint_t win_s, uint_t samplerate, uint_t n_filters, uint_t n_coefs, smpl_t lowfreq, smpl_t highfreq, uint_t channels); 48 /** delete mfcc object 72 49 73 /** \brief Enumeration of mfcc types */ 74 enum xtract_mfcc_types_ { 75 XTRACT_EQUAL_GAIN, 76 XTRACT_EQUAL_AREA 77 }; 50 \param mf mfcc object as returned by new_aubio_mfcc 78 51 79 /** \brief Enumeration of return codes */ 80 enum xtract_return_codes_ { 81 XTRACT_SUCCESS, 82 XTRACT_MALLOC_FAILED, 83 XTRACT_BAD_ARGV, 84 XTRACT_BAD_VECTOR_SIZE, 85 XTRACT_NO_RESULT, 86 XTRACT_FEATURE_NOT_IMPLEMENTED 87 }; 52 */ 53 void del_aubio_mfcc(aubio_mfcc_t *mf); 54 /** mfcc object processing 88 55 89 /** \brief Enumeration of spectrum types */ 90 enum xtract_spectrum_ { 91 XTRACT_MAGNITUDE_SPECTRUM, 92 XTRACT_LOG_MAGNITUDE_SPECTRUM, 93 XTRACT_POWER_SPECTRUM, 94 XTRACT_LOG_POWER_SPECTRUM 95 }; 56 \param mf mfcc object as returned by new_aubio_mfcc 57 \param in input spectrum (win_s long) 58 \param out output mel coefficients buffer (n_filters/2 +1 long) 96 59 97 /** \brief Enumeration of data types*/ 98 typedef enum type_ { 99 XTRACT_FLOAT, 100 XTRACT_FLOATARRAY, 101 XTRACT_INT, 102 XTRACT_MEL_FILTER 103 } xtract_type_t; 60 */ 61 void aubio_mfcc_do(aubio_mfcc_t * mf, cvec_t *in, fvec_t *out); 104 62 105 /** \brief Enumeration of units*/ 106 typedef enum unit_ { 107 /* NONE, ANY */ 108 XTRACT_HERTZ = 2, 109 XTRACT_ANY_AMPLITUDE_HERTZ, 110 XTRACT_DBFS, 111 XTRACT_DBFS_HERTZ, 112 XTRACT_PERCENT, 113 XTRACT_SONE 114 } xtract_unit_t; 63 /** intermediate dct involved in aubio_mfcc_do 115 64 116 /** \brief Boolean */ 117 typedef enum { 118 XTRACT_FALSE, 119 XTRACT_TRUE 120 } xtract_bool_t; 65 \param mf mfcc object as returned by new_aubio_mfcc 66 \param in input spectrum (n_filters long) 67 \param out output mel coefficients buffer (n_filters/2 +1 long) 121 68 122 /** \brief Enumeration of vector format types*/ 123 typedef enum xtract_vector_ { 124 /* N/2 magnitude/log-magnitude/power/log-power coeffs and N/2 frequencies */ 125 XTRACT_SPECTRAL, 126 /* N spectral amplitudes */ 127 XTRACT_SPECTRAL_MAGNITUDES, 128 /* N/2 magnitude/log-magnitude/power/log-power peak coeffs and N/2 129 * frequencies */ 130 XTRACT_SPECTRAL_PEAKS, 131 /* N spectral peak amplitudes */ 132 XTRACT_SPECTRAL_PEAKS_MAGNITUDES, 133 /* N spectral peak frequencies */ 134 XTRACT_SPECTRAL_PEAKS_FREQUENCIES, 135 /* N/2 magnitude/log-magnitude/power/log-power harmonic peak coeffs and N/2 136 * frequencies */ 137 XTRACT_SPECTRAL_HARMONICS, 138 /* N spectral harmonic amplitudes */ 139 XTRACT_SPECTRAL_HARMONICS_MAGNITUDES, 140 /* N spectral harmonic frequencies */ 141 XTRACT_SPECTRAL_HARMONICS_FREQUENCIES, 142 XTRACT_ARBITRARY_SERIES, 143 XTRACT_AUDIO_SAMPLES, 144 XTRACT_MEL_COEFFS, 145 XTRACT_BARK_COEFFS, 146 XTRACT_NO_DATA 147 } xtract_vector_t; 148 149 150 151 152 // Computation 153 154 /** \brief Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner 155 * 156 * \param *data: a pointer to the first element in an array of spectral magnitudes, e.g. the first half of the array pointed to by *resul from xtract_spectrum() 157 * \param N: the number of array elements to be considered 158 * \param *argv: a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a mel-spaced filterbank 159 * \param *result: a pointer to an array containing the resultant MFCC 160 * 161 * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc 162 */ 163 164 165 int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t *fft_dct, cvec_t *fftgrain_dct); 166 167 /** \brief Extract the Discrete Cosine transform of a time domain signal 168 * \param *data: a pointer to the first element in an array of floats representing an audio vector 169 * \param N: the number of array elements to be considered 170 * \param *argv: a pointer to NULL 171 * \param *result: a pointer to an array containing resultant dct coefficients 172 */ 173 int aubio_dct_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t *fft_dct, cvec_t *fftgrain_dct); 69 */ 70 void aubio_dct_do(aubio_mfcc_t * mf, fvec_t *in, fvec_t *out); 174 71 175 72 #ifdef __cplusplus … … 177 74 #endif 178 75 179 #endif 76 #endif // MFCC_H -
src/tempo.c
r7c6c806d r7a46bf6 124 124 } 125 125 126 smpl_t aubio_tempo_get_bpm(aubio_tempo_t *o) { 127 return aubio_beattracking_get_bpm(o->bt); 128 } 129 126 130 void del_aubio_tempo (aubio_tempo_t *o) 127 131 { -
src/tempo.h
r7c6c806d r7a46bf6 50 50 void aubio_tempo_set_threshold(aubio_tempo_t * o, smpl_t threshold); 51 51 52 /** get current tempo 53 54 \param bt beat tracking object 55 56 Returns the currently observed tempo, or 0 if no consistent value is found 57 58 */ 59 smpl_t aubio_tempo_get_bpm(aubio_tempo_t * bt); 60 52 61 /** delete tempo detection object */ 53 62 void del_aubio_tempo(aubio_tempo_t * o);
Note: See TracChangeset
for help on using the changeset viewer.