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

Method UpdatePush2Leds

Source/StepSequencer.cpp:603–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601}
602
603void StepSequencer::UpdatePush2Leds(Push2Control* push2)
604{
605 mPush2Connected = true;
606 int numYChunks = GetNumControllerChunks();
607
608 for (int x = 0; x < 8; ++x)
609 {
610 for (int y = 0; y < 8; ++y)
611 {
612 int rowsPerChunk = std::max(1, (8 / numYChunks));
613 int chunkIndex = y / rowsPerChunk;
614 GridColor color = GetGridColor(x, y);
615 int pushColor = 0;
616 switch (color)
617 {
618 case kGridColorOff: //off
619 pushColor = (chunkIndex % 2 == 0) ? 0 : 124;
620 break;
621 case kGridColor1Dim: //
622 pushColor = 86;
623 break;
624 case kGridColor1Bright: //pressed
625 pushColor = 32;
626 break;
627 case kGridColor2Dim:
628 pushColor = 114;
629 break;
630 case kGridColor2Bright: //root
631 pushColor = 25;
632 break;
633 case kGridColor3Dim: //not in pentatonic
634 pushColor = 116;
635 break;
636 case kGridColor3Bright: //in pentatonic
637 pushColor = 115;
638 break;
639 }
640 push2->SetLed(kMidiMessage_Note, x + (7 - y) * 8 + 36, pushColor);
641 }
642 }
643
644 std::string touchStripLights = { 0x00, 0x21, 0x1D, 0x01, 0x01, 0x19 };
645 for (int i = 0; i < 16; ++i)
646 {
647 int ledLow = (int(((i * 2) / 32.0f) * numYChunks) == mGridYOff) ? 7 : 0;
648 int ledHigh = (int(((i * 2 + 1) / 32.0f) * numYChunks) == mGridYOff) ? 7 : 0;
649 unsigned char c = ledLow + (ledHigh << 3);
650 touchStripLights += c;
651 }
652 push2->GetDevice()->SendSysEx(touchStripLights);
653}
654
655int StepSequencer::GetNumSteps(NoteInterval interval, int numMeasures) const
656{

Callers

nothing calls this directly

Calls 3

SetLedMethod · 0.80
GetDeviceMethod · 0.80
SendSysExMethod · 0.45

Tested by

no test coverage detected