4 channel polyphonic tone generator (blue pill)

Post your cool example code here.
stevestrong
Posts: 1829
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

4 channel polyphonic tone generator (blue pill)

Post by stevestrong » Sat Nov 11, 2017 8:22 pm

Hi,

just for fun:

(the real sound is much better than on the video :mrgreen: )

It is exclusively timer based, so all 4 timers are reserved, configurable channel for each timer in part.
Accurate timing taken from systick.

Source available here: https://github.com/stevstrong/STM32-Tim ... ree/master
Attachments
STM32_TonePlayer.ino.bin.txt
(24.67 KiB) Downloaded 10 times

User avatar
RogerClark
Posts: 7482
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: 4 channel poliphonic tone generator (blue pill)

Post by RogerClark » Sat Nov 11, 2017 8:41 pm

Thanks Steve..

Can you post a link to the speakers... It looks like they are piezo , but are much bigger than I have.


BTW.

I had a crazy idea because I have Indian Myna birds, in the garden , which are a pest and are noisy.
https://en.wikipedia.org/wiki/Common_myna

They mimic the sounds of other birds, so... I thought perhaps if I put BluePills in the trees, which play some simple tune, then perhaps rather than making the sounds of other birds, they may start makimg the sound of these tunes.

The Wallace and Grommit theme tune was going to be the song I use, e.g. just the first 8 notes

It would be a laugh if all the birds started to sing that at as one of their songs ;-)

stevestrong
Posts: 1829
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: 4 channel polyphonic tone generator (blue pill)

Post by stevestrong » Sat Nov 11, 2017 8:48 pm

These are the speakers, they are magnetic, not piezo: https://www.aliexpress.com/item/4PCS-Sp ... 00464.html
Only that the sound of the camera is really miserable.
Yea, it would be fun to learn the birds to sing Mario themes :)

User avatar
RogerClark
Posts: 7482
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: 4 channel polyphonic tone generator (blue pill)

Post by RogerClark » Sat Nov 11, 2017 9:01 pm

Thanks for the link.

PS. did you use resistors in series with the speakers?

stevestrong
Posts: 1829
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: 4 channel polyphonic tone generator (blue pill)

Post by stevestrong » Sat Nov 11, 2017 9:05 pm

nope, the chip is heating up a bit during playing, but it is still working. 8-)
indestructible...

User avatar
RogerClark
Posts: 7482
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: 4 channel polyphonic tone generator (blue pill)

Post by RogerClark » Sat Nov 11, 2017 10:18 pm

stevestrong wrote:
Sat Nov 11, 2017 9:05 pm
nope, the chip is heating up a bit during playing, but it is still working. 8-)
indestructible...
LOL

User avatar
ahull
Posts: 1657
Joined: Mon Apr 27, 2015 11:04 pm
Location: Sunny Scotland
Contact:

Re: 4 channel polyphonic tone generator (blue pill)

Post by ahull » Sat Nov 11, 2017 11:52 pm

Nice... but if you want it a little louder, fire the output(s) though a small transistor
2n2222_amp.jpeg
2n2222_amp.jpeg (25.01 KiB) Viewed 190 times
(+5V would probably work just as well as +9V, and pretty much any similar transistor would replace the 2N2222, and there are almost as many many variations on this circuit as there are stars in the sky)
- Andy Hull -

stevestrong
Posts: 1829
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: 4 channel polyphonic tone generator (blue pill)

Post by stevestrong » Sun Nov 12, 2017 2:09 pm

The sound level is OK, just that the camera mic could not reproduce it appropriately.

Anyway, I forgot to mention that the sw I posted needs this patch: https://github.com/stevstrong/Arduino_S ... 77705acec9
This clears the IRQ flag before enabling the respective IRQ for a timer channel.

ChrisMicro
Posts: 308
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: 4 channel polyphonic tone generator (blue pill)

Post by ChrisMicro » Sun Nov 12, 2017 4:56 pm

Nice :D

Did you try this one.
It's a five channel synth ;-)

stevestrong
Posts: 1829
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: 4 channel polyphonic tone generator (blue pill)

Post by stevestrong » Mon Nov 13, 2017 8:31 am

No, I did not try it.
But does it have only 1 output?
How does it the 5 channel synth?

Post Reply