Changeset b257b60 for src/io/source_sndfile.c
- Timestamp:
- Aug 12, 2015, 7:21:38 PM (9 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:
- 60fc05b
- Parents:
- 3a1a5d6 (diff), 7b2d740 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_sndfile.c
r3a1a5d6 rb257b60 152 152 void aubio_source_sndfile_do(aubio_source_sndfile_t * s, fvec_t * read_data, uint_t * read){ 153 153 uint_t i,j, input_channels = s->input_channels; 154 /* do actual reading*/154 /* read from file into scratch_data */ 155 155 sf_count_t read_samples = sf_read_float (s->handle, s->scratch_data, s->scratch_size); 156 156 157 smpl_t *data;158 157 /* where to store de-interleaved data */ 158 smpl_t *ptr_data; 159 159 #ifdef HAVE_SAMPLERATE 160 160 if (s->ratio != 1) { 161 data = s->input_data->data;161 ptr_data = s->input_data->data; 162 162 } else 163 163 #endif /* HAVE_SAMPLERATE */ 164 164 { 165 data = read_data->data;165 ptr_data = read_data->data; 166 166 } 167 167 168 168 /* de-interleaving and down-mixing data */ 169 169 for (j = 0; j < read_samples / input_channels; j++) { 170 data[j] = 0;170 ptr_data[j] = 0; 171 171 for (i = 0; i < input_channels; i++) { 172 data[j] += s->scratch_data[input_channels*j+i];173 } 174 data[j] /= (smpl_t)input_channels;172 ptr_data[j] += s->scratch_data[input_channels*j+i]; 173 } 174 ptr_data[j] /= (smpl_t)input_channels; 175 175 } 176 176 … … 196 196 sf_count_t read_samples = sf_read_float (s->handle, s->scratch_data, s->scratch_size); 197 197 198 smpl_t **data;199 198 /* where to store de-interleaved data */ 199 smpl_t **ptr_data; 200 200 #ifdef HAVE_SAMPLERATE 201 201 if (s->ratio != 1) { 202 AUBIO_ERR("source_sndfile: no multi channel resampling yet ");202 AUBIO_ERR("source_sndfile: no multi channel resampling yet\n"); 203 203 return; 204 // data = s->input_data->data;204 //ptr_data = s->input_data->data; 205 205 } else 206 206 #endif /* HAVE_SAMPLERATE */ 207 207 { 208 data = read_data->data;208 ptr_data = read_data->data; 209 209 } 210 210 … … 214 214 for (j = 0; j < read_samples / input_channels; j++) { 215 215 for (i = 0; i < read_data->height; i++) { 216 data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i];216 ptr_data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i]; 217 217 } 218 218 } … … 222 222 for (j = 0; j < read_samples / input_channels; j++) { 223 223 for (i = 0; i < input_channels; i++) { 224 data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i];224 ptr_data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i]; 225 225 } 226 226 } … … 232 232 for (j = 0; j < read_samples / input_channels; j++) { 233 233 for (i = input_channels; i < read_data->height; i++) { 234 data[i][j] = (smpl_t)s->scratch_data[j * input_channels + (input_channels - 1)];234 ptr_data[i][j] = (smpl_t)s->scratch_data[j * input_channels + (input_channels - 1)]; 235 235 } 236 236 } … … 265 265 uint_t aubio_source_sndfile_seek (aubio_source_sndfile_t * s, uint_t pos) { 266 266 uint_t resampled_pos = (uint_t)ROUND(pos / s->ratio); 267 return sf_seek (s->handle, resampled_pos, SEEK_SET); 267 sf_count_t sf_ret = sf_seek (s->handle, resampled_pos, SEEK_SET); 268 if (sf_ret == -1) { 269 AUBIO_ERR("source_sndfile: Failed seeking %s at %d: %s\n", s->path, pos, sf_strerror (NULL)); 270 return AUBIO_FAIL; 271 } 272 if (sf_ret != resampled_pos) { 273 AUBIO_ERR("source_sndfile: Tried seeking %s at %d, but got %d: %s\n", 274 s->path, resampled_pos, (uint_t)sf_ret, sf_strerror (NULL)); 275 return AUBIO_FAIL; 276 } 277 return AUBIO_OK; 268 278 } 269 279 … … 273 283 } 274 284 if(sf_close(s->handle)) { 275 AUBIO_ERR("source_sndfile: Error closing file %s: %s ", s->path, sf_strerror (NULL));285 AUBIO_ERR("source_sndfile: Error closing file %s: %s\n", s->path, sf_strerror (NULL)); 276 286 return AUBIO_FAIL; 277 287 }
Note: See TracChangeset
for help on using the changeset viewer.