19class RtttlParserAccess;
52 void play(std::string rtttl);
62#ifdef USE_RTTTL_FINISHED_PLAYBACK_CALLBACK
147#ifdef USE_RTTTL_FINISHED_PLAYBACK_CALLBACK
152 friend class testing::RtttlParserAccess;
Base class for all output components that can output a variable level, like PWM.
uint32_t samples_per_wave_
The number of samples for one full cycle of a note's waveform, in Q10 fixed-point format.
std::string owned_song_
Backing store for play(std::string).
size_t song_find_(char c, size_t from, size_t end) const
Index of the first c in [from, end), or end when absent.
uint32_t last_note_start_time_
The time in milliseconds since microcontroller boot when the last note was started.
uint8_t default_note_denominator_
The default duration of a note (e.g. 4 for a quarter note).
uint16_t position_
The current position in the song.
bool is_busy_() const
Logs and returns true when a song is still playing, so a new one must wait.
uint16_t note_duration_
The duration of the current note in milliseconds.
uint16_t song_len_
Length of the song in bytes; songs are a few hundred bytes, so 16 bits is ample.
void start_()
Parses the header and starts playback of the song the view points at.
uint32_t samples_sent_
The number of samples sent.
output::FloatOutput * output_
The output to write the sound to.
void dump_config() override
void set_state_(State state)
void finish_()
Finalizes the playback of the RTTTL string.
void add_on_finished_playback_callback(F &&callback)
float gain_
The gain of the output.
uint8_t default_octave_
The default octave for a note.
uint32_t output_freq_
The frequency of the current note in Hz.
uint32_t samples_gap_
The number of samples for the gap between notes.
char song_at_(size_t pos) const
The byte of the song at pos, or NUL past its end; the read is flash safe for a PROGMEM song on ESP826...
void set_gain(float gain)
uint32_t samples_count_
The total number of samples to send.
uint16_t wholenote_duration_
The duration of a whole note in milliseconds.
const char * song_
The song being played; points at owned_song_ or at static storage.
size_t song_find_control_(char key, size_t from, size_t end) const
Index of key followed by '=' in [from, end), or end when absent.
void song_name_(char *buf, size_t size, size_t name_len) const
Copies the first name_len bytes of the song, its name, into buf for logging.
State state_
The current state of the RTTTL player.
void set_speaker(speaker::Speaker *speaker)
speaker::Speaker * speaker_
The speaker to write the sound to.
void set_output(output::FloatOutput *output)
CallbackManager< void()> on_finished_playback_callback_
The callback to call when playback is finished.
void set_song_(const char *song, size_t len)
Points the view at a song, clamped to what song_len_ can hold.
void play(std::string rtttl)
Play a song; the string is copied so it may come from anywhere.
constexpr uint8_t DEFAULT_OCTAVE
constexpr uint8_t DEFAULT_NOTE_DENOMINATOR
uint8_t progmem_read_byte(const uint8_t *addr)
const __FlashStringHelper * ProgmemStr
A song in storage that outlives playback, such as a literal from generated code; PROGMEM on ESP8266.