Changes in src/io/source_wavread.c [b40c149:c0a1906]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_wavread.c
rb40c149 rc0a1906 25 25 #include "fvec.h" 26 26 #include "fmat.h" 27 #include "ioutils.h"28 27 #include "source_wavread.h" 29 28 29 #include <errno.h> 30 30 31 #define AUBIO_WAVREAD_BUFSIZE 1024 31 32 32 //#define SHORT_TO_FLOAT(x) (smpl_t)(x * 3.0517578125e-05)33 #define SHORT_TO_FLOAT(x) (smpl_t)(x * 3.0517578125e-05) 33 34 34 35 struct _aubio_source_wavread_t { … … 99 100 s->fid = fopen((const char *)path, "rb"); 100 101 if (!s->fid) { 101 AUBIO_ STRERR("source_wavread: Failed opening %s (%s)\n", s->path, errorstr);102 AUBIO_ERR("source_wavread: Failed opening %s (System error: %s)\n", s->path, strerror(errno)); 102 103 goto beach; 103 104 } … … 132 133 bytes_junk += read_little_endian(buf, 4); 133 134 if (fseek(s->fid, bytes_read + bytes_junk, SEEK_SET) != 0) { 134 AUBIO_ STRERR("source_wavread: Failed opening %s (could not seek past JUNK Chunk: %s)\n",135 s->path, errorstr);135 AUBIO_ERR("source_wavread: Failed opening %s (could not seek past JUNK Chunk: %s)\n", 136 s->path, strerror(errno)); 136 137 goto beach; 137 138 } … … 260 261 bytes_junk += read_little_endian(buf, 4); 261 262 if (fseek(s->fid, bytes_read + bytes_junk, SEEK_SET) != 0) { 262 AUBIO_ STRERR("source_wavread: could not seek past unknown chunk in %s (%s)\n",263 s->path, errorstr);263 AUBIO_ERR("source_wavread: could not seek past unknown chunk in %s (%s)\n", 264 s->path, strerror(errno)); 264 265 goto beach; 265 266 } … … 347 348 uint_t end = 0; 348 349 uint_t total_wrote = 0; 349 uint_t length = aubio_source_validate_input_length("source_wavread", s->path,350 s->hop_size, read_data->length);351 350 if (s->fid == NULL) { 352 351 AUBIO_ERR("source_wavread: could not read from %s (file not opened)\n", … … 354 353 return; 355 354 } 356 while (total_wrote < length) {357 end = MIN(s->read_samples - s->read_index, length- total_wrote);355 while (total_wrote < s->hop_size) { 356 end = MIN(s->read_samples - s->read_index, s->hop_size - total_wrote); 358 357 for (i = 0; i < end; i++) { 359 358 read_data->data[i + total_wrote] = 0; … … 364 363 } 365 364 total_wrote += end; 366 if (total_wrote < length) {365 if (total_wrote < s->hop_size) { 367 366 uint_t wavread_read = 0; 368 367 aubio_source_wavread_readframe(s, &wavread_read); … … 376 375 } 377 376 } 378 379 aubio_source_pad_output (read_data, total_wrote); 380 377 if (total_wrote < s->hop_size) { 378 for (i = end; i < s->hop_size; i++) { 379 read_data->data[i] = 0.; 380 } 381 } 381 382 *read = total_wrote; 382 383 } … … 386 387 uint_t end = 0; 387 388 uint_t total_wrote = 0; 388 uint_t length = aubio_source_validate_input_length("source_wavread", s->path,389 s->hop_size, read_data->length);390 uint_t channels = aubio_source_validate_input_channels("source_wavread",391 s->path, s->input_channels, read_data->height);392 389 if (s->fid == NULL) { 393 390 AUBIO_ERR("source_wavread: could not read from %s (file not opened)\n", … … 395 392 return; 396 393 } 397 while (total_wrote < length) {398 end = MIN(s->read_samples - s->read_index, length- total_wrote);399 for (j = 0; j < channels; j++) {394 while (total_wrote < s->hop_size) { 395 end = MIN(s->read_samples - s->read_index, s->hop_size - total_wrote); 396 for (j = 0; j < read_data->height; j++) { 400 397 for (i = 0; i < end; i++) { 401 398 read_data->data[j][i + total_wrote] = s->output->data[j][i]; … … 403 400 } 404 401 total_wrote += end; 405 if (total_wrote < length) {402 if (total_wrote < s->hop_size) { 406 403 uint_t wavread_read = 0; 407 404 aubio_source_wavread_readframe(s, &wavread_read); … … 415 412 } 416 413 } 417 418 aubio_source_pad_multi_output(read_data, s->input_channels, total_wrote); 419 414 if (total_wrote < s->hop_size) { 415 for (j = 0; j < read_data->height; j++) { 416 for (i = end; i < s->hop_size; i++) { 417 read_data->data[j][i] = 0.; 418 } 419 } 420 } 420 421 *read = total_wrote; 421 422 } … … 441 442 ret = fseek(s->fid, s->seek_start + pos * s->blockalign, SEEK_SET); 442 443 if (ret != 0) { 443 AUBIO_ STRERR("source_wavread: could not seek %s at %d (%s)\n", s->path, pos, errorstr);444 AUBIO_ERR("source_wavread: could not seek %s at %d (%s)\n", s->path, pos, strerror(errno)); 444 445 return AUBIO_FAIL; 445 446 } … … 462 463 } 463 464 if (fclose(s->fid)) { 464 AUBIO_ STRERR("source_wavread: could not close %s (%s)\n", s->path, errorstr);465 AUBIO_ERR("source_wavread: could not close %s (%s)\n", s->path, strerror(errno)); 465 466 return AUBIO_FAIL; 466 467 }
Note: See TracChangeset
for help on using the changeset viewer.