Pages: [1]   Go Down
Author Topic: Serial/MIDI problem  (Read 559 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have a fairly big MIDI converter program that doesn't work quite right.
This stripped down code has the same problem:
Code:
int ledPin =  13;
int trigger = 3;

void setup()   {                
  pinMode(ledPin, OUTPUT);
  pinMode(trigger, OUTPUT);

  digitalWrite(trigger, HIGH);

  // Serial port as MIDI
  Serial.begin(31250);
}

void loop()                    
{
  while (Serial.available() > 0)
  {
    byte in = Serial.read();
  
    if (in == 0x90)  // 90 = keydown midi channel 1
    {    
      doTrigger();
    }
  }
}

void doTrigger()
{
  digitalWrite(ledPin, HIGH);
  digitalWrite(trigger, LOW);
  delay(1);
  digitalWrite(ledPin, LOW);
  digitalWrite(trigger, HIGH);
}

Wait for a key down and the just flip the pin and the LED for 1ms.

It works IF I hit the keys on my MIDI keyboard fairly slow to normal, speeding it up just a little, not anywhere near fast, it doesn't trigger.

I looked at the MIDI sent in a MIDI-monitor, nothing strange there.

Any suggestions?

/frax
Logged

Bremen
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
Arduino!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

BTW: you will not see the LED blink if it's ON for only 1 ms. (sorry, no idea for your primary problem)
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I actually see the LED flash, and the trigger is connected to my Synth so I can also hear when it's working.
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sure you are not sending a lot of other information from the MIDI keyboard?, like polyphonic aftertouch, and all that stuff, so you are flooding your serial connection ?

Just a shot in the dark .-)
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No aftertouch but my keyboard sends out a 0xfe (Active sense) frequently, i'd say about 4 each second.
I still think there would be plenty of time to receive and process midi messages without loosing any key downs.
« Last Edit: July 02, 2010, 10:21:31 am by frax » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 4
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Im out of ideas, anyone?
Logged

Pages: [1]   Go Up
Jump to: