Arduino MIDI Rhythm Section Sequencer
by baritonomarchetto in Circuits > Arduino
14146 Views, 101 Favorites, 0 Comments
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!
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 of 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.
Rhythm section?
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.
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
- 2x 40 pin male single row pin header strip (2.54 mm), better if gold plated
- 1x H11L1 optocoupler
- 1x 1N4148 diode
- 23x 1000 ohm resistors
- 3x 220 ohm resistors
- 2x BC547 pnp transistors
... solder wire, some cables, soldering station, a drilling tool... and spare time :)
Please notice that the buttons in the pictures have been replaced with another type of (even cheaper ...) push buttons because of the outrageous bouncing...
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.
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 software enabled (see 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 1K ohm resistor each to limit the current drain and preserve the microcontroller.
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, but you can use digital pins if you prefer being digital signals. In case you are going to sequence a synth compatible with V-Trig (voltage trigger) signals, a 1k ohm series resistor to reduce the current drain will be sufficient; in case of a S-Trig (switch trigger) synth, you will need a simple pnp switch circuit (see attached scheme).
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 I have used a H11L1 optocoupler because I was not able to run as it should a common 6N138 within the Arduino DUE 3.3V limit.
Software
The 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.
You can download the updated firmware HERE (github link).
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!).
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 ;)
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 matrix or any incoming MIDI note-on message (i.e. from an external MIDI keyboard) will be recorded.
Other functions
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 (soft reset) by keeping presed the "start" button for more than 3 seconds.
You can "swing" your sequence by turning the "swing" potentiometer.
You can disable/enable MIDI echo by pressing "mute" button while keeping pressed the "shift" button. When MIDI echo is enabled (default), whatever information is present at the MIDI INPUT jack will be sent to the MIDI OUTPUT jack (only MIDI note on, note off, pitch bend, aftertouch and control change are echoed).
Both MIDI clock input and output are implemented and enabled by default. 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.
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. A revision later I added polyphony (polyphony per-synth limited to 3 by default).
To sum up:
- while in LIVE mode, if LIVE recording is engaged and the sequence started, you can record incoming MIDI note-on messages, polyphonically. Pitch and volume info will be stored. Pitch bend and aftertoutch infos are lost. MIDI Control Change messages will be stored. Keep in mind that you have only one CC slot per channel, per step.
- If the sequence is stopped, you can record up to 3 pitch values (chord) to a specific step of a specific bar by keeping pressed the destination step button and pressing (at the same time or one by one) the desired keys on the keyboard connected to the MIDI IN port.
Notice that:
- the note 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, notes 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" step (MIDI channel #1 -> "drum" #1 and so on).
You can clear a specific synth sequence by pressing the relative "drum" step button while keeping pressed the "REC" button. Pressing it again will clear the drum sequence too. If a CC sequence was recorded, that will be the first to be erased, then following the order CC -> Synth -> Drum
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 (V-trig or "voltage trigger") or by grounding the arpeggio trigger input (S-Trig or "switch trigger") 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 (Roland TR-909 "rimshot" output was used as an expedient in the past) 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.
Depending on the trigger signal type supported by the synth you want to control, you will need a simple hardware modification: in case of V-trig (i.e. Roland synths) place a 1 Kohm resistor in series with arduino trigger output. In case of a S-trig (i.e. Korg synths) use the shematic attached to the "wiring" step for a safe switch trigger.
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).
You can download the latest test firmware HERE (GitHub link).
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.
Keep in mind that MIDI echo is enabled by default. This means that if you have a MIDI loop between a synth and MRSS, this could cause issues (I experienced a predictable double note triggering most of the times, but also very low notes triggered and a generally unresponsive built-in keyboard with synths with MIDI out acting as MIDI THRU... it depends on the synth). If this is the case, disable MIDI echo by pressing "mute" button while keeping pressed "shift" button.