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

Method ButtonClicked

Source/Looper.cpp:1049–1105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1047}
1048
1049void Looper::ButtonClicked(ClickButton* button, double time)
1050{
1051 if (button == mClearButton)
1052 {
1053 mUndoBuffer->CopyFrom(mBuffer, mLoopLength);
1054 Clear();
1055 }
1056 if (button == mMergeButton && mRecorder)
1057 mRecorder->RequestMerge(this);
1058 if (button == mSwapButton && mRecorder)
1059 mRecorder->RequestSwap(this);
1060 if (button == mCopyButton && mRecorder)
1061 mRecorder->RequestCopy(this);
1062 if (button == mVolumeBakeButton)
1063 mWantBakeVolume = true;
1064 if (button == mSaveButton)
1065 {
1066 Sample::WriteDataToFile(ofGetTimestampString("loops/loop_%Y-%m-%d_%H-%M-%S.wav").c_str(), mBuffer, mLoopLength);
1067 }
1068 if (button == mCommitButton && mRecorder)
1069 mRecorder->Commit(this);
1070 if (button == mDoubleSpeedButton)
1071 {
1072 if (mSpeed == 1)
1073 {
1074 HalveNumBars();
1075 mSpeed = 2;
1076 ResampleForSpeed(GetPlaybackSpeed());
1077 }
1078 }
1079 if (button == mHalveSpeedButton)
1080 {
1081 if (mSpeed == 1 && mLoopLength < MAX_BUFFER_SIZE / 2)
1082 {
1083 DoubleNumBars();
1084 mSpeed = .5f;
1085 ResampleForSpeed(GetPlaybackSpeed());
1086 }
1087 }
1088 if (button == mExtendButton)
1089 {
1090 int newLength = mNumBars * 2;
1091 if (newLength <= 16)
1092 SetNumBars(newLength);
1093 }
1094 if (button == mUndoButton)
1095 mWantUndo = true;
1096 if (button == mWriteOffsetButton)
1097 mWantShiftOffset = true;
1098 if (button == mQueueCaptureButton)
1099 {
1100 mCaptureQueued = true;
1101 mLastCommitTime = time;
1102 }
1103 if (button == mResampleButton)
1104 ResampleForSpeed(GetPlaybackSpeed());
1105}
1106

Callers

nothing calls this directly

Calls 7

ClearFunction · 0.85
ofGetTimestampStringFunction · 0.85
RequestMergeMethod · 0.80
RequestSwapMethod · 0.80
RequestCopyMethod · 0.80
CopyFromMethod · 0.45
CommitMethod · 0.45

Tested by

no test coverage detected