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 
Live streaming at radio.electro-music.com

  host / artist show at your time
  mosc Back on the air tonight - Twyndyllyngs
Please visit the chat
 Forum index » DIY Hardware and Software » Arduino
MIDI w/ Arduino primer
Post new topic   Reply to topic
Page 1 of 1 [6 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
marvkaye



Joined: Mar 14, 2011
Posts: 225
Location: Fla

PostPosted: Thu Sep 06, 2012 7:42 am    Post subject: MIDI w/ Arduino primer Reply with quote  Mark this post and the followings unread

Spotted this Send-and-Receive-MIDI-with-Arduino primer in my latest "what's new" announcement from Instructables. Thought some folks here might enjoy seeing it.

<marv>
Back to top
View user's profile Send private message
elmegil



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

PostPosted: Thu Sep 06, 2012 8:19 am    Post subject: Reply with quote  Mark this post and the followings unread

Suffers from an issue I've seen with many Arduino MIDI tutorials, in that it omits "running mode" which is going to lead any newb into trouble when trying to take MIDI input from a "real world" keyboard or controller.

It does appear to be well written and nice clear diagrams, however Smile
Back to top
View user's profile Send private message
marvkaye



Joined: Mar 14, 2011
Posts: 225
Location: Fla

PostPosted: Thu Sep 06, 2012 8:25 am    Post subject: Reply with quote  Mark this post and the followings unread

Interesting... so what's the "running mode" cure? Or have you found another tutorial that you could point us to that does a better job to keep newbs (like me) from terminal hair loss trying to implement something like this?

<m>
Back to top
View user's profile Send private message
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 20623
Location: The Netherlands, Enschede
Audio files: 150
G2 patch files: 318

PostPosted: Thu Sep 06, 2012 8:56 am    Post subject: Reply with quote  Mark this post and the followings unread

MIDI messages consist of a command byte and possible parameter / data bytes; like for NoteOn you will have a key parameter and a velocity parameter.

MIDI command and parameter bytes are distinguished by the most significant bit, when that bit is a 1 the byte is a command and otherwise it is parameter data.

This distinction makes it possible to omit command repetition if it would be the same as one that was sent before. So when you send a series of note on commands and all those commands are on the same channel you only need specify that command once; then the two data bytes for the first command follow, then two data bytes for the 2nd note on, etc.

When a command is not seen by the MIDI interpreter it uses the previous command, and that one is called the running status.

This also is the rationale for using a note on message with velocity 0 as a note off. A note off command after a note on would break the running status, whereas a note on with a velocity of zero would not.

This compacts the MIDI stream, and also make reaction times on commands shorter.

So, to keep running status all you would have to do is remember the last command seen, and combine that with orphaned data bytes you received to reassemble a complete MIDI message.

For sending MIDI you could omit running status, the MIDI stream will not be optimal, but all connected devices will understand it.

For receiving MIDI you should implement running status as lots of sending gear will use it.

When implementing running status keep in mind that certain MIDI messages do not break running status .. IIRC such holds for MIDI clock .. but better Google for the details there ...

_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
elmegil



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

PostPosted: Thu Sep 06, 2012 9:39 am    Post subject: Reply with quote  Mark this post and the followings unread

Great Summary Smile

This bit me when I was using "roll your own" and copied code to do MIDI, as I was adapting Thomas Henry's MTS-100 to use an Arduino.

I switched to using the "official" Arduino MIDI Library (http://arduino.cc/playground/Main/MIDILibrary), and it was all handled already.

I would strongly recommend that anyone using Arduino for MIDI use the library rather than the home grown code such as that from the Instructable.

To be clear, I don't mean to be disrespecting the Instructable--there's a lot of good information there, I just know that I was originally working from something similar and was, as you say, tearing my hair out over why my keyboard didn't work right until I understood what Blue Hell has explained.
Back to top
View user's profile Send private message
Cynosure
Site Admin


Joined: Dec 11, 2010
Posts: 692
Location: Toronto, Ontario - Canada
Audio files: 39

PostPosted: Wed Sep 12, 2012 7:18 am    Post subject: Reply with quote  Mark this post and the followings unread

Great explanation Jan.

I am also using the MIDI Library and it has been working great so far. There was one minor thing with this though - the note off being a note on with 0 velocity worked for my hardware synths, but I had to add the regular noteoff message for use with Ableton Live. Make sure you use both methods for compatibility.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic
Page 1 of 1 [6 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