You are here:

ActiveXperts.com > SMS and MMS Toolkit > About SMS > RTTTL Format

RTTTL Format

What is RTTTL ?

RTTTL stands for Ring Tones Text Transfer Language. It is a simple text-based format used to create ringtones that can be uploaded to a mobile phone. Most cellphone manufacturers support RTTTL. You can find a example of a RTTTL ringtone below:

Muppets:d=4,o=5,b=250:c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,8a,8p,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,8e,8p,8e,g,2p,c6,
                           c6,a,b,8a,b,g,p,c6,c6,a,8b,a,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,d,8d,c

The Format Specification

A RTTTL ringtone can be devided into 3 parts, which are separated using a colon:

  • The title.
  • Default parameters, like: default duration, pitch and bpm.
  • The actual songdata.

The title

The title of the song, it can have no more than 10 characters. The title of the song in the example above is 'Muppets'

Default parameters

The following parameters are supported in this section:

d Default duration
o Default octave
b Default bpm (beats per minute)

If these parameters are not specified, the following values will be used: Duration: 4, Scale: 6 and BPM: 63 ( :d=4;o=6;b=63: ) The following values are valid for the duration parameter:

1 a full note
2 a half note
4 a quarter note
8 an eighth note
16 a sixteenth note
32 a thirty-second note

The following values are valid for the octave parameter:

5 Note A is 440Hz
6 Note A is 880Hz
7 Note A is 1760Hz
8 Note A is 3520Hz

The default BPM can be one of the following values:

25, 28, 31, 35, 40, 45, 50, 56, 63, 70, 80, 90, 100, 112, 125, 140,
160, 180, 200, 225, 250, 285, 320, 355, 400, 450, 500, 565, 635, 715, 800 and 900.

The songdata

The last section of the string contains the actual songdata. All the notes are separated by a comma. The notes are encoded as follows:

[duration] note [scale] [special-duration],[duration] note [scale] [special-duration], etc...

If the optional values 'duration' and/or 'scale' are left blank, the default parameters from the second section of the RTTTL string are used.

The following notes can be used in a RTTTL string:

P Pause
C Note C
C# Note Cis
D Note D
D# Note Dis
E Note E
F Note F
F# Note Fis
G Note G
G# Note Gis
A Note A
A# Note Ais
H Note H

Examples:

8f#5 1/8th Note Fis, Octave 5
8d5 1/8th Note D, Octave 5
8p 1/8th Pause
c5 Default length, Note C, Octave 5
8d 1/8th Note D, Default octave

How to send a RTTTL ringtone to a mobile phone ?

To send a RTTTL ringtone to a mobile phone, it first has to be encoded and compressed before it is send to the mobile phone as 8 bit data.

The SMS and MMS Toolkit has a built in encoder to convert the RTTTL data into 8 bit data. If this data does not fit into a single SMS message (140 bytes) it will be splitted, and reassambly data is added.

The following code describes how to send a ringtone to a mobile phone through a connected cellphone or GSM modem in just a few lines of code. Before you can use this code, you have to download and install the ActiveXperts SMS and MMS Toolkit.

If you do not have a GSM device connected to your computer, you can also try the second sample that sends the ringtone through our SMPP demo provider.

Send a RTTTL Ringtone through a connected GSM phone or modem:

Option Explicit

Dim objRingtone
Dim objGsm
Dim objMessage
Dim objConstants

Dim i
Dim nNumDevices
Dim strDevices

Set objGsm       = CreateObject ( "ActiveXperts.SmsProtocolGsm" )
Set objMessage   = CreateObject ( "ActiveXperts.SmsMessage" )
Set objConstants = CreateObject ( "ActiveXperts.SmsConstants" )
Set objRingtone  = CreateObject ( "ActiveXperts.SmsDataRingtone" )

nNumDevices = objGsm.GetDeviceCount()
strDevices  = "*** Enter one of the following device names *** " & vbCrLf & vbCrLf

For i = 0 To nNumDevices-1
  strDevices = strDevices & objGsm.GetDevice( i )
  strDevices = strDevices & vbCrLf 
Next

strDevices = strDevices & "COM1" & vbCrLf & "COM2" & vbCrLf & "COM ..." & vbCrLf

' Set Logfile
objGsm.LogFile          = "c:\RingtoneDemo.txt"

' Set Device
Do
  objGsm.Device = inputbox( strDevices, "Input" )
Loop until objGsm.Device <> ""


objRingtone.LoadRTTTL      ( "Muppets:d=4,o=5,b=250:c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,8a,8p,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,8e" &_
                           + ",8p,8e,g,2p,c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,a,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,d,8d,c" )

objRingtone.Encode

' Set recipient
Do
  objMessage.Recipient = inputbox( "Enter the recipients phone number." , "Input" )
Loop until objMessage.Recipient <> ""

objMessage.Format       = objConstants.asMESSAGEFORMAT_DATA_UDH
objMessage.Data         = objRingtone.EncodedMessage

objGsm.Send ( objMessage )

If ( objGsm.LastError <> 0 ) Then
  WScript.Echo ( "Error " & objGsm.LastError & " : " & objGsm.GetErrorDescription ( objGsm.LastError ) )
  WScript.Quit
End If

WScript.Echo "Message successfully submitted."

Send a RTTTL Ringtone through the ActiveXperts SMPP demo server:

Option Explicit

Dim objRingtone
Dim objMessage
Dim objSmpp
Dim objConstants

Set objSmpp      = CreateObject ( "ActiveXperts.SmsProtocolSmpp" )
Set objMessage   = CreateObject ( "ActiveXperts.SmsMessage" )
Set objConstants = CreateObject ( "ActiveXperts.SmsConstants" )
Set objRingtone  = CreateObject ( "ActiveXperts.Ringtone" )

objSmpp.Server             = "smpp.activexperts-labs.com"
objSmpp.ServerPort         =  2775
objSmpp.SystemID           = "AX008"
objSmpp.SystemPassword     = "812056"
objSmpp.SystemType         = "SMPP"
objSmpp.ServerTimeout      =  5000
objSmpp.SystemMode         =  objConstants.asSMPPMODE_TRANSMITTER

objSmpp.LogFile            = "c:\RingtoneDemo.txt"

objSmpp.Connect

If ( objSmpp.LastError <> 0 ) Then
   WScript.Echo "Failed to connect to ActiveXperts SMPP Demo Server" &_
                & vbCrLf & "ERROR " & objSmpp.LastError & " : " & objSmpp.GetErrorDescription ( objSmpp.LastError )
   WScript.Quit
End If

objRingtone.LoadRTTTL      ( "Muppets:d=4,o=5,b=250:c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,8a,8p,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,8e,8p" &_
                           + "8e,g,2p,c6,c6,a,b,8a,b,g,p,c6,c6,a,8b,a,g.,p,e,e,g,f,8e,f,8c6,8c,8d,e,8e,d,8d,c" )

objRingtone.Encode

' Set recipient
Do
   objMessage.Recipient = inputbox( "Enter the recipients phone number.", "Input" )
Loop until objMessage.Recipient <> ""

objMessage.Data   = objRingtone.EncodedMessage
objMessage.Format = objConstants.asMESSAGEFORMAT_DATA_UDH

objSmpp.Send ( objMessage )

If ( objSmpp.LastError <> 0 ) Then
  WScript.Echo ( "Error " & objSmpp.LastError & " : " & objSmpp.GetErrorDescription ( objSmpp.LastError ) )
  WScript.Quit
End If

WScript.Echo "Message successfully submitted."
   
objSmpp.Disconnect

There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/mobile-messaging-component.