ddiakopoulos / hiduino

:musical_keyboard: Native USB-MIDI on the Arduino
http://www.dimitridiakopoulos.com/hiduino
643 stars 110 forks source link

Hidduino input interrupts send rutine #5

Closed s00500 closed 12 years ago

s00500 commented 12 years ago

I`ve got the folloewing problem: I've builted a controller to controll native instruments traktor and it works pretty well but when i try to use led outputs from traktor my controller starts to send the note on and note off command twice

Here's my code

key_in = analogRead(0); // read the value from the sensor key = get_key_1(key_in); // convert into key press if (key != oldkey) // if keypress is detected { delay(100); // wait for debounce time key_in = analogRead(0); // read the value from the sensor key = get_key_1(key_in); // convert into key press if (key != oldkey)
{

  if (key >= 0)
  {
  MIDI.sendNoteOn(key,127,2); 
  onx = 1;
  }
  else
  {
    if (onx == 1) 
    {
      MIDI.sendNoteOff(oldkey,0,2);
      onx = 0;

    }
  }
  oldkey = key;
}

}

int get_key_1(unsigned int input) { int k; for (k = 0; k < 4; k++) { if (input < key_val_1[k]) { return k; }

if (1023 == key_val_1[k]) { return 1023; } } if (k >= 4) k = -1; // No valid key pressed return k; }

s00500 commented 12 years ago

There is some kind of echo happening

21:49:17.300 From HIDUINO Note On 2 $05 127 * ZERO * To HIDUINO Note Off 2 $04 0 21:49:17.327 From HIDUINO Note Off 2 $04 0 21:49:18.000 From HIDUINO Note Off 2 $05 0 21:49:19.074 From HIDUINO Note On 2 $05 127 * ZERO * To HIDUINO Note On 2 $04 127 21:49:19.093 From HIDUINO Note On 2 $04 127 21:49:19.602 From HIDUINO Note Off 2 $05 0

Whats the problem??

ddiakopoulos commented 12 years ago

Hi, please see "HIDUINO echos every message I send to it?!" in the FAQ.

https://github.com/ddiakopoulos/hiduino/wiki/FAQ

s00500 commented 12 years ago

Thank you very much Your the best =D