[dorkbotpdx-blabber] Arduino MIDI Library help needed

Hans Lindauer armatronix at sbcglobal.net
Tue Mar 31 13:49:14 EDT 2009


I did end up asking the programmer who wrote the library for help 
yesterday, and he said:
> Okay, here's the begin method for input and thru enabled:
>
> MIDI.begin(MIDI_OPTO_ON | MIDI_OPTO_EXT | MIDI_THRU_ON);
>
> The problem with this function is the optocoupler, most people will 
> power it directly, but I liked the idea to cut the power from a pin on 
> the Arduino.. It may cause more problems than it brings solutions, so 
> I will remove it on the next upgrade (you're not the first to have 
> troubles with this function).
>
>
> Then, inside your code, at some moment when you want to check if there 
> are any available MIDI messages:
>
> if (MIDI.thru(InputChannelNumberHere) == true) {
>    // get the informations with getType, getData...
> }
>
> MIDI.thru will first read the serial port and check for a MIDI 
> message. If any, it will be mirrored on the output. Then a channel 
> filter is applied to keep only messages that came from the channel you 
> listen to, and if the message matches this condition, it returns 
> "true", and you can get the message data.
>
>
>
> I will try to make some examples for the next release.. 
That makes it clear enough.  However, when I re-read the Playground 
page, it says, "You can send and receive messages of (almost) all kind 
(System messages are not currently supported)."  When I read that 
before, I thought that it meant Sysex messages, but I think it actually 
means what it says, which is that it doesn't it doesn't handle 
start/stop/reset/clock, etc.  (My own janky code handles those, it just 
ignores program changes or whatever the other one is that uses 
three-byte messages.)

Greg's suggestion looks a lot better to me, I like how he doesn't assume 
that you've studied computer science.  I can actually follow his 
instructions.


Jesse Mejia wrote:
> Have you used that library for send and receive or just receive?
>
> As someone who is looking at using arduino+midi (but hasn't gotten my 
> hands dirty yet) could you and/or hans give a brief rundown of the 
> problems to look for in either or both of those two libraries?
>
> Hans - did you have luck last night?
>
> -Jesse
>
>
> On Mar 31, 2009, at 9:13 AM, Greg Borenstein wrote:
>
>> I don't know if you had any success with the Arduino MIDI library 
>> last night, but I've been working with this alternate library recently:
>>
>> http://timothytwillman.com/?page_id=240
>>
>> and I've found it much preferable. It lets you define callback 
>> functions that will be invoked on the occurrence of different midi 
>> events (noteOn, noteOff, etc).
>>
>> It makes receiving midi, especially, a lot easier that the default lib.
>>
>> -- Greg
>>
>>
>> On Mar 30, 2009, at 1:40 PM, Brian Richardson wrote:
>>
>>> heh, if you had phrased the question like that yesterday I would 
>>> have actually looked at the MIDI Library.  It looks like it's trying 
>>> to follow the pattern of the Serial object.  So you should basically 
>>> emulate that a bit.  I'll be at the meeting tonight and I'll try to 
>>> help you out.
>>>
>>> Brian (the dude in the grey hat)
>>>
>>>
>>> Or if somebody who's familiar with C programming wants to sit down 
>>> with me for like 10 minutes tonight at the meeting, I'm sure it's 
>>> obvious what to do.  "look at the reference page to learn how to use 
>>> it, " it says on the website.  Um, OK.
>>>
>>> http://www.arduino.cc/playground/Main/MIDILibrary
>>>
>>> Thanks,
>>> -Hans



More information about the dorkbotpdx-blabber mailing list