Changeset 2ca4b59
- Timestamp:
- Oct 11, 2016, 2:37:25 AM (8 years ago)
- Branches:
- sampler
- Children:
- a125fb9a
- Parents:
- a006c5f
- Location:
- src/synth
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/synth/sampler.c
ra006c5f r2ca4b59 60 60 // current interpolation mode (can be quadratic, timestretch, ...) 61 61 uint_t interp; 62 // reading from a table63 62 aubio_ringbuffer_t *ring; 64 63 uint_t perfectloop; 65 64 uint_t eof_remaining; 66 fvec_t *samples; 67 fmat_t *msamples; 65 // reading from a table 66 fvec_t *table; 67 uint_t table_index; 68 68 // reading from a source 69 69 aubio_source_t *source; … … 171 171 #endif 172 172 173 #if 0 174 s->reading_from = aubio_sampler_reading_from_table; 175 s->perfectloop = 1; 176 s->threaded_read = 0; 177 s->opened = 1; 178 s->finished = 1; 179 s->table_index = 0; 180 #endif 181 173 182 return s; 174 183 beach: … … 196 205 // clean up opening thread 197 206 void *threadret; 207 if (!o->open_thread) return; 198 208 pthread_mutex_destroy(&o->open_mutex); 199 209 if (o->open_thread_running) { … … 206 216 } 207 217 pthread_mutex_destroy(&o->open_mutex); 218 o->open_thread = 0; 208 219 } 209 220 … … 223 234 pthread_cond_destroy(&o->read_avail); 224 235 pthread_cond_destroy(&o->read_request); 236 o->read_thread = 0; 225 237 } 226 238 #endif … … 293 305 #ifdef HAVE_THREADS 294 306 uint_t ret = AUBIO_OK; 307 308 if (o->reading_from == aubio_sampler_reading_from_table) { 309 o->reading_from = aubio_sampler_reading_from_source; 310 o->opened = 0; 311 o->finished = 1; 312 } 295 313 /* open uri in open_thread */ 296 314 if (o->open_thread_running) { … … 549 567 550 568 void 551 aubio_sampler_read_from_table(aubio_sampler_t * o, fvec_t *output, uint_t *read) {569 aubio_sampler_read_from_table(aubio_sampler_t *s, fvec_t *output, uint_t *read) { 552 570 *read = 0; 553 AUBIO_WRN("sampler: _pull_from_table not implemented for %d, %d, %d", 554 o, output->length, *read); 571 if (s->table == NULL) { 572 AUBIO_WRN("sampler: _pull_from_table but table not set %d, %d\n", 573 output->length, *read); 574 } else if (s->playing) { 575 uint_t available = s->table->length - s->table_index; 576 fvec_t tmp; 577 tmp.data = s->table->data + s->table_index; 578 if (available < s->blocksize) { 579 //AUBIO_WRN("sampler: _pull_from_table: table length %d, index: %d, read %d\n", 580 // s->table->length, s->table_index, *read); 581 tmp.length = available; 582 fvec_t tmpout; tmpout.data = output->data; tmpout.length = available; 583 fvec_copy(&tmp, &tmpout); 584 if (s->loop && s->perfectloop) { 585 uint_t remaining = s->blocksize - available; 586 tmpout.data = output->data + available; tmpout.length = remaining; 587 tmp.data = s->table->data; tmp.length = remaining; 588 fvec_copy(&tmp, &tmpout); 589 s->table_index = remaining; 590 *read = s->blocksize; 591 } else { 592 s->table_index = 0; 593 *read = available; 594 } 595 aubio_sampler_do_eof(s); 596 } else { 597 tmp.length = s->blocksize; 598 fvec_copy(&tmp, output); 599 s->table_index += output->length; 600 *read = s->blocksize; 601 } 602 } 603 } 604 605 uint_t 606 aubio_sampler_set_table(aubio_sampler_t *s, fvec_t *samples) { 607 if (!samples || !s) return AUBIO_FAIL; 608 if (s->reading_from == aubio_sampler_reading_from_source) { 609 //aubio_sampler_close_reading_thread(s); 610 } 611 s->table = samples; 612 //AUBIO_INF("sampler: setting table (%d long)\n", s->table->length); 613 s->table_index = 0; 614 s->reading_from = aubio_sampler_reading_from_table; 615 //s->threaded_read = 0; 616 s->opened = 1; 617 s->finished = 1; 618 return AUBIO_OK; 555 619 } 556 620 … … 620 684 if (o->source) { 621 685 ret = aubio_source_seek(o->source, pos); 686 } else { 687 o->table_index = pos; 622 688 } 623 689 return ret; … … 633 699 o->playing = 0; 634 700 } else { 635 aubio_sampler_seek(o, 0); 701 if (o->reading_from == aubio_sampler_reading_from_source) 702 aubio_sampler_seek(o, 0); 636 703 //o->finished = 0; 637 704 } -
src/synth/sampler.h
ra006c5f r2ca4b59 83 83 uint_t aubio_sampler_queue(aubio_sampler_t * o, const char_t * uri ); 84 84 85 /** set array to read from 86 87 \param o sampler, created by new_aubio_sampler() 88 \param samples the vector to set the table to 89 90 \return 0 if successfully set, non-zero otherwise 91 92 */ 93 uint_t aubio_sampler_set_table(aubio_sampler_t *o, fvec_t *samples); 94 85 95 /** process sampler function 86 96
Note: See TracChangeset
for help on using the changeset viewer.