XIAO ESP32-C3 MIDI Synthesizer – Part 3

So, now that the basics are out of the way I’m going to dive into the specifics of the Dream SAM2695 chip itself.

  • 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:

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

The Dream SAM2695

I first encountered this device on a breakout board several years ago, called a “GM Mini Module”. Various tutorials at the time showed how to hook this up to an Arduino. For example, my specific module had the following suggested application:

The breakout was essentially just the SAM2695 with an additional MIDI IN circuit and DIN socket.

At the time it was a component of the “fluxamasynth” – an Arduino shield containing the chip. Whilst the shield is now discontinued, a number of resources still remain online about it: https://github.com/fluxly/Fluxamasynth

Since then there have been a number of modules released that use this neat synth chip, probably the most recognisable of which is perhaps the M5 MDI Synth: https://shop.m5stack.com/products/midi-synthesizer-unit-sam2695

There is also a M5 module with built-in MIDI DIN socket too.

This latest XIAO device follows in the footsteps of all these other variations but adds the microcontroller, and ESP32-C3, to make a complete “system”.

I happen to have three of these devices – the original Dream “GM mini module”, M5 synth and the XIAO, so I’ll do a post about them together at some point, but the all work in essentially the same way.

This series of posts is mostly taking a detailed look at the XIAO MIDI Synthesizer, but the following post shows how to use a XIAO SAMD21 to talk to the M5 Stack Synth: XIAO USB Device to Serial MIDI Converter.

The datasheet for the SAM2695 describes its capabilities:

  • MIDI control processor, serial and parallel interface
  • Synthesis, General MIDI wavetable implementation
  • General MIDI compatible effects: reverb + chorus
  • Spatial Effect
  • 4-band stereo equalizer
  • Stereo DAC. DR: 86dB typ, THD+N: -75dB typ
  • Mike input. DR: 86dB typ, THD+N: -75dB typ
  • Mike echo
  • 64-voice polyphony (without effects)
  • 38-voice polyphony + effects
  • On-chip CleanWave™ wavetable data, firmware, RAM delay lines
  • Audio stereo line output

Interestingly it supports a parallel or serial MIDI access. But using serial is by far the easiest as it can link up directly to another microcontroller’s UART or an opto-isolator of a standard MIDI IN circuit.

The GM Sound Engine

The SAM2695 has two complete instrument banks and a drum set. The banks are as follows:

  • CH1-9,11-16: BANKSEL 0: Full General MIDI Sound set
  • CH1-9,11-16: BANKSEL 127: MT-32 Compatible Sound set
  • CH10: General MIDI Drum Sound set:
    • Program 1: Normal kit, notes 35-81
    • Program 17: “Power Set”, Normal set + note 38 only
    • Program 41: “Brush”, Normal set + notes 35-40 changed
    • Program 49: “Orchestra”, Normal set + notes 27-30, 38-53, 88 changed
    • Program 128: “CM 64/32 Partial”, range of effects and things – MT-32 like

The device also supports effects and an equaliser. All additional controls are configured using either MIDI NRPN or SysEx message. And there are a lot of messages defined in the datasheet!

There are also a number of control messages which apparently have to be sent over the parallel data interface.

But what I am most interested in is the MIDI implementation for the common range of MIDI messages, the most useful of which (to me) are listed below.

MIDI MessageHEXNotesCompatibility
Note On9n kk vvMIDI
Note Off8n kk vvMIDI
Pitch BendEn ll hh14-bit pitch bend data hhllGM
Program ChangeCn ppGM/GS
Channel AftertouchDn vvMIDI
Control ChangeBn cc ddSee table below for specific control change messages
RPNBn 65 …Registered parameter numbers (see datasheet)MIDI/GM
NRPNBn 63 …Non-registered parameter numbers (see datasheet)GS/DREAM
SysExF0 7E 7F 09 01 F7MIDI ResetGM
SysExF0 7F 7F 04 01 00 vv F7Master volumeGM
SysExF0 41 00 42 12 … F7Range of GS specific SysEx messages (see datasheet)GS
SysExF0 00 20 00 00 … F7Dream specific “port write” commandDREAM

MIDI Control Change Messages

CommandHEXDefaults / Notes
Bank SelectBn 00 cc0
ModulationBn 01 cc0 (Rate/Depth set via SysEx)
Portamento TimeBn 05 cc
Channel VolumeBn 07 cc100
PanBn 0A cc64
ExpressionBn 0B cc127
Sustain PedalBn 40 cc0 (>63 ON)
PortamentoBn 41 cc0 (>63 ON)
Sostenuto PedalBn 42 cc0 (>63 ON)
Soft PedalBn 43 cc0 (>63 ON)
ReverbBn 50 vv4 (0..7 = reverb effects)
ChorusBn 51 vv2 (0..7 = chorus effects)
Reverb SendBn 5B vv
Chorus SendBn 5D vv
All Sound OffBn 78 00
Reset All ControllersBn 79 00
All Notes OffBn 7B 00
Mono OnBn 7E 00
Poly OnBn 7F 00Defaults to poly on power up
CC1Bn cc vvcc=00..5F, Fn set by SysEx
CC2Bn cc vvcc=00..5F, Fn set by SysEx

To be honest, I’m not sure I quite understand those last two, but that seems to be what it is saying in the datasheet…

There are a /lot/ of parameters accessible over NRPN or SysEx relating to the routing of signals in the device, the effects and the equaliser. At this point I’m just experimenting with the basics above.

Any of the MIDI interfaces allows me to test it out, but using a XIAO SAMD21 in USB MIDI device mode is the easiest as I can just plug it into a computer and fire up MIDIOx and start messing around with some of the above.

Closing Thoughts

There is a lot to the SAM2695, so I can see why it has captured interest once again after a few years seeming almost forgotten.

It would be nice to build some kind of knob-based interface that supports many of the parameters in the synth, but I guess the major application is meant to be for when some kind of “compatible” sound card is required “off the shelf”. For that, it would appear that the SAM2695 can be a General MIDI Synth, a Roland “General Sound” (GS) Synth or even a Roland MT-32.

Not bad for a small, relatively easily integrated component!

Kevin

Leave a comment