| 579 | } |
| 580 | |
| 581 | void Looper::ResampleForSpeed(float speed) |
| 582 | { |
| 583 | int oldLoopLength = mLoopLength; |
| 584 | SetLoopLength(MIN(int(abs(mLoopLength / speed)), MAX_BUFFER_SIZE - 1)); |
| 585 | mLoopPos /= speed; |
| 586 | while (mLoopPos < 0) |
| 587 | mLoopPos += mLoopLength; |
| 588 | for (int ch = 0; ch < mBuffer->NumActiveChannels(); ++ch) |
| 589 | { |
| 590 | float* oldBuffer = new float[oldLoopLength]; |
| 591 | BufferCopy(oldBuffer, mBuffer->GetChannel(ch), oldLoopLength); |
| 592 | for (int i = 0; i < mLoopLength; ++i) |
| 593 | { |
| 594 | float offset = i * speed; |
| 595 | mBuffer->GetChannel(ch)[i] = GetInterpolatedSample(offset, oldBuffer, oldLoopLength); |
| 596 | } |
| 597 | delete[] oldBuffer; |
| 598 | } |
| 599 | |
| 600 | if (mKeepPitch) |
| 601 | { |
| 602 | mKeepPitch = false; |
| 603 | mPitchShift = 1 / speed; |
| 604 | } |
| 605 | |
| 606 | mSpeed = 1; |
| 607 | mBufferTempo = TheTransport->GetTempo(); |
| 608 | } |
| 609 | |
| 610 | namespace |
| 611 | { |
no test coverage detected