Pages: [1]   Go Down
Author Topic: MIDI in: hardware works, software has a bug  (Read 438 times)
0 Members and 1 Guest are viewing this topic.
Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I put together an small midi-interface according to the notes in http://www.arduino.cc/playground/Main/MIDILibrary
 
The test program works, and now I wanted to use my midi keyboard to drive my Atari Punk Console

through midi. I successfully patched the APC through arduino, so I now what pins to change etc. The thing is:

It will only succeed once, then the program crashes. Also it won't work on the first try. I have to bash the keyboard till I get "lucky" and then it could be any key that would have worked.

basically I just set some analogue pins to make other sounds
Code:
void setnote5() {
  analogWrite(audioPin1, 127);
  analogWrite(audioPin2, 100);
  analogWrite(audioPin3, 255);
}


and then the mainloop checks for midi notes and maps the notes:

Code:
void loop() {
  if (MIDI.read()) {                  
    switch(MIDI.getType()) {            
      case NoteOn:
        switch(MIDI.getData2()) {
         case 36:
          setnote1();
         case 37:
          setnote3();
         case 38:
          setnote4();
         case 39:
          setnote5();
         case 40:
          setnote6();
        
       }                       
        
      case NoteOff:
          setnote2();
      default:
          break;  
    }
  }
}


What is wrong in this simple code? Sometimes it will really set the pins to the right voltages, but only once, and also a random note.

Thanks for any input
« Last Edit: January 16, 2011, 04:38:57 pm by KaOS-bEat » Logged

Pages: [1]   Go Up
Jump to: