Introduction: Arduino MIDI Rhythm Section Sequencer
Having a good software drum machine is easy and cheap today but using a mouse kills the fun for me. This is why I realized what initially was intended as a pure 64 steps hardware MIDI drum sequencer capable of triggering up to 12 different drum elements (parts), but then evolved in a rhythm section sequencer...
... there we go!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: How It Works
This hardware cannot generate sounds on its own, but only sequence external hardware via MIDI. This means you will need a sound generator of your drum sounds (a sampler or a drum synthesizer or a PC with your favourite drum software or whatever you prefer) capable of being triggered by MIDI note-on messages.
It's mainly composed by a 4 x 4 buttons matrix (with LEDs), one for each step of a bar. The whole 64 steps sequence is made up by 16 steps multiplied 4 bars. Each step is 1/16th of a note.
There are two modes of operation: live mode and edit mode.
In edit mode you can actually step-by-step edit your sequence by defineing which drum will play in each step.
Your external hardware instrument ("drum") is triggered by sending a MIDI "note on" message for different "MIDI note numbers" on channel number "10". By default these note numbers are
drum #1 (i.e. kick) -> MIDI note number "60"
drum #2 (i.e. snare) -> MIDI note number "62"
drum #3 (i.e. clap) -> MIDI note number "64"
drum #4 (i.e. Hihat) -> MIDI note number "65"
drum #5 -> MIDI note number "67"
drum #6 -> MIDI note number "69"
drum #7 -> MIDI note number "71"
drum #8 -> MIDI note number "72"
drum #9 -> MIDI note number "74"
drum #10 -> MIDI note number "76"
drum #11 -> MIDI note number "77"
drum #12 -> MIDI note number "79"
You can change these values (and the MIDI channel) in the sketch if you prefer.
In live mode by pressing step buttons you can live play drums associated to each step by sending MIDI messages through serial. You can live record your button presses and/or incoming MIDI messages.
Both in live mode and edit mode you can mute (or unmute) a drum, "roll play" the currently active drum and "swing" your sequence.
Most of drum sequencers are purely MIDI drum parts triggerers, with a fixed MIDI note number for each drum sound. In this case, we have a "rhythm section sequencer" more than a pure "drum sequencer" because you can even sequence synthesizers.
Read the QUICK START GUIDE for more details and a full list of features.
Step 2: Hardware
This project is realized around an Arduino DUE board. I tried to keep the hardware as simple as possible, i.e. by avoiding the use of LED drivers. Arduino DUE is likely not the most appropriate board to handle a bunch of LEDs without a LED driver because of it's output current limits (from 5 mA to 15 mA, depending on the pin), but it's the fastest Arduino and timing is everything when dealing with sequencers. So, keep in mind that THIS hardware configuration is likely pushing your Arduino DUE to it's limits and could damage it in the long term.
This being said, the hardware is mainly a 16 buttons, 16 LEDs (one for each step) sequencer with 5 additional buttons for functions and 3 potentiometers. I also added a red LED after adding a live recording function.
Here is the bill of materials:
- 1x Arduino DUE
- 16x momentary, non latching push buttons with integrated LEDs (you can use external LEDs if you prefer, but remember to use low power LEDs!!)
- 1x red LED (low power!)
- 5x momentary, non latching push buttons
- 3x 10K single turn, linear, potentiometers
- 3x 6.5 mm panel mount mono jack female
- 1x plastic case (I used a 190x140x70 mm case)
- 2x 5-pin DIN female panel mount socket connector (MIDI)
- 1x double sided 70x90 mm perf board (I used a 50x70, but honestly it's a little too small)
- 2x 40 pin male single row pin header strip (2.54 mm)
- 1x 6N138 optocoupler
- 1x 1N4148 diode
- 3x 1000 ohm resistors
- 3x 220 ohm resistors
- 20x 470 ohm resistor
... solder wire, some cables, soldering station, a drilling tool... and spare time :)
Time required to complete the project: 8 - 10 hours
WARNING: ALWAYS wear protective glasses and gloves while drilling! Hot material flackes can be projected to your eyes or come in contact with your skin and cause burns or even more serious damage to you or people around you.
Step 3: Wirings
Step buttons are directly connected to Arduino pins from 22 (step 1) to 37 (step16). Buttons ground is daisy chained and connected to Arduino DUE ground. There's not the need for pullup or pulldown resistors being that Arduino integrated pullup resistors are enabled in the sketch.
The same is true for the additional 5 buttons (Arduino pins 2, 3, 4, 5 and 6), used for functions other than steps. I also placed a 6.5 mm female jack connector in parallel with the "start" button in order to be able to play and stop my sequences remotely.
LEDs are connected to ground (daisy chain) and Arduino DUE pins from 38 (step #1) to 53 (step #16) in series with a 470 ohm resistor each to limit the current drain and preserve the microcontroller. I have tested resistors up to 1 K ohm and can confirm they could be used.
Potentiometers are connected as shown in the attached picture. Notice that the reference voltage is 3.3V, not 5V. Inputs used are A0, A1 and A2.
I also implemented two trigger outputs for arpeggio signals, like those required to arpegiate old 80's synth like the Korg Polysix and Roland Juno 6/60. They are connected to pins A3 and A4, with a 470 ohm series resistor to reduce the current drain. Those are digital signals, so you can use digital pins instead of analog pins if you prefer.
MIDI IN and OUT circuits are schematized in the attached pictures. Notice that, contrary to most arduinos, Rx1 and Tx1 are used by default on DUE boards instead of Rx0 and Tx0. This is great because you can upload your sketch without the need to disconnect Rx every time. Notice also that, contrary to most schemes out there, MIDI IN miss the 10K ohm resistor pulling down pin 7 on the optoisolator. All examples on the 6N138 datasheet leave that pin floating, sooo... but most important, it actually woks!
Step 4: Software
The attached sketch has been written within the Arduino IDE and must be uploaded to your Arduino DUE board. I will not go into details about how to upload the sketch to your arduino DUE. If this is your first experience with Arduino DUE read this. If this is your first experience with arduino IDE, please read this too.
Important Note: at today it is not possible to upload .ino nor .zip files to the Instructables server. You can download the updated firmware HERE.
The sketch relies on the excellent FortySevenEffects MIDI library. You will need to install the library in your arduino IDE.
MIDI out notes assigned to each drum are defined by the drumNote[STEPS_NUM] variable in the sketch. You can change them at your will.
MIDI out channel number for drums is set to "10" by default.
I am not a coder in real life and for sure there are better ways to code what we are in the need for here. If you are a coder with any suggestion, you are welcome! Please send me any variation that can increase the code's efficiency/effectiveness and I will include it to the main sketch (citing the Contributor obviously!).
Step 5: Quick Start Guide
DRUMS: STEP-BY-STEP SEQUENCING
As soon as you power up your sequencer (or reset it), an empty sequence will be loaded. The sequencer boots up in edit mode, with the first bar holded/locked and the first drum (i.e. kick) selected. This means that by pressing any step button, you will immediately assign "kick" to those steps. The volume the drum will be triggered is set by the position of the "volume" potentiometer when assigning the drum to the step. By re-pressing a previously assigned step button you will de-assign the current drum on that step.
If you press "start" button, you see your LEDs running from left to right, top to bottom, playing "kick" any time a kick step is crossed.
By keeping pressed "shift" button you will see the 1st step LED on the 1st row turned on (meaning the first drum is selected) and first step LED on the fourth row (meaning that you are locked to the first bar). You can now change the drum you want to sequence by pressing another step button while keeping "shift" pressed. After selecting the new drum, release "shift". All LEDs will turn off (because you have not assigned the new drum to any step) and you can start assigning the new drum to steps. Repeat for all the drums you need (up to 12).
Now that you have created a nice pattern, keep pressed "shift" and turn off the highligted step on the bottom row (it should be the 1st step of the 4th row if you have adopted the same layout I used): you have just "unlocked" the sequence which will now run over all the 4 bars. Bottom raw LEDs will start "moveing", indicating which bar is currently being played (bar progression). You will notice that only when in the first bar a sequence will play, with all the other 3 bars generating no sounds. This is because you have assigned drums only to the first bar, the others being left blank. You can fill them by hand (select a new bar by pressing one of the last 4 step buttons while keeping pressed "shift", select one of the drums, fill the steps etc. etc.) or copy and paste the bar sequence you created to all bars by entering edit mode (re-lock to first bar) and pressing "record" (which now assumes the "paste" function) while keeping pressed "shift". Easier done than said.
DRUMS: LIVE PLAY MODE
On startup the sequencer is in edit mode. To exit edit mode you must keep pressed "shift" and press the bar button currently held/locked (the step button on 4th row turned on). This will turn off the LED of the previously locked bar and unlock the sequence. You are now in live play mode.
In live play mode, by pressing any step button the drum associated to that button will be triggered.
If you want to live record your sequence, start the sequence by pressing "play", then press "record" button (only in live play mode). A red LED will turn on. Your playing on the drum sequencer control panel or any incoming MIDI note-on message will be recorded.
By pressing "roll" button, the currently active drum will be played at each step (in a roll). This works in both "step-by-step" and "live-play" modes.
By pressing any step button while keeping pressed the "mute" button the drum associated to that step will be muted (or unmuted). This works in both "step-by-step" and "live-play" modes.
You can clear a specific drum sequence by pressing the relative step button while keeping pressed the "REC" button.
You can clear the whole sequence by keeping presed the "start" button for more than 3 seconds.
You can "swing" your sequence by turning the "swing" potentiometer. Notice that the "swing" potentiometer is labeled "pitch" in the pictures. That's because it was a "menu-dive" function in a previous iteration of the sketch, made more accessible now ;)
Both MIDI clock input and output are implemented. In case no clock input is received, tempo is set with the dedicated potentiometer. In case a MIDI clock input is received, tempo is computed from that and the tempo potentiometer will be unresponsive. MIDI clock is always sent to the MIDI out.
Step 6: Rhythm Section!
The original idea was a "pure" 64 steps MIDI drum sequencer to sequence up to 12 independent drum parts. After some testing, I noticed that it would have been nice to control a bass line too, and I assigned the feature of a variable pitch-per-step to the latest drum only. After that, I modified the code again so that I could change the pitch in every drum and control up to 12 synthesizers (monophonically).
To sum up:
- while in LIVE mode, if LIVE recording is engaged and the sequence started, you can record incoming MIDI pitches and volumes.
- If the sequence is stopped, you can record a pitch value to a specific step of a specific bar by keeping pressed the destination step button and pressing the desired key on the keyboard connected to the MIDI IN port.
- the pitched sound triggered on a step is "killed" on the very next step. To increase the note lenght, act on the "release" VCA parameter of your synthesizer.
- contrary to drums, pitched sounds cannot be played in a roll by pressing the "roll" button.
- When recording LIVE, the incoming MIDI channel data is stored in the relative "drum" (MIDI channel #1 -> "drum" #1 and so on).
You can clear a specific drum/synth sequence by pressing the relative "drum" step button while keeping pressed the "REC" button.
Step 7: Arpeggio Triggers
Early '80's pre-MIDI synths are often equipped with a sometimes called "arpeggio trigger input". By sending a 2.5 to 5.0 V trig signal you can tell the synthesiser to advance one step on an arpeggio sequence. This could be difficult to manage with a sequencer without a dedicated trigger out (sometimes "rimshot" sounds from a dedicated out where/are used as an expedient) but with a microcontroller board you can easily manage such signal and control your synth arpeggio as it was meant to by the factory.
This rhythm section sequencer includes the possibility to trigger the arpeggiator of two different synthesizers, independently.
The use is very easy: select drum 11 or 12 (press step 11 or 12 while pressing "shift") and activate the steps you want the arpeggiator to move of one step. This way you can "program" very tight 1/16th of a note lenght regular arpeggios by activating all steps, or 1/8th by activating every other step. In addition, you can program more complex arpeggios by activating steps following an un-regular path.
Step 8: If Things Don't Work...
Even a relatively simple project like this most likely will not work 100% the first time you turn it on. Here, In example, the corrispondence between buttons and LEDs is crucial, and an unmathched wiring will make the sequencer unuseful.
In order to test all the different components that make up the step sequencer, I wrote a simple test sketch (see attachment).
Important Note: at today it is no more possible to upload .ino nor .zip files to the Instructables server. You can download the latest tet firmware HERE.
The test sketch works as follows:
- press a step button: the corresponding LED should turn on and a MIDI note-on on channel 10 will be sent to the MIDI output.
- press a function button: one of the first 5 LEDs will turn on.
- turn a potentiometer: LEDS will light accordingly (first pot -> first LEDs row, second pot -> second LEDs row, third pot -> third LEDs row).
- if a MIDI note on is received, first LED will blink.
This is an entry in the