Having listed out a few Arduino Audio and MIDI Frameworks and having spent some time recently with the XIAO SAMD21, I thought I'd take a closer look at the ML Synth Tools XIAO synth.
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.
ML SAMD21 Mini Synth
One of the demonstrations for ML_Synth_Tools is the SAMD21 Simple Synth which will run on my XIAO: https://github.com/marcel-licence/samd21_mini_synth.
To install the library requires the following:
- Download the ZIP from GitHub for ML_SynthTools, expand and copy to the Arduino Libraries folder.
- Download the ZIP from GitHub for samd21_mini_synth, expand, rename the innermost samd21_mini_synth-main directory to samd21_mini_synth, and move it to the Arduino sketch (src) folder.
- Open the samd21_mini_synth.ino file, set board to the Seeed XIAO SAMD21 and perform a test build. It should all build ok at this point.
There is a video tutorial on setting everything up here: https://www.youtube.com/watch?v=ZNxGCB-d68g, although this is geared up for the ESP32 version of the synth.
To use the library, there are two configuration steps really. First, the file config.h contains some high-level configuration options. By default it is configured for serial MIDI, but you can add USB MIDI host or device functionality here.
The library also comes pre-built for use with Marcel's Edirol MIDI controller, so some MIDI configuration is required. This happens in the z_config.ino file from the examples. The two key structures to be setup are defined in ML_SynthTools/midi_interface.h.
MIDI controllers are defined in midiControllerMapping which is a series of entries in the format:
- MIDI channel (I believe it is stored as 0-15, I don't know if it supports OMNI channel).
- MIDI CC number (0 to 127).
- Name for the control as a text string.
- MIDI callback function.
- Parameter value handling callback function.
- User data for the parameter callback function.
A second structure, midiMapping_s, is also used that defines the handlers for various MIDI messages with entries for the following:
- Raw messages.
- Note on.
- Note off.
- Pitch bend.
- Modulation wheel.
- Program change.
- Real-time messages.
- Song position.
- MIDI controller map.
- MIDI controller map size (number of entries).
This is the MIDI Configuration I used (z_config.ino):
struct midiControllerMapping sdempMapping[] = { { 0, 0x10, "R1", NULL, Synth_SetParam, SYNTH_PARAM_WAVEFORM_1}, { 0, 0x11, "R2", NULL, Synth_SetParam, SYNTH_PARAM_WAVEFORM_2}, { 0, 0x12, "R3", NULL, Synth_SetParam, SYNTH_PARAM_MODULATION_PITCH}, { 0, 0x13, "R4", NULL, Synth_SetParam, SYNTH_PARAM_MODULATION_SPEED}, { 0, 0x14, "R5", NULL, Synth_SetParam, SYNTH_PARAM_PITCH_BEND_RANGE}, { 0, 0x15, "R7", NULL, Delay_SetFeedback, 0}, { 0, 0x16, "R8", NULL, Delay_SetLevel, 0}, { 0, 0x17, "H1", NULL, Synth_ModulationWheel, 0}, }; struct midiMapping_s midiMapping = { NULL, Synth_NoteOn, Synth_NoteOff, Synth_PitchBend, Synth_ModulationWheel, sdempMapping, sizeof(sdempMapping) / sizeof(sdempMapping[0]), }; I used the config (config.h) largely "as is" but had to add the following parameter:
#define MIDI_SERIAL1_BAUDRATE 31250
without this, the midi_interface.h defaults to a MIDI baud rate of 115200 for some reason.
I used this with my Arduino MIDI Multi Pot Controller to give me the 8 MIDI CC pots 0x10-0x17 as required above. But the way the controls work wasn't particularly intuitive to me. In particular, I believe there is a bug in the pitch bend setting, as in mini_synth, it looks to me that both the modulation pitch and pitch bend parameters set the modulation pitch...
case SYNTH_PARAM_PITCH_BEND_RANGE: chControl[actCh].modulation.pitch = (value) * MODULATION_PITCH_MAX; break; case SYNTH_PARAM_MODULATION_PITCH: chControl[actCh].modulation.pitch = (value) * MODULATION_PITCH_MAX; break;
The delay effect sounded pretty neat, but it took a while to get a feel for how the modulation effect was working. In particular, I didn't get much of a difference in modulation waveform. Also, setting the modulation pitch to zero seems to stop all sound production regardless of modulation speed or level settings.
It is interesting to note that both the sine and triangle waves, when playing chords, will significantly increase the amplitude of the output signal.
Hardware
I've installed this onto my XIAO MIDI Proto PCB and have wired up the DAC output (from the pad erroneously labelled "6") via coupling capacitors to a TRS socket for audio output.

I'm controlling it using my XIAO MIDI Synth Board PCB running my Arduino MIDI Multi Pot Controller code. The synth parameters are thus mapped onto the pots as follows:

Closing Thoughts
The synth itself sounds pretty good and there is a lot going on with this toolkit that would probably reward the time it takes to get to know it. But there are a few things that hold me back at the moment:
- The default setup is all geared up for Marcel's specific MIDI controller, so it takes a while to work out what MIDI functions are available for whatever application is being built and then map that onto your own device.
- There are no options for localised control so everything has to be over MIDI meaning that the above has to happen before any of the sample applications can be tried.
- I think I've managed to get the SAMD mini synth into a mess every now and again, requiring it needing a reset to wake up again, but I'm not quite sure how I've managed it.
- I've not found any documentation of things like the MIDI functions or the synth controls anywhere so far, apart from reading the code.
- ... and certain key parts of the code are unavailable as source.
I guess for me personally, this will take a fair bit of time getting to grips with what the possibilities are, but I'm reluctant to take that time due to the fact that it isn't fully open source (at the moment at least), yet it also hasn't got the level of documentation required to be a "product" either.
I'm also not totally sold on the MIDI implementation - having to read the code each time to work out how to set up the MIDI controllers to give access to all the parameters. I'll have to attempt to develop a standard mapping for one of my own MIDI controllers to make life easier, seeing as the synth itself doesn't have a mapping of its own as such. This is probably something for my Arduino MIDI Multi MUX Controller.
Also, unless I'm missing something, it doesn't seem to support MIDI OMNI channel mode, and I can't see anywhere where it will handle a received SysEx message, so I'm wondering if there is still development on the MIDI side to be done.
Having said all that, the idea of significant polyphony is definitely appealing, so I might persevere a little more yet. The sample videos of Marcel's excellent playing certainly show off the potential of the code at its best far more than my crummy demo video!
The XIAO SAMD21 is probably the least performant of all the architectures supported by the Synth Library, especially this "chiptune synth" application, so I also need to have a go with some of the others. In particular the "organ" demonstration is the one Marcel uses to show off the toolkit.
This might also be my cue to properly start playing with an ESP32!
Kevin

No comments:
Post a Comment