#include <speaker.h>
Definition at line 29 of file speaker.h.
◆ add_audio_output_callback()
void esphome::speaker::Speaker::add_audio_output_callback |
( |
std::function< void(uint32_t, uint32_t, uint32_t, uint32_t)> && |
callback | ) |
|
|
inline |
Callback function for sending the duration of the audio written to the speaker since the last callback.
Parameters:
- Duration in milliseconds. Never rounded and should always be less than or equal to the actual duration.
- Remainder duration in microseconds. Rounded duration after subtracting the previous parameter from the actual duration.
- Duration of remaining, unwritten audio buffered in the speaker in milliseconds.
- System time in microseconds when the last write was completed.
Definition at line 112 of file speaker.h.
◆ finish()
virtual void esphome::speaker::Speaker::finish |
( |
| ) |
|
|
inlinevirtual |
◆ get_audio_stream_info()
◆ get_mute_state()
bool esphome::speaker::Speaker::get_mute_state |
( |
| ) |
|
|
inline |
◆ get_pause_state()
virtual bool esphome::speaker::Speaker::get_pause_state |
( |
| ) |
const |
|
inlinevirtual |
◆ get_volume()
float esphome::speaker::Speaker::get_volume |
( |
| ) |
|
|
inline |
◆ has_buffered_data()
virtual bool esphome::speaker::Speaker::has_buffered_data |
( |
| ) |
const |
|
pure virtual |
◆ is_running()
bool esphome::speaker::Speaker::is_running |
( |
| ) |
const |
|
inline |
◆ is_stopped()
bool esphome::speaker::Speaker::is_stopped |
( |
| ) |
const |
|
inline |
◆ play() [1/3]
virtual size_t esphome::speaker::Speaker::play |
( |
const uint8_t * |
data, |
|
|
size_t |
length, |
|
|
TickType_t |
ticks_to_wait |
|
) |
| |
|
inlinevirtual |
Plays the provided audio data.
If the speaker component doesn't implement this method, it falls back to the play method without this parameter.
- Parameters
-
data | Audio data in the format specified by set_audio_stream_info method. |
length | The length of the audio data in bytes. |
ticks_to_wait | The FreeRTOS ticks to wait before writing as much data as possible to the ring buffer. |
- Returns
- The number of bytes that were actually written to the speaker's internal buffer.
Reimplemented in esphome::i2s_audio::I2SAudioSpeaker, esphome::mixer_speaker::SourceSpeaker, and esphome::resampler::ResamplerSpeaker.
Definition at line 38 of file speaker.h.
◆ play() [2/3]
virtual size_t esphome::speaker::Speaker::play |
( |
const uint8_t * |
data, |
|
|
size_t |
length |
|
) |
| |
|
pure virtual |
Plays the provided audio data.
If the audio stream is not the default defined in "esphome/core/audio.h" and the speaker component implements it, then this should be called after calling set_audio_stream_info
.
- Parameters
-
data | Audio data in the format specified by set_audio_stream_info method. |
length | The length of the audio data in bytes. |
- Returns
- The number of bytes that were actually written to the speaker's internal buffer.
Implemented in esphome::i2s_audio::I2SAudioSpeaker, esphome::mixer_speaker::SourceSpeaker, and esphome::resampler::ResamplerSpeaker.
◆ play() [3/3]
size_t esphome::speaker::Speaker::play |
( |
const std::vector< uint8_t > & |
data | ) |
|
|
inline |
◆ set_audio_dac()
◆ set_audio_stream_info()
◆ set_mute_state()
virtual void esphome::speaker::Speaker::set_mute_state |
( |
bool |
mute_state | ) |
|
|
inlinevirtual |
◆ set_pause_state()
virtual void esphome::speaker::Speaker::set_pause_state |
( |
bool |
pause_state | ) |
|
|
inlinevirtual |
◆ set_volume()
virtual void esphome::speaker::Speaker::set_volume |
( |
float |
volume | ) |
|
|
inlinevirtual |
◆ start()
virtual void esphome::speaker::Speaker::start |
( |
| ) |
|
|
pure virtual |
◆ stop()
virtual void esphome::speaker::Speaker::stop |
( |
| ) |
|
|
pure virtual |
◆ audio_dac_
◆ audio_output_callback_
CallbackManager<void(uint32_t, uint32_t, uint32_t, uint32_t)> esphome::speaker::Speaker::audio_output_callback_ {} |
|
protected |
◆ audio_stream_info_
◆ mute_state_
bool esphome::speaker::Speaker::mute_state_ {false} |
|
protected |
◆ state_
◆ volume_
float esphome::speaker::Speaker::volume_ {1.0f} |
|
protected |
The documentation for this class was generated from the following file:
- /opt/build/esphome/esphome/components/speaker/speaker.h