Arduino MIDI VS1053 Synth – Part 2

I’m planning a use of the VS1053 shield but need to be able to pre-select which instruments to play and which channels to respond to.  This revisits the Arduino MIDI VS1053 Synth and adds that functionality.

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
  • VS1053 Shield for example the Sparkfun Musical Instrument Shield or the Adafruit VS1053 breakout
  • MIDI input device (see Arduino MIDI Interfaces)
  • Amplification and jack lead

The Circuit

There is no circuit, just plugging the shields together as before.

2020-07-28 11.45.36

The Code

To gain the ability to choose instruments and channels, a couple of small additions to the code are required.  Filtering on channel has already been discussed in the Arduino MIDI Filter so I use the same “bitmask” trick here.

Setting up instruments is relatively straight forward too – it just requires the MIDI instrument numbers to be used with the appropriate program change message for the required channel. I opted to use a list with 16 entries – one for each channel – although only channels corresponding to a bit being set in the filter will be acted upon.

The only quirk is channel 10 as this is usually reserved for a drum kit. I simply ignore any voice in the channel 10 position.

One other thing to consider – the previous code that allowed the instrument to be changed using a potentiometer is still there, but this is only now relevant if channel 1 is made active using the bitmask and can be optionally left out if required.

Once the VS1053 is initialised (all fully described in the previous project) I cycle through all active channels sending out the program change messages to initialise the voices.  Then we are all ready to go.

Normally with a sound setup you’d probably have a digital audio workstation (DAW) that will send out all the channel initialisation messages to set the appropriate voices.  In this case, this allows for the Arduino to become a fixed instrument without any further initialisation required.

Find it on GitHub here.

Update: There is new code that has now been validated for both VS1003 and VS1053 support.  It also includes improvements to the MIDI support so is recommended over the above code.  See here for further details: Arduino MIDI VS1003 or VS1053 Synth.

Closing Thoughts

This is a simple update to the previous tutorial but one that makes integrating the VS1053 with other modules a little easier.

Kevin

Leave a comment