Changeset 6d41dac
 Timestamp:
 Nov 17, 2018, 1:54:20 PM (14 months ago)
 Branches:
 feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
 Children:
 f6bfc26
 Parents:
 0316feb
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/spectral/filterbank_mel.c
r0316feb r6d41dac 210 210 } 211 211 212 static uint_t aubio_filterbank_check_freqs (aubio_filterbank_t *fb UNUSED, 213 smpl_t samplerate, smpl_t *freq_min, smpl_t *freq_max) 214 { 215 if (samplerate <= 0) { 216 AUBIO_ERR("filterbank: set_mel_coeffs samplerate should be > 0\n"); 217 return AUBIO_FAIL; 218 } 219 if (*freq_max < 0) { 220 AUBIO_ERR("filterbank: set_mel_coeffs freq_max should be > 0\n"); 221 return AUBIO_FAIL; 222 } else if (*freq_max == 0) { 223 *freq_max = samplerate / 2.; 224 } 225 if (*freq_min < 0) { 226 AUBIO_ERR("filterbank: set_mel_coeffs freq_min should be > 0\n"); 227 return AUBIO_FAIL; 228 } 229 return AUBIO_OK; 230 } 231 212 232 uint_t 213 233 aubio_filterbank_set_mel_coeffs (aubio_filterbank_t * fb, smpl_t samplerate, … … 215 235 { 216 236 uint_t m, retval; 217 smpl_t start , end, step;237 smpl_t start = freq_min, end = freq_max, step; 218 238 fvec_t *freqs; 219 239 fmat_t *coeffs = aubio_filterbank_get_coeffs(fb); 220 240 uint_t n_bands = coeffs>height; 221 241 222 if (samplerate <= 0) { 223 AUBIO_ERR("filterbank: set_mel_coeffs samplerate should be > 0\n"); 224 return AUBIO_FAIL; 225 } 226 if (freq_max < 0) { 227 AUBIO_ERR("filterbank: set_mel_coeffs freq_max should be > 0\n"); 228 return AUBIO_FAIL; 229 } else if (freq_max == 0) { 230 end = aubio_hztomel(samplerate / 2.); 231 } else { 232 end = aubio_hztomel(freq_max); 233 } 234 if (freq_min < 0) { 235 AUBIO_ERR("filterbank: set_mel_coeffs freq_min should be > 0\n"); 236 return AUBIO_FAIL; 237 } else { 238 start = aubio_hztomel(freq_min); 239 } 242 if (aubio_filterbank_check_freqs(fb, samplerate, &freq_min, &freq_max)) { 243 return AUBIO_FAIL; 244 } 245 246 start = aubio_hztomel(start); 247 end = aubio_hztomel(end); 240 248 241 249 freqs = new_fvec(n_bands + 2); … … 259 267 { 260 268 uint_t m, retval; 261 smpl_t start , end, step;269 smpl_t start = freq_min, end = freq_max, step; 262 270 fvec_t *freqs; 263 271 fmat_t *coeffs = aubio_filterbank_get_coeffs(fb); 264 272 uint_t n_bands = coeffs>height; 265 273 266 if (samplerate <= 0) { 267 AUBIO_ERR("filterbank: set_mel_coeffs samplerate should be > 0\n"); 268 return AUBIO_FAIL; 269 } 270 if (freq_max < 0) { 271 AUBIO_ERR("filterbank: set_mel_coeffs freq_max should be > 0\n"); 272 return AUBIO_FAIL; 273 } else if (freq_max == 0) { 274 end = aubio_hztomel_htk(samplerate / 2.); 275 } else { 276 end = aubio_hztomel_htk(freq_max); 277 } 278 if (freq_min < 0) { 279 AUBIO_ERR("filterbank: set_mel_coeffs freq_min should be > 0\n"); 280 return AUBIO_FAIL; 281 } else { 282 start = aubio_hztomel_htk(freq_min); 283 } 274 if (aubio_filterbank_check_freqs(fb, samplerate, &freq_min, &freq_max)) { 275 return AUBIO_FAIL; 276 } 277 278 start = aubio_hztomel_htk(start); 279 end = aubio_hztomel_htk(end); 284 280 285 281 freqs = new_fvec (n_bands + 2);
Note: See TracChangeset
for help on using the changeset viewer.