Building a DIY MIDI Controller vs. Buying One

You might have thought that the MIDI may be dead and taken over by something brand new by now. But, time and again it has been shown that the protocol has too much versatility in itself to discard it. It’s been around since the 80s and shows no sign of quitting!

The protocol does not transmit a sound itself, rather it contains a command set that includes note-ons/offs, pitch bend, velocity and other parameters. The sound card of a computer already contains a wave-table and through it produces various sounds.

Just like a keyboard, mouse, joystick and other input devices are created for streamlining the computer experience, there are devices that are specifically built for controlling, transmitting or processing MIDI.

The most common types of controllers include:

  • Keyboard – a keyboard controller is a device that is designed much like a piano and contains a number of other features including faders, buttons & knobs. The purpose is to transmit MIDI data to computer software synths or other connected sequencers. The greatest advantage of keyboard controllers over others is its synergistic set of features that gives it robustness.
  • Faders, Buttons & Knobs – other than piano styled keyboards there are other MIDI devices that can provide dynamic input/output based on physical variables like pressure, rotation, velocity, etc. The best feature of such devices is that they provide greater hands-on control over much wider parameters, and take only a fraction of space. These devices are many times called analog devices as they have infinite values that can be set.

A few top MIDI Controllers from the market include:

  1. M-Audio Axiom ($190 – $300)
  2. Novation Nocturn ($90)
  3. Akai MPD32 ($320)
  4. Fatar StudioLogic Numa ($1150)
  5. Behringer U-Control UMA25S ($100)

All these MIDI controllers and many more contain loads of functionalities, which one might think are enough to experiment with. However, there is a very huge factor that comes in the way of producing MIDI music: price.

Unless you’re willing to compromise on quality by a “great” deal, its very hard to find a MIDI Controller that can provide you with all the desired features and not burn down your pocket at the same time. In addition, pre-built MIDI Controllers have limited functionality, and while it might be true that they are more than enough for exploration, some people may find them too limited, when they want to go one step ahead.

So is there an alternative to all this? Yes!

Enter the world of micro-controller powered development boards. Basically, the world of electronics has progressed so far that anyone with a micro-controller board can develop his/her very own MIDI controller or any other electronic product for that matter. Basically, a micro-controller has the following features:

  • A number of digital inputs for connection on/off controls like buttons.
  • A number of analog inputs for connecting varying controls like faders and dials.
  • A number of digital outputs for components like LEDs or starting off motors.
  • Special ports for connecting the board to PC or other devices; the most common standard followed by micro-controllers today is USB or 5-PIN.
  • A micro-controller at the heart for processing all input data and producing output without the need for processing power from elsewhere.

While there are many other features that a micro controller may have unique to it, these are the few that every single one has.

In addition to the hardware side, micro controller boards also offer a software element so that the micro-controller can be programmed and perform a set function. Think of the entire board as a computer that can be programmed to carry out particular tasks autonomously, except in comparison to full-blown computers, the development is easy to learn & very very cheap.

Common micro controllers include:

  1. PIC 16F877 – $7
  2. Parallela Micro ServerBoard – $100
  3. EFM32 Giant Gecko Starter Kit – $29
  4. Nanode Winode 4 – $50
  5. Arduino Uno – $20
  6. Raspberry Pi 2 – $40
  7. Arduino Leonardo – $18

Before you get upset at some boards costing $10+ read this: Some of these boards, such are the Arduino Uno are completely open source. For the consumer, this means that anyone can essentially create the exact same board and sell it for less. Go to AliExpress.com and search for an Arduino Uno. You’ll find boards for $3! And guess what? The quality is no different from the $20 version.

This is great for anyone on a budget. Still, with open source hardware, I recommend getting at least one board from the original manufacturer just to show your support for the project.

The previous list on micro controllers is in no particular order, but as it can be seen there are a variety of alternatives available for someone who is ready to build his/her own MIDI controller. The best thing about micro-controllers is that they provide the user with nearly endless possibilities and customization, since they are programmable. For someone like a hobbyist who can’t afford expensive MIDI controllers, a $20 micro-controller like the Arduino Leonardo can provide a great opportunity.

The most important thing you need to ask yourself at this point is whether you’re up for a steep learning curve or not. I recommend and teach using the Arduino Uno because it’s an easy-to-learn board that has no limits. Something like the PIC is a lot harder to build a MIDI controller from.

If you really want the easiest experience and no learning curve, my recommendation is to check out the Brain Jr. by Livid Instruments.

All micro-controllers can be made to perform the desired function, if one is properly trained, however for newbies it is highly recommended to start from Arduino as there is tons of material on the internet for support.

So how does a Micro-controller aid in building a MIDI Controller? The answer is simple; the micro-controller sits at the center of all operations and is connected by a number of buttons or knobs, which serve as input. The signals from these input devices is processed and transmitted onto the software synth on your PC or Mac which then emulates the desired sound from the sound card.

Yes, its all that simple and to show it, let me give a simple example to get you off the deck.

Too long, didn’t read?

Well, here’s a simple conclusion:

Building a MIDI controller can be a lot cheaper that buying one as long as your willing to do a bit of learning.

Bonus: Building A Simple MIDI Controller

Setting up a Windows Machine

