SatCat5
satcat5::io::RtttlDecoder Class Reference

Detailed Description

Ring Tone Text Transfer Language (RTTTL) interpreter.

RTTTL is a compact plaintext format for monophonic music, originally used for Nokia mobile-phone ringtones, e.g.:

Beethoven:d=4,o=5,b=160:c,e,c,g,c,c6,8b,8a,8g,8a,8g,8f,8e,8f,8e,8d,c,e,g,e,c6,g.

See also: This interactive RTTTL editor.

This class accepts RTTTL input and emits "notes" as duration and rate pairs, encoded as consecutive u16 + u32 values. Duration is measured in milliseconds. Rate zero indicates silence; otherwise it sets phase-increment per clock cycle as used in "cfgbus_piezo.vhd", i.e., rate = round(2^32 * freq_hz / refclk_hz).

Definition at line 33 of file codec_rtttl.h.

#include <codec_rtttl.h>

Inheritance diagram for satcat5::io::RtttlDecoder:
[legend]
Collaboration diagram for satcat5::io::RtttlDecoder:
[legend]

Public Member Functions

constexpr RtttlDecoder (satcat5::io::Writeable *spkr, u64 refclk_hz)
 Link this decoder to a playback device. More...
 
void flush ()
 If playback is in progress, halt immediately.
 
bool play (const char *src)
 Decode and play the specified song (string input). More...
 
bool play (satcat5::io::Readable *src)
 Decode and play the specified song (stream input). More...
 
virtual void data_unlink (satcat5::io::Readable *src)
 Unlink this EventListener from the designated source, because the designated Readable object is being destroyed. More...
 

Protected Member Functions

void data_rcvd (satcat5::io::Readable *src) override
 The data_rcvd() callback is polled whenever data is available. More...
 
bool read_note (satcat5::io::Readable *src)
 

Protected Attributes

satcat5::io::Writeable *const m_spkr
 Output device.
 
const u64 m_scale
 Frequency conversion.
 
u32 m_duration
 Default note duration.
 
u32 m_octave
 Default octave.
 
u32 m_whole_note
 Duration of whole note.
 
satcat5::io::PacketBuffer m_queue
 Playback queue.
 
u8 m_raw [SATCAT5_RTTTL_BUFFER]
 Raw working buffer.
 

Constructor & Destructor Documentation

◆ RtttlDecoder()

constexpr satcat5::io::RtttlDecoder::RtttlDecoder ( satcat5::io::Writeable spkr,
u64  refclk_hz 
)
inlineconstexpr

Link this decoder to a playback device.

Parameters
spkrIs the buffer for the playback device.
refclk_hzIs the reference clock frequency, in Hz.

Definition at line 38 of file codec_rtttl.h.

Member Function Documentation

◆ data_rcvd()

void RtttlDecoder::data_rcvd ( satcat5::io::Readable src)
overrideprotectedvirtual

The data_rcvd() callback is polled whenever data is available.

A pointer is provided to assist handlers with multiple sources. Child objects of io::EventListener MUST override this method.

Implements satcat5::io::EventListener.

Definition at line 111 of file codec_rtttl.cc.

◆ data_unlink()

virtual void satcat5::io::EventListener::data_unlink ( satcat5::io::Readable src)
inlinevirtualinherited

◆ play() [1/2]

bool RtttlDecoder::play ( const char *  src)

Decode and play the specified song (string input).

Returns
True if the entire sequence was enqueued for playback.

Definition at line 48 of file codec_rtttl.cc.

◆ play() [2/2]

bool RtttlDecoder::play ( satcat5::io::Readable src)

Decode and play the specified song (stream input).

Returns
True if the entire sequence was enqueued for playback.

Definition at line 58 of file codec_rtttl.cc.


The documentation for this class was generated from the following files: