MCP4725 MIDI Sample Player

This is an update to my MCP4725 Sample Player to have it “playable” over MIDI rather than be triggered via a button.

Warning! I strongly recommend using an old or second hand keyboard for your MIDI 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
  • MCP4725 breakout board
  • 1x button
  • MIDI in module (see: Arduino MIDI Interfaces)
  • Cheap (i.e. not an expensive amp or computer!) means of playing audio from a headphone jack
  • Breadboard and jumper wires

The Circuit

This uses the same circuit as before but this time needs some kind of MIDI receive module connecting to the Arduino’s RX pin.

I actually used the shield I built for use with Mozzi (see MCP4725 and Mozzi – Part 2).

The Code

Most of the code is the same as for the MCP4725 Sample Player but instead of looking for a button to be pressed I am looking for a specific MIDI note on event on a specific MIDI channel.

As no other processing will go on while the sample is being played it is a good idea to make the MIDI event as specific as possible – hence looking for a single note on event – although in theory it could play the sample in response to any MIDI event.

The details of how to get a sample into the code are the same as already described in MCP4725 Sample Player.

Find it on GitHub here.

Closing Thoughts

I’m not sure how many samples could be stored – in principle it would be possible to have several in the Arduino’s memory.  But it would be nice to have different notes trigger different sounds.

The simplest way of doing this for multiple sounds would be to follow the principles already described in some of the following projects:

But using things like samples stored on an SD card, as required in the above, is a bit over-kill for just playing a single sound like this.

Kevin

Leave a comment