Microsoft MakeCode

RTTTL tunes extension

Ring Tone Transfer Language… is a popular format for tunes. With this library, you can play existing RTTL tunes in Arcade.

4 Likes

This is fantastic! Thank you very much for sharing this. I hope they make this part of the main code.
Using a timer to separately play a melody during a game just got easier. I was so excited by this extension that I just had to put it in my game:

3 Likes

It took me a few tries to get the correct amount of Ts in that name.

2 Likes

For people interrested by finding tunes, this forum post has a bunch https://forum.arduino.cc/index.php?topic=510297.0

3 Likes

0.6 is also microbit compatible.

How does this work? I cannot add the extension to my game.

Add an extension as usual. In the search bar, use the following URL: https://github.com/pelikhan/pxt-rtttl.git

I don’t know why it didn’t work before, but thanks! What do I do now? Is it a ts extension?

It adds one block to the Music category in the toolbox:

image

Use the links mentioned earlier in this thread to find some RTTTL tunes, or craft your own!

2 Likes

I have noticed that some RTTTL tunes are not playing as expected.

Using this site:

and the ‘Leisure suit Larry’ theme:
LeisureSuit:d=16,o=6,b=56:f.5,f#.5,g.5,g#5,32a#5,f5,g#.5,a#.5,32f5,g#5,32a#5,g#5,8c#.,a#5,32c#,a5,a#.5,c#.,32a5,a#5,32c#,d#,8e,c#.,f.,f.,f.,f.,f,32e,d#,8d,a#.5,e,32f,e,32f,c#,d#.,c#

sounds a lot different using the extension. Could it be that I don’t have the correct BPM?

Oh man … that tune! Fond memories.

It doesn’t seem to like the 32nd notes. I replaced them with 16th notes, and it was … happier? At least the melody seemed much more familiar.

Anyway, try this one. I shifted the time signature to avoid the 32nd notes. The half-notes still seem to play a little long, but other than that, it sounds accurate. Play it at half the suggested speed (i.e. play it at 112 bpm instead of 224).

LeisureSuit:d=4,o=6,b=224:f.5,f#.5,g.5,g#5,8a#5,f5,g#.5,a#.5,8f5,g#5,8a#5,g#5,2c#.,a#5,8c#,a5,a#.5,c#.,8a5,a#5,8c#,d#,2e,c#.,f.,f.,f.,f.,f,8e,d#,2d,a#.5,e,8f,e,8f,c#,d#.,c#

1 Like

Hi, @peli !

I sent a PR your way. Feel free to gimme a holler via GitHub if you have any questions.

:pray: I’ll bump later today. For the trim issue, trim before splitting

1 Like

We’ll have to figure a way to share those melodies somewhere.

1 Like

I tried a handful of variations and couldn’t get it to work. I’m not comfortable enough with lambda functions in JS to make the compiler happy. I eventually threw my hands in the air and left it for you. :smile:

Thanks for this extension, @peli ! I’m more comfortable with traditional music notation, so I feel right at home with RTTL notation.

Since you changed the notation I had to find out how the RTTTL format works. :man_shrugging: Wikipedia explains the notation quite well. I see that you have changed the default duration from ‘d=16’ to ‘d=4’, which means also having to divide the notes that do specify a duration by 4.

Thank you Alex for helping me with this, it does sound much better now.

1 Like

Alex fixes + white space issue bundled in v0.0.9!

2 Likes

I will update the library and try some different tunes.