ESPHome  2025.2.0
Data Structures | Enumerations | Functions
esphome::audio Namespace Reference

Data Structures

class  AudioDecoder
 
struct  AudioFile
 
class  AudioReader
 
class  AudioResampler
 
class  AudioSinkTransferBuffer
 
class  AudioSourceTransferBuffer
 
class  AudioStreamInfo
 
class  AudioTransferBuffer
 

Enumerations

enum  AudioFileType : uint8_t { AudioFileType::NONE = 0, AudioFileType::FLAC, AudioFileType::MP3, AudioFileType::WAV }
 
enum  AudioDecoderState : uint8_t { AudioDecoderState::DECODING = 0, AudioDecoderState::FINISHED, AudioDecoderState::FAILED }
 
enum  FileDecoderState : uint8_t {
  FileDecoderState::MORE_TO_PROCESS, FileDecoderState::IDLE, FileDecoderState::POTENTIALLY_FAILED, FileDecoderState::FAILED,
  FileDecoderState::END_OF_FILE
}
 
enum  HttpStatus {
  HTTP_STATUS_OK = 200, HTTP_STATUS_NO_CONTENT = 204, HTTP_STATUS_PARTIAL_CONTENT = 206, HTTP_STATUS_MULTIPLE_CHOICES = 300,
  HTTP_STATUS_MOVED_PERMANENTLY = 301, HTTP_STATUS_FOUND = 302, HTTP_STATUS_SEE_OTHER = 303, HTTP_STATUS_NOT_MODIFIED = 304,
  HTTP_STATUS_TEMPORARY_REDIRECT = 307, HTTP_STATUS_PERMANENT_REDIRECT = 308, HTTP_STATUS_BAD_REQUEST = 400, HTTP_STATUS_UNAUTHORIZED = 401,
  HTTP_STATUS_FORBIDDEN = 403, HTTP_STATUS_NOT_FOUND = 404, HTTP_STATUS_METHOD_NOT_ALLOWED = 405, HTTP_STATUS_NOT_ACCEPTABLE = 406,
  HTTP_STATUS_LENGTH_REQUIRED = 411, HTTP_STATUS_INTERNAL_ERROR = 500
}
 
enum  AudioReaderState : uint8_t { AudioReaderState::READING = 0, AudioReaderState::FINISHED, AudioReaderState::FAILED }
 
enum  AudioResamplerState : uint8_t { AudioResamplerState::RESAMPLING, AudioResamplerState::FINISHED, AudioResamplerState::FAILED }
 

Functions

const char * audio_file_type_to_string (AudioFileType file_type)
 Helper function to convert file type to a const char string. More...
 
void scale_audio_samples (const int16_t *audio_samples, int16_t *output_buffer, int16_t scale_factor, size_t samples_to_scale)
 Scales Q15 fixed point audio samples. More...
 

Enumeration Type Documentation

◆ AudioDecoderState

enum esphome::audio::AudioDecoderState : uint8_t
strong
Enumerator
DECODING 
FINISHED 
FAILED 

Definition at line 30 of file audio_decoder.h.

◆ AudioFileType

enum esphome::audio::AudioFileType : uint8_t
strong
Enumerator
NONE 
FLAC 
MP3 
WAV 

Definition at line 108 of file audio.h.

◆ AudioReaderState

enum esphome::audio::AudioReaderState : uint8_t
strong
Enumerator
READING 
FINISHED 
FAILED 

Definition at line 17 of file audio_reader.h.

◆ AudioResamplerState

enum esphome::audio::AudioResamplerState : uint8_t
strong
Enumerator
RESAMPLING 
FINISHED 
FAILED 

Definition at line 22 of file audio_resampler.h.

◆ FileDecoderState

enum esphome::audio::FileDecoderState : uint8_t
strong
Enumerator
MORE_TO_PROCESS 
IDLE 
POTENTIALLY_FAILED 
FAILED 
END_OF_FILE 

Definition at line 37 of file audio_decoder.h.

◆ HttpStatus

Enumerator
HTTP_STATUS_OK 
HTTP_STATUS_NO_CONTENT 
HTTP_STATUS_PARTIAL_CONTENT 
HTTP_STATUS_MULTIPLE_CHOICES 
HTTP_STATUS_MOVED_PERMANENTLY 
HTTP_STATUS_FOUND 
HTTP_STATUS_SEE_OTHER 
HTTP_STATUS_NOT_MODIFIED 
HTTP_STATUS_TEMPORARY_REDIRECT 
HTTP_STATUS_PERMANENT_REDIRECT 
HTTP_STATUS_BAD_REQUEST 
HTTP_STATUS_UNAUTHORIZED 
HTTP_STATUS_FORBIDDEN 
HTTP_STATUS_NOT_FOUND 
HTTP_STATUS_METHOD_NOT_ALLOWED 
HTTP_STATUS_NOT_ACCEPTABLE 
HTTP_STATUS_LENGTH_REQUIRED 
HTTP_STATUS_INTERNAL_ERROR 

Definition at line 26 of file audio_reader.cpp.

Function Documentation

◆ audio_file_type_to_string()

const char * esphome::audio::audio_file_type_to_string ( AudioFileType  file_type)

Helper function to convert file type to a const char string.

Parameters
file_type
Returns
const char pointer to the readable file type

Definition at line 40 of file audio.cpp.

◆ scale_audio_samples()

void esphome::audio::scale_audio_samples ( const int16_t *  audio_samples,
int16_t *  output_buffer,
int16_t  scale_factor,
size_t  samples_to_scale 
)

Scales Q15 fixed point audio samples.

Scales in place if audio_samples == output_buffer.

Parameters
audio_samplesPCM int16 audio samples
output_bufferBuffer to store the scaled samples
scale_factorQ15 fixed point scaling factor
samples_to_scaleNumber of samples to scale

Definition at line 57 of file audio.cpp.