Hey!
I'm putting together my first MIDI controller in Arduino and the CC it's sending out is a little too unmanaged. I want to take "if (cc != oldValue*" and change it a little to mean this:*
If the new CC is different to but at least 3 away from the old value, send the CC.
Thanks to anyone that can help
Maybe this can be of some help:
void DoCC( int new_CC ){
 static int prev_CC = 0;
 if( new_CC >= ( prev_CC + 3 ) || new_CC <= ( prev_CC - 3 ) ){
 Â
  prev_CC = new_CC;
  //Send CC
 }
}
raviolifaceman:
If the new CC is different to but at least 3 away from the old value, send the CC.
const int deadZone = 3;
if ((newValue+deadzone) < oldValue || newValue > (oldValue+deadZone)) {
}
Thanks, that's perfect and it solved the problem perfectly
johnwasser:
raviolifaceman:
If the new CC is different to but at least 3 away from the old value, send the CC.const int deadZone = 3;
if ((newValue+deadzone) < oldValue || newValue > (oldValue+deadZone)) {
}
The deadZone needs to be 2 otherwise the 'at least 3 away' becomes 'at least 4 away'.