micropython icon indicating copy to clipboard operation
micropython copied to clipboard

Music on multiple pins

Open jrmhaig opened this issue 10 years ago • 7 comments

This is probably going way off the beaten track here and maybe the answer is "it probably cannot be done".

I would like to play music on multiple pins but if I try:

music.play('a:30', microbit.pin0)
music.play('b:30', microbit.pin1)

it plays the second note on both pins. If I use music.pitch instead of music.play (which is what I really want because I'm being even more contrary) the note turns into a distorted screech.

jrmhaig avatar Dec 19 '15 23:12 jrmhaig

The simple answer is "it probably cannot be done". I seem to recollect that polyphony (two or more notes at once) was either not possible, or so fiddly to get done that it wasn't (yet) worth the effort. If the latter, I guess it'd be prioritised depending on user feedback and feature requests.

Ask me sometime about my micro:bit orchestra. ;-)

ntoll avatar Dec 19 '15 23:12 ntoll

Ahem Consider this a feature request (and I'm hoping it is possible but too fiddly). :-)

I happen to have found a score for Ron Grainer's Dr Who theme and I think that Delia Derbyshire would have approved. For the moment I'll have to see how well I can sync multiple bits.

jrmhaig avatar Dec 19 '15 23:12 jrmhaig

Anything is possible :) In this case we'd need to steal a second hardware timer to get an independent PWM channel. From memory that is actually possible.

dpgeorge avatar Dec 21 '15 00:12 dpgeorge

Note that through BBC learning, we recently surfaced an approved arrangement of Ron Grainer's Doctor Who Theme via the Doctor Who activities - in both PXT and Python. No polyphonics in this case but it sounds pretty good. I was thinking we could use @ntoll trick of radio sync between two micro:bits to get the accompaniment running on a second micro:bit. It's in the 'secret area' once you hack into the Dalek mothership.

DavidWhaleMEF avatar May 12 '17 10:05 DavidWhaleMEF

Erm, you've seen this? :-)

https://www.youtube.com/watch?v=uLIaXOPBD_M

Officially "Awesomeness on stilts" (according to @ntoll)

jrmhaig avatar May 12 '17 10:05 jrmhaig

Oh yes, I remember seeing that at the time you did it, but I must admit we all forgot about it!

Have you surfaced the code for this, and if so, would you mind sharing the link to it?

DavidWhaleMEF avatar May 12 '17 11:05 DavidWhaleMEF

For reference: https://gist.github.com/ntoll/f762c1e2c06104854b6142df4cb3c095

ntoll avatar May 12 '17 15:05 ntoll