rtttl tunes to microbit converter

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
Post Reply
fizban
Posts: 24
Joined: Mon Oct 24, 2016 2:32 pm

rtttl tunes to microbit converter

Post by fizban » Thu Apr 13, 2017 12:44 pm

There are lots of options to play rtttl tunes (aka nokia ring tones) on Arduinos and directly in micropython parsing it directly, but the micro:bit has its own format for playing tunes and parsing an rtttl string does not seem efficient. Besides, the play function in micropython allows for asynchronous playing. So, I have uploaded to my repository and Excel file with macros (I am sorry for those without Excel, but schools typically have Excel installed on their machines), which allows converting rtttl sequences to micropython code:

This

Code: Select all

WeWishYo:d=4,o=6,b=35:16a5,16d6,32d6,32e6,32d6,32c#6,16b5,16g5,16b5,16e6,32e6,32f#6,32e6,32d6,16c#6,16a5,16c#6,16f#6,32f#6,32g6,32f#6,32e6,16d6,16b5,16a5,16b5,16e6,16c#6,8d6


Would be converted to this

Code: Select all

import music
# WeWishYo
music.set_tempo(ticks=16, bpm=35)
tune = ['A5', 'D6', 'D:2', 'E', 'D', 'C#', 'B5:4', 'G', 'B', 'E6', 'E:2', 'F#',
        'E', 'D', 'C#:4', 'A5', 'C#6', 'F#', 'F#:2', 'G', 'F#', 'E', 'D:4',
        'B5', 'A', 'B', 'E6', 'C#', 'D:8']
music.play(tune)
There are lots of resources on the internet for rtttl tunes, but my recommended first stop would be the Picaxe website. You can also use different tools to convert midi files to rtttl.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: rtttl tunes to microbit converter

Post by dhylands » Thu Apr 13, 2017 4:17 pm

I wrote a small RTTTL parser for MicroPython:
viewtopic.php?f=14&t=2172&p=12291#p12291

You could also probably use that to do your conversion if you wanted to do it in python rather than Excel.

fizban
Posts: 24
Joined: Mon Oct 24, 2016 2:32 pm

Re: rtttl tunes to microbit converter

Post by fizban » Thu Apr 13, 2017 9:35 pm

I actually took a look at your project. Nicely done, by the way. But I wanted some kind of GUI and Excel was just a quick way of getting this functionality done. It serves my purpose and, if it is useful to others, there it is for anyone to use it.

Post Reply