- Timestamp:
- Sep 17, 2009, 4:02:04 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:
- 4e0fbe6
- Parents:
- addc9ec
- Location:
- src/spectral
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/spectral/filterbank_mel.c
raddc9ec rb507607 27 27 28 28 void 29 aubio_filterbank_set_mel_coeffs (aubio_filterbank_t * fb, uint_t samplerate,29 aubio_filterbank_set_mel_coeffs (aubio_filterbank_t * fb, smpl_t samplerate, 30 30 smpl_t freq_min, smpl_t freq_max) 31 31 { … … 42 42 uint_t logFilters = 27; 43 43 uint_t allFilters = linearFilters + logFilters; 44 45 if (allFilters > n_filters) { 46 AUBIO_WRN("not enough Mel filters, got %d but %d needed\n", 47 n_filters, allFilters); 48 } 44 49 45 50 //buffers for computing filter frequencies … … 65 70 for (filter_cnt = 0; filter_cnt < logFilters + 2; filter_cnt++) { 66 71 freqs->data[0][filter_cnt + linearFilters] = 67 lastlinearCF * ( pow(logSpacing, filter_cnt + 1));72 lastlinearCF * (POW(logSpacing, filter_cnt + 1)); 68 73 } 69 74 … … 84 89 } 85 90 86 //AUBIO_DBG("filter tables frequencies\n");87 //for(filter_cnt=0; filter_cnt<allFilters; filter_cnt++)88 // AUBIO_DBG("filter n. %d %f %f %f %f\n",89 // filter_cnt, lower_freqs->data[0][filter_cnt],90 // center_freqs->data[0][filter_cnt], upper_freqs->data[0][filter_cnt],91 // triangle_heights->data[0][filter_cnt]);92 93 91 //filling the fft_freqs lookup table, which assigns the frequency in hz to each bin 94 92 for (bin_cnt = 0; bin_cnt < win_s; bin_cnt++) { … … 96 94 } 97 95 98 //building each filter table99 for (filter_cnt = 0; filter_cnt < allFilters; filter_cnt++) {100 96 101 //TODO:check special case : lower freq =0 102 //calculating rise increment in mag/Hz 103 smpl_t riseInc = 104 triangle_heights->data[0][filter_cnt] / 105 (center_freqs->data[0][filter_cnt] - lower_freqs->data[0][filter_cnt]); 97 /* zeroing begining of filter */ 98 fvec_zeros(filters); 106 99 107 //zeroing begining of filter 100 /* building each filter table */ 101 for (filter_cnt = 0; filter_cnt < n_filters; filter_cnt++) { 102 103 /* skip first elements */ 108 104 for (bin_cnt = 0; bin_cnt < win_s - 1; bin_cnt++) { 109 filters->data[filter_cnt][bin_cnt] = 0.0;110 105 if (fft_freqs->data[0][bin_cnt] <= lower_freqs->data[0][filter_cnt] && 111 106 fft_freqs->data[0][bin_cnt + 1] > lower_freqs->data[0][filter_cnt]) { … … 115 110 bin_cnt++; 116 111 117 //positive slope 112 /* compute positive slope step size */ 113 smpl_t riseInc = 114 triangle_heights->data[0][filter_cnt] / 115 (center_freqs->data[0][filter_cnt] - lower_freqs->data[0][filter_cnt]); 116 117 /* compute coefficients in positive slope */ 118 118 for (; bin_cnt < win_s - 1; bin_cnt++) { 119 119 filters->data[filter_cnt][bin_cnt] = 120 120 (fft_freqs->data[0][bin_cnt] - 121 121 lower_freqs->data[0][filter_cnt]) * riseInc; 122 //if(fft_freqs->data[0][bin_cnt]<= center_freqs->data[0][filter_cnt] && fft_freqs->data[0][bin_cnt+1]> center_freqs->data[0][filter_cnt])122 123 123 if (fft_freqs->data[0][bin_cnt + 1] > center_freqs->data[0][filter_cnt]) 124 124 break; 125 125 } 126 //bin_cnt++;126 bin_cnt++; 127 127 128 //negative slope 128 /* compute negative slope step size */ 129 smpl_t downInc = 130 triangle_heights->data[0][filter_cnt] / 131 (upper_freqs->data[0][filter_cnt] - center_freqs->data[0][filter_cnt]); 132 133 /* compute coefficents in negative slope */ 129 134 for (; bin_cnt < win_s - 1; bin_cnt++) { 135 filters->data[filter_cnt][bin_cnt] += 136 (upper_freqs->data[0][filter_cnt] - 137 fft_freqs->data[0][bin_cnt]) * downInc; 130 138 131 //checking whether last value is less than 0...132 smpl_t val =133 triangle_heights->data[0][filter_cnt] - (fft_freqs->data[0][bin_cnt] -134 center_freqs->data[0][filter_cnt]) * riseInc;135 if (val >= 0)136 filters->data[filter_cnt][bin_cnt] = val;137 else138 filters->data[filter_cnt][bin_cnt] = 0.0;139 140 //if(fft_freqs->data[0][bin_cnt]<= upper_freqs->data[0][bin_cnt] && fft_freqs->data[0][bin_cnt+1]> upper_freqs->data[0][filter_cnt])141 //TODO: CHECK whether bugfix correct142 139 if (fft_freqs->data[0][bin_cnt + 1] > upper_freqs->data[0][filter_cnt]) 143 140 break; 144 141 } 145 //bin_cnt++; 146 147 //zeroing tail 148 for (; bin_cnt < win_s; bin_cnt++) 149 filters->data[filter_cnt][bin_cnt] = 0.f; 142 /* nothing else to do */ 150 143 151 144 } -
src/spectral/filterbank_mel.h
raddc9ec rb507607 46 46 \param n_filters number of filters 47 47 \param win_s window size 48 \param samplerate 48 \param samplerate audio sampling rate 49 49 \param freq_min lowest filter frequency 50 50 \param freq_max highest filter frequency … … 52 52 */ 53 53 void aubio_filterbank_set_mel_coeffs (aubio_filterbank_t * fb, 54 uint_t samplerate, smpl_t freq_min, smpl_t freq_max);54 smpl_t samplerate, smpl_t freq_min, smpl_t freq_max); 55 55 56 56 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.