SAM2965 Music Synthesizer

This strand is for discussion of the SAM2695 music synthesizer chip. John Maloney has developed a MicroBlocks library that can be used with this synthesizer:

The music synthesizer chip is currently about $15 and is relatively easy to use with the MicroBlocks MIDI library (which I think that Bernat helped develop). Here's the data sheet for the synthesizer chip:

Sam2965 Data Sheet

We are currently using the music synthesizer with a MicroBlocks and a micro:bit. Our eventual goal is to drive the music synthesizer directly from Snap! John believes that this could be done using a USB to serial adapter, using the Snap! web serial command in the Chrome or Edge browser.

Tristar10, an electrical engineering student, is taking the lead on this project. We’ll use this strand to report progress or issues that we counter. Here's an image of the chip connected to a micro:bit.


I tried with this setup with the wiring diagram provided and this is the code that I provided. It refused to make sound. I tried with my external audio and it still doesn't work. I believe pinouts are configured correctly since it has power supply and a ground so the tx must be correct. I will investigate more into the issue.

A bunch of issues with your code.

First of all, you're setting the MIDI output to USB. Are you using a USB synth? From Glen's picture, I don't think you are.

Second, are you using a MIDI sequencer? If not, then MIDI start playing makes no difference. Again, from Glen's picture, it looks like you're using the M5 synth, not a sequencer.

I suggest you read up on the MIDI with MicroBlocks article in our learn site to get a sense of how the library works:

Additionally, asking on the Snap! forum is fine, but if you're using MicroBlocks you may find more users and answers in our Discord server: MicroBlocks

Hi,

First of all, I would like to thank you for your reply and advice. I read through the whole article before I started working. Quoting from the link that both you and Glen provided, " If your board supports it, you can interface it to a USB MIDI device. Just select USB in the

block and click on it." In this case, we are using a microcontroller to power through a MIDI device, and this is the only option available when you have everything set-up. ** EDIT: after playing around I found out you can enter a number with this block instead of using the dropdown menu. Setting that to the correct TX pin makes it working. Thank you for your insight. **

To address your second question, the reason why I have the block MIDI start playing is because it is not making any sound at all, so I am just playing with all the different blocks trying to make it work.

Finally, if you are not familiar with Glen, he is teaching a course in a University and this thread is used to keep track of the progress and answer questions. In this case, I am directly asking to him. Quoting from his posts: "We are currently using the music synthesizer with a MicroBlocks and a micro:bit. Our eventual goal is to drive the music synthesizer directly from Snap!" So the propose of this thread is to make sure we keep track of this whole progress, finally and hopefully we can use this device paired with Glen's music library for Snap! to provide students with a better experience with Snap!

Hope this answers your questions :slight_smile: Peace!


I tried to make a drum beat using the play MIDI drum function, and it appears that it can use two of these functions running the same time to produce two tracks. I can show this in today's class.
It is worth to mention that despite this is running offline, it still has inconsistency issues. Sometimes some of the notes are not playing. I will take a look at what might be the issue

@tristar10

Regarding @bromagosa's point about the USB, even though you are connected to the micro:bit via USB, the micro:bit itself can't process MIDI commands over USB. I believe you would only select the USB connection if you were connecting directly to a synth that has USB MIDI input. Instead, try setting the MIDI to play over the pin number that the synth module is connected to on the BitBoard. In @glenbull's photo, this is Pin 13. That's how I got it to work before handing it off to you. The other thing you'll need to do is make sure the wires coming out of the SAM 2692 are properly connected, voltage to voltage, ground to ground, and signal to signal. Since we're not sending a signal from the synth module back to the board, you don't need to connect the white transfer wire.

I wasn't aware that the MicroBlocks has a Discord channel, and I know Glen doesn't use Discord, so we couldn't previously recommend that. This thread is a good place to post updates, but if we have more technical questions, it might be good to follow Bernat's recommendation and join the Discord.

Let me know if the above information solves the problem. I just got more SAM 2692s yesterday, so I'll connect one shortly and see if I can replicate the problem and solution.

