8u2 midi

Hello everyone

Im trying to reprogramm the 8u2 as generic MIDI device. I got as far as sending hard-coded MIDI-messages to my computer, but i cant catch the serial messages sent from my Arduino and change them to MIDI-messages.
As base file i took the Arduino-usbserial.c
I think my fault lies in taking the wrong variable as input from the atmega:

while (BufferCount--)
{
      channelMIDIMessages(RingBuffer_Remove(&USARTtoUSB_Buffer), buffercnt);
      if(buffercnt == 2) 
      {
            sendMIDIMessage();
            buffercnt = 0;
      } else
      {
            buffercnt++;
      }
}

I thought, the function RingBuffer_Remove(&USARTtoUSB_Buffer) returns the byte read from the atmega, but i never get anything from it.

Here is my entire code from the file Arduino-usbserial.c

I would put a bounty on this.

Sadly enough, I don't know much about LUFA :frowning: , but it's one coolest and most interesting aspects of the new arduino UNO.

hold on!

I had MIDI working in the other direction (computer to arduino) but that was easier. Even then it only seemed to work on Linux and not on Windows so I gave up.

Getting MIDI from the Arduino into the computer is a little harder. From reading the docs I think you have to wait for all the bytes of the message to come through before sending it (usually 3 bytes). So you do have to do a little parsing of the data as it comes in. Don't bother with ringbuffers, you don't need them at MIDI speeds, just send each complete message as you get it.

I might have another look at it again in the future, i have an idea for a project which might need it...

I got it to work now, after i decided to throw out all this ringbuffer stuff since i found a very simple command to read serial messages from the arduino on this forum (Serial_IsCharReceived() and Serial_RxByte()).
The parsing i do on the function channelMidiMessage, i save the messages in an array of length 3 and as soon as i have 3 messages i put it together and send it further on.
If anyone is interested, my colleague will put the project on sourceforge as soon as were finished with it and i will post the link here :wink:
Thx for the help