Arduino MIDI VS1053 Synth

One of the nice things about that VS1053 shield is that the device has a fully general MIDI compliant mode.  As well as playing MP3s and other audio files, it can either play MIDI files (as if it was just another audio file) or even better for my purposes, it can run in a real-time MIDI mode.

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!

There weren’t really any tutorials that really showed how to do this, but the following generously provided open, sample code with the details:

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 (for example, a MIDI shield)
  • Amplification and jack lead
  • Breadboard and jumper wires

The Circuit

This is just a collection of two shields and an Arduino as follows:

2020-07-28 11.45.36

To use the VS1053 in real-time MIDI mode there are two things you could do.  If your hardware supports it (the Sparkfun and Adafruit modules do) you can use hardware settings to tell the VS1053 to start up listening to MIDI.  For this to happen, the VS1053 serial port must be connected to the Arduino and GPIO0 and GPIO1 must be set LOW and HIGH respectively.  If this happens then the VS1053 will respond to any MIDI data it receives on its serial port automatically.

Unfortunately for my cheap VS1053 shield, I had two issues: first, GPIO0 and GPIO1 were hard-wired via a 10k resistor (surface mount 104 resistors to be precise) to GND, so they were always LOW on power up.  Secondly, the TX/RX pins of the VS1053 were not connected to anything.  Both of these can be seen in the photo below, taking the pin descriptions from the VS1053 datasheet.

2020-07-08 21.55.50

Thankfully, the VS1053 has an alternative way to configure real-time MIDI mode by way of a “firmware patch”, which is a mechanism provided by the manufacturer for loading new features in the VS1053 chip itself making it a very versatile little device!

It can also receive MIDI commands using the same SPI bus that it uses for receiving files to play, so that is what I’ll do.

The Code

This code isn’t using the VS1053 library I used in the Arduino MP3 Piano as that is geared up mostly for playing sample or audio files from the SD card via the shield.

This time, as mentioned above, we need some “magic” code to put the shield into real-time MIDI mode, and then more code to send MIDI data out over the SPI bus, both of which I’m not going to attempt to explain.  These were based on the examples I found on the Internet linked above, so massive thanks to both Matthias Neeracher and Nathan Seidle for making this code available.

So ignoring that part of the code that does all the hard work, the rest is pretty straight forward, which is why I put this in the “beginners” category of project.

Basically, I use the Arduino MIDI library and in the main loop in its “polling mode” – basically whenever it tells me it has received something over MIDI, I just send it straight over to the VS1053.  That’s it!

It works fine for note messages, but I have tested it with anything more complicated yet, such as control messages, although from reading the code it looks like it should largely work ok.

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

I’d like to pull out my Arduino Simple MIDI Controller to create something to select the different patches on the board. I also have a USB MIDI controller keyboard that I’d like to hook up to this to make a pretty self-contained simple MIDI synthesizer, so I might look at that next.

Kevin

4 thoughts on “Arduino MIDI VS1053 Synth

  1. Does this allow a usb midi keyboard through the usb in of the arduino, and then be directed as midi in/out through the shield to control another midi device?

    Like

    1. This project doesn’t directly as the Arduino Uno doesn’t have USB host functionality, but it is possible to add a shield as described in some of my other posts and adjust the code to redirect USB over to the VS1053 or if you just want a USB MIDI to MIDI converter, then any off-the shelf MIDI shield will do it.

      Another option might be to use one of the Uno-like variants with native USB support such as the Arduino Leonardo. Alternatively, the Adafruit feather ecosystem has a number of boards that support native USB and it has a VS1053 based feather wing too. There is the added bonus (if it is something of interest) that there are several that can be programmed in CircuitPython instead of Arduino too.

      Have a browse of the “USB MIDI” tag on my blog for the former and the “Adafruit” or “Feather” tag for the latter.

      Kevin

      Like

    1. As I don’t have this shield myself, I can’t say for sure, but it looks pretty similar to the one I’ve been using, so it might just be a case of configuring the correct pins and seeing how you get on?

      Kevin

      Like

Leave a comment