Pages: [1]   Go Down
Author Topic: 8u2 midi  (Read 1349 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
Code:
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.
Logged

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

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

http://www.pasteall.org/18222
Logged

Forum Administrator
Torino, Italia
Offline Offline
Sr. Member
*****
Karma: 4
Posts: 386
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would put a bounty on this.

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

hold on!
Logged

Offline Offline
God Member
*****
Karma: 32
Posts: 507
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged


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

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 smiley-wink
Thx for the help
Logged

Pages: [1]   Go Up
Jump to: