Arduino Multi-track MIDI Loop Station

by baritonomarchetto in Circuits > Arduino

15213 Views, 47 Favorites, 0 Comments

Arduino Multi-track MIDI Loop Station

20190617_100449[1].jpg
20190617_100455[1].jpg
20190617_100509[1].jpg

A loop station, or a looper, is essentially a tool to playback in real-time your instrumental riffs (loops). It's not intended as a recording media, but an instrument to shape the inspiration without distraction (and eventually perform live...).

There are plenty of audio recording loop stations out there, both in the form of dedicated hardware (almost every single guitar pedal manufacturer has its own product) or computer software (the excellent Linux Sooper Looper or windows Mobius, to cite the most known). I could only find few projects about DIY non-audio but MIDI loopers, meaning a tool to record MIDI events and play them immediately back in a loop. Most of these projects (all of them, I should say) are abandoned or lost ... well, here we are with a complete project for everyone!

This Arduino MIDI loop station simply keeps track of incoming MIDI events and play them back. You only have to press the record pedal, create your best riff ever and stop recording by pressing the pedal again. Super easy :)

This project is based on easy to find open hardware (Arduino DUE), software (my own firmware and Arduino IDE) and can be customized to reflect you preferences.

Let's do it!


Limits

Before you start to acquire hardware parts for the project, let me tell you which are its limits so that you can decide to go forward or stop here.

- due to hardware limits (Aduino DUE memory essentially), the default maximum lenght of the phrase you can record is limited to 46 seconds.

- loops cannot be stored and played back after shut down. You can send them to a PC and save them, though.

- there's no notes quantization.

- MIDI clock is supported, but on a preliminary stage at this time.

- MIDI messages recorded are note on, note off, control changes and pitch bend; other MIDI messages such as after touch, program change, SysEx, etc. are disregarded.

- max polyphony is set to 10 by default (again, Aduino DUE memory limits).

On the plus side, MIDI streams from multiple different instruments, each transmitting on it's own channel, are supported; this means that you can record multiple MIDI instruments at once, layered or with their own track (more pros on the next step ;) ).

If liveing with these limitations seems reasonable (and it is for me), you will have a very good time with this thing ;)

How It Works

The MIDI loop station here is very simple to operate. It works in a way similar to those hardware audio loop stations every guitar pedal manufacturer has in its own catalog.

1) Select the track you want to record your MIDI sequence to. By default track "one" is chosen, but you can change it by pressing one of the tracks buttons (one for each track).

2) When you press the "REC" switch/foot pedal the first time, the looper is engaged. The green LED lights up. It will wait untill your first note is received before starting to record the actual sequence/riff.

3) When you have finished your sequence, press the "REC" switch/foot pedal again to define the actual lenght of the riff. The green LED lights off. The looper will start to reproduce your MIDI sequence immediately. If you reach the max time, recording will stop automatically and the sequence will start being reproduced in a loop.

4) Now, you can decide to overdub your sequence on the current track or select a new track and record on it, by depressing the "REC" switch/foot pedal. In both cases the yellow LED will light up, even if the new track is empty, because it is a "slave" track (slaved to the very first track recorded). Press again to stop overdubbing (yellow LED goes off).

For those of you confortable with audio looping stations, this MIDI progression is called "REC/PLAY/OVERDUB" and is the only supported.

If at any time you feel that your latest overdub is not ok, you can delete it by pressing the "undo" switch/foot pedal. You can clear the whole current track by keeping the "REC" pedal pressed for more than 3 seconds; you can reset the looper (software reset) by pressing the first three track buttons at the same time or by clearing all the used tracks.

You can mute/unmute a track by pressing the track button of the current track.

You can send a PANIC! message by pressing the panic button. You can even send a PANIC! message by pressing the first two tracks buttons at the same time.

The looper has a built in simple metronome: a note on MIDI message for note number "64" is sent at a 100 BPM on channel 10 (the channel you presumably have your drum machine listening to). You can increase or decrease tempo by turing the rotary encoder; by depressing the rotary encoder switch you can enable/disable the metronome. Notice that your drum machine must be set to play a sound (snare, bass or whatever sound you prefer) when receiving MIDI note "64" or the metronome will be mute.

A barebone version of this MIDI loopstation could be made up with a single foot switch to start and stop recording. Keeping the switch pressed for more than 3 seconds will re-initialize the loop station.

If you want to invest some additional time developing the hardware, adding switches and buttons will make the loop station more flexible. In the picture is how I have configured my four tracks (up to five are supported) full featured loop station.

IMPORTANT NOTE: the hardware in my pictures is a prototype. I used more jack sockets than needed but only four buttons for tracks. This is because when i started the project I was not completly sure what the final requirements would be.

