Changeset 1d01e515 for src/io/source_sndfile.c
- Timestamp:
- Sep 23, 2016, 2:43:35 AM (8 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:
- dab4a4c
- Parents:
- 50a8260
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_sndfile.c
r50a8260 r1d01e515 60 60 uint_t input_hop_size; 61 61 #ifdef HAVE_SAMPLERATE 62 aubio_resampler_t * resampler;62 aubio_resampler_t **resamplers; 63 63 fvec_t *input_data; 64 fmat_t *input_mat; 64 65 #endif /* HAVE_SAMPLERATE */ 65 66 … … 127 128 128 129 #ifdef HAVE_SAMPLERATE 129 s->resampler = NULL;130 130 s->input_data = NULL; 131 s->input_mat = NULL; 132 s->resamplers = NULL; 131 133 if (s->ratio != 1) { 134 uint_t i; 135 s->resamplers = AUBIO_ARRAY(aubio_resampler_t*, s->input_channels); 132 136 s->input_data = new_fvec(s->input_hop_size); 133 s->resampler = new_aubio_resampler(s->ratio, 4); 137 s->input_mat = new_fmat(s->input_channels, s->input_hop_size); 138 for (i = 0; i < (uint_t)s->input_channels; i++) { 139 s->resamplers[i] = new_aubio_resampler(s->ratio, 4); 140 } 134 141 if (s->ratio > 1) { 135 142 // we would need to add a ring buffer for these … … 190 197 191 198 #ifdef HAVE_SAMPLERATE 192 if (s->resampler ) {193 aubio_resampler_do(s->resampler , s->input_data, read_data);199 if (s->resamplers) { 200 aubio_resampler_do(s->resamplers[0], s->input_data, read_data); 194 201 } 195 202 #endif /* HAVE_SAMPLERATE */ … … 214 221 #ifdef HAVE_SAMPLERATE 215 222 if (s->ratio != 1) { 216 AUBIO_ERR("source_sndfile: no multi channel resampling yet\n"); 217 return; 218 //ptr_data = s->input_data->data; 223 ptr_data = s->input_mat->data; 219 224 } else 220 225 #endif /* HAVE_SAMPLERATE */ … … 252 257 253 258 #ifdef HAVE_SAMPLERATE 254 if (s->resampler) { 255 //aubio_resampler_do(s->resampler, s->input_data, read_data); 259 if (s->resamplers) { 260 for (i = 0; i < input_channels; i++) { 261 fvec_t input_chan, read_chan; 262 input_chan.data = s->input_mat->data[i]; 263 input_chan.length = s->input_mat->length; 264 read_chan.data = read_data->data[i]; 265 read_chan.length = read_data->length; 266 aubio_resampler_do(s->resamplers[i], &input_chan, &read_chan); 267 } 256 268 } 257 269 #endif /* HAVE_SAMPLERATE */ … … 314 326 aubio_source_sndfile_close(s); 315 327 #ifdef HAVE_SAMPLERATE 316 if (s->resampler != NULL) { 317 del_aubio_resampler(s->resampler); 328 if (s->resamplers != NULL) { 329 uint_t i = 0, input_channels = s->input_channels; 330 for (i = 0; i < input_channels; i ++) { 331 if (s->resamplers[i] != NULL) { 332 del_aubio_resampler(s->resamplers[i]); 333 } 334 } 335 AUBIO_FREE(s->resamplers); 318 336 } 319 337 if (s->input_data) { 320 338 del_fvec(s->input_data); 339 } 340 if (s->input_mat) { 341 del_fmat(s->input_mat); 321 342 } 322 343 #endif /* HAVE_SAMPLERATE */
Note: See TracChangeset
for help on using the changeset viewer.