Arduino Mozzi Sample Drum Sequencer

This project combines the Arduino Mozzi Sample Drum Machine with the code from the Arduino VS1003 Drum Machine and the buttons from the Analog Keypad Tone Controller.

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
  • 2x “analog keypads” as described in Analog Keypad Tone Controller.
  • 8 ohm speaker or old headphone speaker (or external amplification)
  • 1x 220Ω resistor (for the speaker)
  • Mozzi Output Circuit – optional but recommended
  • Breadboard and jumper wires

The Circuit

AnalogKeypadToneController_bb

The simple version is exactly the same as described in the Analog Keypad Tone Controller.  This is enough to get you playing but isn’t going to be very loud.  I hooked mine up to a Mozzi Output Circuit and fed it into an external (sacrificial, for testing) amplifier.

IMG_5199

The Code

All the code is code that has been discussed elsewhere on this blog already, but here is the top level summary:

The main code loop runs inside the Mozzi updateControl function and has the following functionality.

IF it is time to play a beat, based on the current tempo THEN:
  See which drums need to play on this beat from the pattern
  Start the samples for these drums
  Move on to the next step in the pattern

Do one of the following on each scan:
1:Read the first keypad
  Extract the drum and information for beats 1,2,3 from the keypress
  Update the pattern to play that drum on that beat
2:Read the second keypad
  Repeat the above for the beats 4,5,6
3:IF using a tempo pot THEN
  Read the pot and update the tempo

I’ve split the keypad/tempo pot (if used) reading across different scans.  I’m also using the Mozzi-provided mozziAnalogRead which doesn’t block processing whilst reading the analog inputs like the usual Arduino analogRead function.

Find it on GitHub here.

Closing Thoughts

The volume still isn’t great, but some of that could be the samples.  The bass drum in particular doesn’t come out very well on the video.

But fixed-“pitch” drum samples is not really showing off the library – I could be using any sounds and it is possible to adjust the frequency of playback, which could come from a potentiometer, keys, or even MIDI!  So that might be something to explore next.

It would actually be really great if you could record a sample and then play it back, but I’m not sure that would be possible with the Arduino – there just isn’t the dynamic memory, and there are probably much easier ways to do that anyway – e.g. reading MP3s off a memory card; using a dedicated “sampler” module; or playing audio samples from memory card.

Kevin

Leave a comment