Code: Select all
esp_audio_cfg_t cfg = {
.in_stream_buf_size = 10 * 1024,
.out_stream_buf_size = 6 * 1024,
.evt_que = NULL,
.resample_rate = 0,
.hal = NULL,
};
audio_hal_codec_config_t audio_hal_codec_cfg = AUDIO_HAL_ES8388_DEFAULT();
audio_hal_codec_cfg.i2s_iface.samples = AUDIO_HAL_16K_SAMPLES;
cfg.hal = audio_hal_init(&audio_hal_codec_cfg, 0);
cfg.evt_que = xQueueCreate(3, sizeof(esp_audio_state_t));
audio_hal_ctrl_codec(cfg.hal, AUDIO_HAL_CODEC_MODE_BOTH, AUDIO_HAL_CTRL_START);
player = esp_audio_create(&cfg);
wav_encoder_cfg_t wav_enc_cfg = DEFAULT_WAV_ENCODER_CONFIG();
audio_pipeline_cfg_t pipeline_cfg = DEFAULT_AUDIO_PIPELINE_CONFIG();
recorder = audio_pipeline_init(&pipeline_cfg);
audio_pipeline_register(recorder, i2s_stream_reader, "i2s");
audio_pipeline_register(recorder, wav_encoder_init(&wav_enc_cfg), "wav");
audio_pipeline_register(recorder, fs_stream_writer, "file");
audio_pipeline_link(recorder, (const char *[]) {"i2s", "wav", "file"}, 3);
audio_element_set_uri(fs_stream_writer, "/sdcard/rec.wav");