USB MIDI keyboard simple question, is this possible or not?


my question: would it be possible to connect a USB MIDI keyboard to arduino and make arduino send all midi data
to my computer, with one modification: I want to have a fixed velocity-value for note-ons, possible? thank you!

In fact I can even simplify the question: can arduino send all midi data to the computer without modification? :slight_smile: I use multiple identical MIDI USB keyboards but the computer only detects 1 unique device, maybe if they all pass through an arduino, the computer recognizes multiple unique devices...possible?

As I don't need velocity, I could use this parameter to differentiate between the keyboards. It's impossible to make them work on different midi channels.

One keyboard is relatively easy to do and modifying the midi stream from the keyboard before sending it on to the PC is also easy.
More than one keyboard requires that you write code to merge the data from each keyboard. A Midi message is usually two or more bytes so that you can't just forward the midi bytes as they arrive from the keyboards because you would then jumble them all together. You would have to store the incoming data from each keyboard until you have read a complete midi message, modify it and then send it on its way.
If you use an Arduino MEGA (or a Teensy3/3.1) you will have 3 serial ports you could use for keyboards and then send the data to the PC over USB. I don't think any standard PC software would be able to differentiate between keyboards using only the velocity value. If you only have 3 keyboards, your merger software will know which keyboard is which and can therefore modify the midi info to put each one on a different channel (and can also fix the velocity value).
Possible? yes. But it'll be a fair bit of work.


thank you for your reply,

in the software I use (Max Msp) it's very easy to differentiate using only velocity.
so if I use an arduino for each USB MIDI keyboard I have, would it still be that difficult?

arduino 1 receiving midi from keyboard 1 has to output velocity 10 for all noteons
arduino 2 receiving midi from keyboard 2 had to output velocity 11 for all noteons
arduino 3....

what do you think?

(no software seems to detect multiple keyboards at the moment, the serial number, vendor-ID, production-ID,...
is the same for all of them, only the location-ID seems to be different...)

so if I use an arduino for each USB MIDI keyboard I have, would it still be that difficult?

One Arduino per keyboard makes it a whole lot easier. Each one can be compiled to set the velocity to whatever value you like - alternatively it could set a different channel for each one and then it would work with other software too.


thank you! one last question, my USB MIDI Keyboards need to be powered by usb, the same usb-cable that sends midi,
there is only one cable connected between the keyboards and my computer, there are no other ports on the keyboards.
Can arduino or the computer still power the keyboards with this setup? (keyboard => arduino => computer)

could I use a usb split cable to send the USB MIDI keyboard to the computer (for powering) AND to arduino (for further processing)?

there is only one cable connected between the keyboards and my computer, there are no other ports on the keyboards.

I have a M-audio keyboard which has USB, one MIDI connector and a 5V DC power input. It can be powered from USB or the DC jack. You're saying the only connector your keyboards have is USB? If so, that's going to be a problem because somehow you have to read the midi data from the USB port and have a USB connection to the PC. I don't know how/if you can do that. I had assumed your keyboards were like mine with USB and a midi plug.


What if I use a split-cable with one end going to arduino and the other end to a usb power adapter instead of the computer?

The problem is that you are trying to connect the Arduino’s USB port to both the PC and a keyboard. Ignoring the connection ot the PC for a moment, I don’t know if you can connect a USB midi keyboard to an Arduino and have it read the midi data. Perhaps this is possible with a Leonardo (and maybe a Due?) but I don’t think it can be done with Arduino Mega, Nano etc.
If it is possible to connect a USB keyboard to a Leonardo (i.e. so that the Leonardo can read the MIDI stuff) you could send the midi data out a separate serial port and use a USB to Serial adapter to connect that to the PC. Of course, you’d need one Leonardo and serial adapter for each keyboard.


I'm forgetting the power requirement. Even if the Leonardo could read Midi from an attached USB keyboard, your keyboards need to get power from the USB. You would need some way of splitting the cable to provide power. I have no idea whether that can be done.


thanks again for your reply Pete, I was thinking about arduino ADK rev 3:

the bigger USB “b” port of arduino is of course connected to the computer. The bigger usb “b” port of the keyboard is connected to a splitcable (2x male normal usb) of which one goes into the “normal” USB port of arduino ADK rev 3, and the other (if needed) to a self powered USB hub… : ) possible?

this is the splitcable.

next to this possible solution, should arduino not be able to power my midi keyboard?

The ADK has an Arduino UNO. The UNO's USB port can only provide power to the Arduino - it can't get power from the Arduino.
What sort of USB cable does the keyboard have? i.e. what sort of USB connector is on the end? I presume that it is USB A.
I don't think that the splitter cable is going to help.
There are two problems. One is that, AFAIK, there's no way for the UNO to read the USB midi data from the keyboard. There may be other devices which can do that (Leonardo or Teensy 3 maybe?). The second problem is that if your keyboard's cable has a USB A on the end, you can't even connect it to the UNO USB port anyway.
Sorry, I don't think this is going to work.


are you sure we're talking about the same arduino:

this one has 2 usb ports, a big one (B) for powering of the arduino itself, and a second smaller one (A) ..for an external device, like a midi keyboard I would guess, No?
The keyboards have the bigger (square-shaped) USB "B" at the end, it fits to the cable I sent you, no problem.

still problematic you think?

to clarify: I play on the keyboards, keyboards each with split-cable go to power adapter (for power) and 2nd usb port of their dedicated arduino. Each Arduino processes the midi data and sends them to the computer (though a cable going from arduino's bigger USB B to a usb port of the computer. This cable also powers the arduino).

OK. My bad.
As you say, the ADK has two USB ports. The USB B connects to the PC. The other one is a host interface (is it a USB A?) so I presume that it can handle a midi keyboard. The issue will be whether there is any existing example code to show how it is done.
The other trick will be powering the keyboard. I don't know if the ADK host port can provide power and, if so, whether it is enough to power the keyboard.
There don't seem to be any messages on the forum about using the ADK to host a midi keyboard.

I hope someone who is familiar with the ADK can help out.



Did you ever get it to work? I'm trying to do something similar.