Hi Jo,
Thanks for replying. I've updated that on my previous thread. Please check it out. I did not know you can type in the number until I tried.


During this week's project experimentation, I tried to make more elements into the drum beat that I made using MicroBlocks. I have the following findings:

  1. The "select MIDI instrument" block is not working. It could be that I miss-used, but changing the instrument assigned to a given channel seems to have no effect, as the instruments are all left in default piano mode.
  2. Once the signal is piled up, the system becomes inevitably slow. I am surprised that the threshold is actually lower than the one in snap. My guess is the synthesizer module is too small in computing power to handle bigger projects. I am not expecting much though, since we've all mentioned that this is an extremely cheap synth. With the microcontroller removed and just using serial, I don't think there is going to be a difference. On the flip side, there are no latency issues which is neat, but the student might find themselves trying a couple of times before they can manage to play the whole part using the synth.
  3. Expanding the thought, even though I am not completely sure, but there might be a way to play midi directly with our laptops in an easier way without using DAWs or assistance, or even other websites. The only concern is snap seems not having APIs to contact with other websites. We can discuss this more in class tomorrow.

I know this is a report meant for Glen, but I really can't help myself, sorry! I need to reiterate that there's an article out there that shows the proper way to use these libraries. These über long strings of almost identical blocks should always make you think there must be a better way to do what you're trying to do.

Thinking of music in terms of milliseconds can drive you crazy very soon, too. Again, look at the article for a better way to handle tempo, durations and beats.

As per your three points:

The select instrument block does work fine, but you don't seem to be using different instruments or different channels at all, at least according to your screenshot. The article explains how that works, too.

I've done live sessions with this exact module. The module is not the problem, as isn't the microcontroller or the software. Please, pretty please, look at the article and learn how to use the libraries :pray:

From said article: «One of your options would be to use a software synthesizer -such as FluidSynth-, which receives MIDI commands via the same USB cable that MicroBlocks is using to communicate to the board.»

But now I'm confused. You're talking about Snap!, not MicroBlocks? In that case, you may be interested in my test WebMIDI project for Snap!. It's just a proof of concept and it doesn't handle time as precisely as MicroBlocks does -since Snap! has to share processor time with many other processes, unlike a microcontroller-, but I could share it with you if you're interested.

Cheers.

From what I see, Romagosa isn't trying to be disrespectful. He's trying to hand out constructive criticism. He's not suggesting that you haven't looked at the article, rather that you haven't seen enough of it. He is glad to help you out, but it kind of looks like you're denying it. I'm just going off of what I've recently read. But if you are correct, then I will keep calm and accept it.

Hi, Mr. Student.

I understand you're angry with the World. I am too, but I don't take it out on random people online, especially when they're trying to help.

I assumed you didn't read the article because you aren't using any of the blocks from the Rhythm or Scales & Chords libraries, which solve most of your issues with timing and synchrony. You're chocking the poor module with too many serial messages at the same time and some of them are interfering with each other. From the screenshot, you're also asking for instrument changes for the same channel at the same time. That will cause some messages to get garbled up.

The fact that I've been in many workshops with these exact modules with lots of students and everyone managed to switch instruments made me think that the issue is not with the MIDI library or the module, but with some missinterpretarion from your side. That's what I was trying to help with.

But if that's how you respond when offered help from the very people who've built the tools you're using, I guess it's no wonder you're learning on your own! :slight_smile:

If you still want help, I can point to the parts of the article that will get you answers. Or you could share the code -not just a screenshot- so we can review it and send you corrections. You could also join our Discord where many others can help.

Good luck, and take that anger out on a real drum kit. That's how punk was born :slight_smile:

Here's my last reply: I've tried that library by using the sample code per my last reply. You are right I should include the whole thing in the screenshot. However, I have established with Jo that it is not a problem with my code but something else. Also as I said, I know you are helping, but I don't like how you had "constructive criticism" that incorporated irony. Even if you don't think so, I feel like that. Anyways, it comes down to a personal thing, so in other words, it's just our vibe does not match, which is no big deal. Either way, I wish you have a good rest of your day.