Changeset 30efdd0
- Timestamp:
- Sep 29, 2016, 4:31:10 PM (8 years ago)
- Branches:
- sampler, timestretch
- Children:
- 4acee97
- Parents:
- 1e4b7f6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/effects/timestretch_rubberband.c
r1e4b7f6 r30efdd0 43 43 44 44 aubio_source_t *source; 45 uint_t source_hopsize; /**< hop size at which the source is read */ 45 46 fvec_t *in; 46 47 uint_t eof; … … 53 54 54 55 static void aubio_timestretch_warmup (aubio_timestretch_t * p); 55 static sint_t aubio_timestretch_fetch(aubio_timestretch_t *p );56 static sint_t aubio_timestretch_fetch(aubio_timestretch_t *p, uint_t fetch); 56 57 57 58 aubio_timestretch_t * … … 62 63 p->samplerate = samplerate; 63 64 p->hopsize = hopsize; 65 p->source_hopsize = hopsize; 64 66 p->pitchscale = 1.; 65 67 p->eof = 0; 66 68 67 p->source = new_aubio_source(uri, samplerate, hopsize);69 p->source = new_aubio_source(uri, samplerate, p->source_hopsize); 68 70 if (!p->source) goto beach; 69 71 if (samplerate == 0 ) p->samplerate = aubio_source_get_samplerate(p->source); 70 72 71 p->in = new_fvec( hopsize);73 p->in = new_fvec(p->source_hopsize); 72 74 73 75 if (stretchratio <= MAX_STRETCH_RATIO && stretchratio >= MIN_STRETCH_RATIO) { … … 86 88 87 89 p->rb = rubberband_new(p->samplerate, 1, p->rboptions, p->stretchratio, p->pitchscale); 88 rubberband_set_max_process_size(p->rb, p-> hopsize);90 rubberband_set_max_process_size(p->rb, p->source_hopsize); 89 91 //rubberband_set_debug_level(p->rb, 10); 90 92 … … 102 104 { 103 105 // warm up rubber band 104 uint_t source_read = 0;105 106 unsigned int latency = MAX(p->hopsize, rubberband_get_latency(p->rb)); 106 int available = rubberband_available(p->rb); 107 while (available <= (int)latency) { 108 aubio_source_do(p->source, p->in, &source_read); 109 // for very short samples 110 if (source_read < p->hopsize) p->eof = 1; 111 rubberband_process(p->rb, (const float* const*)&(p->in->data), p->hopsize, p->eof); 112 available = rubberband_available(p->rb); 113 } 107 aubio_timestretch_fetch(p, latency); 114 108 } 115 109 … … 192 186 193 187 sint_t 194 aubio_timestretch_fetch(aubio_timestretch_t *p )195 { 196 uint_t source_read = p-> hopsize;188 aubio_timestretch_fetch(aubio_timestretch_t *p, uint_t length) 189 { 190 uint_t source_read = p->source_hopsize; 197 191 // read more samples from source until we have enough available or eof is reached 198 192 int available = rubberband_available(p->rb); 199 while ((available < (int) p->hopsize) && (p->eof == 0)) {193 while ((available < (int)length) && (p->eof == 0)) { 200 194 aubio_source_do(p->source, p->in, &source_read); 201 if (source_read < p-> hopsize) {195 if (source_read < p->source_hopsize) { 202 196 p->eof = 1; 203 197 } … … 205 199 available = rubberband_available(p->rb); 206 200 } 207 return source_read;201 return available; 208 202 } 209 203 … … 211 205 aubio_timestretch_do (aubio_timestretch_t * p, fvec_t * out, uint_t * read) 212 206 { 213 int available = aubio_timestretch_fetch(p );207 int available = aubio_timestretch_fetch(p, p->hopsize); 214 208 // now retrieve the samples and write them into out->data 215 209 if (available >= (int)p->hopsize) {
Note: See TracChangeset
for help on using the changeset viewer.