Processes as many processing frames of the samples 'inputBuffer', store the result into 'outputBuffer'
| 503 | // Processes as many processing frames of the samples 'inputBuffer', store |
| 504 | // the result into 'outputBuffer' |
| 505 | void TDStretch::processSamples() |
| 506 | { |
| 507 | int ovlSkip, offset; |
| 508 | int temp; |
| 509 | |
| 510 | /* Removed this small optimization - can introduce a click to sound when tempo setting |
| 511 | crosses the nominal value |
| 512 | if (tempo == 1.0f) |
| 513 | { |
| 514 | // tempo not changed from the original, so bypass the processing |
| 515 | processNominalTempo(); |
| 516 | return; |
| 517 | } |
| 518 | */ |
| 519 | |
| 520 | // Process samples as long as there are enough samples in 'inputBuffer' |
| 521 | // to form a processing frame. |
| 522 | while ((int)inputBuffer.numSamples() >= sampleReq) |
| 523 | { |
| 524 | // If tempo differs from the normal ('SCALE'), scan for the best overlapping |
| 525 | // position |
| 526 | offset = seekBestOverlapPosition(inputBuffer.ptrBegin()); |
| 527 | |
| 528 | // Mix the samples in the 'inputBuffer' at position of 'offset' with the |
| 529 | // samples in 'midBuffer' using sliding overlapping |
| 530 | // ... first partially overlap with the end of the previous sequence |
| 531 | // (that's in 'midBuffer') |
| 532 | overlap(outputBuffer.ptrEnd((uint)overlapLength), inputBuffer.ptrBegin(), (uint)offset); |
| 533 | outputBuffer.putSamples((uint)overlapLength); |
| 534 | |
| 535 | // ... then copy sequence samples from 'inputBuffer' to output: |
| 536 | |
| 537 | // length of sequence |
| 538 | temp = (seekWindowLength - 2 * overlapLength); |
| 539 | |
| 540 | // crosscheck that we don't have buffer overflow... |
| 541 | if ((int)inputBuffer.numSamples() < (offset + temp + overlapLength * 2)) |
| 542 | { |
| 543 | continue; // just in case, shouldn't really happen |
| 544 | } |
| 545 | |
| 546 | outputBuffer.putSamples(inputBuffer.ptrBegin() + channels * (offset + overlapLength), (uint)temp); |
| 547 | |
| 548 | // Copies the end of the current sequence from 'inputBuffer' to |
| 549 | // 'midBuffer' for being mixed with the beginning of the next |
| 550 | // processing sequence and so on |
| 551 | assert((offset + temp + overlapLength * 2) <= (int)inputBuffer.numSamples()); |
| 552 | memcpy(pMidBuffer, inputBuffer.ptrBegin() + channels * (offset + temp + overlapLength), |
| 553 | channels * sizeof(SAMPLETYPE) * overlapLength); |
| 554 | |
| 555 | // Remove the processed samples from the input buffer. Update |
| 556 | // the difference between integer & nominal skip step to 'skipFract' |
| 557 | // in order to prevent the error from accumulating over time. |
| 558 | skipFract += nominalSkip; // real skip size |
| 559 | ovlSkip = (int)skipFract; // rounded to integer skip |
| 560 | skipFract -= ovlSkip; // maintain the fraction part, i.e. real vs. integer skip |
| 561 | inputBuffer.receiveSamples((uint)ovlSkip); |
| 562 | } |
nothing calls this directly
no test coverage detected