Using a Flora as a USB MIDI source?

Wearable electronics: boards, conductive materials, and projects from Adafruit!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
neurogami
 
Posts: 10
Joined: Fri Jan 04, 2013 6:01 pm

Using a Flora as a USB MIDI source?

Post by neurogami »

Are there any simple examples of using a Flora as a USB MIDI source? I want to load a sketch onto the Flora, and then have some MIDI application (e.g. Renoise or Ableton Live) recognize the Flora as a MIDI input device when the Flora is plugged into a USB port.

However, I've not found any explanations of how to use the HID MIDI capabilities of the Flora.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Using a Flora as a USB MIDI source?

Post by adafruit_support_rick »

A search on the Arduino site turns up quite a few pages and libraries on MIDI

User avatar
neurogami
 
Posts: 10
Joined: Fri Jan 04, 2013 6:01 pm

Re: Using a Flora as a USB MIDI source?

Post by neurogami »

From the search:
About 11,500 results
Thanks, but that's not at all helpful.

These do not describe using the HID MIDI capabilities of the Flora. I already did the generic search on "MIDI" and it's all over the place and not very useful. What needs to be done for an Uno is different for a Lilypad and presumably different for a Flora, etc.

Perhaps, when it comes to MIDI, the Flora is no different than any other Arduino board, in which case the claims of HID MIDI are false (or at best misleading).

But let's play along. The first hit links to an Arduino MIDI library. I tried that. I can load it. I then shutdown the IDE, unplug and replug the Flora USB, and see if it gets detected as a USB device. Nope. Doesn't work.

The promotional material for the Flora specifically says that it can, unlike many other Arduino boards, do HID MIDI. Why is it so hard for someone at Adafruit to point me to something that explains exactly that? Is it even true?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Using a Flora as a USB MIDI source?

Post by adafruit_support_rick »

The promotional material for the Flora specifically says that it can, unlike many other Arduino boards, do HID MIDI.
Sorry, I didn't realize we promised HID MIDI support with the FLORA.
Where did you see that? I can't find it.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Using a Flora as a USB MIDI source?

Post by adafruit_support_rick »

Have a look at this thread. There are one or two MIDI HID stacks for the ATmega32U4 mentioned. The FLORA is an ATmega32U4 processor, equivalent to a Leonardo.
http://forum.arduino.cc/index.php?topic=108577.0%22

User avatar
neurogami
 
Posts: 10
Joined: Fri Jan 04, 2013 6:01 pm

Re: Using a Flora as a USB MIDI source?

Post by neurogami »

The HID stuff is described on the ""getting started" page: http://www.adafruit.com/products/659
The FLORA has USB HID support, so it can act like a mouse, keyboard, MIDI, etc. to attach directly to cellphones.

and the product page: http://www.adafruit.com/products/659
The FLORA has USB HID support, so it can act like a mouse or keyboard to attach directly to computers.
(Interesting that the product page omits mentioning MIDI.)

I'll take a look at those Leonardo links.

Thank you!

User avatar
neurogami
 
Posts: 10
Joined: Fri Jan 04, 2013 6:01 pm

Re: Using a Flora as a USB MIDI source?

Post by neurogami »

OK, I looked at that thread. It's possible that someplace in all that there are links to links that give an example and explain what to do.

Compared to, say, the Teensy, this is really BANNED.

If you're going to claim that a device does USB HID stuff it should not be so hard to point users to some basic examples using that specific board to do exactly that. From what I've been able to understand from that link the Leonardo (and therefor possibly the Flora) can support firmware that provides a USB stack in order to do USB HID.

At this point I may as well give up and just use the Teensy which Just Works (though it doesn't have quite the form factor as the Flora).

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Using a Flora as a USB MIDI source?

Post by adafruit »

The leonardo core was supposed to integrate MIDI support from teensy but they never did - there *are* examples out there such as https://github.com/rkistner/arcore but the IDE team has not folded it in :(

sounds like teensy is the way to go for you!

User avatar
neurogami
 
Posts: 10
Joined: Fri Jan 04, 2013 6:01 pm

Re: Using a Flora as a USB MIDI source?

Post by neurogami »

Update: after much searching, guessing, and finagling I managed to get arcore[0] to run with the Flora and load a simple sketch to loop and send noteon/noteoff

I need to write this up now so that others can do this.


[0] https://github.com/rkistner/arcore/

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Using a Flora as a USB MIDI source?

Post by adafruit_support_rick »

Congrats! Looking forward to the writeup :D

User avatar
paulstoffregen
 
Posts: 444
Joined: Sun Oct 11, 2009 11:23 am

Re: Using a Flora as a USB MIDI source?

Post by paulstoffregen »

Hi, Paul here... the creator of Teensy. Of course, if you want USB MIDI that "just works", I believe you should use a Teensy board. ;)