Follow these steps to get your Windows ready to receive data:

  1. Install CoolSoft Virtual MIDI Synth. (http://coolsoft.altervista.org/it/virtualmidisynth#download)
  2. Launch the software and in the “MIDI Mapper tab” select the program as Windows Media Player Default Peripheral.
  3. Install Virtual Piano MIDI Keyboard (http://vmpk.sourceforge.net/#Download)
  4. Launch, click on Edit > MIDI Connections.
  5. Select Windows MM in the “MIDI In Driver List”.
  6. Select FluidSynth in the “MIDI Out Driver List”.
  7. All done.

Hardware Required

This part may be a bit discouraging or confusing to starters, however let me tell you that there are countless cheap sources of components. Here are few of the top ones:

  • Jameco – great way to acquire components within the US at affordable rates.
  • AliExpress – all components made in China so you can imagine the cost.
  • Sparkfun – a bit expensive but the components have features that fit the bill. A lot of super cool and unique components!

For this project you’ll need:

  • An Arduino board with Native USB Port, e.g. Zero, Micro, DUE, Leonardo, etc. ($20 – $40)
  • 7 tactile push-buttons ($3)
  • 10k Ohm Linear Potentiometer ($1)
  • wire

Circuit

circuit

Make the connections so that the final circuit look like this.

Programming

Fire up the good ol’ Arduino IDE and make use of the following sketch. If you’re looking for explanations, read our article on programming for the non-techie:

 

/*
   This examples shows how to make a simple seven keys MIDI keyboard with volume control

   Created: 4/10/2015
   Author: Arturo Guadalupi <[email protected]>
   
   http://www.arduino.cc/en/Tutorial/MidiDevice
*/

#include "MIDIUSB.h"
#include "PitchToNote.h"
#define NUM_BUTTONS  7

const uint8_t button1 = 2;
const uint8_t button2 = 3;
const uint8_t button3 = 4;
const uint8_t button4 = 5;
const uint8_t button5 = 6;
const uint8_t button6 = 7;
const uint8_t button7 = 8;

const int intensityPot = 0;  //A0 input

const uint8_t buttons[NUM_BUTTONS] = {button1, button2, button3,button4, button5, button6, button7};
const byte notePitches[NUM_BUTTONS] = {C3, D3, E3, F3, G3, A3, B3};

uint8_t notesTime[NUM_BUTTONS];
uint8_t pressedButtons = 0x00;
uint8_t previousButtons = 0x00;
uint8_t intensity;

void setup() {
  for (int i = 0; i < NUM_BUTTONS; i++)
    pinMode(buttons[i], INPUT_PULLUP);
}


void loop() {
  readButtons();
  readIntensity();
  playNotes();
}

// First parameter is the event type (0x0B = control change).
// Second parameter is the event type, combined with the channel.
// Third parameter is the control number number (0-119).
// Fourth parameter is the control value (0-127).

void controlChange(byte channel, byte control, byte value) {
  midiEventPacket_t event = {0x0B, 0xB0 | channel, control, value};
  MidiUSB.sendMIDI(event);
}

void readButtons()
{
  for (int i = 0; i < NUM_BUTTONS; i++)
  {
    if (digitalRead(buttons[i]) == LOW)
    {
      bitWrite(pressedButtons, i, 1);
      delay(50);
    }
    else
      bitWrite(pressedButtons, i, 0);
  }
}

void readIntensity()
{
  int val = analogRead(intensityPot);
  intensity = (uint8_t) (map(val, 0, 1023, 0, 127));
}

void playNotes()
{
  for (int i = 0; i < NUM_BUTTONS; i++)
  {
    if (bitRead(pressedButtons, i) != bitRead(previousButtons, i))
    {
      if (bitRead(pressedButtons, i))
      {
        bitWrite(previousButtons, i , 1);
        noteOn(0, notePitches[i], intensity);
        MidiUSB.flush();
      }
      else
      {
        bitWrite(previousButtons, i , 0);
        noteOff(0, notePitches[i], 0);
        MidiUSB.flush();
      }
    }
  }
}

// First parameter is the event type (0x09 = note on, 0x08 = note off).
// Second parameter is note-on/note-off, combined with the channel.
// Channel can be anything between 0-15. Typically reported to the user as 1-16.
// Third parameter is the note number (48 = middle C).
// Fourth parameter is the velocity (64 = normal, 127 = fastest).

void noteOn(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
  MidiUSB.sendMIDI(noteOn);
}

void noteOff(byte channel, byte pitch, byte velocity) {
  midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
  MidiUSB.sendMIDI(noteOff);
}

Conclusion

This was just one of the several possibilities that await you if you choose the DIY path. Not only is the path light on the budget but it also gives the musician/hobbyist a chance to learn about the foundation of the wonderful MIDI protocol. Hope you enjoyed it!

Next:

Leave a Comment

3 comments

  1. Hi. im building a midi controller.
    But whant to know if you can help me with 2 function that i want to have in the controller for exemple in the novation nocturn you have a rotary that can be mapped just by puting the mouse cursor on the top of the nob on the daw that you want to map and automaticly assumes it.
    An another is how can i have a 4 fader midi controller for exemple following automacly the tracks that im selecting in tha DAw like nocturn allso does it ….Sorry for the big questions….

Go back to the top of this page.