Arkham/elm-rttl/1.0.0

RTTL

Parse ringtones written using RTTL and Nokia Composer

= Ringtone
{ tempo : BPM
, tones : List Tone
}

A ringtone has a well-defined tempo in BPM (beats-per-minute) and is composed by multiple tones, which can be either pitches or pauses.

Parsing

parseComposer : { tempo : Int } -> String -> Result (List DeadEnd) Ringtone

Parse a ringtone expressed in the Nokia Composer format. It is a less generic format compared to RTTL since you can only express 3 octaves. Since the format does not specify a tempo, you will need to choose one.

Here's an example: 4c2 4d2 4e2 16- 8.#a3

Encoding

encode : Ringtone -> Value

Encode ringtone as a list of { frequency, duration } objects