Changes in / [5e9bdca:a2019c4]
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
.travis.yml
r5e9bdca ra2019c4 19 19 os: linux 20 20 compiler: gcc 21 env: HAVE_AUBIO_DOUBLE=1 CFLAGS="-O3" WAFOPTS="--enable-fftw3 "21 env: HAVE_AUBIO_DOUBLE=1 CFLAGS="-O3" WAFOPTS="--enable-fftw3 --disable-avcodec" 22 22 - python: 2.7 23 23 os: linux -
src/aubio_priv.h
r5e9bdca ra2019c4 325 325 #endif 326 326 327 #if !defined(_MSC_VER) 328 #define AUBIO_STRERROR(errno,buf,len) strerror_r(errno, buf, len) 329 #else 330 #define AUBIO_STRERROR(errno,buf,len) strerror_s(buf, len, errno) 331 #endif 332 327 333 /* handy shortcuts */ 328 334 #define DB2LIN(g) (POW(10.0,(g)*0.05f)) -
src/io/ioutils.c
r5e9bdca ra2019c4 20 20 21 21 #include "aubio_priv.h" 22 #include "fmat.h" 22 23 23 24 uint_t … … 51 52 } 52 53 return AUBIO_OK; 54 } 55 56 uint_t 57 aubio_source_validate_input_length(const char_t *kind, const char_t *path, 58 uint_t hop_size, uint_t read_data_length) 59 { 60 uint_t length = hop_size; 61 if (hop_size < read_data_length) { 62 AUBIO_WRN("%s: partial read from %s, trying to read %d frames, but" 63 " hop_size is %d\n", kind, path, read_data_length, hop_size); 64 } else if (hop_size > read_data_length) { 65 AUBIO_WRN("%s: partial read from %s, trying to read %d frames into" 66 " a buffer of length %d\n", kind, path, hop_size, read_data_length); 67 length = read_data_length; 68 } 69 return length; 70 } 71 72 uint_t 73 aubio_source_validate_input_channels(const char_t *kind, const char_t *path, 74 uint_t source_channels, uint_t read_data_height) 75 { 76 uint_t channels = source_channels; 77 if (read_data_height < source_channels) { 78 AUBIO_WRN("%s: partial read from %s, trying to read %d channels," 79 " but found output of height %d\n", kind, path, source_channels, 80 read_data_height); 81 channels = read_data_height; 82 } else if (read_data_height > source_channels) { 83 // do not show a warning when trying to read into more channels than 84 // the input source. 85 #if 0 86 AUBIO_WRN("%s: partial read from %s, trying to read %d channels," 87 " but found output of height %d\n", kind, path, source_channels, 88 read_data_height); 89 #endif 90 channels = source_channels; 91 } 92 return channels; 93 } 94 95 void 96 aubio_source_pad_output (fvec_t *read_data, uint_t source_read) 97 { 98 if (source_read < read_data->length) { 99 AUBIO_MEMSET(read_data->data + source_read, 0, 100 (read_data->length - source_read) * sizeof(smpl_t)); 101 } 102 } 103 104 void 105 aubio_source_pad_multi_output (fmat_t *read_data, 106 uint_t source_channels, uint_t source_read) { 107 uint_t i; 108 if (source_read < read_data->length) { 109 for (i = 0; i < read_data->height; i++) { 110 AUBIO_MEMSET(read_data->data[i] + source_read, 0, 111 (read_data->length - source_read) * sizeof(smpl_t)); 112 } 113 } 114 115 // destination matrix has more channels than the file 116 // copy channels from the source to extra output channels 117 if (read_data->height > source_channels) { 118 for (i = source_channels; i < read_data->height; i++) { 119 AUBIO_MEMCPY(read_data->data[i], read_data->data[i % source_channels], 120 sizeof(smpl_t) * read_data->length); 121 } 122 } 53 123 } 54 124 -
src/io/ioutils.h
r5e9bdca ra2019c4 54 54 uint_t channels); 55 55 56 /** validate length of input 56 /** validate length of source output 57 58 \param kind the object kind to report on 59 \param path the path to report on 60 \param hop_size number of frames to be read 61 \param read_data_length actual length of input 62 63 \return hop_size or the maximum number of frames that can be written 64 */ 65 uint_t 66 aubio_source_validate_input_length(const char_t *kind, const char_t *path, 67 uint_t hop_size, uint_t read_data_length); 68 69 /** validate height of source output 70 71 \param kind the object kind to report on 72 \param path the path to report on 73 \param source_channels maximum number of channels that can be written 74 \param read_data_height actual height of input 75 76 \return write_data_height or the maximum number of channels 77 */ 78 uint_t 79 aubio_source_validate_input_channels(const char_t *kind, const char_t *path, 80 uint_t source_channels, uint_t read_data_height); 81 82 /** pad end of source output vector with zeroes 83 84 \param read_data output vector to pad 85 \param source_read number of frames read 86 87 */ 88 void 89 aubio_source_pad_output (fvec_t *read_data, uint_t source_read); 90 91 /** pad end of source output matrix with zeroes 92 93 \param read_data output matrix to pad 94 \param source_channels number of channels in the source 95 \param source_read number of frames read 96 97 */ 98 void 99 aubio_source_pad_multi_output (fmat_t *read_data, uint_t source_channels, 100 uint_t source_read); 101 102 /** validate length of sink input 57 103 58 104 \param kind the object kind to report on 59 105 \param path the path to report on 60 106 \param max_size maximum number of frames that can be written 61 \param write_data_length actual length of input vector/matrix107 \param write_data_length actual length of input 62 108 \param write number of samples asked 63 109 … … 68 114 uint_t max_size, uint_t write_data_length, uint_t write); 69 115 70 /** validate height of input116 /** validate height of sink input 71 117 72 118 \param kind the object kind to report on 73 119 \param path the path to report on 74 \param max_sizemaximum number of channels that can be written120 \param sink_channels maximum number of channels that can be written 75 121 \param write_data_height actual height of input matrix 76 122 -
src/io/sink_wavwrite.c
r5e9bdca ra2019c4 163 163 unsigned char buf[5]; 164 164 uint_t byterate, blockalign; 165 size_t written = 0; 165 166 166 167 /* open output file */ 167 168 s->fid = fopen((const char *)s->path, "wb"); 168 169 if (!s->fid) { 169 AUBIO_ERR("sink_wavwrite: could not open %s (%s)\n", s->path, strerror(errno)); 170 char errorstr[256]; 171 AUBIO_STRERROR(errno, errorstr, sizeof(errorstr)); 172 AUBIO_ERR("sink_wavwrite: could not open %s (%s)\n", s->path, errorstr); 170 173 goto beach; 171 174 } 172 175 173 176 // ChunkID 174 fwrite("RIFF", 4, 1, s->fid);177 written += fwrite("RIFF", 4, 1, s->fid); 175 178 176 179 // ChunkSize (0 for now, actual size will be written in _close) 177 fwrite(write_little_endian(0, buf, 4), 4, 1, s->fid);180 written += fwrite(write_little_endian(0, buf, 4), 4, 1, s->fid); 178 181 179 182 // Format 180 fwrite("WAVE", 4, 1, s->fid);183 written += fwrite("WAVE", 4, 1, s->fid); 181 184 182 185 // Subchunk1ID 183 fwrite("fmt ", 4, 1, s->fid);186 written += fwrite("fmt ", 4, 1, s->fid); 184 187 185 188 // Subchunk1Size 186 fwrite(write_little_endian(16, buf, 4), 4, 1, s->fid);189 written += fwrite(write_little_endian(16, buf, 4), 4, 1, s->fid); 187 190 188 191 // AudioFormat 189 fwrite(write_little_endian(1, buf, 2), 2, 1, s->fid);192 written += fwrite(write_little_endian(1, buf, 2), 2, 1, s->fid); 190 193 191 194 // NumChannels 192 fwrite(write_little_endian(s->channels, buf, 2), 2, 1, s->fid);195 written += fwrite(write_little_endian(s->channels, buf, 2), 2, 1, s->fid); 193 196 194 197 // SampleRate 195 fwrite(write_little_endian(s->samplerate, buf, 4), 4, 1, s->fid);198 written += fwrite(write_little_endian(s->samplerate, buf, 4), 4, 1, s->fid); 196 199 197 200 // ByteRate 198 201 byterate = s->samplerate * s->channels * s->bitspersample / 8; 199 fwrite(write_little_endian(byterate, buf, 4), 4, 1, s->fid);202 written += fwrite(write_little_endian(byterate, buf, 4), 4, 1, s->fid); 200 203 201 204 // BlockAlign 202 205 blockalign = s->channels * s->bitspersample / 8; 203 fwrite(write_little_endian(blockalign, buf, 2), 2, 1, s->fid);206 written += fwrite(write_little_endian(blockalign, buf, 2), 2, 1, s->fid); 204 207 205 208 // BitsPerSample 206 fwrite(write_little_endian(s->bitspersample, buf, 2), 2, 1, s->fid);209 written += fwrite(write_little_endian(s->bitspersample, buf, 2), 2, 1, s->fid); 207 210 208 211 // Subchunk2ID 209 fwrite("data", 4, 1, s->fid);212 written += fwrite("data", 4, 1, s->fid); 210 213 211 214 // Subchunk1Size (0 for now, actual size will be written in _close) 212 fwrite(write_little_endian(0, buf, 4), 4, 1, s->fid); 215 written += fwrite(write_little_endian(0, buf, 4), 4, 1, s->fid); 216 217 // fwrite(*, *, 1, s->fid) was called 13 times, check success 218 if (written != 13) { 219 char errorstr[256]; 220 AUBIO_STRERROR(errno, errorstr, sizeof(errorstr)); 221 AUBIO_WRN("sink_wavwrite: writing header to %s failed, expected %d" 222 " write but got only %d (%s)\n", s->path, 13, written, errorstr); 223 return AUBIO_FAIL; 224 } 213 225 214 226 s->scratch_size = s->max_size * s->channels; … … 227 239 } 228 240 241 static 242 void aubio_sink_wavwrite_write_frames(aubio_sink_wavwrite_t *s, uint_t write) 243 { 244 uint_t written_frames = 0; 245 246 written_frames = fwrite(s->scratch_data, 2 * s->channels, write, s->fid); 247 248 if (written_frames != write) { 249 char errorstr[256]; 250 AUBIO_STRERROR(errno, errorstr, sizeof(errorstr)); 251 AUBIO_WRN("sink_wavwrite: trying to write %d frames to %s, but only %d" 252 " could be written (%s)\n", write, s->path, written_frames, errorstr); 253 } 254 s->total_frames_written += written_frames; 255 } 229 256 230 257 void aubio_sink_wavwrite_do(aubio_sink_wavwrite_t *s, fvec_t * write_data, uint_t write){ 231 uint_t c = 0, i = 0 , written_frames = 0;258 uint_t c = 0, i = 0; 232 259 uint_t length = aubio_sink_validate_input_length("sink_wavwrite", s->path, 233 260 s->max_size, write_data->length, write); … … 238 265 } 239 266 } 240 written_frames = fwrite(s->scratch_data, 2, length * s->channels, s->fid); 241 242 if (written_frames != write) { 243 AUBIO_WRN("sink_wavwrite: trying to write %d frames to %s, " 244 "but only %d could be written\n", write, s->path, written_frames); 245 } 246 s->total_frames_written += written_frames; 247 return; 267 268 aubio_sink_wavwrite_write_frames(s, length); 248 269 } 249 270 250 271 void aubio_sink_wavwrite_do_multi(aubio_sink_wavwrite_t *s, fmat_t * write_data, uint_t write){ 251 uint_t c = 0, i = 0 , written_frames = 0;272 uint_t c = 0, i = 0; 252 273 253 274 uint_t channels = aubio_sink_validate_input_channels("sink_wavwrite", s->path, … … 261 282 } 262 283 } 263 written_frames = fwrite(s->scratch_data, 2, length * s->channels, s->fid); 264 265 if (written_frames != write * s->channels) { 266 AUBIO_WRN("sink_wavwrite: trying to write %d frames to %s, " 267 "but only %d could be written\n", write, s->path, written_frames / s->channels); 268 } 269 s->total_frames_written += written_frames; 270 return; 284 285 aubio_sink_wavwrite_write_frames(s, length); 271 286 } 272 287 … … 274 289 uint_t data_size = s->total_frames_written * s->bitspersample * s->channels / 8; 275 290 unsigned char buf[5]; 291 size_t written = 0, err = 0; 276 292 if (!s->fid) return AUBIO_FAIL; 277 293 // ChunkSize 278 fseek(s->fid, 4, SEEK_SET);279 fwrite(write_little_endian(data_size + 36, buf, 4), 4, 1, s->fid);294 err += fseek(s->fid, 4, SEEK_SET); 295 written += fwrite(write_little_endian(data_size + 36, buf, 4), 4, 1, s->fid); 280 296 // Subchunk2Size 281 fseek(s->fid, 40, SEEK_SET); 282 fwrite(write_little_endian(data_size, buf, 4), 4, 1, s->fid); 297 err += fseek(s->fid, 40, SEEK_SET); 298 written += fwrite(write_little_endian(data_size, buf, 4), 4, 1, s->fid); 299 if (written != 2 || err != 0) { 300 char errorstr[256]; 301 AUBIO_STRERROR(errno, errorstr, sizeof(errorstr)); 302 AUBIO_WRN("sink_wavwrite: updating header of %s failed, expected %d" 303 " write but got only %d (%s)\n", s->path, 2, written, errorstr); 304 } 283 305 // close file 284 306 if (fclose(s->fid)) { 285 AUBIO_ERR("sink_wavwrite: Error closing file %s (%s)\n", s->path, strerror(errno)); 307 char errorstr[256]; 308 AUBIO_STRERROR(errno, errorstr, sizeof(errorstr)); 309 AUBIO_ERR("sink_wavwrite: Error closing file %s (%s)\n", s->path, errorstr); 286 310 } 287 311 s->fid = NULL; -
src/io/source_apple_audio.c
r5e9bdca ra2019c4 25 25 #include "fvec.h" 26 26 #include "fmat.h" 27 #include "ioutils.h" 27 28 #include "io/source_apple_audio.h" 28 29 … … 210 211 uint_t c, v; 211 212 UInt32 loadedPackets = aubio_source_apple_audio_read_frame(s); 213 uint_t length = aubio_source_validate_input_length("source_apple_audio", 214 s->path, s->block_size, read_to->length); 212 215 smpl_t *data = (smpl_t*)s->bufferList.mBuffers[0].mData; 213 216 214 for (v = 0; v < loadedPackets; v++) { 217 length = MIN(loadedPackets, length); 218 219 for (v = 0; v < length; v++) { 215 220 read_to->data[v] = 0.; 216 221 for (c = 0; c < s->channels; c++) { … … 220 225 } 221 226 // short read, fill with zeros 222 if (loadedPackets < s->block_size) { 223 for (v = loadedPackets; v < s->block_size; v++) { 224 read_to->data[v] = 0.; 225 } 226 } 227 228 *read = (uint_t)loadedPackets; 229 return; 227 aubio_source_pad_output(read_to, length); 228 229 *read = (uint_t)length; 230 230 } 231 231 232 232 void aubio_source_apple_audio_do_multi(aubio_source_apple_audio_t *s, fmat_t * read_to, uint_t * read) { 233 233 uint_t c, v; 234 uint_t length = aubio_source_validate_input_length("source_apple_audio", 235 s->path, s->block_size, read_to->length); 236 uint_t channels = aubio_source_validate_input_channels("source_apple_audio", 237 s->path, s->channels, read_to->height); 234 238 UInt32 loadedPackets = aubio_source_apple_audio_read_frame(s); 235 239 smpl_t *data = (smpl_t*)s->bufferList.mBuffers[0].mData; 236 240 237 for (v = 0; v < loadedPackets; v++) { 238 for (c = 0; c < read_to->height; c++) { 241 length = MIN(loadedPackets, length); 242 243 for (v = 0; v < length; v++) { 244 for (c = 0; c < channels; c++) { 239 245 read_to->data[c][v] = data[ v * s->channels + c]; 240 246 } 241 247 } 242 // if read_data has more channels than the file 243 if (read_to->height > s->channels) { 244 // copy last channel to all additional channels 245 for (v = 0; v < loadedPackets; v++) { 246 for (c = s->channels; c < read_to->height; c++) { 247 read_to->data[c][v] = data[ v * s->channels + (s->channels - 1)]; 248 } 249 } 250 } 251 // short read, fill with zeros 252 if (loadedPackets < s->block_size) { 253 for (v = loadedPackets; v < s->block_size; v++) { 254 for (c = 0; c < read_to->height; c++) { 255 read_to->data[c][v] = 0.; 256 } 257 } 258 } 259 260 *read = (uint_t)loadedPackets; 261 return; 248 249 aubio_source_pad_multi_output(read_to, s->channels, (uint_t)length); 250 251 *read = (uint_t)length; 262 252 } 263 253 -
src/io/source_avcodec.c
r5e9bdca ra2019c4 61 61 #include "fvec.h" 62 62 #include "fmat.h" 63 #include "ioutils.h" 63 64 #include "source_avcodec.h" 64 65 … … 489 490 uint_t end = 0; 490 491 uint_t total_wrote = 0; 491 while (total_wrote < s->hop_size) { 492 end = MIN(s->read_samples - s->read_index, s->hop_size - total_wrote); 492 uint_t length = aubio_source_validate_input_length("source_avcodec", s->path, 493 s->hop_size, read_data->length); 494 while (total_wrote < length) { 495 end = MIN(s->read_samples - s->read_index, length - total_wrote); 493 496 for (i = 0; i < end; i++) { 494 497 read_data->data[i + total_wrote] = 0.; … … 500 503 } 501 504 total_wrote += end; 502 if (total_wrote < s->hop_size) {505 if (total_wrote < length) { 503 506 uint_t avcodec_read = 0; 504 507 aubio_source_avcodec_readframe(s, &avcodec_read); … … 512 515 } 513 516 } 514 if (total_wrote < s->hop_size) { 515 for (i = total_wrote; i < s->hop_size; i++) { 516 read_data->data[i] = 0.; 517 } 518 } 517 518 aubio_source_pad_output(read_data, total_wrote); 519 519 520 *read = total_wrote; 520 521 } … … 525 526 uint_t end = 0; 526 527 uint_t total_wrote = 0; 527 while (total_wrote < s->hop_size) { 528 end = MIN(s->read_samples - s->read_index, s->hop_size - total_wrote); 529 for (j = 0; j < read_data->height; j++) { 528 uint_t length = aubio_source_validate_input_length("source_wavread", s->path, 529 s->hop_size, read_data->length); 530 uint_t channels = aubio_source_validate_input_channels("source_wavread", 531 s->path, s->input_channels, read_data->height); 532 while (total_wrote < length) { 533 end = MIN(s->read_samples - s->read_index, length - total_wrote); 534 for (j = 0; j < channels; j++) { 530 535 for (i = 0; i < end; i++) { 531 536 read_data->data[j][i + total_wrote] = … … 534 539 } 535 540 total_wrote += end; 536 if (total_wrote < s->hop_size) {541 if (total_wrote < length) { 537 542 uint_t avcodec_read = 0; 538 543 aubio_source_avcodec_readframe(s, &avcodec_read); … … 546 551 } 547 552 } 548 if (total_wrote < s->hop_size) { 549 for (j = 0; j < read_data->height; j++) { 550 for (i = total_wrote; i < s->hop_size; i++) { 551 read_data->data[j][i] = 0.; 552 } 553 } 554 } 553 554 aubio_source_pad_multi_output(read_data, s->input_channels, total_wrote); 555 555 556 *read = total_wrote; 556 557 } -
src/io/source_sndfile.c
r5e9bdca ra2019c4 27 27 #include "fvec.h" 28 28 #include "fmat.h" 29 #include "ioutils.h" 29 30 #include "source_sndfile.h" 30 31 … … 170 171 uint_t i,j, input_channels = s->input_channels; 171 172 /* read from file into scratch_data */ 172 sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data, s->scratch_size); 173 uint_t length = aubio_source_validate_input_length("source_sndfile", s->path, 174 s->hop_size, read_data->length); 175 sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data, 176 s->input_channels * length); 177 178 length = MIN(read_samples / s->input_channels, length); 173 179 174 180 /* where to store de-interleaved data */ … … 184 190 185 191 /* de-interleaving and down-mixing data */ 186 for (j = 0; j < read_samples / input_channels; j++) {192 for (j = 0; j < length; j++) { 187 193 ptr_data[j] = 0; 188 194 for (i = 0; i < input_channels; i++) { … … 198 204 #endif /* HAVE_SAMPLERATE */ 199 205 200 *read = (int)FLOOR(s->ratio * read_samples / input_channels + .5); 201 202 if (*read < s->hop_size) { 203 for (j = *read; j < s->hop_size; j++) { 204 read_data->data[j] = 0; 205 } 206 } 206 *read = (int)FLOOR(s->ratio * length + .5); 207 208 aubio_source_pad_output (read_data, *read); 207 209 208 210 } … … 211 213 uint_t i,j, input_channels = s->input_channels; 212 214 /* do actual reading */ 213 sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data, s->scratch_size); 215 uint_t length = aubio_source_validate_input_length("source_sndfile", s->path, 216 s->hop_size, read_data->length); 217 uint_t channels = aubio_source_validate_input_channels("source_sndfile", 218 s->path, s->input_channels, read_data->height); 219 sf_count_t read_samples = aubio_sf_read_smpl (s->handle, s->scratch_data, 220 length * s->input_channels); 221 222 length = MIN(read_samples / s->input_channels, length); 214 223 215 224 /* where to store de-interleaved data */ … … 224 233 } 225 234 226 if (read_data->height < input_channels) { 227 // destination matrix has less channels than the file; copy only first 228 // channels of the file, de-interleaving data 229 for (j = 0; j < read_samples / input_channels; j++) { 230 for (i = 0; i < read_data->height; i++) { 231 ptr_data[i][j] = s->scratch_data[j * input_channels + i]; 232 } 233 } 234 } else { 235 // destination matrix has as many or more channels than the file; copy each 236 // channel from the file to the destination matrix, de-interleaving data 237 for (j = 0; j < read_samples / input_channels; j++) { 238 for (i = 0; i < input_channels; i++) { 239 ptr_data[i][j] = s->scratch_data[j * input_channels + i]; 240 } 241 } 242 } 243 244 if (read_data->height > input_channels) { 245 // destination matrix has more channels than the file; copy last channel 246 // of the file to each additional channels, de-interleaving data 247 for (j = 0; j < read_samples / input_channels; j++) { 248 for (i = input_channels; i < read_data->height; i++) { 249 ptr_data[i][j] = s->scratch_data[j * input_channels + (input_channels - 1)]; 250 } 235 for (j = 0; j < length; j++) { 236 for (i = 0; i < channels; i++) { 237 ptr_data[i][j] = s->scratch_data[j * input_channels + i]; 251 238 } 252 239 } … … 265 252 #endif /* HAVE_SAMPLERATE */ 266 253 267 *read = (int)FLOOR(s->ratio * read_samples / input_channels + .5); 268 269 if (*read < s->hop_size) { 270 for (i = 0; i < read_data->height; i++) { 271 for (j = *read; j < s->hop_size; j++) { 272 read_data->data[i][j] = 0.; 273 } 274 } 275 } 276 254 *read = (int)FLOOR(s->ratio * length + .5); 255 256 aubio_source_pad_multi_output(read_data, input_channels, *read); 277 257 } 278 258 -
src/io/source_wavread.c
r5e9bdca ra2019c4 25 25 #include "fvec.h" 26 26 #include "fmat.h" 27 #include "ioutils.h" 27 28 #include "source_wavread.h" 28 29 … … 348 349 uint_t end = 0; 349 350 uint_t total_wrote = 0; 351 uint_t length = aubio_source_validate_input_length("source_wavread", s->path, 352 s->hop_size, read_data->length); 350 353 if (s->fid == NULL) { 351 354 AUBIO_ERR("source_wavread: could not read from %s (file not opened)\n", … … 353 356 return; 354 357 } 355 while (total_wrote < s->hop_size) {356 end = MIN(s->read_samples - s->read_index, s->hop_size- total_wrote);358 while (total_wrote < length) { 359 end = MIN(s->read_samples - s->read_index, length - total_wrote); 357 360 for (i = 0; i < end; i++) { 358 361 read_data->data[i + total_wrote] = 0; … … 363 366 } 364 367 total_wrote += end; 365 if (total_wrote < s->hop_size) {368 if (total_wrote < length) { 366 369 uint_t wavread_read = 0; 367 370 aubio_source_wavread_readframe(s, &wavread_read); … … 375 378 } 376 379 } 377 if (total_wrote < s->hop_size) { 378 for (i = end; i < s->hop_size; i++) { 379 read_data->data[i] = 0.; 380 } 381 } 380 381 aubio_source_pad_output (read_data, total_wrote); 382 382 383 *read = total_wrote; 383 384 } … … 387 388 uint_t end = 0; 388 389 uint_t total_wrote = 0; 390 uint_t length = aubio_source_validate_input_length("source_wavread", s->path, 391 s->hop_size, read_data->length); 392 uint_t channels = aubio_source_validate_input_channels("source_wavread", 393 s->path, s->input_channels, read_data->height); 389 394 if (s->fid == NULL) { 390 395 AUBIO_ERR("source_wavread: could not read from %s (file not opened)\n", … … 392 397 return; 393 398 } 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++) {399 while (total_wrote < length) { 400 end = MIN(s->read_samples - s->read_index, length - total_wrote); 401 for (j = 0; j < channels; j++) { 397 402 for (i = 0; i < end; i++) { 398 403 read_data->data[j][i + total_wrote] = s->output->data[j][i]; … … 400 405 } 401 406 total_wrote += end; 402 if (total_wrote < s->hop_size) {407 if (total_wrote < length) { 403 408 uint_t wavread_read = 0; 404 409 aubio_source_wavread_readframe(s, &wavread_read); … … 412 417 } 413 418 } 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 } 419 420 aubio_source_pad_multi_output(read_data, s->input_channels, total_wrote); 421 421 422 *read = total_wrote; 422 423 } -
tests/src/io/base-source_custom.h
r5e9bdca ra2019c4 94 94 if (read != hop_size) return 1; 95 95 96 // read again in undersized vector 97 del_fvec(vec); 98 vec = new_fvec(hop_size - 1); 99 aubio_source_custom_do(s, vec, &read); 100 if (read != hop_size - 1) return 1; 101 102 // read again in oversized vector 103 del_fvec(vec); 104 vec = new_fvec(hop_size + 1); 105 aubio_source_custom_do(s, vec, &read); 106 if (read != hop_size) return 1; 107 96 108 // seek to 0 97 109 if(aubio_source_custom_seek(s, 0)) return 1; 98 110 99 111 // read again as multiple channels 112 aubio_source_custom_do_multi(s, mat, &read); 113 if (read != hop_size) return 1; 114 115 // read again as multiple channels in an undersized matrix 116 del_fmat(mat); 117 mat = new_fmat(channels - 1, hop_size); 118 aubio_source_custom_do_multi(s, mat, &read); 119 if (read != hop_size) return 1; 120 121 // read again as multiple channels in an undersized matrix 122 del_fmat(mat); 123 mat = new_fmat(channels, hop_size - 1); 124 aubio_source_custom_do_multi(s, mat, &read); 125 if (read != hop_size - 1) return 1; 126 127 // read again as multiple channels in an oversized matrix 128 del_fmat(mat); 129 mat = new_fmat(channels + 1, hop_size); 130 aubio_source_custom_do_multi(s, mat, &read); 131 if (read != hop_size) return 1; 132 133 // read again as multiple channels in an oversized matrix 134 del_fmat(mat); 135 mat = new_fmat(channels, hop_size + 1); 100 136 aubio_source_custom_do_multi(s, mat, &read); 101 137 if (read != hop_size) return 1; -
tests/src/io/test-source.c
r5e9bdca ra2019c4 90 90 if (read != hop_size) return 1; 91 91 92 // read again in undersized vector 93 del_fvec(vec); 94 vec = new_fvec(hop_size - 1); 95 aubio_source_do(s, vec, &read); 96 if (read != hop_size - 1) return 1; 97 98 // read again in oversized vector 99 del_fvec(vec); 100 vec = new_fvec(hop_size + 1); 101 aubio_source_do(s, vec, &read); 102 if (read != hop_size) return 1; 103 92 104 // seek to 0 93 105 if(aubio_source_seek(s, 0)) return 1; 94 106 95 107 // read again as multiple channels 108 aubio_source_do_multi(s, mat, &read); 109 if (read != hop_size) return 1; 110 111 // read again as multiple channels in an undersized matrix 112 del_fmat(mat); 113 mat = new_fmat(channels - 1, hop_size); 114 aubio_source_do_multi(s, mat, &read); 115 if (read != hop_size) return 1; 116 117 // read again as multiple channels in an undersized matrix 118 del_fmat(mat); 119 mat = new_fmat(channels, hop_size - 1); 120 aubio_source_do_multi(s, mat, &read); 121 if (read != hop_size - 1) return 1; 122 123 // read again as multiple channels in an oversized matrix 124 del_fmat(mat); 125 mat = new_fmat(channels + 1, hop_size); 126 aubio_source_do_multi(s, mat, &read); 127 if (read != hop_size) return 1; 128 129 // read again as multiple channels in an oversized matrix 130 del_fmat(mat); 131 mat = new_fmat(channels, hop_size + 1); 96 132 aubio_source_do_multi(s, mat, &read); 97 133 if (read != hop_size) return 1;
Note: See TracChangeset
for help on using the changeset viewer.