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

Method OnPush2Control

Source/NoteTable.cpp:498–589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496}
497
498bool NoteTable::OnPush2Control(Push2Control* push2, MidiMessageType type, int controlIndex, float midiValue)
499{
500 if (mPush2GridDisplayMode == Push2GridDisplayMode::PerStep)
501 {
502 int sequenceRows, pitchCols, pitchRows;
503 GetPush2Layout(sequenceRows, pitchCols, pitchRows);
504
505 if (type == kMidiMessage_Note)
506 {
507 if (controlIndex >= 36 && controlIndex <= 99)
508 {
509 int gridIndex = controlIndex - 36;
510 int x = gridIndex % 8;
511 int y = 7 - gridIndex / 8;
512
513 if (y < sequenceRows)
514 {
515 int index = x + y * 8;
516 if (midiValue > 0)
517 mPush2HeldStep = index;
518 else if (index == mPush2HeldStep)
519 mPush2HeldStep = -1;
520 }
521 else if (y < sequenceRows + pitchRows)
522 {
523 if (midiValue > 0)
524 {
525 int index = x + (pitchRows - 1 - (y - sequenceRows)) * pitchCols;
526 if (index < 0 || index >= mNoteRange)
527 {
528 //out of range, do nothing
529 }
530 else if (mPush2HeldStep != -1)
531 {
532 mGrid->SetVal(mPush2HeldStep, index, mGrid->GetVal(mPush2HeldStep, index) > 0 ? 0 : 1);
533 }
534 else
535 {
536 //I'm not liking this "queued pitch" behavior, let's disable it for now
537 //mQueuedPitches[RowToPitch(index)] = true;
538 }
539 }
540 }
541
542 return true;
543 }
544 }
545 }
546 else if (mPush2GridDisplayMode == Push2GridDisplayMode::GridView)
547 {
548 if (type == kMidiMessage_Note)
549 {
550 int gridIndex = controlIndex - 36;
551 int x = gridIndex % 8;
552 int y = gridIndex / 8;
553 int col = x + mGridControlOffsetX;
554 int row = y + mGridControlOffsetY;
555 if (gridIndex >= 0 && gridIndex < 64 &&

Callers

nothing calls this directly

Calls 3

SetValMethod · 0.80
GetValMethod · 0.80

Tested by

no test coverage detected