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

Method CheckboxUpdated

Source/ClipLauncher.cpp:149–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149void ClipLauncher::CheckboxUpdated(Checkbox* checkbox, double time)
150{
151 for (int i = 0; i < mSamples.size(); ++i)
152 {
153 if (checkbox == mSamples[i].mPlayCheckbox)
154 {
155 int currentlyPlaying = -1;
156 for (int j = 0; j < mSamples.size(); ++j)
157 {
158 if (j != i && mSamples[j].mPlay)
159 currentlyPlaying = j;
160 }
161 for (int j = 0; j < mSamples.size(); ++j)
162 {
163 if (j != i)
164 mSamples[j].mPlay = false;
165 }
166 int newPlaying = -1;
167 for (int j = 0; j < mSamples.size(); ++j)
168 {
169 if (mSamples[j].mPlay)
170 newPlaying = j;
171 }
172 if (currentlyPlaying != newPlaying)
173 {
174 mSampleMutex.lock();
175 float data[JUMP_BLEND_SAMPLES];
176 ChannelBuffer temp(data, JUMP_BLEND_SAMPLES);
177 if (currentlyPlaying != -1)
178 mSamples[currentlyPlaying].mSample->ConsumeData(time, &temp, JUMP_BLEND_SAMPLES, true);
179 mJumpBlender.CaptureForJump(0, data, JUMP_BLEND_SAMPLES, gBufferSize);
180 mSampleMutex.unlock();
181 }
182 }
183
184 if (checkbox == mSamples[i].mGrabCheckbox)
185 {
186 if (mSamples[i].mHasSample)
187 {
188 if (mSamples[i].mPlay)
189 mSampleMutex.lock();
190
191 int bufferSize;
192 mSamples[i].mSample->Create(mLooper->GetLoopBuffer(bufferSize));
193 mSamples[i].mNumBars = mLooper->GetNumBars();
194 mLooper->Clear();
195
196 if (mSamples[i].mPlay)
197 mSampleMutex.unlock();
198
199 for (int j = 0; j < mSamples.size(); ++j)
200 mSamples[j].mPlay = (j == i);
201 }
202 else
203 {
204 mSamples[i].mPlay = false;
205 mSamples[i].mSample->Create(1);
206 }

Callers

nothing calls this directly

Calls 7

sizeMethod · 0.80
ConsumeDataMethod · 0.80
CaptureForJumpMethod · 0.80
GetLoopBufferMethod · 0.80
CreateMethod · 0.45
GetNumBarsMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected