VS1053 and MIDI Revisited

Right back when I first started looking at the VS1053 I looked into the MIDI mode, which can be enabled in hardware, but at the time I opted for a software route to using the boards with MIDI.

This post finally takes a fresh look at the range of VS1053 boards available and how to use them as pure hardware MIDI modules.

Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

If you are new to microcontrollers, see the Getting Started pages.

Cheap VS1053 Modules

I’ve already looked at the cheap VS1053 shields you can get for the Arduino Uno.  The modules I’ve used so far look like this.  On the left is the VS1053 shield. On the right is a “VS1003/VS1053 module” that is actually the more limited VS1003 device.

IMG_7149

Here are some resources for how to drive those:

To complete “the set” of cheap modules, this short diversion shows how to connect up the final type of module, which looks like this, to an Arduino Uno.

Once again I still have that slightly nervous uncertainly around the use of 3V or 5V logic (more here), but as the circuitry is all the same as the shield (and they are pretty cheap modules), I’ve just gone for it again and hooked them up and it seems… ok… (for the time being!).  If in doubt, I’d suggest you use a 3V3 microcontroller…

Arduino-VS1053-Module_bb

Once the SPI links have been made (D11-D13) pretty much any of the digital pins can be used to connect to the module, but here I’ve retained the pins used by the shield version of the module, which means all previous code will just run “as is” with no changes required.

This configuration can be tested directly with the Arduino MIDI VS1003 or VS1053 Synth for example by connecting the Arduino’s RX pin to a MIDI module.

More Sophisticated Modules

If the ambiguity of the voltage levels is a concern and you’d like a bit more support in using your module, then both Adafruit and Sparkfun produce modules for Arduino using the VS1053 too, both with proper level shifting built in:

Adafruit also have a Feather Wing version of their VS1053 shield, which I’ve already talked about here: Adafruit Feather MIDI and Music.  This is part of a natively 3V3 ecosystem of microcontrollers and add-ons.

Adafruit also produce a VS1053 CODEC module, again with full level shifting to be both 3V and 5V tolerant, that I’ll talk about in a bit.

Hardware MIDI

As I’ve mentioned before, the VS1053 can boot up into a MIDI synth mode, where MIDI data can be received on the VS1053’s RX pin and sent to a built-in General MIDI synth engine.

The VS1053 datasheet describes the “Real Time MIDI mode” and states that it is activated when the VS1053 GPIO0 is LOW and GPIO1 is HIGH.  In this mode the VS1053 UART is configured for the MIDI baud rate of 31250 and MIDI data can be sent in either via the UART (RX) or over SPI.

My previous projects have all taken advantage of real-time MIDI mode, but by enabling it through software by sending specific VS1053 code to the device over SPI.  The advantage of loading code this way is that an upgraded MIDI parser is also loaded.  If the hardware method of enabling MIDI is used, the default (built-in) MIDI parser of the VS1053 is used which has some limitations.

More details are available in the VLSI application note “rtmidi: VS10xx Real-time MIDI Input” but the main issues appear to be:

  • The MIDI “input queue” for the UART isn’t very big, so might get overloaded with a complex MIDI stream.
  • The parser doesn’t know how to handle SysEx messages.

The implications of the latter seem to be that it will treat a SysEx data stream as if it was non-SysEx midi data.  This means that if the SysEx data stream includes 0x80 (say) then the parser will treat it as a NoteOff message rather than as part of a SysEx set of data bytes.

That sounds like quite a significant bug to me, but I guess it is possible to work around it if it is known about and the simplicity of being able to use one of these modules without a microcontroller might make it worth it.

MIDI Mode for Adafruit and Sparkfun Modules

These are fully supported from what I can see, although I don’t have either of them personally to try.

Full details of how to do this for the Adafruit Music Maker Shield MIDI Synth can be found here.  Two links are required on the board – one to tie GPIO1 HIGH to 3V3 and one to connect the VS1053 RX pin to an Arduino pin (they suggest D2 and then recommend the use of SoftwareSerial to drive it).

The Sparkfun module isn’t so obvious, but the hookup guide shows that by default the VS1053 RX pin is connected to the Arduino’s D3 and GPIO1 is connected to D4, so I’m assuming that setting D4 HIGH on startup will enable MIDI input again using SoftwareSerial to D3.

IMG_7150

Details for the Adafruit Music Maker Feather Wing can be found here.  This involves making a solder jumper across the two MIDI pads on the underside of the board.  The VS1053 RX is connected to the TX pin on the Feather.  This does, however, mean it can’t be used with the Adafruit MIDI Feather Wing with a Feather board, as that too is expecting to use the RX/TX pins.  There is more detail of the problem, and details of how I used SPI MIDI mode to get around this issue, in my Adafruit Feather MIDI and Music project.

