XIAO ESP32-C3 MIDI Synthesizer – Part 6
Expanding on my previous posts, I thought it might be interesting to see how I might be able to add some additional IO to the MIDI Synth. This is an exploration of some options there.
- Part 1 – Getting started and getting code running.
- Part 2 – Swapping the ESP32-C3 for a SAMD21 to get USB MIDI.
- Part 3 – Taking a deeper look at the SAM2695 itself.
- Part 4 – A USB MIDI Synth Module using the SAMD21 again as a USB MIDI Host.
- Part 5 – A Serial MIDI Synth Module using the original ESP32-C3.
- Part 6 – Pairs the Synth with a XIAO Expansion board to add display and potentiometers.
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 tutorials for the main concepts used in this project:
- Getting Started with the XIAO MIDI Synthesizer
- XIAO SAMD21, Arduino and MIDI
- XIAO SAMD21, Arduino and MIDI – Part 6
If you are new to microcontrollers, see the Getting Started pages.
The Synth Grove Connector
One option to immediately explore for me was the Grove connector on the Synth – highlighted by the blue rectangle in the photo below. I’m thinking at this stage of the XIAO Expander Module (more here) and how that might give some options for easily hooking up to the Synth.
There one obvious issue with this, and one not so obvious issue.
First, of course, there is no access to this connector through the case. My initial thought was to simply remove the PCB from the case and use it as a stand-alone board. On initial inspection it seemed that there were two screws holding it down. Not so, a more thorough inspection (after remove the two screws and still not being able to remove it), revealed a third screw underneath the “light pipe” for the LEDs.
Unfortunately that light pipe is pretty well wedged into the case making removal particularly tricky. But without removing the light pipe, it isn’t possible to get to the screw at all.
I did wonder about making a hole in the 3D printed case. A better option might be to get hold of the published 3D print files and add a hole and make my own (they are available via the product page).
But both options would probably end up changing the original case somehow – even if printing my own, I still need to get the original PCB out somehow and that brings me back to the light pipe issue.
The second issue isn’t quite so obvious. In that photo we can see that the pins for the Grove connector are labelled as follows (top to bottom):
- NC
- TX
- 5V
- GND
The UART on the XIAO expander board, which I’d like to use, is labelled:
- RX7
- TX6
- 3V3
- GND
Checking in with the Synth schematic, the connector is wired as follows:
SYS_MIDI connects to the MIDI_IN pin of the SAM2695, so actually connecting “TX to TX” in this instance should be ok.
5V might be an issue though, as it really does look like (to me) that it really means 5V – it is the input to the TPL740F33 that generates the 3V3 power signal, as well as feeding the amplifier directly. The datasheet of the TPL740F33 does seem to imply that if receiving 3V3 it can still generate 3V3 so it might be ok? The amplifier obviously won’t be as powerful though running off 3V3.
Anyway, for now, instead I’ve just opted to use the GPIO again, wired into the expansion sockets with the XIAO removed.
At the XIAO expander end, I’ve used the additional pins rather than the Grove connector, as they support a 5V output.
The downsides to this approach:
- I’m not using the Grove connectors, which would have been really neat.
- I have no access to the four buttons on the XIAO MIDI Synth.
But I do now have access to two I2C Grove connectors, a GPIO Grove, and the RX part of the UART Grove too as well as the on-board display.
If a XIAO SAMD21 is used, then the previous code for USB to the Synth can be used directly – see XIAO ESP32-C3 MIDI Synthesizer – Part 2.
If the XIAO ESP32-C3 is used, then an additional serial MIDI connection is required. This can be connected to the Grove UART connector (using the RX pin, and leaving TX unconnected) or the RX pin of the additional 8-way pin header on the expansion board. Then the code from this will work directly: XIAO ESP32-C3 MIDI Synthesizer – Part 5.
Adding a Display and Program Control
I already have some code that has done this for a XIAO on an expansion board here XIAO SAMD21, Arduino and MIDI – Part 6.
But for this to work usefully with the Synth module, I need to adjust the routing so that MIDI goes from USB to serial, but the program change messages are also sent via serial to the synth module. That has already been address in previous parts, to I just need to merge the code with that from XIAO ESP32-C3 MIDI Synthesizer – Part 4.
This is the result.
There is a bit of jitter on the analog pot, but that is only because I’m using the original fairly simplified algorithm to detect changes. If I was fussed about it, I’d reuse the averaging class from Arduino MIDI Atari Paddles. And to be honest, a capacitor on the pot would probably go quite a long way too…
As a test, I also powered the device from the Grove UART port connecting it as follows:
- Expander GND – GND Synth
- Expander 3V3 – 5V IN Synth
- Expander TX – RX/D6 Synth
- Expander RX – N/C
And this all worked fine. So I think a Grove to Grove lead would work fine if I had access to the Synth’s Grove port.
This does mean that the exact same code can work with the M5 Synth module using a Grove to Grove lead. The downside of this, even though it is a lot simpler in connectivity terms, is that there is now external audio out like there is on the XIAO Synth.
For completeness the same code can be used with the XIAO ESP32-C3 and serial MIDI, see the photo at the start of this blog.
To turn off all USB handling in the code, the following must be commented out:
//#define HAS_USB
//#define SER_TO_USB
//#define MIDI_USB_PCCC
For other parts of the code, the Arduino abstraction for A0 maps over to the ESP32-C3 fine. The only thing to watch out for is the increased analog resolution from 10 to 12 bits, but a call to analogReadResolution(10) drops that back to the expected 10 bits.
Oh and the Serial port to use is different:
- XIAO SAMD21: Serial1
- XIAO ESP32-C3: Serial0
Closing Thoughts
If I can be bothered, it would be nice to actually display the General MIDI voice name on the display. The SAM2695 also has its MT-32 mode, so having some means of selecting that might be interesting too.
And so far I’ve largely only messed about with driving it on a single MIDI channel, so there is a lot more that could be done there.
Kevin
#controlChange #esp32c3 #midi #programChange #SAM2695 #samd21 #usbMidi #xiao