Rtttl to RobotC

Hello, I was using the Ringtone converted on robot C when I realized it does not convert larger Rtttls. Does anyone know of another way I can convert Rtttl to RobotC?

http://www.robotc.net/blog/2010/09/07/ringtone-converter-for-robotc/
This guy was giving out an excel sheet that converted to RobotC for you but his email no longer works so I cannot contact him.

Can you let RobotC convert the ringtone in chucks? As a standard for SMS transfer, RTTTL is subject to the maximum 918 character limit, and the way it breaks more 160 characters into chunks, so it wouldn’t be surprising that they put limits on the built in converter.

If that doesn’t work, of course, you could do it manually. It’s not necessarily fun, but it is definitely rewarding.

You could probably write a fairly simple program to accomplish this for you if you are really motivated and want to learn something along the way. Here is how I’d approach this: Your objective is to convert RTTTL file into ROBOTC commands. More specifically this would involve converting each note of the RTTTL file to to a PlayTone RobotC command.

RTTL file general format is specified here. The gist of what you want to do is this:

  1. Read in the default settings of the RTTTL file (everything after the first colon and before the second one). Deliminator should be comma, Then store properties for the default durations, tempo, and octave
  2. Read the rest of the RTTTL file into an array, deliminator should be comma again
  3. Read through each element of the array, parse and run the notes through a note->frequency dictionary. Parse the durations also if given.
  4. RobotC tones can be played as PlayTone(frequencyHZ, Length). Using the parsed notes and if given parsed durations (otherwise use default) and write out the PlayTone() commands to a file

I wrote a rtttl converter for ConVEX a few years ago, not directly applicable to use in ROBOTC but it could be used as a starting point.

Input was in this form


char tune3] = "Super Mario:d=4,o=5,b=100:16e6,16e6,32p,8e6,16c6,8e6,8g6,8p,8g,8p,8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,16p,8c6,16p,8g,16p,8e,16p,8a,8b,16a#,8a,16g.,16e6,16g6,8a6,16f6,8g6,8e6,16c6,16d6,8b,8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16c7,16p,16c7,16c7,p,16g6,16f#6,16f6,16d#6,16p,16e6,16p,16g#,16a,16c6,16p,16a,16c6,16d6,8p,16d#6,8p,16d6,8p,16c6";

and was passed to the converter like this.


vexAudioPlayRtttl( tune3, 128, 1 );

yep this is a great starting point. Seems almost like exactly what the OP is looking for.

After a brief inspection of JPearman’s code, I just realized and wanted to point out that using a dictionary directly is not strictly necessary. His way is cleaner imo.