Skip to content

Commit

Permalink
Merge pull request #2 from daschuer/potmeter_fix
Browse files Browse the repository at this point in the history
Minor refactoring in Midi to Control path
  • Loading branch information
rryan committed Jan 4, 2014
2 parents bc4188a + 7f67962 commit 872e1d8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/control/controlbehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ double ControlPotmeterBehavior::defaultValue(double dDefault) const {
}

double ControlPotmeterBehavior::valueToWidgetParameter(double dValue) {
if (m_dValueRange == 0.0) {
return 0;
}
if (dValue > m_dMaxValue) {
dValue = m_dMaxValue;
} else if (dValue < m_dMinValue) {
dValue = m_dMinValue;
}
if (m_dValueRange == 0.0) {
return 0;
}
return (dValue - m_dMinValue) / m_dValueRange;
}

double ControlPotmeterBehavior::widgetParameterToValue(double dParam) {
return m_dMinValue + dParam * m_dValueRange;
return m_dMinValue + (dParam * m_dValueRange);
}

double ControlPotmeterBehavior::valueToMidiParameter(double dValue) {
Expand All @@ -82,8 +82,8 @@ void ControlPotmeterBehavior::setValueFromMidiParameter(MidiOpCode o, double dPa

#define maxPosition 1.0
#define minPosition 0.0
#define middlePosition ((maxPosition-minPosition)/2.0)
#define positionrange (maxPosition-minPosition)
#define middlePosition ((maxPosition - minPosition) / 2.0)
#define positionrange (maxPosition - minPosition)

ControlLogpotmeterBehavior::ControlLogpotmeterBehavior(double dMaxValue)
: ControlPotmeterBehavior(0, dMaxValue) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/midi/midicontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void MidiController::receive(unsigned char status, unsigned char control,

// computeValue not (yet) done on pitch messages because it all assumes 7-bit numbers
} else {
double currMixxxControlValue = pCO->getValueToMidi();
double currMixxxControlValue = pCO->getMidiParameter();
newValue = computeValue(options, currMixxxControlValue, value);
}

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/softtakeover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ bool SoftTakeover::ignore(ControlObject* control, float newValue, bool midiVal)
threshold = scaleFactor*(threshold/128.0f);
}

double currentValue = midiVal ? control->getValueToMidi() : control->get();
double currentValue = midiVal ? control->getMidiParameter() : control->get();
double difference = currentValue - newValue;
double prevDiff = 0;
bool sameSide = false;
Expand Down
2 changes: 1 addition & 1 deletion src/controlobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void ControlObject::setValueFromMidi(MidiOpCode o, double v) {
}
}

double ControlObject::getValueToMidi() const {
double ControlObject::getMidiParameter() const {
return m_pControl ? m_pControl->getMidiParameter() : 0.0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/controlobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ControlObject : public QObject {
// DEPRECATED: Called to set the control value from the controller
// subsystem.
virtual void setValueFromMidi(MidiOpCode o, double v);
virtual double getValueToMidi() const;
virtual double getMidiParameter() const;

protected:
// Key of the object
Expand Down
1 change: 1 addition & 0 deletions src/widget/wpushbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ void WPushButton::setValue(double v) {
}

void WPushButton::paintEvent(QPaintEvent* e) {
Q_UNUSED(e);
QStyleOption option;
option.initFrom(this);
QStylePainter p(this);
Expand Down

0 comments on commit 872e1d8

Please sign in to comment.