Skip to content

Commit

Permalink
Added missing rounding and commented out leftover qDebug
Browse files Browse the repository at this point in the history
  • Loading branch information
kpr0th committed Dec 22, 2023
1 parent 9fe9996 commit b1f3206
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ui/src/virtualconsole/vccuelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,10 +817,12 @@ void VCCueList::slotCurrentStepChanged(int stepNumber)

float stepVal;
int stepsCount = m_tree->topLevelItemCount();
if (stepsCount < 256)
if (stepsCount < 256) {
stepVal = 256.0 / (float)stepsCount; //divide up the full 0..255 range
else
stepVal = (float)qFloor((stepVal * 100000) + 0.5) / 100000; //round to 5 decimals to fix corner cases
} else {
stepVal = 1.0;
}
// value->step# truncates down in slotSideFaderValueChanged; so use ceiling for step#->value
float slValue = stepVal * (float)stepNumber;
if (slValue > 255)
Expand All @@ -836,7 +838,11 @@ void VCCueList::slotCurrentStepChanged(int stepNumber)
m_sideFader->setValue(upperBound);
m_topPercentageLabel->setText(QString("%1").arg(qCeil(slValue)));
m_sideFader->blockSignals(false);
//qDebug() << "Slider value:" << m_sideFader->value() << "->" << 255-qCeil(slValue) << "( disp:" << slValue << ") Step range:" << upperBound << lowerBound;

//qDebug() << "Slider value:" << m_sideFader->value() << "->" << 255-qCeil(slValue)
// << "(disp:" << slValue << ")" << "Step range:" << upperBound << lowerBound
// << "(stepSize:" << stepVal << ")"
// << "(raw lower:" << ((float)256.0 - slValue - stepVal) << ")";
}
}
else
Expand Down Expand Up @@ -1223,7 +1229,7 @@ void VCCueList::slotSideFaderValueChanged(int value)
newStep = ch->stepsCount() - 1;
else
newStep = qFloor((float)value / stepSize);
qDebug() << "value:" << value << " new step:" << newStep << " stepSize:" << stepSize;
//qDebug() << "value:" << value << " new step:" << newStep << " stepSize:" << stepSize;
}

if (newStep == ch->currentStepIndex())
Expand Down

0 comments on commit b1f3206

Please sign in to comment.