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

Method LoadState

Source/LoopStorer.cpp:276–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276void LoopStorer::LoadState(FileStreamIn& in, int rev)
277{
278 IDrawableModule::LoadState(in, rev);
279
280 if (ModularSynth::sLoadingFileSaveStateRev < 423)
281 in >> rev;
282 LoadStateValidate(rev <= GetModuleSaveStateRev());
283
284 in >> mCurrentBufferIdx;
285 mQueuedSwapBufferIdx = -1;
286 for (int i = 0; i < mSamples.size(); ++i)
287 mSamples[i]->mIsCurrentBuffer = (i == mCurrentBufferIdx);
288
289 if (mCurrentBufferIdx != 0)
290 {
291 mSamples[0]->mBuffer = mSamples[mCurrentBufferIdx]->mBuffer;
292
293 int loopLength;
294 mSamples[mCurrentBufferIdx]->mBuffer = mLooper->GetLoopBuffer(loopLength);
295 mSamples[mCurrentBufferIdx]->mNumBars = mLooper->GetNumBars();
296 mSamples[mCurrentBufferIdx]->mBufferLength = loopLength;
297 }
298
299 mLoadMutex.lock();
300 for (auto* sampleData : mSamples)
301 {
302 if (!sampleData->mIsCurrentBuffer)
303 {
304 in >> sampleData->mNumBars;
305 in >> sampleData->mBufferLength;
306 if (sampleData->mBufferLength != -1)
307 {
308 int readLength;
309 sampleData->mBuffer->Load(in, readLength, ChannelBuffer::LoadMode::kAnyBufferSize);
310 assert(sampleData->mBufferLength == sampleData->mBuffer->BufferSize());
311 }
312 }
313 }
314 mLoadMutex.unlock();
315}
316
317LoopStorer::SampleData::SampleData()
318{

Callers

nothing calls this directly

Calls 6

LoadStateValidateFunction · 0.85
sizeMethod · 0.80
GetLoopBufferMethod · 0.80
BufferSizeMethod · 0.80
GetNumBarsMethod · 0.45
LoadMethod · 0.45

Tested by

no test coverage detected