MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / ResampleForSpeed

Method ResampleForSpeed

Source/Looper.cpp:581–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

579}
580
581void 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
610namespace
611{

Callers 2

SyncLoopLengthsMethod · 0.80
ButtonClickedMethod · 0.80

Calls 5

BufferCopyFunction · 0.85
GetInterpolatedSampleFunction · 0.85
NumActiveChannelsMethod · 0.80
GetChannelMethod · 0.80
GetTempoMethod · 0.45

Tested by

no test coverage detected