Page 1 of 1

rtttl tunes to microbit converter

Posted: Thu Apr 13, 2017 12:44 pm
by fizban
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.

Re: rtttl tunes to microbit converter

Posted: Thu Apr 13, 2017 4:17 pm
by dhylands
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.

Re: rtttl tunes to microbit converter

Posted: Thu Apr 13, 2017 9:35 pm
by fizban
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.