(If you liked this page, then you might also like this page)
Convert RTTTL or PTTTL to .mp3 audio
RTTTL (Ring Tone Text Transfer Language) is a method of storing monophonic melodies in simple text files, used in old Nokia phones to describe ringtones. If you want to convert RTTTL ringtone files into MP3/WAV audio files for use on a modern smartphone (complete with authentic shitty-sounding beeps), you can do it here.
Paste the contents of an RTTTL file below (or select one of the built-in examples) to download an mp3 audio file that plays the tones dscribed in the RTTTL text you provided. The tones generated have a very slight attack/decay to avoid nasty clicks and pops. (also converts PTTTL, which is my hacky extension of RTTTL that allows polyphony & vibrato - scroll down for a full description)
Code
The code used for PTTTL/RTTTL parsing and audio generation can be found on github:
https://github.com/eriknyquist/ptttlPolyphonic Tone Text Transfer Language (PTTTL)
Polyphonic Tone Text Transfer Language (PTTTL) describes polyphonic melodies in human-readable plain text files. PTTTL is a superset of Nokia's RTTTL format, used for monophonic ringtones.
PTTTL format
Because PTTTL is a superset of RTTTL, valid RTTTL strings are also valid PTTTL strings. A parser that properly handles PTTTL can also handle RTTTL.
A PTTTL string is made up of three colon-seperated sections; name section, default values section, and data section.
Whitespace characters, empty lines, and text beginning with a "/" character until the end of a line are ignored.
name section
The first section in a PTTTL file is an arbitrary string up to 256 charactes long, intended to be used as the name of the song
default values section
The next section after the name section is the default values section, and it is the same as the default values section from the RTTTL format, except with two additional vibrato-related settings:
b=123, d=8, o=4, f=7, v=10
- b - beat, tempo: tempo in BPM (Beats Per Minute)
- d - duration: default duration of a note if none is specified
- o - octave: default octave of a note if none is specified
- f - frequency: default vibrato frequency if none is specified, in Hz
- v - variance: default vibrato variance from the main pitch if none is specified, in Hz
data section
The PTTTL data section is just like the RTTTL data section, in that a melody consists of multiple comma-seperated notes to be played sequentially. Unlike RTTTL, PTTTL allows multiple melodys to be defined, separated by the vertical pipe character |, all of which will be played in unison.
The format of a note is identical to that described by the RTTTL format. Each note includes, in sequence; a duration specifier, a standard music note, either a, b, c, d, e, f or g (optionally followed by '#' or 'b' for sharps and flats, or a dot '.' for dotted rhythms), and an octave specifier. If no duration or octave specifier are present, the default applies.
Durations
Valid values for note duration:
- 1 - whole note
- 2 - half note
- 4 - quarter note
- 8 - eighth note
- 16 - sixteenth note
- 32 - thirty-second note
Dotted rhythm patterns can be formed by adding a period "." either after the note letter (e.g. c#. or c#.5), or after the octave number (e.g. c#5.)
Notes
Valid values for note pitch (non case-sensitive):
- P - rest or pause
- A
- A# / Bb
- B / Cb
- C
- C# / Db
- D
- D# / Eb
- E / Fb
- F / E#
- F# / Gb
- G
- G# / Ab
Octave
Valid values for note octave are between 0 and 8.
Vibrato
Optionally, vibrato may be enabled and configured for an individual note. This is done by appending a v to the end of the note, and optionally frequency and variance values seperated by a - character. For example:
- 4c#v refers to a C# quarter note with vibrato enabled, using default settings
- 4c#v10-15 refers to a C# quarter note with vibrato enabled, using a vibrato frequency of 10Hz, with a maximum vibrato variance of 15Hz from the main pitch.
Comments
Single-line comments are supported. A comment begins with a single forward slash (or you can use a double forward slash, if that's what you're used to) and terminates at the end of the line. Everything between the first forward slash and the end of the line is ignored by the PTTTL parser.
Test Melody:
b=123, d=4, o=4:
// Comment on a line of its own
16c, 8p, 16c |
16e, 8p, 16e | // Comment after some notes
16g5, 8p, 16g5
Example
Consider the following PTTTL string:
// 123 beats-per-minute, default quarter note, default 4th octave
Test Melody:
b=123, d=4, o=4:
16c, 8p, 16c | 16e, 8p, 16e | 16g5, 8p, 16g5
This would play 3 sixteenth notes simultaneously (C, octave 4; E, octave 4; G, octave 5), followed by an eighth note rest, followed by the same three sixteenth notes again
Note that the above sample is much easier to read if we put each melody on a new line and align the notes in columns. This is the recommended way to write PTTTL:
// Nicely aligned
Test Melody:
b=123, d=4, o=4:
16c, 8p, 16c |
16e, 8p, 16e |
16g5, 8p, 16g5
In order to keep things readable for large PTTTL files with multiple concurrent tracks, a semicolon character ; can be used further break up melodies into more practical blocks. Just as the veritcal pipe character | seperates concurrent tracks within a single polyphonic melody, the semicolon character seperates multiple sequential polyphonic melodies within a single data section. Blocks of notes seperated by semicolons will be "stitched together", or concatenated, in the final output.
The semicolon does not affect any of the timings or pitch of the generated tones; it just makes the PTTTL source a bit more readable, and gives you more options for organizing the lines when writing music. For a good example of why the semicolon is useful, have a look at the "Polyphonic example" sample file by selecting it from the "Sample RTTTL/PTTTL file" from the dropdown at the top of this page.