Changeset fa713bd
 Timestamp:
 Nov 17, 2018, 3:15:07 AM (13 months ago)
 Branches:
 feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
 Children:
 04cd251
 Parents:
 2886984
 Location:
 src/spectral
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

src/spectral/filterbank_mel.c
r2886984 rfa713bd 207 207 return retval; 208 208 } 209 210 uint_t 211 aubio_filterbank_set_mel_coeffs (aubio_filterbank_t * fb, smpl_t samplerate, 212 smpl_t freq_min, smpl_t freq_max) 213 { 214 uint_t m, retval; 215 smpl_t start, end, step; 216 fvec_t *freqs; 217 fmat_t *coeffs = aubio_filterbank_get_coeffs(fb); 218 uint_t n_bands = coeffs>height; 219 220 if (freq_max < 0) { 221 AUBIO_ERR("filterbank: set_mel_coeffs freq_max should be > 0\n"); 222 return AUBIO_FAIL; 223 } else if (freq_max == 0) { 224 end = aubio_hztomel(samplerate / 2.); 225 } else { 226 end = aubio_hztomel(freq_max); 227 } 228 if (freq_min < 0) { 229 AUBIO_ERR("filterbank: set_mel_coeffs freq_min should be > 0\n"); 230 return AUBIO_FAIL; 231 } else { 232 start = aubio_hztomel(freq_min); 233 } 234 if (n_bands <= 0) { 235 AUBIO_ERR("filterbank: set_mel_coeffs n_bands should be > 0\n"); 236 return AUBIO_FAIL; 237 } 238 239 freqs = new_fvec(n_bands + 2); 240 step = (end  start) / (n_bands + 1); 241 242 for (m = 0; m < n_bands + 2; m++) 243 { 244 freqs>data[m] = MIN(aubio_meltohz(start + step * m), samplerate/2.); 245 } 246 247 retval = aubio_filterbank_set_triangle_bands (fb, freqs, samplerate); 248 249 /* destroy vector used to store frequency limits */ 250 del_fvec (freqs); 251 return retval; 252 } 253 254 uint_t 255 aubio_filterbank_set_mel_coeffs_htk (aubio_filterbank_t * fb, smpl_t samplerate, 256 smpl_t freq_min, smpl_t freq_max) 257 { 258 uint_t m, retval; 259 smpl_t start, end, step; 260 fvec_t *freqs; 261 fmat_t *coeffs = aubio_filterbank_get_coeffs(fb); 262 uint_t n_bands = coeffs>height; 263 264 if (freq_max < 0) { 265 AUBIO_ERR("filterbank: set_mel_coeffs freq_max should be > 0\n"); 266 return AUBIO_FAIL; 267 } else if (freq_max == 0) { 268 end = aubio_hztomel_htk(samplerate / 2.); 269 } else { 270 end = aubio_hztomel_htk(freq_max); 271 } 272 if (freq_min < 0) { 273 AUBIO_ERR("filterbank: set_mel_coeffs freq_min should be > 0\n"); 274 return AUBIO_FAIL; 275 } else { 276 start = aubio_hztomel_htk(freq_min); 277 } 278 if (n_bands <= 0) { 279 AUBIO_ERR("filterbank: set_mel_coeffs n_bands should be > 0\n"); 280 return AUBIO_FAIL; 281 } 282 283 freqs = new_fvec (n_bands + 2); 284 step = (end  start) / (n_bands + 1); 285 286 for (m = 0; m < n_bands + 2; m++) 287 { 288 freqs>data[m] = MIN(aubio_meltohz_htk(step * m), samplerate/2.); 289 } 290 291 retval = aubio_filterbank_set_triangle_bands (fb, freqs, samplerate); 292 293 /* destroy vector used to store frequency limits */ 294 del_fvec (freqs); 295 return retval; 296 } 
src/spectral/filterbank_mel.h
r2886984 rfa713bd 58 58 \param samplerate audio sampling rate 59 59 60 The filter coefficients are built according toMalcolm Slaney's Auditory61 Toolbox , available online at the following address (see file mfcc.m):60 The filter coefficients are built to match exactly Malcolm Slaney's Auditory 61 Toolbox implementation (see file mfcc.m). The number of filters should be 40. 62 62 63 References 64  65 66 Malcolm Slaney, *Auditory Toolbox Version 2, Technical Report #1998010* 63 67 https://engineering.purdue.edu/~malcolm/interval/1998010/ 64 68 … … 67 71 smpl_t samplerate); 68 72 73 /** Mel filterbank initialization 74 75 \param fb filterbank object 76 \param samplerate audio sampling rate 77 \param fmin start frequency, in Hz 78 \param fmax end frequency, in Hz 79 80 The filterbank will be initialized with bands linearly spaced in the mel 81 scale, from `fmin` to `fmax`. 82 83 References 84  85 86 Malcolm Slaney, *Auditory Toolbox Version 2, Technical Report #1998010* 87 https://engineering.purdue.edu/~malcolm/interval/1998010/ 88 89 */ 90 uint_t aubio_filterbank_set_mel_coeffs(aubio_filterbank_t * fb, 91 smpl_t samplerate, smpl_t freq_min, smpl_t freq_max); 92 93 /** Mel filterbank initialization 94 95 \param fb filterbank object 96 \param samplerate audio sampling rate 97 \param fmin start frequency, in Hz 98 \param fmax end frequency, in Hz 99 100 The bank of filters will be initalized to to cover linearly spaced bands in 101 the Htk mel scale, from `fmin` to `fmax`. 102 103 References 104  105 106 Douglas O'Shaughnessy (1987). *Speech communication: human and machine*. 107 AddisonWesley. p. 150. ISBN 9780201165203. 108 109 HTK Speech Recognition Toolkit: http://htk.eng.cam.ac.uk/ 110 111 */ 112 uint_t aubio_filterbank_set_mel_coeffs_htk(aubio_filterbank_t * fb, 113 smpl_t samplerate, smpl_t freq_min, smpl_t freq_max); 114 69 115 #ifdef __cplusplus 70 116 }
Note: See TracChangeset
for help on using the changeset viewer.