InformIT

The World of Mobile Ring Tones

Date: Feb 20, 2004

Return to the article

You may not be named Ludwig, Johann, or Jimmy, but you can still program your own cool tunes for your cell phone. Bob Reselman shows just how easy it is, using Java.

Ring tones are a cool way to customize your cell phone. You can make your cell phone play Beethoven's Fifth Symphony, Led Zeppelin's "Whole Lotta Love," or a tune of your own making. And you can use the cell phone emulator that ships with the Java Mobile Toolkit to test your creations.

In this article I'll show you how to make ring tones using Ring Tones Text Transfer Language (RTTTL). Then I'll show you how to use the emulator in the Java Wireless Toolkit (WTK) to listen to the ring tones that I demonstrate and those that you can make on your own. You don't need to know programming or music theory to understand this article. Knowing a little about musical keys and scales will make some points easier to comprehend. But for the foundation of RTTTL, I'll teach you all that you need to know. However, in order to operate the RTTTL Player that I made for this article, you will need to have the Java Wireless Toolkit installed on your computer. You can download it for free here.

Understanding RTTTL

Ring Tones Text Transfer Language is a simple text-based format that you use to create ring tones that can be uploaded into your cell phone via various cell phone uploading techniques. (The mechanics of wireless uploading are beyond the scope of this article. However, as I mentioned earlier, I will show you how to use the cell phone emulator in the WTK to listen to your RTTTL files.)

Just about all cell phone manufacturers support RTTTL. Your cell phone has the smarts to be able to decipher a melody written in an RTTTL text file and play it as a ring tone.

The RTTTL format is easy to learn and easy to use. Let's take a look at a simple well-known melody in standard musical notation: the main theme from the first movement of Beethoven's Fifth Symphony (see Figure 1).

Figure 1Figure 1 The opening theme of Beethoven's Fifth Symphony.

Now, let's take a look at the same melody in RTTTL:

fifth:d=4,o=5,b=63:8P,8G5,8G5,8G5,2D#5

If none of this makes sense to you at this point, don't worry. We're going to address the particulars in a moment. The important thing to get from viewing the two examples above is a feel for how the same melody is represented in two different notational formats—notes on a traditional music staff and in RTTTL.

The RTTTL Format

An RTTTL file is made up of a single string, divided into three sections separated by colons (:). In the example below, I've color-coded the Beethoven's Fifth example for demonstration purposes.

fifth:d=4,o=5,b=63:8P,8G5,8G5,8G5,2D#5

  1. The first section (blue text) is the name of the RTTTL melody.

  2. The second section (aqua text) defines the default values for the file.

  3. The third section (green text) describes the melody.

The structure for the first section is straightforward and obeys a single rule: The name can have no more than 10 characters.

The second section is more complex. It describes the melody defaults. There are three categories of default values: duration, octave, and beat. The way that RTTTL handles these default categories is to define each category with a single character and then assign a value to that character. The second section of the color-coded example above shows the default values:

To translate the default values above into lay terms, you might say something like this:

The default values for this melody are as follows. Unless otherwise specified, any note played will have a duration of quarter note, as indicated by the notation d=4. Unless otherwise indicated, any note identified will be played in the fifth octave, indicated by the notation o=5. The tempo for this melody (how fast it goes) will be 63 beats per minute, as indicated by the notation b=63.

Before we move on to the last section of the RTTTL string, the place where the actual melody is described, let's take moment to get a fuller understanding of the duration, octave, and beat defaults, both technologically and musically.

Duration

The length of a musical sound is what we refer to as the duration of the note. If musicians had a more scientific heritage, duration would be indicated as a length of time—play this note for a second, play that note for half a second, play another note for two seconds, for example. But exact time notation is not in the musician's legacy. Instead, to the befuddlement of every elementary school music student, musical duration is measured relative to other notes using a system of whole notes, half notes, quarter notes, eighth notes, and so on. In most instances, the quarter note is the single unit of measure, in which each quarter note receives one beat. Thus, if you were to count evenly, saying "1, 2, 3, 4," you would get a musical pattern that looks like Figure 2.

Figure 2Figure 2 A simple quarter-note pattern.

There are times when you might not want to play a note on a beat—just have silence. In musical terms, this is called a rest. For example, count "1, 2, 3, 4" evenly again. But this time, skip saying "2," and just pause when you get to that point: "1, <pause>, 3, 4." When you do this, you'll have a musical pattern that looks like Figure 3. Notice the symbol following the first quarter note. This is a quarter-note rest symbol. This means not to play any note for one beat. RTTTL handles rests as pauses and can be programmed accordingly. You'll learn how to program pauses in a later section.

Figure 3Figure 3 A simple quarter-note pattern with a quarter-note rest.

In RTTTL, you place a duration number before a pitch. For example, if you want to play the pitch A for a quarter note, you indicate this in RTTTL as follows:

4A

If you want RTTTL to play the pitch E for a half note, you write this:

2E

The following list shows the RTTTL duration values and their musical equivalents.

