Syntax:
speaker_config_t config(void);
Description:
Parameters:
Return:
struct speaker_config_t
{
/// i2s_data_out (for spk)
int pin_data_out = I2S_PIN_NO_CHANGE;
/// i2s_bck
int pin_bck = I2S_PIN_NO_CHANGE;
/// i2s_ws (lrck)
int pin_ws = I2S_PIN_NO_CHANGE;
/// output sampling rate (Hz)
uint32_t sample_rate = 48000;
/// use stereo output
bool stereo = false;
/// use single gpio buzzer, ( need only pin_data_out )
bool buzzer = false;
/// use DAC speaker, ( need only pin_data_out ) ( for ESP32, only GPIO_NUM_25 or GPIO_NUM_26 )
/// ※ for ESP32, need `i2s_port = I2S_NUM_0`. ( DAC+I2S_NUM_1 is not available )
bool use_dac = false;
/// Zero level reference value when using DAC ( 0=Dynamic change )
uint8_t dac_zero_level = 0;
/// multiplier for output value
uint8_t magnification = 16;
/// for I2S dma_buf_len (max 1024)
size_t dma_buf_len = 256;
/// for I2S dma_buf_count
size_t dma_buf_count = 8;
/// background task priority
uint8_t task_priority = 2;
/// background task pinned core
uint8_t task_pinned_core = ~0;
/// I2S port
i2s_port_t i2s_port = i2s_port_t::I2S_NUM_0;
};
Syntax:
void config(const speaker_config_t& cfg);
Description:
Parameters:
Return:
Syntax:
bool begin(void);
Description:
Parameters:
Return:
Syntax:
void end(void);
Description:
Parameters:
Return:
Syntax:
bool isRunning(void);
Description:
Parameters:
Return:
Syntax:
bool isEnabled(void);
Description:
Parameters:
Return:
Syntax:
bool isPlaying(void);
Description:
Parameters:
Return:
Syntax:
size_t isPlaying(uint8_t channel);
Description:
Parameters:
Return:
Syntax:
size_t getPlayingChannels(void);
Description:
Parameters:
Return:
Syntax:
void setVolume(uint8_t master_volume);
Description:
Parameters:
Return:
Syntax:
uint8_t getVolume(void);
Description:
Parameters:
Return:
Syntax:
void setAllChannelVolume(uint8_t volume);
Description:
Parameters:
Return:
Syntax:
void setChannelVolume(uint8_t channel, uint8_t volume);
Description:
Parameters:
Return:
Syntax:
uint8_t getChannelVolume(uint8_t channel);
Description:
Parameters:
Return:
Syntax:
void stop(void);
Description:
Parameters:
Return:
Syntax:
void stop(uint8_t channel);
Description:
Parameters:
Return:
Syntax:
bool tone(float frequency, uint32_t duration, int channel, bool stop_current_sound, const uint8_t* raw_data, size_t array_len, bool stereo = false);
Description:
Parameters:
Return:
Syntax:
bool tone(float frequency, uint32_t duration = UINT32_MAX, int channel = -1, bool stop_current_sound = true);
Description:
Parameters:
Return:
Syntax:
bool playRaw(const int8_t* raw_data, size_t array_len, uint32_t sample_rate = 44100, bool stereo = false, uint32_t repeat = 1, int channel = -1, bool stop_current_sound = false);
bool playRaw(const uint8_t* raw_data, size_t array_len, uint32_t sample_rate = 44100, bool stereo = false, uint32_t repeat = 1, int channel = -1, bool stop_current_sound = false);
bool playRaw(const int16_t* raw_data, size_t array_len, uint32_t sample_rate = 44100, bool stereo = false, uint32_t repeat = 1, int channel = -1, bool stop_current_sound = false);
Description:
Parameters:
Return:
Syntax:
bool playWav(const uint8_t* wav_data, size_t data_len = ~0u, uint32_t repeat = 1, int channel = -1, bool stop_current_sound = false);
Description:
Parameters:
Return: