Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 11 additions & 46 deletions res/controllers/midi-components-0.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,53 +362,18 @@
this.firstValueReceived = false;
};
Pot.prototype = new Component({
relative: false,
shift: function () {
if (this.relative) {
this.input = function (channel, control, value, status, group) {
// Do not manipulate inKey, just store the position of the
// physical potentiometer for calculating how much it moves
// when shift is released.
if (this.MSB !== undefined) {
value = (this.MSB << 7) + value;
}
this.previousValueReceived = value;
}
input: function (channel, control, value, status, group) {
if (this.MSB !== undefined) {
value = (this.MSB << 7) + value;
}
},
unshift: function () {
this.input = function (channel, control, value, status, group) {
if (this.MSB !== undefined) {
value = (this.MSB << 7) + value;
}
if (this.relative) {
if (this.previousValueReceived !== undefined) {
var delta = (value - this.previousValueReceived) / this.max;
if (this.invert) {
delta = -delta;
}
this.inSetParameter(this.inGetParameter() + delta);
} else {
var newValue = value / this.max;
if (this.invert) {
newValue = 1 - newValue;
}
if (this.loadStateOnStartup) {
this.inSetParameter(newValue);
}
}
this.previousValueReceived = value;
} else {
var newValue = this.inValueScale(value);
if (this.invert) {
newValue = 1 - newValue;
}
this.inSetParameter(newValue);
if (!this.firstValueReceived) {
this.firstValueReceived = true;
this.connect();
}
}
var newValue = this.inValueScale(value);
if (this.invert) {
newValue = 1 - newValue;
}
this.inSetParameter(newValue);
if (!this.firstValueReceived) {
this.firstValueReceived = true;
this.connect();
}
},
// Input handlers for 14 bit MIDI
Expand Down
20 changes: 8 additions & 12 deletions src/control/controlbehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ double ControlPotmeterBehavior::valueToParameter(double dValue) {
if (m_dValueRange == 0.0) {
return 0;
}
if (!m_bAllowOutOfBounds) {
if (dValue > m_dMaxValue) {
dValue = m_dMaxValue;
} else if (dValue < m_dMinValue) {
dValue = m_dMinValue;
}
if (dValue > m_dMaxValue) {
dValue = m_dMaxValue;
} else if (dValue < m_dMinValue) {
dValue = m_dMinValue;
}
return (dValue - m_dMinValue) / m_dValueRange;
}
Expand Down Expand Up @@ -118,12 +116,10 @@ double ControlLogPotmeterBehavior::valueToParameter(double dValue) {
if (m_dValueRange == 0.0) {
return 0;
}
if (!m_bAllowOutOfBounds) {
if (dValue > m_dMaxValue) {
dValue = m_dMaxValue;
} else if (dValue < m_dMinValue) {
dValue = m_dMinValue;
}
if (dValue > m_dMaxValue) {
dValue = m_dMaxValue;
} else if (dValue < m_dMinValue) {
dValue = m_dMinValue;
}
double linPrameter = (dValue - m_dMinValue) / m_dValueRange;
double dbParamter = ratio2db(linPrameter + m_minOffset * (1 - linPrameter));
Expand Down