| 1594 | } |
| 1595 | |
| 1596 | void Push2Control::OnMidiControl(MidiControl& control) |
| 1597 | { |
| 1598 | if (mGridControlInterface != nullptr) |
| 1599 | { |
| 1600 | bool handled = mGridControlInterface->OnPush2Control(this, kMidiMessage_Control, control.mControl, control.mValue); |
| 1601 | if (handled) |
| 1602 | return; |
| 1603 | } |
| 1604 | |
| 1605 | if (control.mControl >= 71 && control.mControl <= 78) //main encoders |
| 1606 | { |
| 1607 | int controlIndex = control.mControl - 71 + mModuleViewOffset; |
| 1608 | bool justResetParameter = gTime - mLastResetTime < 1000; |
| 1609 | if (controlIndex < mSliderControls.size() && !justResetParameter) |
| 1610 | { |
| 1611 | float currentNormalized = mSliderControls[controlIndex]->GetMidiValue(); |
| 1612 | float increment = control.mValue < 64 ? control.mValue : control.mValue - 128; |
| 1613 | increment *= mShiftHeld ? .0005f : .005f; |
| 1614 | |
| 1615 | FloatSlider* floatSlider = dynamic_cast<FloatSlider*>(mSliderControls[controlIndex]); |
| 1616 | if (floatSlider && floatSlider->GetModulator() && floatSlider->GetModulator()->Active() && floatSlider->GetModulator()->CanAdjustRange()) |
| 1617 | { |
| 1618 | IModulator* modulator = floatSlider->GetModulator(); |
| 1619 | float min = floatSlider->GetMin(); |
| 1620 | float max = floatSlider->GetMax(); |
| 1621 | float modMin = ofMap(modulator->GetMin(), min, max, 0, 1); |
| 1622 | float modMax = ofMap(modulator->GetMax(), min, max, 0, 1); |
| 1623 | |
| 1624 | modulator->GetMin() = ofMap(modMin - increment, 0, 1, min, max, K(clamp)); |
| 1625 | modulator->GetMax() = ofMap(modMax + increment, 0, 1, min, max, K(clamp)); |
| 1626 | } |
| 1627 | else |
| 1628 | { |
| 1629 | mSliderControls[controlIndex]->SetFromMidiCC(currentNormalized + increment, NextBufferTime(false), false); |
| 1630 | } |
| 1631 | } |
| 1632 | } |
| 1633 | else if (control.mControl >= kAboveScreenButtonRow && control.mControl < kAboveScreenButtonRow + 8) //buttons below encoders |
| 1634 | { |
| 1635 | int controlIndex = control.mControl - kAboveScreenButtonRow; |
| 1636 | if (mScreenDisplayMode == ScreenDisplayMode::kNormal || mScreenDisplayMode == ScreenDisplayMode::kMap) |
| 1637 | { |
| 1638 | controlIndex += mModuleViewOffset; |
| 1639 | if (controlIndex < mButtonControls.size()) |
| 1640 | { |
| 1641 | if (control.mValue > 0) |
| 1642 | { |
| 1643 | if (mNewButtonHeld) |
| 1644 | { |
| 1645 | mButtonControls[controlIndex]->StartBeacon(); |
| 1646 | AddFavoriteControl(mButtonControls[controlIndex]); |
| 1647 | } |
| 1648 | else if (mDeleteButtonHeld) |
| 1649 | { |
| 1650 | mButtonControls[controlIndex]->StartBeacon(); |
| 1651 | RemoveFavoriteControl(mButtonControls[controlIndex]); |
| 1652 | } |
| 1653 | else if (mInMidiControllerBindMode) |
no test coverage detected