gfabiano / rtttl-cpp

C++ Parser for Ring Tone Text Transfer Language (RTTTL)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ring Tone Text Transfer Language Parser

This single header library can parse RTTTL text and deliver the frequency and duration for each note.

Using the RTTTL library

Instantiate an instance of the RTTTL class, passing the c_str to the constuctor

char str[] = "PacMan:d=16,o=6,b=140:b5,b,f#,d#,8b,8d#,c,c7,g,f,8c7,8e,b5,b,f#,d#,8b,8d#,32d#,32e,f,32f,32f#,g,32g,32g#,a,8b:"
RTTTL tune(str);

Then use the notes generated (freq, msec) to play music. The method get_notes() returns a vector of struct with all needed info, in this form:

struct atomic_note {
    char name[3] = {0};  // Name of note, including diesis
    int duration;
    int octave;
    double freq;
    int msec;
};

About

C++ Parser for Ring Tone Text Transfer Language (RTTTL)

License:Apache License 2.0


Languages

Language:C++ 96.6%Language:Meson 3.4%