Buttons and foot switches are electronically equivalents and you can use one instead of the other; for my needs, being that there is always too little floor space (damn lovely effect pedals ;)), I have constrained foot pedals to the single REC function.

Hardware

20190424_184549.jpg
20190425_112217.jpg
20190425_113031.jpg
20190617_100533[1].jpg

Bill of materials:

Full featured 5-tracks MIDI loop station:

1x Arduino DUE

7x momentary push buttons

1x plastic case (I used a 150 x 110 x 70 mm case)

2x 5-pin DIN female panel mount MIDI socket connector

1x 6.3 mm panel mount jack socket

1x double sided 50x70 mm perf board

5x 3 mm LED (green)

1x 3 mm LED (yellow)

1x incremental rotary encoder

1x H11L1 optocoupler

1x 1N4148 diode

3x 1000 ohm resistors

3x 220 ohm resistors

10x 470 ohm resistors

Some solder wire, some cables, soldering station... and spare time :)

Time required to complete the project: 6-9 hours

Why not a UNO?

First tests (and a starting working code) was written on a "regular" arduino UNO board. This board has RAM limits that forced me to reduce the polyphony to "4", max lenght to less than 4 seconds and a resolution of 40 ms at max. This with no multichannel handling. By removing the velocity tracking too, I was able to rise the recording time up to 7 seconds.

With a UNO you can realize a "working" MIDI loop station then, but highly limited.

Software

The software heavily rely on FortySevenEffects MIDI library. This library is great and makes this sort of projects doable even for non coders geeks like me.

Arduino IDE and it's community is another important part of this "success".

I will not go into details about how to upload the sketch to your arduino DUE. If this is your first experience with arduino IDE, please read this first.

I wrote two different versions of the code, based on two completely different approaches.

The working principle of version 1 is that during recording or overdubbing Arduino DUE checks and stores in it's (volatile) memory the supported MIDI events (note on, note off, control change and pitch bend); time axis is quantized in 20 ms steps and received messages are stored in those slots accordingly. While playing, stored MIDI messages are sent back to the synth respecting the time quantization.

Working principle of version 2, instead, is to "simply" record midi event and time at which the event must be triggered. Version 2 has different limits than version 1 (listed on a previous step). try them both and use the one that works better for you.

There's a preliminar Clock handling too, but it will need some tweaks to work as it should. Code assumes that you record a 4/4 - 4 bars loop (16 beats).

You can deactivate external clock by keeping pressed the "panic" button when turning on the looper.

Codes are uploaded HERE. Comments are placed all over them, so that you can bend those firmware at your will ;)


My projects are free and for everybody. You are anyway welcome if you want to donate some change to help me cover components costs and push the development of new projects.

>>HERE<< is my paypal donation page, just in case you would like to contribute ;)

Wirings

arduinDUE_MIDI_OUT.png
looper pinout.PNG
DUE MIDI IN H11L1.jpg

MIDI IN and MIDI OUT circuits are reported in the attached pics. Notice that TX1 and RX1 are used, not TX0 and RX0.

Arduino DUE input pins cannot handle 5V, but 3.3V; this is why a H11L1 optocoupler is used instead of a more common 6N138. I have evidences that using a 6N138 coupled with a voltage divider to reduce the signal voltage going to TX1, as in my first prototipe, could work erratically in some setups.

LEDs are connected to Arduino DUE output pins via 470 Ohm resistors. You can use resistors up to 1K ohm to reduce the current going to LEDs and reduce their luminosity.

Buttons/switches/jacks are directly connected to Arduino input pins thanks to input pullup resistors, activated in the sketch. There's no need for external (pulldown) resistors.

The rotary encoder is connected to GND and +5V. It goes to Arduino input pins passing through 2 480 ohm resistors, one for each encoder data output.

Arduino DUE is powered directly from 5V pin and ground via a +5V DC hub.

All grounds are tied toghether.

Attached is a table with connections from arduino pins to IN/OUT peripheral. Arduino pin numbers reflect those in my proptotype hardware and could look (they someway are...) random. You can easily modify the pin location in the sketch at your will ;)

What If I Have More Than One MIDI Source?

20190617_103317[1].jpg

After a brief search for a MIDI merger, I found that the most practical (and cheap) solution was a MIDI switcher.

A MIDI switcher is a passive device that enables a MIDI source and disables all the other sources. Simple as that.

The heart of a MIDI switcher is a multi positional (mine is 6 position), 2 poles switch. It is very important that the number of poles is "2" because every MIDI socket must be completely cut if unselected and not in comunication with the others. Attached is a pic of the one I realized for my own use.

At THIS LINK a scheme.