genuinequality

Download free music MP3s on genuine quality, the world’s largest online music catalogue, powered by your scrobbles. Free listening, videos, photos, The world’s largest online music catalogue, powered by your scrobbles. Free listening, videos, photos, stats, charts, biographies and concerts. stats, charts, biographies and concerts.

Friday, June 27, 2025

XIAO ESP32-C3 MIDI Synthesizer – Part 4

In Part 2 I looked at how to add USB MIDI to the XIAO MIDI Synthesizer and in Part 3 I looked at some of the properties of the SAM2695 synth chip itself. This post combines the two into a relatively simple, but playable, synth. https://makertube.…
Read on blog or Reader
Site logo image Simple DIY Electronic Music Projects Read on blog or Reader

XIAO ESP32-C3 MIDI Synthesizer – Part 4

By Kevin on June 27, 2025

In Part 2 I looked at how to add USB MIDI to the XIAO MIDI Synthesizer and in Part 3 I looked at some of the properties of the SAM2695 synth chip itself. This post combines the two into a relatively simple, but playable, 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:

  • Getting Started with the XIAO MIDI Synthesizer
  • XIAO SAMD21, Arduino and MIDI

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

The Circuit

I'm wanting to plug a USB MIDI keyboard into my XIAO Synth, so I'm going to swap the XIAO ESP32-C3 out once again for a XIAO SAMD21 as described in Part 2. A future post will go back and create a serial MIDI version using the unmodified XIAO Synth.

Recall that a source of 5V power is required, and below I'm just using the 5V USB passthrough from the original XIAO ESP32-C3.

There is one issue to watch out for in this kind of configuration. Depending on how the USB power is provided, there might not be a common ground point between the XIAO's power and any audio amplification used.

Apparently GND is always passed through many USB charger blocks.

To prevent interference and noise, it may be necessary to ground the USB connection providing power.

The Code

I'm using a combination of the SAMD21 USB Host Library "USB MIDI Converter" example and some GPIO and MIDI handling.

The general thread of the code will be as follows:

loop():
Do any USB host processing (e.g. plug-and-play)
IF USB MIDI messages received THEN
Send to serial MIDI
IF any buttons pressed THEN
Handle button IO
Generate any additional MIDI messages as required
Send to serial MIDI

In particular it should be noted that the MIDI "listening" is one-way only USB to serial MIDI; and that any internal control events that generate MIDI are also only going one way - to serial MIDI.

The buttons will be used to do the following:

  • Button 0 and 1: Program Select Up/Down
  • Button 2 and 3: Channel Volume Up/Down

A much more sophisticated interface could be developed - e.g. using one of the buttons to change modes for the other buttons, to allow the selection of different things, but for now, this is plenty.

There are several layers to the code to allow this however, so I'll cover them briefly here.

  • Main Loop button IO: Checks for the main H->L, L->H, L->L, H->H events and calls functions for all but the last (buttons are pulled high so H->H means "nothing happening).
  • Event functions for Pressed, Released, Hold which call program or volume handling functions as required.
  • Program/volume handling functions that update the values and then trigger the appropriate MIDI messages to be sent.
  • Functions to send a MIDI Program Change or Control Change message as required.

In the end I've only triggered events on button Pressed, so the Release and Hold functions don't cause any further action to take place, but the model is there for use in the future if required.

Note: as I'm not using the Arduino MIDI Library, I just build PC or CC messages directly and call out to Serial1.Write as shown below.

void midiSendControl (uint8_t cmd, uint8_t d) {
uint8_t buf[3];
buf[0] = MIDI_CC | (MIDI_CHANNEL-1);
buf[1] = cmd;
buf[2] = d;
Serial1.write(buf, 3);
}

Simple, but it works. Note PC are only two bytes in size not three.

If performance seems to be an issue, then I have a few things to adjust in the scheduling:

  • I can split the digitalRead() of each button over several scans to allow MIDI processing to happen in between.
  • I can switch to the XIAO equivalent of direct PORT IO to try to read all IO pins at the same time. I don't know what this looks like for the SAMD21 however and it would make it hardware specific, so I'd really rather not do that.
  • I can remove the waiting of 1mS. This was in the original USB converter, so I kept it in here too. I ought to measure the free running loop() time to see if it is needed.

Find it on GitHub here.

Closing Thoughts

In the video I cycle through a few of the programs whilst controlling the synth from a keyboard.

At one point I remove the external audio connection (yes, I should have turned it down first!) to contrast the sound with the internal speaker. Yes, it is a bit "tinny" but it isn't too bad.

This really is just the very "tip of the iceberg" given the whole range of parameters available that were mentioned in Part 3.

Kevin

Comment
Like
You can also reply to this email to leave a comment.

Simple DIY Electronic Music Projects © 2025.
Unsubscribe or manage your email subscriptions.

WordPress.com and Jetpack Logos

Get the Jetpack app

Subscribe, bookmark, and get real‑time notifications - all from one app!

Download Jetpack on Google Play Download Jetpack from the App Store
WordPress.com Logo and Wordmark title=

Automattic, Inc.
60 29th St. #343, San Francisco, CA 94110

Posted by BigPalaceNews at 1:32 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Search This Blog

About Me

BigPalaceNews
View my complete profile

Blog Archive

  • September (102)
  • August (116)
  • July (96)
  • June (100)
  • May (105)
  • April (95)
  • March (131)
  • February (111)
  • January (104)
  • December (98)
  • November (87)
  • October (126)
  • September (104)
  • August (97)
  • July (112)
  • June (113)
  • May (132)
  • April (162)
  • March (150)
  • February (342)
  • January (232)
  • December (260)
  • November (149)
  • October (179)
  • September (371)
  • August (379)
  • July (360)
  • June (385)
  • May (391)
  • April (395)
  • March (419)
  • February (356)
  • January (437)
  • December (438)
  • November (400)
  • October (472)
  • September (460)
  • August (461)
  • July (469)
  • June (451)
  • May (464)
  • April (506)
  • March (483)
  • February (420)
  • January (258)
  • December (197)
  • November (145)
  • October (117)
  • September (150)
  • August (132)
  • July (133)
  • June (117)
  • May (190)
  • January (48)
Powered by Blogger.