Skip to content

A rich web-based Ring Tone Text Transfer Language (RTTTL) composer.

License

Notifications You must be signed in to change notification settings

ImSkully/rtttl-web-composer

Repository files navigation

RTTTL Web Composer Logo

RTTTL Web Composer

Deno Badge Deno Fresh Badge

License Badge Discord Badge Open Web Application

A rich web based composer for creating Ring Tone Text Transfer Language (RTTTL).

  • 📝 Interactive, responsive, and user-friendly web interface for creating RTTTL ringtones
  • 🎶 Dynamic RTTTL generation and browser playback using Web Audio API
  • 📦 Generate or import RTTTL ringtone strings

This tool was originally built with vanilla HTML, CSS & JS for the sake of simplicity, but eventually outgrew the basics and required a web framework to streamline development and better comply with modern standards. The application is built using the Fresh web framework with Deno for the backend and build process. The frontend also uses the Tabler UI framework, BS5, and jQuery for interactivity.


RTTTL

Note

For a more detailed description on RTTTL and its background history, specifications, and how it works, check out What is RTTTL?

RTTTL (Previously referred to as Nokring) was originally developed in 1996 by Nokia for use in their mobile phones back when they were the dominant force in the mobile phone market and the most common method of composing, and sharing ringtones was through text messages. The format was simple and easy to understand which made its adoption quite popular though was quickly replaced by more modern formats such as MIDI and MP3 ringtones which offered more features and better sound quality.

The RTTTL format is still used today in some applications and devices such as hobbyist Arduino projects, IoT devices, and older mobile phones.

Hardware

If you are interested in playing ringtones composed in RTTTL on physical hardware, or you may already possess the necessary electrical components to build a simple circuit, you can use the following example below as a starting reference for the basics.

Alternatively, if you prefer a ready-made hardware solution that comes ready to go out of the box then something like the Apollo MSR-2 for Home Assistant is a great option for playing RTTTL. For more information on usage, refer to the MSR-2 Buzzer documentation.

Components

Circuit Diagram

The following diagram is an example representation of a good basic circuit that connects a piezo buzzer to an ESP32 controller on a breadboard:

ESP32 Buzzer Breadboard Diagram

Note that the actual circuit will vary depending on your controller:

  • For ESP8266 boards, the software PWM output pins available are any in the range GPIO0 - GPIO16
  • For ESP32 boards, the LEDC PWM channel can acts as output (diagram) and you can normally use any pin in the range GPIO0 - GPIO33

Code

If your microcontroller is compatible with ESPHome then you can fortunately make use of the existing RTTTL component to easily play the RTTTL strings composed on the web application directly on the ESP device, see the RTTTL Component documentation for more information, the source for the underlying RTTTL library can be found here.

# Buzzer (ESP32 controller)
output:
  - platform: ledc
    pin: GPIO12
    id: buzzer
rtttl:
    output: buzzer

# Example API action
api:
  actions:
    - action: play_rtttl
      variables:
        song_str: string
      then:
        - rtttl.play:
            rtttl: !lambda 'return song_str;'

You can now invoke the play_rtttl action with song_str set to a valid RTTTL string such as:

# Example RTTTL tone to play.
song_str: "James Bond:d=4, o=5, b=320:c, 8d, 8d, d, 2d, c, c, c, c, 8d#, 8d#, 2d#, d, d, d, c, 8d, 8d, d, 2d, c, c, c, c, 8d#, 8d#, d#, 2d#, d, c#, c, c6, 1b., g, f, 1g."

License

This project is made available under the GPL-2.0 License.