Changeset 71b1b4b
- Timestamp:
- Sep 6, 2007, 3:52:19 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:
- 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. - Files:
-
- 5 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
examples/aubiomfcc.c
rdcc649c r71b1b4b 46 46 //compute mag spectrum 47 47 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); 48 58 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"); 53 62 54 63 … … 79 88 int main(int argc, char **argv) { 80 89 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 81 109 examples_common_process(aubio_process,process_print); 82 110 examples_common_del(); 83 111 debug("End of program.\n"); 84 112 fflush(stderr); 113 114 //destroying filterbank 115 free(mf); 116 85 117 return 0; 86 118 } -
src/Makefile.am
rdcc649c r71b1b4b 22 22 onset.h \ 23 23 tempo.h \ 24 filter.h 24 filter.h 25 25 26 nodist_pkginclude_HEADERS = config.h 26 27 … … 69 70 tempo.h \ 70 71 filter.c \ 71 filter.h 72 filter.h \ 72 73 73 74 AM_CFLAGS = @AUBIO_CFLAGS@ @FFTWLIB_CFLAGS@ @SAMPLERATE_CFLAGS@ -
src/aubio.h
rdcc649c r71b1b4b 80 80 #include "onset.h" 81 81 #include "tempo.h" 82 #include "mfcc.h" 82 83 83 84 #ifdef __cplusplus -
src/filterbank.c
rdcc649c r71b1b4b 21 21 */ 22 22 23 #include " aubiofilterbank.h"23 #include "filterbank.h" 24 24 25 25 // Initialization 26 26 27 int aubio_mfcc_init(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, float **fft_tables){27 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){ 28 28 29 29 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, 31 31 freq_bw_mel, *mel_peak, *height_norm, *lin_peak; 32 32 … … 39 39 freq_bw_mel = (mel_freq_max - mel_freq_min) / freq_bands; 40 40 41 mel_peak = ( float *)malloc((freq_bands + 2) * sizeof(float));41 mel_peak = (smpl_t *)malloc((freq_bands + 2) * sizeof(smpl_t)); 42 42 /* +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)); 44 44 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)); 46 46 47 47 if(mel_peak == NULL || height_norm == NULL || -
src/filterbank.h
rdcc649c r71b1b4b 18 18 along with this program; if not, write to the Free Software 19 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 21 20 */ 22 21 23 22 #ifndef AUBIOFILTERBANK_H 24 # include AUBIOFILTERBANK_H23 #define AUBIOFILTERBANK_H 25 24 26 #define NYQUIST 22050.f27 25 28 26 // Struct Declaration … … 31 29 typedef struct aubio_mel_filter_ { 32 30 int n_filters; 33 float **filters;31 smpl_t **filters; 34 32 } aubio_mel_filter; 35 33 … … 40 38 * 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 41 39 */ 42 int aubio_mfcc_init(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, float **fft_tables);40 int aubio_mfcc_init(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, smpl_t ** fft_tables); 43 41 44 42 #endif -
src/mfcc.c
rdcc649c r71b1b4b 23 23 24 24 #include "mffc.h" 25 #include "aubiofilterbank.h"26 25 27 26 // Computation … … 42 41 } 43 42 43 //TODO: check that zero padding 44 44 for(n = filter + 1; n < N; n++) result[n] = 0; 45 45 … … 51 51 int aubio_dct_do(const float *data, const int N, const void *argv, float *result){ 52 52 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 /* 53 68 fftwf_plan plan; 54 69 … … 57 72 58 73 fftwf_execute(plan); 59 fftwf_destroy_plan(plan); 74 fftwf_destroy_plan(plan);*/ 60 75 61 76 return XTRACT_SUCCESS; -
src/mfcc.h
rdcc649c r71b1b4b 24 24 #define MFCC_H 25 25 26 #include "filterbank.h" 26 27 27 28 //libXtract enums
Note: See TracChangeset
for help on using the changeset viewer.