r/ArduinoProjects • • Aug 29 '20

Built myself a USB Midi controller based around an Arduino Due

Post image
191 Upvotes

11 comments sorted by

10

u/Sam1967 Aug 29 '20

So I decided I needed a small challenge to fill in some spare time and I chose to make my own USB midi controller to control my DAW (which is Reaper, by the way). I’ll be more than happy to share any information on how I made this from any perspective, or even the code that it runs. I shall point out though this is my first significant project with Arduino so I can’t speak to the quality of the code J As you can see it still needs to be sealed up as a unit and I had to split it across two boxes, as mentioned below.

Features and Functionality

The left unit has eight analog sliders, which I use to set the mix/volume levels in the DAW across the master and seven other tracks. Below that there are eight rotary analog knobs, used here to set the left-right stereo pan over the tracks.

The right unit has several rows of buttons –

Eight mute buttons for the master and seven other tracks

A reset button, to restart the unit if needed

Seven record arm buttons to arm the tracks for recording

Six control buttons for transport - back, forward, play, record, pause and stop

Eight more analog rotary knobs that can be assigned to different functions. In my case I have assigned the first four to the macro controls in the Arturia Pigments 2 virtual synth and the other four I assign as needed to other parameters (FX or other synth controls I want to vary).

One inch OLED display panel that displays the last MIDI command sent, just to make debugging easier really – it’s hardly needed.

Physical Build

The panels and box are 3d printed. I only have a small 3d printer (Creality Ender) so due to the limited print size I had to separate the build into two boxes. The panels were done with the spaces for the knobs and buttons already cut out in the design, for the rest I used a dremel.

I wanted the tracks to be colored to match the track colors in the DAW. Initially I tried painting but I was unhappy with the finish, so I got hold of some self-adhesive vinyl wrap and used that. To my eye it looks pretty good and it was easy to cut around the holes in the top panel. The choice of colors was rather determined by the stock of vinyl in the store I had to choose from! The lettering is done with 5mm self-adhesive lettering I had left over from a modelling project.

Hardware/Electronics Build

The box is built around an Arduino Due board. I picked this because it has loads of digital and analog inputs and can also act as a USB host, which the normal Arduino cant without an add-on shield.

The Due in fact has only twelve analog inputs and I have twenty four analog controls, so I used a multiplexer board to get the extra inputs. This comes as a separate board from Sparkfun based around a CD74HC4067 chip. Selection between the 16 inputs on the board is done with four of the Due’s digital pins.

The OLED display is a cheap I2C display I had lying about from another project, I2C is rather easy to use in this case, just two dedicated control pins.

The analog controls are all 10K linear potentiometers of course, with the Due the ADC gives a resolution of 1024 values, midi only needs 128 so it’s perfect. The digital buttons are cheap push to make ones I had spare.

Software

Everything was done in the Arduino IDE, the language is basically taken from C/C++ and its rather simple to code, I think its less than 250 lines of code and it only took me an hour or two to get right. Apart from the libraries to drive the display (wire, Adafruit GFX and Adafruit SSD1306) the only other needed library is MIDIUSB.

It really is only a matter of looping through the analog inputs, then the multiplexer and then the digital pins, reading values and sending any changes out over midi. Midi fortunately is rather a simple protocol to build and it was no great effort to get it working based on the examples in the library. Its just building a midi CC command with a different control number for each knob and button and a value attached.

Integration to the DAW

As I mentioned I use Reaper, of course it would work with any DAW that can learn midi CC commands. I actually used the Realearn addon for the mapping, but its really overkill. The main benefit is that its easier to route CC commands into virtual instruments with Realearn, otherwise the built in Reaper midi learning also works just fine.

I set up a template in Reaper with all the tracks defined and named, and set the colors to match the design of the box. Then I set up the VSTs I usually use for synths, tracks for my hardware synths and FX processing.

Still to do/Improvements

I need to finalize and tidy up of course. But I do already notice the box is a tiny bit slow, that’s due to the rather slow nature of Arduinos of course. I think the main delay is in selecting the input channel on the multiplexer every time via the digital pins. Arduino by default is rather conservative about that and using direct port access would be way faster no doubt.

I’d also like to improve on the physical housing, maybe go with nicer buttons now I know it all works well. Or maybe a nicer box … well wood even, if I have a spare hour or ten.

I also wired the buttons directly to digital pin inputs, it would of course be possible to wire them in a grid and use less pins.

Next Project?

Of course my eye has already fallen on my box of odds and ends. I found some ultrasonic distance sensors, a keypad, light sensors and some other parts. I am pondering getting another Due (or something smaller) and making a more musical controller, that can trigger notes based on distance and light or some such nonsense.

3

u/rufusdufus0 Aug 29 '20 edited Sep 29 '20

Yeah, I'd love to see some code! Would this also work on any Arduino that supports USB (i.e. pro micro, Leonardo)?

3

u/Sam1967 Aug 29 '20

I already posted the code here, you can see it at

https://github.com/sammy1967/midicontroller

I'm no coder by the way, but anyway :) Yes I think you'd be fine with any such Arduino that can be used as a USB device, there's nothing especially complex there. See my other remark on maybe breadboarding this with just one 10K pot to check it works for you and using Pocket Midi to test it.

1

u/BLuDaDoG Aug 29 '20

Nicely done, very cool project! The separate boxes could even be a good thing if they were setup to work independently. Modular studio kinda thing.

I also use a creality ender, one day when I get some time I may try to do a smaller 4 track version

1

u/Sam1967 Aug 29 '20

Thank you! Yes I think so, well it would work quicker if I had two Unos and less ports to poll too I guess (or do without the multiplexer, thats actually the slowest bit). The Ender is really a great little printer in my view, I get a ton of use out of it. Edit: It also occurs to me that two boxes would be cool if you had one for mixing/DAW and one for controlling whatever VST you are running.

1

u/[deleted] Aug 29 '20

Cool. Software or hardware button debouncing ?

1

u/Sam1967 Aug 29 '20

I didnt implement any debouncing yet in fact, so far it hasnt been an issue as I guess the length of the loop when it scans through the analog ports means I havent seen it. It is on my to-do list though .

2

u/[deleted] Sep 15 '20

[removed] — view removed comment

1

u/Sam1967 Sep 15 '20

Native USB support and lots of ports basically, which the uno doesn't have

1

u/[deleted] Sep 15 '20

[removed] — view removed comment

1

u/Sam1967 Sep 15 '20

Yes indeed it would be fine for a smaller project but mine has 24 analog inputs, the leonardo has 6 (afaik), so then I'd need 2 multiplexers .... and that would be 8 digital ones gone .... and I have a ton of buttons :)

I'm working on my next MIDI controller project which is smaller and a leonardo would be ideal for that though.