- Timestamp:
- Oct 8, 2016, 8:59:30 PM (8 years ago)
- Branches:
- sampler
- Children:
- 128589e
- Parents:
- 88a774c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/synth/sampler.c
r88a774c rfefbbd8 133 133 s->available = 0; 134 134 135 s->threaded_read = 0; 136 s->perfectloop = 0; 135 137 #if 0 // naive mode 136 138 s->source_blocksize = s->blocksize; 137 s->perfectloop = 0; 138 #elif 0 // threaded mode 139 #elif 0 // threaded mode, no ringbuffer 139 140 s->source_blocksize = s->blocksize; 140 // FIXME: perfectloop fails if source_blocksize > 2048 ?! 141 //s->source_blocksize = 4096; //32 * s->blocksize; 142 s->perfectloop = 0; 143 s->threaded_read = 0; 144 #elif 1 // unthreaded ringbuffer mode 141 s->threaded_read = 1; 142 #elif 0 // unthreaded, with ringbuffer 145 143 s->source_blocksize = 2048; //32 * s->blocksize; 146 // FIXME: perfectloop fails if source_blocksize > 2048 ?!147 //s->source_blocksize = 4096; //32 * s->blocksize;148 144 s->perfectloop = 1; 149 #endif 145 #elif 1 // threaded with ringhbuffer 146 s->source_blocksize = 2048; //32 * s->blocksize; 147 s->perfectloop = 1; 148 s->threaded_read = 1; 149 #endif 150 // FIXME: perfectloop fails if source_blocksize > 2048 with source_avcodec 151 //s->source_blocksize = 8192; 150 152 151 153 if (s->perfectloop || s->source_blocksize != s->blocksize) { … … 153 155 s->ring = new_aubio_ringbuffer(s->source_blocksize, s->blocksize); 154 156 } 157 //s->channels = 1; 158 //s->source_moutput = new_fmat(s->source_blocksize, s->channels); 155 159 156 160 #ifdef HAVE_THREADS … … 158 162 159 163 if (s->threaded_read) { 160 s->source_blocksize = s->blocksize; 161 //s->source_output = new_fvec(s->source_blocksize); 162 s->channels = 1; 163 s->source_moutput = new_fmat(s->source_blocksize, s->channels); 164 //AUBIO_WRN("sampler: starting reading thread\n"); 164 165 aubio_sampler_open_reading_thread(s); 165 } else if (0) {166 s->source_blocksize = s->blocksize;167 } else {168 //s->source_blocksize = 16*s->blocksize;169 //s->source_blocksize = 8192; //s->blocksize;170 //s->ring = new_aubio_ringbuffer(s->source_blocksize, s->source_blocksize);171 166 } 172 167 #endif … … 337 332 338 333 uint_t aubio_sampler_reading_from_source_ring_fetch(aubio_sampler_t*s); 334 339 335 void *aubio_sampler_readfn(void *z) { 340 336 aubio_sampler_t *p = z; … … 348 344 //AUBIO_WRN("sampler: readfn(): file started\n"); 349 345 if (p->ring) { 350 aubio_sampler_reading_from_source_ring_fetch(p);346 p->available = aubio_sampler_reading_from_source_ring_fetch(p); 351 347 } else { 352 348 p->available = aubio_sampler_pull_from_source(p); … … 485 481 *read = 0; 486 482 if (ring_avail > 0) { 483 // pull remaining frames in ring buffer 487 484 aubio_ringbuffer_pull(s->ring, output, ring_avail); 488 485 check_wrote += ring_avail; 489 486 *read += ring_avail; 490 487 } 488 // signal eof, seek to 0 if looping 491 489 aubio_sampler_do_eof(s); 490 // read new frames from source early if needed 492 491 aubio_sampler_do_perfectloop(s); 492 // write the remaining frames 493 493 *read += aubio_sampler_write_remaining_ring(s, output, ring_avail); 494 494 } … … 529 529 //AUBIO_WRN("sampler: got %d available in _read_from_source\n", available); 530 530 // read -> number of samples read 531 if (available >= (sint_t)s->blocksize) { 532 fvec_copy(s->source_output, output); 533 *read = s->blocksize; 534 } else if (available > 0) { 535 fvec_copy(s->source_output, output); 536 *read = available; 531 if (!s->perfectloop && s->source_blocksize == s->blocksize) { 532 if (available >= (sint_t)s->blocksize) { 533 fvec_copy(s->source_output, output); 534 *read = s->blocksize; 535 } else if (available > 0) { 536 fvec_copy(s->source_output, output); 537 *read = available; 538 } else { 539 fvec_zeros(output); 540 *read = 0; 541 } 537 542 } else { 538 fvec_zeros(output); 539 *read = 0; 543 aubio_sampler_reading_from_source_ring_pull(s, output, read); 540 544 } 541 545 //*read = s->available; … … 547 551 #ifdef HAVE_THREADS 548 552 if (s->threaded_read) { // if threaded 549 if (s->source_blocksize == s->blocksize) { 550 aubio_sampler_read_from_source_threaded(s, output, read); 551 } else { 552 //abort(); 553 } 553 aubio_sampler_read_from_source_threaded(s, output, read); 554 554 } else 555 555 #endif … … 578 578 tmpout.length = s->blocksize - wrote; 579 579 aubio_ringbuffer_pull(s->ring, &tmpout, tmpout.length); 580 //*read += tmpout.length;581 #if 0582 int ring_avail = aubio_ringbuffer_get_available(s->ring);583 AUBIO_WRN("sampler: perfectloop, "584 "%d left in ring, looping pulled %d more, wrote %d + %d\n",585 ring_avail, s->available, wrote, tmpout.length);586 #endif587 580 check_wrote += tmpout.length; 588 581 return tmpout.length; … … 597 590 s->available = aubio_sampler_pull_from_source(s); 598 591 if (s->available <= 0) { 599 AUBIO_ERR("sampler: loopingbut s->available = 0 !\n");592 AUBIO_ERR("sampler: perfectloop but s->available = 0 !\n"); 600 593 } else { 601 //AUBIO_ERR("sampler: perfectloop fetch and push more\n");602 594 aubio_ringbuffer_push(s->ring, s->source_output, s->available); 603 595 } … … 621 613 return -1; 622 614 } 623 // do actual reading624 615 aubio_source_do(s->source, s->source_output, &source_read); 625 #if 0626 if (source_read < s->source_blocksize) {627 //AUBIO_ERR("sampler: _pull_from_source: short read %d < %d\n", source_read,628 // s->source_blocksize);629 //aubio_sampler_do_eof(s);630 if (s->loop) {631 AUBIO_ERR("sampler: _pull_from_source: loop, should seeking to 0? %d / %d\n",632 source_read, s->source_blocksize);633 //aubio_sampler_seek(s, 0);634 }635 }636 //AUBIO_ERR("sampler: _pull_from_source: read %d / %d\n", source_read, length);637 #endif638 616 return source_read; 639 617 }
Note: See TracChangeset
for help on using the changeset viewer.