MIDI to USB - Keyboard Mod

Hi! I'm planning on starting this project using as base an old cheap keyboard with Midi output (DIN-5). I bought those Chinese MIDI-USB interfaces but they are unreliable, so I'm returning it and thinking about building this adapter/interface using an Arduino Pro Micro (ATmega32u4)

The idea is to remove the DIN-5 connector and tap the keyboard’s internal MIDI UART signal, feeding it into the Pro Micro. It would handle the USB-MIDI conversion internally, allowing to use an USB cable as a MIDI output like modern ones.

Any advice? What would i need?Thanks!

i think so called TTL USB converter can this.

i found this sketch:


#include <Control_Surface.h> // Include the Control Surface library

USBMIDI_Interface midiusb;
// use this one instead to dump all MIDI data to the serial monitor
// USBDebugMIDI_Interface midiusb;
HardwareSerialMIDI_Interface midiser = {Serial1, MIDI_BAUD};

// Create a MIDI pipe factory to connect the MIDI interfaces to eachother and to the Control Surface
MIDI_PipeFactory<5> pipes;

// Example for adding extra controllers:
// CCPotentiometer pot = { A0, MIDI_CC::Expression_Controller };

// pin to which the power LED is connected
const int ledPin = 10;

// setup code
void setup() {
  Serial.begin(115200);

  // turn on the power LED
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);

  // forward MIDI USB to MIDI serial
  midiusb >> pipes >> midiser;
  // forward MIDI serial to MIDI USB
  midiser >> pipes >> midiusb;
  // send control suface messages only to MIDI USB
  Control_Surface >> pipes >> midiusb;

  // connect both MIDI USB and serial to control surface
  midiser >> pipes >> Control_Surface;
  midiusb >> pipes >> Control_Surface;

  // initialize Control Surface _after_ connecting the interfaces
  Control_Surface.begin();
}

// main processing loop
void loop() {
  Control_Surface.loop();
}

more info on DIY Midi Interface Arduino 6N138 Project & Kit 2021

1 Like

I play keyboards in a band, and in the past I've used a couple of MIDI-to-USB converter cables without any issues (with a Roland keyboard and a Windows PC running VST host software like Chainer), so you may have received a faulty converter/cable, a driver issue, or something else.
Just wondering, what's your interface (post a link) and what exactly do you mean by "unreliable"?

Maybe I used the wrong term, what i meant was that I heard some of them played ghost notes or sometimes skip some notes. In my case, the touch sensitivity isn't as good as I'd like; sometimes it plays loud notes when I touch it softly, and vice versa, while the keyboard one is good.
Also, the cable was more expensive than an Arduino, so if I can get something better or the same for less, I'd prefer it.

Thanks! seems good, i'll take a look

I can just confirm I've never had any problems like this when using a MIDI-USB cable adapter, so either the one you have is defective (in which case, ask for a replacement...) or there's some other problem you should investigate.
If I were you, my first step would be to ask for a replacement or buy another MIDI-USB cable from another source (you said it's "Chinese", so I hope it's not AliExpress or Temu; go with a more reliable and easily traceable seller and read the reviews...) and see if you get the same exact problem.

I mean, if the cable isn't the real problem, even using an Arduino as a MIDI device I'm afraid the problem might persist... This is why I recommend checking carefully to avoid building something that doesn't work.

If this is the case, I assume you let Windows (?) installs its own generic plug-n-play MIDI drivers for the USB MIDI driver, so what software/DAW are you using to play your MIDI keyboard? If you use VSTs, which VST host are you using and which VST(s)? And what's your audio output—a dedicated sound card or an internal one? Are you using ASIO drivers?

It's not AliExpress or Temu. Here where I live I found 2 types of MIDI-USB cables, the first one is the cheapest and the classic type (image). The other seems to be better, having the interface in the USB instead of in the center, but the prices goes way up.


I understand it could be a problem of my keyboard but even buying the Arduino is cheaper than the cable i bought and i would like to start a little project so if it works I think it would be worth it even if it works the same as the cable. I'm going to modify the keyboard case, so I'll have to take it apart anyway.

I'm using Alpine Linux with a VST host called Carla, using Jack with Alsa-MIDI as driver and my output is the internal sound card. I've used another midi with USB connection and it works fine.

Looks very similar to the ones I've had in the past (I switched all my keyboards to MIDI ones with native USB interface, so no converter is required anymore) and I'm pretty sure they are all made in China but I never had the problems you described here. If you bought that cable from a local shop, I'd go there asking for a replacement and/or test it with the reseller.

Hm, in this case I'm afraid I can't be of much help, my experience is on Windows architecture only (and never known of an "Alpine" distrib), but based on your system and software description I suspect the problem lies on the PC side, not the cable adapter. You described a "chain" of softwares and drivers, and it's hard to understand if one of the elements is causing the issues, so you could start using a "shorter" version i.e. using just something to show "raw" messages data from the MIDI port (i.e. I don't know if ALSA-MIDI has kinda "logging" or there's another Linux program to dump recveived MIDI data).

Or, to make sure if the problem is caused on the calbe/keyboard side or your PC, just ask someone to borrow you a MIDI keyboard with USB output and play some notes: if the problem is still there, the culprit is inside your PC, otherwise it's either the cable (more likely, and in this case ask for a replacement or a refund and buy it from another shot/site) or the keyboard (less likely, but cannot be ruled out).
this is about "solving" your problem.
But you also wrote:

This is obviously appreciated in spirit because it corresponds to the spirit of all of us hobbyists. So if you still want to try building your own MIDI to USB converter, that's obviously a good thing, but unfortunately I can't give you much advice, especially since you're using Linux, which I have no experience interfacing with MIDI, VST, or anything else (I also work with Linux, but not in these areas).

Furthermore, getting a system to "see" a MIDI device from USB isn't exactly easy; the simplest solution is usually to use the Arduino serial port to send the messages via USB, along with a specific software (on Windows, "Serial MIDI converter" or, better yet, "Hairless MIDI" I think can run on Linux too) that acts as a "bridge," meaning it "maps" the data coming from the serial port to a MIDI device. Sorry, I can't tell you more about it right now.