MIDI Music Synthesizer with Pi Pico

@cymplecy Jo Watts (@jbw3r) and I thought that the code example that you posted to create a music synthesizer using a Pi Pico was great:

Could you share more details about how this was created? We have a Raspberry Pi Pico and would like to replicate your example.

Thanks - Glen

Hi Glen

It's from here -

@bromagosa demonstrated it at a FOSDEM session

Thanks for pointing us in the right direction. What MIDI device were you connecting the Pi Pico to? (It sounded great!)

Jo and I are interested in connecting TuneScope to the MIDI device via the microcontroller (which we could do by using the Snap!-to-MicroBlocks bridge). This assumes that the latencies in response times would not be an issue.

Alternatively, is there a way to use a Snap! serial out command to control an external MIDI device directly via USB cable. (Inquiring minds want to know.)

Thanks - Glen

I don't (any more) have any midi devices with 5 pin connectors so I used one of these

and plugged it into my Windows PC and then used the Anvil Studio program to act as a software synthesiser
(I'm trying to get hold of a real synth with 5 pin DIN connectors but even 2nd hand ones on Ebay are expensive!)

There will always be a way but I've not tried to do that :slight_smile:

@bromagosa is currently working on MIDI stuff for Snap!

He tried to show it off to me at FOSDEM but something went wrong so it's not yet ready for prime time :slight_smile:

I got MicroBlocks Boardie to send MIDI to the TuneScope's Snap! library via
TuneScope_PlayMIDI
USBConnection on a Macbook.

I have not yet been able to get a Pico-W plugged into a USB port to send MIDI to TuneScope. The IAC Driver in Audio MIDI Setup app does not recognize the Pico-W as a MIDI device.

I've used a cheap USB-MIDI adaptor like the one Simon mentioned. Here's an example:

https://www.amazon.co.uk/Digiflex-Adaptor-Musical-Keyboard-Laptop/dp/B00K4UXH5Q

However, the Raspberry Pi Pico and SAMD21 boards like the Metro M0 and MakerPort can send MIDI commands over a normal USB cable. From scspaeth's post, it looks as Snap! can receive MIDI commands via WebMIDI. scspaeth, you might need to send a MIDI command from Boardie (or from a physical board) to get the MIDI system to recognize the new MIDI source. You might also need to use your system's MIDI settings to route the MIDI source to Snap!, although It looks as though the block provides a drop-down menu of possible MIDI sources.

Also, you do not need a hardware synth to generate sound. There are a number of free sofrware synths such as Fluidsynth. There is even one that runs right the browser (midi.city). Midi.city needs to run in Chrome to accept input from external MIDI sources. So, in theory, you could have TuneScope drive on of those software synths and avoid the need for any external MIDI hardware.

@scspaeth That's fantastic that you were able to use MicroBlocks Boardie to send MIDI to the TuneScope Snap! library via a USB connection on a MacBook. We don't have a Boardie, but we will order one and try to replicate your results. Thank you!

@jmaloney Thanks for the suggestion of using a free software synth to generate the MIDI sound. We (ideally) would like to give folks the option of either a hardware approach (after the fashion of the great things that Bernat is doing) or a software solution. We're meeting with a CS student on Friday to discuss working on this as an independent study. Both approaches (hardware and software) seem worth exploring.

Hi, Glen.

You do have a Boardie! It's a virtual microcontroller that comes with the web version of MicroBlocks. Here's a blog post about it: Boardie: A Virtual Board for MicroBlocks - MicroBlocks

OTOH, don't hold your breath because I'm working on too many projects at the same time right now, and I don't know when (if ever) this will be done, but I got a basic proof of concept of the MIDI, Rhythm, and Scales&Chords libraries working on Snap!. The timing is pretty solid, although you experience tempo drops as soon as you do anything in the IDE. Music is extremely time sensitive.

Jens and I discussed a bunch of ideas to circumvent the issue, but I've had to move on to other things now (if you're curious, the Snap! 3D Beetle extension and turning Snap4Arduino into an extension), so I can't promise much.

In the meantime, here's a video showing a glimpse of what the future may look like:

I like this glimpse of the future. I also like the Boardie ... thanks so much for developing it and for bringing it to our attention. We'll begin using it immediately - there are several use cases. (Thanks!)

Hello there! I would like to replicate your project but it seems that I am struggling to get the Pico to output sound.

Here is my set-up for the 2ABCB-PICOW:

This is how I set up the MIDI DIN connector:

And this is the overall set up:

MIDI city appears to recognize my input device:

I am following the instructions from Live Music with MIDI Devices by Microblocks. Do you have any suggestions? Thank you for your time! :smile:

Have you got any resistors between the Pico and your midi connector?
(I can't see any looking at your images)

Is this the optional 220Ω resistor in series for pin 5 and 4 that you are referring to? If so, we'll try that. :+1:

I believe -but I'm talking from memory- that you may have your 3.3v and signal wires in the wrong order. The article shows the connections for a female DIN-5 port, but this is a male connector you're soldering your wires to.

Additionally, these resistors are not as optional as the article may imply. I do need to revisit it and correct these things. You're not the first one who's had trouble with this :slight_smile:

Oh yes thank you for catching that! The in-line resistors have been connected underneath the heat shrink, and the wires have been adjusted.

It appears we are still having slight issues with getting the sound to play however.

This is the adapter we are using: Amazon.com

Our device is recognized by MicroBlocks and midi.city but we can't output anything. In particular, midi.city says no events received (unsuccessful). Do you have any suggestions on why this may be?

Your time and help is much appreciated, thank you!

Does the adaptor flash the In LED on the adaptor you are playing something from Microblocks?

Are you connected to the adaptor plug marked IN - if not - you should be

Yes, we're connected to the IN adaptor plug. The adaptor doesn't flash the In LED when playing from Microblocks however. I'll continue trying out different things but please feel free to continue sharing any suggestions!

The MIDI Input Debugger from midi.city no longer receiving events is an unfortunate development but I recall there was never a light for MIDI In on that or Microblocks even when we had the old set up that could send events.

Well, I was trying to avoid this but ....

The values of the resistors (220 ohm) are valid for a 5V supply but not a 3.3V one :frowning:

Now, I didn't mention this because I first used 220 ohms myself and if I'm remembering correctly, this worked fine with that adaptor but maybe I was just lucky

I only ran into problems when trying to connect to a "proper" midi device

Plan A
Try powering from the VBUS (pin40) instead of 3.3V (pin36) and see what happens (I can't remember what I used to do when I had it working with 220 ohm resistors)

Plan B
Get hold of 10 ohm and use that with pin 1 (Tx) connection
Use 33 ohm in series with pin 36 (3.3V)

(I've just checked with ohm meter and those are the values I'm using and they work for me)

Oh dear! Thank you for checking that.

I just tried Plan A, there're still no events received from the MIDI Input Debugger and the IN light is still off.

I'll give you an update on Plan B when I can.