The Adafruit VS1053 CODEC module similarly has the ability to boot into MIDI mode, as described here.  As all VS1053 GPIO are broken out on the module, it is a relatively simple matter to connect GPIO0 to GND and GPIO1 to 3V3 (NOT 5V!).

From what I can see, whilst the RX link isn’t on the 5V tolerant side, so doesn’t go through a level shifter, there is a diode between the VS1053 RX pin and the external RX connection, acting as protection and level shifting.  The schematic labels the RX header as “RX_5V” so it can be connected directly to either a 3V or 5V microcontroller’s TX pin or to a 3V or 5V MIDI IN circuit.

Here is a summary of the connections required for the two Adafruit modules (Red = 3V3; Black = GND; Blue = MIDI IN).  Recall that the Music Maker Wing requires the MIDI solder jumper enabled.

Adafruit-VS1053_bb

It is actually possible to use the Feather Music Maker and MIDI Wings together if no microcontroller is required, but the RX and TX pins need tying together.  The MIDI module sends MIDI data to the RX connection (IN is on RX), but the VS1053’s receiver is listening on the TX connection (which would normally be the OUT from a microcontroller).  Remember, everything has to be powered via 3V3.  One advantage of having RX/TX tied together like this is that the MIDI OUT socket becomes a simple (unbuffered) hardware THRU port as well.

Here I’ve used a quad expander to mount both boards and get access to the RX/TX pins (to tie them together with a green jumper in the photo) and 3V3 and GND, which I’ve taken power from a RP2040 Feather – but it is power only, no microcontroller control is used.  The VS1053 receives MIDI from the MIDI Wing and generates its own audio output completely autonomously.

IMG_7151

Cheap Hardware MIDI

So on to the cheap modules.  Is hardware MIDI possible on those?  Yes, apparently, but some mods are required to the boards.  There are details here of someone who managed it:

I’m using my “red” non-shield module, so these are the changes I’m going to have to make.

  1. Remove the indicated 100K surface mount resistor connected to the top arrowed pin (this is GPIO1 and the resistor currently pulls it LOW).
  2. Cut the trace indicated linked to the bottom arrowed pin (this is the RX pin, pulled to IOVDD as it is not currently in use).
  3. Connect GPIO1 (arrowed, top) to the 3V3 connector of the regulator (indicated) via a 100K resistor.  It might even be possible to use the removed surface mount resistor.  It might at least be possible to use the freed pad.
  4. Connect a fine wire to the RX pin (arrowed, bottom) which will need connecting to a MIDI module or microcontroller (3V3 level) TX pin.
  5. Connect XRESET to 3V3 too via a 10K resistor.  As this is an active LOW reset signal, it needs to be tied HIGH for the VS1053 to boot.

In the end (as I really don’t have the tools for such fine-pitched work) I lifted the VS1053 RX pin (26) and soldered a wire to it.  Then I installed pin headers on GND and 5V with an additional pin header (not connected to the original board) that I could use to solder to the VS1053 RX pin.

Note: although the board requires a 5V supply, the RX pin is functioning at 3V3 logic levels.

For my first attempt I really couldn’t get this to work!  I couldn’t spot anything wrong – I could see MIDI signals on an oscilloscope, but they didn’t seem to be registering with the VS1053.

The pull-up on GPIO1 (that should have been connected to 3V3 via a 100k resistor) only seemed to be reading around 3.0V.  GPIO0 seemed to still be pulled LOW as is required.  The datasheet suggests that HIGH should be between 0.7 CVDD (core voltage ~1.85V) and IOVDD+0.3 (~3.6V) so that should be fine.  A voltage drop of 0.3V for a 100K implies a leakage current of 3uA which is probably… ok?

Eventually I realised that I hadn’t done anything with the VS1053 RESET signal. Left floating the VS1053 must have still been in its RESET state.  Tying this HIGH (via a 10K resistor) solved the problem.

Closing Thoughts

I’ve managed to dig into the use of the VS1053 quite a bit more with this post.

Given the relative costs of a module that actually properly supports MIDI mode properly, it isn’t easy to justify the time and effort attempting to patch the cheaper modules – but I’m glad I was able to finally get it to work!

But at this point, I think I’d recommend either the Feather Music Maker Wing or the VS1053 CODEC boards from Adafruit as the best way to get hardware MIDI up and running.

But seeing as using a microcontroller also allows the use of an updated MIDI parser too, I think that keeping a microcontroller in the setup has a lot of advantages still as well.  In the opening video, the filming stops just before the amount of MIDI data overwhelms the VS1053’s input buffer and locks it up completely!

Kevin

Leave a comment