函数原型:
speaker_config_t config(void);
功能说明:
传入参数:
返回值:
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;
};
函数原型:
void config(const speaker_config_t& cfg);
功能说明:
传入参数:
返回值:
函数原型:
bool begin(void);
功能说明:
传入参数:
返回值:
函数原型:
void end(void);
功能说明:
传入参数:
返回值:
函数原型:
bool isRunning(void);
功能说明:
传入参数:
返回值:
函数原型:
bool isEnabled(void);
功能说明:
传入参数:
返回值:
函数原型:
bool isPlaying(void);
功能说明:
传入参数:
返回值:
函数原型:
size_t isPlaying(uint8_t channel);
功能说明:
传入参数:
返回值:
函数原型:
size_t getPlayingChannels(void);
功能说明:
传入参数:
返回值:
函数原型:
void setVolume(uint8_t master_volume);
功能说明:
传入参数:
返回值:
函数原型:
uint8_t getVolume(void);
功能说明:
传入参数:
返回值:
函数原型:
void setAllChannelVolume(uint8_t volume);
功能说明:
传入参数:
返回值:
函数原型:
void setChannelVolume(uint8_t channel, uint8_t volume);
功能说明:
传入参数:
返回值:
函数原型:
uint8_t getChannelVolume(uint8_t channel);
功能说明:
传入参数:
返回值:
函数原型:
void stop(void);
功能说明:
传入参数:
返回值:
函数原型:
void stop(uint8_t channel);
功能说明:
传入参数:
返回值:
函数原型:
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);
功能说明:
传入参数:
返回值:
函数原型:
bool tone(float frequency, uint32_t duration = UINT32_MAX, int channel = -1, bool stop_current_sound = true);
功能说明:
传入参数:
返回值:
函数原型:
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);
功能说明:
传入参数:
返回值:
函数原型:
bool playWav(const uint8_t* wav_data, size_t data_len = ~0u, uint32_t repeat = 1, int channel = -1, bool stop_current_sound = false);
功能说明:
传入参数:
返回值: