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

Method MergeIn

Source/Looper.cpp:913–939  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

911}
912
913void Looper::MergeIn(Looper* otherLooper)
914{
915 int newNumBars = MAX(mNumBars, otherLooper->mNumBars);
916
917 SetNumBars(newNumBars);
918
919 otherLooper->SetNumBars(newNumBars);
920
921 if (mVol > 0.01f)
922 {
923 for (int ch = 0; ch < mBuffer->NumActiveChannels(); ++ch)
924 {
925 Mult(otherLooper->mBuffer->GetChannel(ch), (otherLooper->mVol * otherLooper->mVol) / (mVol * mVol), mLoopLength); //keep other looper at same apparent volume
926 Add(mBuffer->GetChannel(ch), otherLooper->mBuffer->GetChannel(ch), mLoopLength);
927 }
928 }
929 else //ours was silent, just replace it
930 {
931 mBuffer->CopyFrom(otherLooper->mBuffer, mLoopLength);
932 mVol = 1;
933 }
934
935 otherLooper->Clear();
936
937 if (mRecorder)
938 mLastCommit = mRecorder->IncreaseCommitCount();
939}
940
941void Looper::SwapBuffers(Looper* otherLooper)
942{

Callers 1

RequestMergeMethod · 0.80

Calls 8

MultFunction · 0.85
AddFunction · 0.85
NumActiveChannelsMethod · 0.80
GetChannelMethod · 0.80
IncreaseCommitCountMethod · 0.80
SetNumBarsMethod · 0.45
CopyFromMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected