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

Method DoCommit

Source/Looper.cpp:391–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389}
390
391void Looper::DoCommit(double time)
392{
393 PROFILER(LooperDoCommit);
394
395 assert(mCommitBuffer);
396
397 {
398 PROFILER(Looper_DoCommit_undo);
399 mUndoBuffer->CopyFrom(mBuffer, mLoopLength);
400 }
401
402 if (mReplaceOnCommit)
403 Clear();
404
405 if (mMute)
406 {
407 Clear();
408 mMute = false;
409 mMuteRamp.Start(time, mMute ? 0 : 1, time + 1);
410 }
411
412 {
413 PROFILER(LooperDoCommit_commit);
414 int commitSamplesBack = mCommitMsOffset / gInvSampleRateMs;
415 int commitLength = mLoopLength + LOOPER_COMMIT_FADE_SAMPLES;
416 for (int i = 0; i < commitLength; ++i)
417 {
418 int idx = i - LOOPER_COMMIT_FADE_SAMPLES;
419 int pos = int(mLoopPos + (idx * GetPlaybackSpeed()) + mLoopLength) % mLoopLength;
420 float fade = 1;
421 if (idx < 0)
422 fade = float(LOOPER_COMMIT_FADE_SAMPLES + idx) / LOOPER_COMMIT_FADE_SAMPLES;
423 if (idx >= mLoopLength - LOOPER_COMMIT_FADE_SAMPLES)
424 fade = 1 - (float(idx - (mLoopLength - LOOPER_COMMIT_FADE_SAMPLES)) / LOOPER_COMMIT_FADE_SAMPLES);
425
426 for (int ch = 0; ch < mBuffer->NumActiveChannels(); ++ch)
427 {
428 mBuffer->GetChannel(ch)[pos] += mCommitBuffer->GetSample(ofClamp(commitLength - i - commitSamplesBack, 0, MAX_BUFFER_SIZE - 1), ch) * fade;
429 }
430 }
431 }
432
433 mClearCommitBuffer = true;
434}
435
436void Looper::Fill(ChannelBuffer* buffer, int length)
437{

Callers

nothing calls this directly

Calls 7

ClearFunction · 0.85
ofClampFunction · 0.85
NumActiveChannelsMethod · 0.80
GetChannelMethod · 0.80
CopyFromMethod · 0.45
StartMethod · 0.45
GetSampleMethod · 0.45

Tested by

no test coverage detected