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

Method ButtonClicked

Source/NoteLooper.cpp:328–374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

326}
327
328void NoteLooper::ButtonClicked(ClickButton* button, double time)
329{
330 if (button == mClearButton)
331 {
332 for (int i = 0; i < (int)mCurrentNotes.size(); ++i)
333 {
334 if (mCurrentNotes[i] != nullptr)
335 {
336 mNoteOutput.PlayNote(time, i, 0, mCurrentNotes[i]->GetVoiceIdx());
337 mCurrentNotes[i] = nullptr;
338 }
339 }
340 for (int i = 0; i < (int)mInputNotes.size(); ++i)
341 {
342 if (mInputNotes[i] != nullptr)
343 {
344 mNoteOutput.PlayNote(time, i, 0, mInputNotes[i]->GetVoiceIdx());
345 mInputNotes[i] = nullptr;
346 }
347 }
348 mCanvas->Clear();
349 mMinRow = 127;
350 mMaxRow = 0;
351 }
352 for (size_t i = 0; i < mSavedPatterns.size(); ++i)
353 {
354 if (button == mSavedPatterns[i].mStoreButton)
355 mSavedPatterns[i].mNotes = mCanvas->GetElements();
356
357 if (button == mSavedPatterns[i].mLoadButton)
358 {
359 mCanvas->Clear();
360 mMinRow = 127;
361 mMaxRow = 0;
362 for (auto& element : mSavedPatterns[i].mNotes)
363 {
364 mCanvas->AddElement(element);
365
366 int row = element->mRow;
367 if (row < mMinRow)
368 mMinRow = row;
369 if (row > mMaxRow)
370 mMaxRow = row;
371 }
372 }
373 }
374}
375
376void NoteLooper::SetNumMeasures(int numMeasures)
377{

Callers

nothing calls this directly

Calls 5

sizeMethod · 0.80
GetVoiceIdxMethod · 0.80
AddElementMethod · 0.80
PlayNoteMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected