|
SatCat5
|
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.:
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>
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. | |
|
inlineconstexpr |
Link this decoder to a playback device.
| spkr | Is the buffer for the playback device. |
| refclk_hz | Is the reference clock frequency, in Hz. |
Definition at line 38 of file codec_rtttl.h.
|
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.
|
inlinevirtualinherited |
Unlink this EventListener from the designated source, because the designated Readable object is being destroyed.
Child objects of io::EventListener MAY override this method if action is required.
Reimplemented in satcat5::io::Override, satcat5::io::MuxUp, satcat5::io::MuxDown, satcat5::io::BufferedPackets, satcat5::io::BufferedStream, satcat5::io::BufferedCopy, satcat5::eth::SwitchLogReader, satcat5::eth::Dispatch, satcat5::ccsds_spp::Dispatch, satcat5::ccsds_aos::Dispatch, satcat5::ccsds_aos::Channel, satcat5::test::MockOffload::Port, and satcat5::freertos::MessageCopy.
Definition at line 54 of file io_readable.h.
| bool RtttlDecoder::play | ( | const char * | src | ) |
Decode and play the specified song (string input).
Definition at line 48 of file codec_rtttl.cc.
| bool RtttlDecoder::play | ( | satcat5::io::Readable * | src | ) |
Decode and play the specified song (stream input).
Definition at line 58 of file codec_rtttl.cc.