electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Arduino
Testing MIDI IN
Post new topic   Reply to topic
Page 1 of 1 [3 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
MusicMan11712



Joined: Aug 08, 2009
Posts: 734
Location: Upstate New York USA
Audio files: 148

PostPosted: Tue Jul 03, 2012 6:45 pm    Post subject: Testing MIDI IN Reply with quote  Mark this post and the followings unread

While exploring my arduino last summer, I wrote a little sketch to test whether or not I was correctly receiving midi in by echoing that data to the console in the arduino's programming environment. I haven't tested it this year, but it should help others do the same.

I used the Arduino Mega 2560, which has 4 serial I/O ports. Also, the pins might be different from other arduinos.

Code:

/*
 MIDI IN test
 
 This sketch is an attempt to read midi in and display it.
 
 This is one step in the process of creating an arduino-based midi router/processor/arpeggiator.

 started 05 Aug 2011
 modified
 by Dr. Steve [aka MusicMan11712]

 
 */
 
 // MIDI IN Buffer [as an array]
int MidiDataBuffer [256];
 
 // Buffer Pointers [as indexes]
unsigned char WritePointer = 0;
unsigned char ReadPointer = 0;
byte WP = 0;
byte RP = 0;

 // Incoming Data
int IncomingByte = 0;         // incoming serial byte

 // SETUP
void setup() {
  //  Set MIDI baud rate:
  Serial1.begin(31250);
  Serial.begin(9600);
  // Clear MidiDataBuffer and reset write/read pointers
  for (int n=0; n<256> 0) {
    // get incoming byte:
    IncomingByte = Serial1.read();
   Serial.println (IncomingByte,HEX);
  }
}

void establishContact() {
  while (Serial.available() <= 0) {
    Serial.println("0,0,0");   // send an initial string
    delay(300);
  } 
}
Back to top
View user's profile Send private message
elmegil



Joined: Mar 20, 2012
Posts: 1509
Location: Chicago
Audio files: 14

PostPosted: Tue Jul 03, 2012 9:51 pm    Post subject: Reply with quote  Mark this post and the followings unread

The Mega (or some model with multiple serial ports) is really your best bet here for doing MIDI development. I did a lot of work with an uno equivalent (started out as the Mintduino breadboard kit, and ended up soldered into a small protoboard), and i beat my head on MIDI stuff until I got the Mega.

Some of my experiences got written up here:

http://electro-music.com/forum/topic-52722.html
Back to top
View user's profile Send private message
MusicMan11712



Joined: Aug 08, 2009
Posts: 734
Location: Upstate New York USA
Audio files: 148

PostPosted: Wed Jul 04, 2012 5:23 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks for chiming in on this and for posting the link to the thread with your comments--useful info there. I realized after I posted the midi in test code that it wouldn't work on a single UART Arduino since midi needs one serial connection and communication with the serial monitor needs another. (I chose the Mega 2560 specifically because it had 4 UARTs.)

Like you, for midi I/O I used an old joystick to midi cable. I didn't take it apart, though.

Steve
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic
Page 1 of 1 [3 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Arduino
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use