But the reason I'm posting here is because I'd like to point out that HID and MIDI are entirely different and unrelated protocols. Believe me, I implemented both of these from scratch, years before Arduino made their first Leonardo board. I'm pretty familiar with the details of these USB protocols...

USB MIDI uses the USB audio class protocol. Data is transported using USB bulk protocol endpoints, with MIDI messages packed into 32 bit structures within the USB packets. Most MIDI messages are 3 bytes. The 4th byte has a redundant copy of the channel number and an additional cable number, allowing the USB MIDI protocol to emulate up to 16 separate MIDI cables, each transporting the usual 16 MIDI channels.

USB HID uses the HID class protocol. Data is transported using USB interrupt protocol endpoints, or control transfers in some cases. HID data is defined as reports, where numerous values of varying bit widths are bit-wise packed together.

There's really no similarity between these 2 protocols. Why some people mistakenly call USB MIDI as "HID" is a great mystery to me. Perhaps it's because Microsoft Windows includes so few drivers that automatically load for the standardized USB classes, so any that do are incorrectly thought to be "HID"? I've seen this misunderstanding on several sites. It's simply incorrect.

Adafruit's "Getting Started with FLORA" tutorial incorrectly states "The FLORA has USB HID support, so it can act like a mouse, keyboard, MIDI, etc. to attach directly to cellphones." I clicked the Feedback link just now.

User avatar
neurogami
 
Posts: 10
Joined: Fri Jan 04, 2013 6:01 pm

Re: Using a Flora as a USB MIDI source?

Post by neurogami »

Paul, thanks for that info. I'm cleaning up a blog post that will describe my efforts to get MIDI working on the Flora. The tl;dr: "Using arcore it's fine on Ubuntu 10.04, essentially unworkable on Windows 7. Just use Teensy for MIDI."

I was unaware of the finer points about HID and MIDI, and this is really good information to have. I'll make a point of pointing out your comment in my blog post.

Also, big thanks for the Teensy!

User avatar
paulstoffregen
 
Posts: 444
Joined: Sun Oct 11, 2009 11:23 am

Re: Using a Flora as a USB MIDI source?

Post by paulstoffregen »

I'm curious to see your blog post.

Do you actually have any Teensy boards?

User avatar
neurogami
 
Posts: 10
Joined: Fri Jan 04, 2013 6:01 pm

Re: Using a Flora as a USB MIDI source?

Post by neurogami »

The post is here: http://neurogami.com/blog/neurogami-get ... -midi.html

Yes, I have a Teensy 2.0++ and thinking of picking up one or two 3.1 boards. In addition to using MIDI I want to see about using the Teensy with OSC (thanks to this post: http://forum.pjrc.com/threads/18849-Open-Sound-Control).

I'm a big fan of OSC, so I wrote a short book: http://osc.justthebestparts.com/

User avatar
paulstoffregen
 
Posts: 444
Joined: Sun Oct 11, 2009 11:23 am

Re: Using a Flora as a USB MIDI source?

Post by paulstoffregen »

Yeah, someday I'm going to implement a USB RNDIS/CDC-ETH hybrid (needed for compatibility with all 3 operating systems) and build a couple of the UDP-based protocols on top of it. OSC and E1.31 are the main ones, where low latency from network stack on the PC/Mac to code on the microcontroller really matters. I'll probably only do this on Teensy 3.x, where the extra RAM makes these kinds of protocols much easier, and the fast CPU lets you actually do things quickly with such speedy data without resorting to assembly or other tough programming.

At the moment I'm still crazy busy with the audio library, and then I need to look at CAN bus and a ton of other little things, mostly documenting libraries that are already ported and working. It's unlikely I'll really work on this for several months, maybe not until sometime in 2015... but it is on my list to do eventually.

Locked
Please be positive and constructive with your questions and comments.

Return to “Wearables”