Arduino MIDI Rotary Encoder Multi-Track Step Sequencer

Now I have the option for multiple colours for my step sequencer displays, I thought it might be interesting to start experimenting with a “multi-track” step sequencer.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

These are the key Arduino tutorials for the main concepts used in this project:

If you are new to Arduino, see the Getting Started pages.

Parts list

  • Arduino Uno
  • 1x rotary encoder “breakout” (switched encoder type)
  • NeoPixel style ring, string or “square” of LEDS – any size
  • One of the Arduino MIDI Interfaces or Ready-Made MIDI Modules
  • Breadboard and jumper wires (optional)
  • Additional power supply for the NeoPixels if you are using a large number of LEDs!

The Circuit

ArduinoMIDIRE7SegmentController-Part3_bb

The fundamental circuit is the same as the previous project, but this time in addition to the 12-LED ring, I also have an 8×8 grid.  I’m taking the precaution of using an additional power supply though for this may LEDs so as not to risk overloading the Arduino.  As per the recommendations from the Adafruit tutorial I’ve included a large capacitor across the power supply.

This project should be tailorable to any number of LEDs.  I am working to the following:

  • for the 12-LED ring, two tracks of 6 steps each.
  • for the 8×8 LED matrix, 8 tracks of 8 steps each.
  • for a 1×8 LED strip, four tracks of 8 steps each (sharing LEDs!).

Once again the LED chain is driven from D6 and the rotary encoder is plugged in directly to A0 to A4 and using A0 and A1 as GND and VCC respectively.  I’m still using a MIDI interface on RX/TX/5V/GND – in the case of the 8×8 grid, I’ve used a MIDI DIN connector with two resistors embedded in it…

Warning: DOUT and DIN on my 8×8 matrix were the wrong way round!  When I first connected it up, nothing happened…

IMG_5487

The Code

This wasn’t too complex to update to support multiple tracks.  In essence, I’ve had to do the following:

  • Add a new edit mode to select the track to program.
  • In play mode, loop through all tracks to play all sounding notes for each step.
  • Provide the option for different colours of LED for each track and different MIDI channels per track.
  • “lastnote” now needs to remember the last note for each track.
  • The steps[] array now needs to support multiple tracks too.

I’ve updated the steps[] array to be a two dimensional array:

byte steps[NUM_TRACKS][NUM_STEPS];

By default the number of LEDS should be equal to NUM_STEPS x NUM_TRACKS, but other options are possible.  I’ve also had to introduce routines to support working out the LED index from both a step and a track and I decided that I’d visually represent track selection by illuminating the first and last LED for each track.

It is possible to re-use LEDs across tracks or steps.  Full details are provided in the code for some options, but I suggest you experiment! Note if the same LEDs are used for multiple tracks, then the highest numbered track with a playing LED will illuminate.

IMG_5490

Various combinations of STEPs and TRACKs are possible and they can be mapped onto LEDs in different ways.  Here are some examples:

  • LEDS = NUM_STEPS x NUM_TRACKS could be used for a NUM_STEPS x NUM_TRACKS grid of LEDs.
  • LEDS = NUM_STEPS could be used if multiple tracks are represented by different colours re-using the same set of LEDs.
  • LEDS = NUM_STEPS / 2 if there are more steps than LEDs and the LEDs are used twice for each track.

And so on. These would probably work best when the NUM_LEDS is either a multiple or integer fraction of the other parameters.  In theory it should be possible to re-use LEDs for both steps and tracks, but I’m really not sure I could recommend it!

If re-using LEDs for tracks, then you really have to set up the ledStepOn array of colours to make each track a different colour, otherwise things will get very confusing very quickly…

These are the configuration options to play with, with the above examples for NUM_LEDS:

#define NUM_STEPS 6
#define NUM_TRACKS 2
#define NUM_LEDS (NUM_STEPS*NUM_TRACKS)
//#define NUM_LEDS NUM_STEPS
//#define NUM_LEDS (NUM_STEPS/2)

The tempo is considered “global” and affects all tracks simultaneously.

Find it on GitHub here.

Closing Thoughts

The basic functionality for this is largely there now and works ok. It is a little tedious to enter notes for a larger number of tracks, but it is possible. To be really practical there would need to either be some way of storing sequences or some way of loading them – e.g. via MIDI.

The tempo and beat is common to all tracks at present.  One enhancement might be to support a tempo per track, then some interesting phasing of cross-rhythms would be possible. Another option would be to support different lengths of LEDs per track (e.g. concentric rings) so again some interesting poly-rhythms might result.

Kevin

IMG_5488

Leave a comment