26static const size_t SAMPLE_BUFFER_SIZE = 2048;
44 void play(std::string rtttl);
59 ret = (ret * 10) + (this->
rtttl_[this->position_++] -
'0');
125 void play(Ts...
x)
override { this->
rtttl_->
play(this->value_.value(
x...)); }
virtual void play(Ts... x)=0
Base class for all automation conditions.
Helper class to easily give an object a parent of type T.
Base class for all output components that can output a variable level, like PWM.
FinishedPlaybackTrigger(Rtttl *parent)
bool check(Ts... x) override
TEMPLATABLE_VALUE(std::string, value) void play(Ts... x) override
int samples_per_wave_
The number of samples for one full cycle of a note's waveform, in Q10 fixed-point format.
uint16_t wholenote_
The duration of a whole note in milliseconds.
uint32_t last_note_
The time the last note was started.
int samples_sent_
The number of samples sent.
uint16_t note_duration_
The duration of the current note in milliseconds.
int samples_gap_
The number of samples for the gap between notes.
int sample_rate_
The sample rate of the speaker.
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.
float gain_
The gain of the output.
uint32_t output_freq_
The frequency of the current note in Hz.
void add_on_finished_playback_callback(std::function< void()> callback)
uint16_t default_duration_
The default duration of a note (e.g. 4 for a quarter note).
size_t position_
The current position in the RTTTL string.
void set_gain(float gain)
uint16_t default_octave_
The default octave for a note.
State state_
The current state of the RTTTL player.
void set_speaker(speaker::Speaker *speaker)
int samples_count_
The total number of samples to send.
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 play(std::string rtttl)
std::string rtttl_
The RTTTL string to play.
void play(Ts... x) override
Providing packet encoding functions for exchanging data with a remote host.