Hello list,
another tiny patch which I'd like to share. I was a bit annoyed that the
pitch slider doesn't center properly at MIDI value 64, which becomes
clear when looking at the "value/127." code. I tweaked the perfectly
linear transformation into piecewise linear, so that values 0..64 give
0..0.5 and 64..127 give 0.5..1.0 (no typo!).
Those of you using high-res MIDI controls probably won't notice
anything, but it's safer to check... With coarse controllers, this
method gives you the full range of values, centers perfectly and differs
only slightly (by less than 1%) from the perfectly linear method.
Albert: thanks a lot for committing my last patch, and sorry for
bothering you with yet another minuscule piece of code change. Nothing
big coming from me, i'm afraid.
Ján
Index: mixxx/src/controlpotmeter.cpp
===================================================================
--- mixxx/src/controlpotmeter.cpp (revision 1772)
+++ mixxx/src/controlpotmeter.cpp (working copy)
@@ -69,17 +69,20 @@
double ControlPotmeter::getValueToWidget(double dValue)
{
- return 127.*(dValue-m_dMinValue)/m_dValueRange;
+ float out = (dValue-m_dMinValue)/m_dValueRange;
+ return (out < 0.5) ? out*128. : out*126. + 1.;
}
double ControlPotmeter::GetMidiValue()
{
- return 127.*(m_dValue-m_dMinValue)/m_dValueRange;
+ float out = (m_dValue-m_dMinValue)/m_dValueRange;
+ return (out < 0.5) ? out*128. : out*126. + 1.;
}
double ControlPotmeter::getValueFromWidget(double dValue)
{
- return m_dMinValue + (dValue/127.)*m_dValueRange;
+ float out = (dValue < 64) ? dValue / 128. : (dValue-1) / 126.;
+ return m_dMinValue + out * m_dValueRange;
}
void ControlPotmeter::setValueFromThread(double dValue)
@@ -106,7 +109,8 @@
void ControlPotmeter::setValueFromMidi(MidiCategory, double v)
{
- m_dValue = m_dMinValue + (v/127.)*m_dValueRange;
+ float out = (v < 64) ? v / 128. : (v-1) / 126.;
+ m_dValue = m_dMinValue + out*m_dValueRange;
emit(valueChanged(m_dValue));
}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel