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

Method LoadState

Source/BufferShuffler.cpp:514–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

512}
513
514void BufferShuffler::LoadState(FileStreamIn& in, int rev)
515{
516 IDrawableModule::LoadState(in, rev);
517 if (rev < 0)
518 return;
519
520 LoadStateValidate(rev <= GetModuleSaveStateRev());
521
522 in >> mWidth;
523 in >> mHeight;
524 Resize(mWidth, mHeight);
525
526 int savedSampleRate;
527 in >> savedSampleRate;
528 int savedLength;
529 in >> savedLength;
530 int savedChannelCount;
531 in >> savedChannelCount;
532 if (savedSampleRate == gSampleRate)
533 {
534 mInputBuffer.Load(in, savedLength, ChannelBuffer::LoadMode::kAnyBufferSize);
535 }
536 else
537 {
538 ChannelBuffer readBuffer(savedLength);
539 readBuffer.Load(in, savedLength, ChannelBuffer::LoadMode::kAnyBufferSize);
540
541 float sampleRateRatio = (float)gSampleRate / savedSampleRate;
542 int adjustedLength = savedLength * sampleRateRatio;
543 mInputBuffer.SetNumActiveChannels(savedChannelCount);
544 for (int ch = 0; ch < savedChannelCount; ++ch)
545 {
546 float* destBuffer = mInputBuffer.GetChannel(ch);
547 float* srcBuffer = readBuffer.GetChannel(ch);
548 for (int i = 0; i < adjustedLength; ++i)
549 destBuffer[i] = GetInterpolatedSample(i / sampleRateRatio, srcBuffer, savedLength);
550 }
551 }
552}

Callers

nothing calls this directly

Calls 5

LoadStateValidateFunction · 0.85
GetInterpolatedSampleFunction · 0.85
SetNumActiveChannelsMethod · 0.80
GetChannelMethod · 0.80
LoadMethod · 0.45

Tested by

no test coverage detected