Skip to content

Commit

Permalink
Update handling of long press (SynthstromAudible#1578)
Browse files Browse the repository at this point in the history
Updated handling of long presses in automation view to account for the case where the effective length of the clip falls within the rightmost column selected in the long press
  • Loading branch information
seangoodvibes authored Mar 25, 2024
1 parent 50ab08e commit 1b37635
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/deluge/gui/views/automation_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4036,14 +4036,16 @@ void AutomationView::handleMultiPadPress(ModelStackWithAutoParam* modelStackWith
int32_t effectiveLength, int32_t xScroll, int32_t xZoom,
bool modEncoderAction) {

int32_t firstPadLeftEdge = getPosFromSquare(firstPadX, xScroll, xZoom);
int32_t secondPadRightEdge = getPosFromSquare(secondPadX + 1, xScroll, xZoom);
int32_t secondPadLeftEdge = getPosFromSquare(secondPadX, xScroll, xZoom);

if (effectiveLength <= 0 || secondPadRightEdge > effectiveLength) {
if (effectiveLength <= 0 || secondPadLeftEdge > effectiveLength) {
return;
}

if (modelStackWithParam && modelStackWithParam->autoParam) {
int32_t firstPadLeftEdge = getPosFromSquare(firstPadX, xScroll, xZoom);
int32_t secondPadRightEdge = getPosFromSquare(secondPadX + 1, xScroll, xZoom);

int32_t firstPadValue = 0;
int32_t secondPadValue = 0;

Expand All @@ -4064,12 +4066,6 @@ void AutomationView::handleMultiPadPress(ModelStackWithAutoParam* modelStackWith
secondPadValue = calculateKnobPosForPadPress(modelStackWithParam, outputType, secondPadY) + kKnobPosOffset;
}

// converting variables to float for more accurate interpolation calculation
float firstPadValueFloat = static_cast<float>(firstPadValue);
float firstPadXFloat = static_cast<float>(firstPadLeftEdge);
float secondPadValueFloat = static_cast<float>(secondPadValue);
float secondPadXFloat = static_cast<float>(secondPadRightEdge - kParamNodeWidth);

// clear existing nodes from long press range

// reset interpolation settings to default
Expand All @@ -4084,6 +4080,12 @@ void AutomationView::handleMultiPadPress(ModelStackWithAutoParam* modelStackWith
setParameterAutomationValue(modelStackWithParam, secondPadValue - kKnobPosOffset, squareStart, secondPadX,
effectiveLength, xScroll, xZoom);

// converting variables to float for more accurate interpolation calculation
float firstPadValueFloat = static_cast<float>(firstPadValue);
float firstPadXFloat = static_cast<float>(firstPadLeftEdge);
float secondPadValueFloat = static_cast<float>(secondPadValue);
float secondPadXFloat = static_cast<float>(squareStart);

// loop from first pad to last pad, setting values for nodes in between
// these values will serve as "key frames" for the interpolation to flow through
for (int32_t x = firstPadX; x <= secondPadX; x++) {
Expand Down Expand Up @@ -4156,14 +4158,17 @@ void AutomationView::handleMultiPadPress(ModelStackWithAutoParam* modelStackWith
void AutomationView::renderDisplayForMultiPadPress(ModelStackWithAutoParam* modelStackWithParam, Clip* clip,
int32_t effectiveLength, int32_t xScroll, int32_t xZoom,
int32_t xDisplay, bool modEncoderAction) {
int32_t firstPadLeftEdge = getPosFromSquare(leftPadSelectedX, xScroll, xZoom);
int32_t secondPadRightEdge = getPosFromSquare(rightPadSelectedX + 1, xScroll, xZoom);

if (effectiveLength <= 0 || secondPadRightEdge > effectiveLength) {
int32_t secondPadLeftEdge = getPosFromSquare(rightPadSelectedX, xScroll, xZoom);

if (effectiveLength <= 0 || secondPadLeftEdge > effectiveLength) {
return;
}

if (modelStackWithParam && modelStackWithParam->autoParam) {
int32_t firstPadLeftEdge = getPosFromSquare(leftPadSelectedX, xScroll, xZoom);
int32_t secondPadRightEdge = getPosFromSquare(rightPadSelectedX + 1, xScroll, xZoom);

int32_t knobPosLeft = getParameterKnobPos(modelStackWithParam, firstPadLeftEdge) + kKnobPosOffset;

uint32_t squareStart = std::min(effectiveLength, secondPadRightEdge) - kParamNodeWidth;
Expand Down

0 comments on commit 1b37635

Please sign in to comment.