Octave

Think of an octave as the region that a scale occupies in musical space. Figure 10 shows two scales on the musical staff. These two scales are the C Major scale, made famous in that well-known tune "Do-Re-Mi," from the musical The Sound of Music. Notice that the second scale repeats the first one, but an octave higher. If you were to sing "Do-Re-Mi-Fa-Sol-La-Ti-Do" twice, continuing up the scale the second time, you would be moving through two octaves of musical space.

Figure 10Figure 10 Two scales occupy two octaves of musical space.

RTTTL supports four octaves, from the A below middle C, to four scales up. RTTTL refers to these octaves by the numbers 5-8. Figure 11 illustrates in musical terms the octaves supported by RTTTL.

Figure 11Figure 11 RTTTL supports playing melodies in four octaves.

Beat

Musically, the beat is measured on a per-minute basis. If a melody is assigned a "60 beats per minute" value, this means that the melody will get one beat each second. If you want the melody to go twice as fast, you increase the beat to 120. Figure 12 shows the musical notation for setting the quarter note to 60 beats per minute.

Figure 12Figure 12 Musicians use this notation to describe beat.

Creating a Melody in RTTTL

You create a melody in RTTTL by building a sequence of duration-pitch-octave character groupings, separating groups with a comma. Let's take a look at a duration-pitch-octave character group, as shown in Figure 13.

Figure 13Figure 13 RTTTL uses a duration-pitch-octave character grouping.

The grouping 4C6 in Figure 13 instructs RTTTL to play the pitch C in the sixth octave for a duration of one quarter-note. If you want RTTTL to play the pitch D in the seventh octave for an eighth note, you write this:

8D7

It's also possible to play a D pitch without a duration or octave indication, simply by writing this:

D

In this case, the defaults settings for the duration and octave values of the RTTTL string kick in.

The following table shows the pitch values for RTTTL.

RTTTL Character

Pitch

P

Pause, rest

C

C

C#

C sharp, D flat

D

D

D#

D sharp, E flat

E

E, F flat

F

F, E sharp

F#

F sharp, G flat

G

G

G#

G sharp, A flat

A

A

A#

A sharp, B flat

H

B


Notice that the character P indicates a rest (pause). Because rests don't occur in an octave, you don't use an octave indicator when asking RTTTL to play a rest. For example, if you want RTTTL to play a quarter-note rest, you write this:

4P

RTTTL uses the character H for the pitch B and considers sharps and flats to be equivalent pitch values. For example, to indicate the pitch A flat, you use the characters G#.

NOTE

Granted, this distinction is most valid in the realm of traditional western music theory and not particularly relevant to those of you who want to make simple melodies. But I imagine that some of you who know a little bit about musical harmony might be irritated by the absence of pitch notation relevant to western musical scales and keys. On behalf of the mobile device manufacturers and telecom industry, I apologize.

Reviewing Beethoven's Fifth

Let's go back to the Beethoven's Fifth Symphony theme and analyze the particulars of the melody as written in RTTTL. Here's the theme in RTTTL again:

fifth:d=4,o=5,b=63:8P,8G5,8G5,8G5,2D#5

Now that we have discussed the particulars of the RTTTL format, this string should have more meaning:

Now let's look at the melody:

8P,8G5,8G5,8G5,2D#5

