#include <audio_resampler.h>
|
| AudioResampler (size_t input_buffer_size, size_t output_buffer_size) |
| Allocates the input and output transfer buffers.
|
|
esp_err_t | add_source (std::weak_ptr< RingBuffer > &input_ring_buffer) |
| Adds a source ring buffer for audio data.
|
|
esp_err_t | add_sink (std::weak_ptr< RingBuffer > &output_ring_buffer) |
| Adds a sink ring buffer for resampled audio.
|
|
esp_err_t | add_sink (speaker::Speaker *speaker) |
| Adds a sink speaker for decoded audio.
|
|
esp_err_t | start (AudioStreamInfo &input_stream_info, AudioStreamInfo &output_stream_info, uint16_t number_of_taps, uint16_t number_of_filters) |
| Sets up the class to resample.
|
|
AudioResamplerState | resample (bool stop_gracefully, int32_t *ms_differential) |
| Resamples audio from the ring buffer source and writes to the sink.
|
|
void | set_pause_output_state (bool pause_state) |
| Pauses sending resampled audio to the sink.
|
|
Definition at line 29 of file audio_resampler.h.
◆ AudioResampler()
esphome::audio::AudioResampler::AudioResampler |
( |
size_t | input_buffer_size, |
|
|
size_t | output_buffer_size ) |
Allocates the input and output transfer buffers.
- Parameters
-
input_buffer_size | Size of the input transfer buffer in bytes. |
output_buffer_size | Size of the output transfer buffer in bytes. |
Definition at line 14 of file audio_resampler.cpp.
◆ add_sink() [1/2]
esp_err_t esphome::audio::AudioResampler::add_sink |
( |
speaker::Speaker * | speaker | ) |
|
Adds a sink speaker for decoded audio.
- Parameters
-
speaker | pointer to speaker component |
- Returns
- ESP_OK if successsful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated
Definition at line 37 of file audio_resampler.cpp.
◆ add_sink() [2/2]
esp_err_t esphome::audio::AudioResampler::add_sink |
( |
std::weak_ptr< RingBuffer > & | output_ring_buffer | ) |
|
Adds a sink ring buffer for resampled audio.
Takes ownership of the ring buffer in a shared_ptr.
- Parameters
-
output_ring_buffer | weak_ptr of a shared_ptr of the sink ring buffer to transfer ownership |
- Returns
- ESP_OK if successsful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated
Definition at line 28 of file audio_resampler.cpp.
◆ add_source()
esp_err_t esphome::audio::AudioResampler::add_source |
( |
std::weak_ptr< RingBuffer > & | input_ring_buffer | ) |
|
Adds a source ring buffer for audio data.
Takes ownership of the ring buffer in a shared_ptr.
- Parameters
-
input_ring_buffer | weak_ptr of a shared_ptr of the sink ring buffer to transfer ownership |
- Returns
- ESP_OK if successsful, ESP_ERR_NO_MEM if the transfer buffer wasn't allocated
Definition at line 20 of file audio_resampler.cpp.
◆ resample()
AudioResamplerState esphome::audio::AudioResampler::resample |
( |
bool | stop_gracefully, |
|
|
int32_t * | ms_differential ) |
Resamples audio from the ring buffer source and writes to the sink.
- Parameters
-
stop_gracefully | If true, it indicates the file decoder is finished. The resampler will resample all the remaining audio and then finish. |
ms_differential | Pointer to a (int32_t) variable that will store the difference, in milliseconds, between the duration of input audio used and the duration of output audio generated. |
- Returns
- AudioResamplerState
Definition at line 90 of file audio_resampler.cpp.
◆ set_pause_output_state()
void esphome::audio::AudioResampler::set_pause_output_state |
( |
bool | pause_state | ) |
|
|
inline |
Pauses sending resampled audio to the sink.
If paused, it will continue to process internal buffers.
- Parameters
-
pause_state | If true, audio data is not sent to the sink. |
Definition at line 79 of file audio_resampler.h.
◆ start()
esp_err_t esphome::audio::AudioResampler::start |
( |
AudioStreamInfo & | input_stream_info, |
|
|
AudioStreamInfo & | output_stream_info, |
|
|
uint16_t | number_of_taps, |
|
|
uint16_t | number_of_filters ) |
Sets up the class to resample.
- Parameters
-
input_stream_info | The incoming sample rate, bits per sample, and number of channels |
output_stream_info | The desired outgoing sample rate, bits per sample, and number of channels |
number_of_taps | Number of taps per FIR filter |
number_of_filters | Number of FIR filters |
- Returns
- ESP_OK if it is able to convert the incoming stream, ESP_ERR_NO_MEM if the transfer buffers failed to allocate, ESP_ERR_NOT_SUPPORTED if the stream can't be converted.
Definition at line 46 of file audio_resampler.cpp.
◆ accumulated_frames_generated_
uint32_t esphome::audio::AudioResampler::accumulated_frames_generated_ {0} |
|
protected |
◆ accumulated_frames_used_
uint32_t esphome::audio::AudioResampler::accumulated_frames_used_ {0} |
|
protected |
◆ input_buffer_size_
size_t esphome::audio::AudioResampler::input_buffer_size_ |
|
protected |
◆ input_stream_info_
◆ input_transfer_buffer_
◆ output_buffer_size_
size_t esphome::audio::AudioResampler::output_buffer_size_ |
|
protected |
◆ output_stream_info_
◆ output_transfer_buffer_
◆ pause_output_
bool esphome::audio::AudioResampler::pause_output_ {false} |
|
protected |
◆ resampler_
std::unique_ptr<esp_audio_libs::resampler::Resampler> esphome::audio::AudioResampler::resampler_ |
|
protected |
The documentation for this class was generated from the following files: