- Timestamp:
- Sep 17, 2009, 1:25:10 AM (15 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:
- cfd35db
- Parents:
- 06cae6c
- Location:
- src/spectral
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/spectral/filterbank.c
r06cae6c r3b3b03e 29 29 30 30 /** \brief A structure to store a set of n_filters filters of lenghts win_s */ 31 struct aubio_filterbank_t_ { 32 uint_t win_s; 33 uint_t n_filters; 34 fvec_t *filters; 31 struct aubio_filterbank_t_ 32 { 33 uint_t win_s; 34 uint_t n_filters; 35 fvec_t *filters; 35 36 }; 36 37 37 aubio_filterbank_t * new_aubio_filterbank(uint_t n_filters, uint_t win_s){ 38 aubio_filterbank_t * 39 new_aubio_filterbank (uint_t n_filters, uint_t win_s) 40 { 38 41 /* allocate space for filterbank object */ 39 aubio_filterbank_t * fb = AUBIO_NEW(aubio_filterbank_t);40 fb->win_s =win_s;41 fb->n_filters =n_filters;42 aubio_filterbank_t *fb = AUBIO_NEW (aubio_filterbank_t); 43 fb->win_s = win_s; 44 fb->n_filters = n_filters; 42 45 43 46 /* allocate filter tables, an fvec of length win_s and of filter_cnt channel */ 44 fb->filters = new_fvec (win_s, n_filters);47 fb->filters = new_fvec (win_s, n_filters); 45 48 46 49 return fb; 47 50 } 48 51 49 void del_aubio_filterbank(aubio_filterbank_t * fb){ 50 del_fvec(fb->filters); 51 AUBIO_FREE(fb); 52 void 53 del_aubio_filterbank (aubio_filterbank_t * fb) 54 { 55 del_fvec (fb->filters); 56 AUBIO_FREE (fb); 52 57 } 53 58 54 void aubio_filterbank_do(aubio_filterbank_t * f, cvec_t * in, fvec_t *out) { 59 void 60 aubio_filterbank_do (aubio_filterbank_t * f, cvec_t * in, fvec_t * out) 61 { 55 62 uint_t i, j, fn; 56 63 57 64 /* apply filter to all input channel, provided out has enough channels */ 58 uint_t max_channels = MIN (in->channels, out->channels);59 uint_t max_filters = MIN(f->n_filters, out->length);65 uint_t max_channels = MIN (in->channels, out->channels); 66 uint_t max_filters = MIN (f->n_filters, out->length); 60 67 61 68 /* reset all values in output vector */ 62 fvec_zeros (out);69 fvec_zeros (out); 63 70 64 71 /* apply filters on all channels */ … … 66 73 67 74 /* for each filter */ 68 for (fn = 0; fn < max_filters; fn++) {75 for (fn = 0; fn < max_filters; fn++) { 69 76 70 77 /* for each sample */ 71 for (j = 0; j < in->length; j++) {72 78 for (j = 0; j < in->length; j++) { 79 out->data[i][fn] += in->norm[i][j] * f->filters->data[fn][j]; 73 80 } 74 81 75 82 /* threshold to VERY_SMALL_NUMBER to avoid log oveflow */ 76 out->data[i][fn] = MAX (VERY_SMALL_NUMBER, out->data[i][fn]);83 out->data[i][fn] = MAX (VERY_SMALL_NUMBER, out->data[i][fn]); 77 84 78 85 /* compute logarithm */ 79 out->data[i][fn] = LOG (out->data[i][fn]);86 out->data[i][fn] = LOG (out->data[i][fn]); 80 87 } 81 88 } … … 84 91 } 85 92 86 fvec_t * aubio_filterbank_get_coeffs(aubio_filterbank_t * f) { 93 fvec_t * 94 aubio_filterbank_get_coeffs (aubio_filterbank_t * f) 95 { 87 96 return f->filters; 88 97 } -
src/spectral/filterbank.h
r06cae6c r3b3b03e 32 32 33 33 #ifdef __cplusplus 34 extern "C" { 34 extern "C" 35 { 35 36 #endif 36 37 … … 45 46 */ 46 47 47 aubio_filterbank_t * new_aubio_filterbank(uint_t n_filters, uint_t win_s);48 aubio_filterbank_t *new_aubio_filterbank (uint_t n_filters, uint_t win_s); 48 49 49 50 /** destroy filterbank object … … 52 53 53 54 */ 54 void del_aubio_filterbank (aubio_filterbank_t * fb);55 void del_aubio_filterbank (aubio_filterbank_t * fb); 55 56 56 57 /** compute filterbank … … 61 62 62 63 */ 63 void aubio_filterbank_do (aubio_filterbank_t * fb, cvec_t * in, fvec_t *out);64 void aubio_filterbank_do (aubio_filterbank_t * fb, cvec_t * in, fvec_t * out); 64 65 65 66 /** return a pointer to the fvec object containing all filter coefficients … … 68 69 69 70 */ 70 fvec_t * aubio_filterbank_get_coeffs(aubio_filterbank_t * f);71 fvec_t *aubio_filterbank_get_coeffs (aubio_filterbank_t * f); 71 72 72 73 #ifdef __cplusplus … … 74 75 #endif 75 76 76 #endif // FILTERBANK_H77 #endif // FILTERBANK_H
Note: See TracChangeset
for help on using the changeset viewer.