Soundgin Synth Serial Problems

Hi, I recently made a Notes And Volts NaV-1 synthesizer, which has an atmega328p for the brains, and a soundgin synthesizer chip making the noise.

You can find the schematic here:

The midi signal is coming in on the hardware TX/RX pins at 31250, and then a 9600 SoftwareSerial object talks to the soundgin chip on pins 3 and 4.

The guy who invented this design plugged it all in and fired it up and it worked just fine, but I've not been able to get the synth to not drop notes. I believe I have eliminated the possibility of hardware being the problem, so now I'm taking a look at software, but this is by far the most complex thing I've ever built, and I haven't dealt with SoftwareSerial objects on the arduino before.

The software seems to be dropping midi signals most of the time without passing them on to the soundgin... intermittently it will work, though. I've had several EE's with arduino experience looking at this for about 3 weeks now and everybody's stumped.

Could somebody that knows a whole lot about serial on the 328p do a code review to help me figure out why the midi signals are being dropped?

My main loop is just this:

void loop() { // Main Loop
  MIDI.read();  // See if there are any new MIDI messages
  menu(); // Check state of Rotary Encoder and Buttons - Update LCD
}

And the callback function for the midi library is this:

void MyHandleNote(byte channel, byte pitch, byte velocity) { 

  if (velocity != 0) { 
    digitalWrite(LED,HIGH);  //Turn LED on

    if (currentNote == 0) {
      currentNote = pitch;
      trigger(pgm_read_byte(&lookup[currentNote]));
    }
    else {
      newNote = pitch;
      trigger(pgm_read_byte(&lookup[newNote]));
    }
  } else {//A NOTE ON message with a velocity = Zero is actualy a NOTE OFF
    if (pitch == newNote){
      newNote = 0;
      trigger(pgm_read_byte(&lookup[currentNote]));
    }
    else if (pitch == currentNote && newNote != 0){
      currentNote = newNote;
      newNote = 0;
      trigger(pgm_read_byte(&lookup[currentNote]));
    }
    else if (pitch == currentNote){
      digitalWrite(LED,LOW);//Turn LED off
      release();
      currentNote = 0;
      newNote = 0;
    }
  }
}

If you want to see any other parts of the code, you can find it here:

And here's a video to give you an idea of what the behavior is like:

Thanks.

Are you sure that your keyboard is not sending running status information?

Yes, positive. I made another MIDI input circuit on my Mega, and captured all the data... my E-MU X-Board 25 controller does not send running status information, and uses 0 velocity note-on messages for note-offs instead of the 0x80 messages. The Mega also captured every message without dropping any, so I know it's not the MIDI input's fault that messages are being dropped on the soundgin synth; rather it's the SoftwareSerial is interfering with the hardware serial's reception.

I think the problem is with your 6N138 circuit. I've had issues like you're having with my projects if the correct value from pin 6 to +V wasn't correct and/or I didn't use a pulldown resistor on pin 7. A quick google search shows the most popular value from pin 6 to +V is 470 ohms (instead of the current 270 ohm on the NaV-1 site) and 1K ohm from pin 7 to ground (open circuit currently shown)..although I think any value in the 1-5K range is probably fine.

You... are absolutely right! Replacing the resistor configuration with the one found on the updated notes and volts midi input circuit page worked! Thanks so much for making me take another look at it!

Video of it working!