8#include <freertos/FreeRTOS.h>
22static constexpr float SILENT_VOLUME_THRESHOLD = 0.001f;
40 virtual size_t play(
const uint8_t *data,
size_t length, TickType_t ticks_to_wait) {
51 virtual size_t play(
const uint8_t *data,
size_t length) = 0;
53 size_t play(
const std::vector<uint8_t> &data) {
return this->
play(data.data(), data.size()); }
78 audio_dac->set_volume(volume);
96 this->
audio_dacs_.assign_copy(&audio_dac, audio_dac !=
nullptr ? 1 : 0);
132 audio_dac->set_mute_on();
134 audio_dac->set_mute_off();
142 audio_dac->on_audio_started();
Lightweight read-only view over a const array stored in RODATA (will typically be in flash memory).
virtual size_t play(const uint8_t *data, size_t length)=0
Plays the provided audio data.
virtual void set_volume(float volume)
size_t play(const std::vector< uint8_t > &data)
void notify_audio_dacs_started_()
Tells every audio dac that its audio clocks are running; call from the main loop.
void set_audio_dac(audio_dac::AudioDac *audio_dac)
Sets a single audio dac (nullptr for none), replacing any list; keeps its own copy of the pointer.
virtual float get_volume()
virtual bool get_pause_state() const
virtual void set_pause_state(bool pause_state)
CallbackManager< void(uint32_t, int64_t)> audio_output_callback_
void set_audio_stream_info(const audio::AudioStreamInfo &audio_stream_info)
audio::AudioStreamInfo & get_audio_stream_info()
void add_audio_output_callback(F &&callback)
Callback function for sending the duration of the audio written to the speaker since the last callbac...
virtual bool get_mute_state()
virtual void set_mute_state(bool mute_state)
virtual bool has_buffered_data() const =0
void set_audio_dacs(audio_dac::AudioDac *const *audio_dacs, size_t count)
Codegen only: the table must outlive this speaker. Every DAC listed is fed by this speaker's audio ou...
audio::AudioStreamInfo audio_stream_info_
bool has_audio_dac_() const
Whether volume and mute are handled in hardware by at least one audio dac.
ConstVector< audio_dac::AudioDac *, true > audio_dacs_
bool is_silent_() const
Whether the output should be silent: muted, or the volume is effectively zero.
void apply_audio_dac_mute_()
Uses the audio dacs' mute as the silence mechanism, since a dac's minimum volume is often audible.