The melody begins with an eighth note rest (8P), followed by three eighth notes of the pitch G, in the fifth octave (8G5), and ending with a half note of E flat in the fifth octave (2D#5).

NOTE

Wondering why I say that D# is E flat? Look again at the staff notation for the Fifth (see Figure 14). The pitch is written as E flat. The Fifth Symphony is composed in the key of C minor. In the key of C minor, the third pitch in the scale is E flat, not D sharp. In fact, theoretically there isn't any D sharp in the key of C minor. Thus, I use the RTTTL D# notation to generate the sound, but musically the note is E flat.

Figure 14Figure 14 Here's the opening theme from the Fifth again.

NOTE

Yes, I agree that this is a confusing idea and only makes sense if you understand the theory behind keys and scales. And, as I said earlier, naming pitches according to the scale in which they occur has confused elementary music students since day one. After all, who cares what you call the pitches in "Whole Lotta Love"? The important thing is that it sounds cool, right?

With regard to starting the melody with an eighth-note rest (8P), such a beginning creates a question that has perplexed musical scholars since Beethoven wrote the piece. Why start a piece of music with a rest? Why not just start it? Beethoven was no dope, and certainly not sloppy when it came to publishing his music. He must have had a reason for doing this. But, sadly we will never really know. We can only imagine. Such is the virtue of great music: It makes you think every time that you get near it.

Anyway, back to RTTTL.

Creating Dotted Rhythms

RTTTL allows you to create notes with a dotted duration. Musically, a dotted duration is one in which a note is given the duration of "itself plus half." For example, a dotted quarter note has a value of a quarter note plus an eighth note. A dotted eighth note has a duration value of an eighth note plus a sixteenth note. This concept is illustrated in Figure 15.

Figure 15Figure 15 Dotting a note increases the note's length by half.

You dot a note by adding the period (.) character to the end of a duration-pitch-octave grouping. For example, if you want to dot a quarter note with a pitch of C in the fifth register, you write this:

4C5.

Thus, the rhythm shown in Figure 16 translates into this RTTTL string:

dotting:d=4,o=5,b=63:4C5.,8C5,2C5,4C5.,8C5,2C5

Figure 16Figure 16 A musical phrase that uses a dotted quarter note.

Making a Custom Ring Tone

You now have the knowledge to create a custom ring tone using RTTTL. You know the format for creating notes; now it's just a matter of stitching the notes together into a melody. The only question that remains is what melody you're going to create.

This is where the fun comes in!

Using the RTTTL Player

To help you learn to write RTTTL melodies, I created a Java application using the Wireless Toolkit. The application is called RTTTL Player, and is available in a zip file that you can download from my web site.

This section shows you how to use the RTTTL Player to play your melodies after you create them. You need to put your RTTTL files on a web server—either one on the Internet or running on your desktop computer under Localhost. The RTTTL player is hard-coded to get files from an HTTP URL.

CAUTION

The RTTTL format is fairly strict. For example, using an octave indicator on a pause will cause an error, as will misplacing the period when trying to write a dotted rhythm in a duration-pitch-octave group (both of which I've done many times). Pay attention to the details of the format. The best thing to do is to download one of the sample files that I provide for this article and dabble with the existing melody to get new variations. With a little trial-and-error you'll come up with interesting music. Once you get a solid understanding of the format, you'll create ring tones that will amaze your friends and impress your in-laws.

Installing the RTTTL Player

Typically, the Java Wireless Toolkit installs by default into the directory C:\WTK20 on a Windows system. The Toolkit installs a subfolder (C:\WTK20\APPS) containing the sample apps that ship with it. After you download the zip file, follow these steps:

  1. Extract the zip file into a folder called C:\WTK20\APPS\RTTTLPlayer.

  2. TIP

    If you use the Extract to Here option in WinZip, the program will create the RTTTL folder for you automatically, as shown in Figure 17.

    Figure 17Figure 17 Extracting the RTTTL Player.

  3. The zip file contains two files, RTTTLPlayer.jar and RTTTLPlayer.jad, which will be copied into the C:\WTK20\APPS\RTTTLPlayer folder. After extracting the files, invoke the Run MIDP Application utility that ships with the Wireless Toolkit. (It's located in the J2ME program group by default, as shown in Figure 18.)

  4. Figure 18Figure 18 Running the MIDP application.

  5. This Java application takes a few moments to get up and running. When you invoke the application, it opens a file-browsing dialog box that points to the Wireless Toolkit folder. Navigate to \WTK20\apps\RTTTLPlayer (see Figure 19).

  6. Figure 19Figure 19 Navigating to the RTTTLPlayer folder.

  7. Select the Java description file RTTTLPlayer.jad and click the Run button (see Figure 20).

  8. Figure 20Figure 20 Selecting the Java description file.

    If the toolkit has been installed properly and the RTTTLPlayer files have been extracted correctly, the Wireless Toolkit cell phone emulator will open, showing the RTTTL Player app as an item in the cell phone's launch list, as shown in Figure 21. Click the Launch button on the emulator. This button is at the right of the cell phone, above the keypad. This will invoke the RTTTL Player in the emulator.

    Figure 21Figure 21 Click the Launch button to start the RTTTLPlayer.

  9. Now all you need to do is enter a URL for an RTTTL file (see Figure 22).

  10. TIP

    Don't try to cut-and-paste the URL. The cell phone emulator doesn't respect the Windows cut-and-paste functionality. You must enter URLs directly using your computer's keyboard or by using your mouse to click keys on the keypad; the text-entry technique that's commonly used on a cell phone allows one numeric key to accommodate up to three alphabetic characters.

    Figure 22Figure 22 Enter the URL for the RTTTL file you want.

Using the Sample Files

I've created many sample files that illustrate all the points that I've covered in this article. The individual files are listed below; if you prefer, you can download all the RTTTL files created for this article.

After you feel comfortable working with the sample files that I've provided, you can make your own RTTTL files and run them under a web server on the Internet or on your local computer. All you need to do is put the files in a place where the RTTTL Player can find them via a URL that you enter into the cell phone emulator.

Conclusion

We've covered a lot in this article. I've shown you the fundamentals of RTTTL, provided you with an opportunity to do some musical thinking, and demonstrated how to use the RTTTL Player to listen to your creations.

In the next article in this series, I'll show you how I created the RTTTL Player using the Java Wireless Toolkit, and give you an introduction to programming your own wireless applications using the WTK.

I hope that you've found this article to be informative and thought-provoking. I also hope that you use what you've learned to create wonderful music. The world needs more wonderful music, not less.

800 East 96th Street, Indianapolis, Indiana 46240