Here is my initialization code for audio pipeline
Code: Select all
void RECORDER_init(void)
{
esp_log_level_set(TAG, ESP_LOG_INFO);
ESP_LOGI(TAG, "Create audio pipeline for recording");
audio_pipeline_cfg_t pipeline_cfg = DEFAULT_AUDIO_PIPELINE_CONFIG();
pipeline = audio_pipeline_init(&pipeline_cfg);
mem_assert(pipeline);
ESP_LOGI(TAG, "Create http stream to post data to server");
//init streamu http
http_stream_cfg_t http_cfg = HTTP_STREAM_CFG_DEFAULT();
http_cfg.task_prio = 22;
http_cfg.task_core = 0;
http_cfg.type = AUDIO_STREAM_WRITER;
http_cfg.event_handle = _http_stream_event_handle;
http_stream_writer = http_stream_init(&http_cfg);
ESP_LOGI(TAG, "Create i2s stream to read audio data from codec chip");
//init streamu i2s
i2s_stream_cfg_t i2s_cfg = I2S_STREAM_CFG_DEFAULT();
i2s_cfg.type = AUDIO_STREAM_READER;
i2s_cfg.i2s_port = 0;
i2s_cfg.task_core = 1;
i2s_cfg.i2s_config = (i2s_config_t)
{
.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_RX),
.sample_rate = 44100,
.bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
.communication_format = I2S_COMM_FORMAT_I2S_MSB,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 8,
.dma_buf_len = 1024,
.use_apll = true,
.tx_desc_auto_clear = false,
.fixed_mclk = 1
};
static const i2s_pin_config_t pin_config =
{
.bck_io_num = GPIO_NUM_26,
.ws_io_num = GPIO_NUM_25,
.data_out_num = I2S_PIN_NO_CHANGE,
.data_in_num = GPIO_NUM_33
};
i2s_stream_reader = i2s_stream_init(&i2s_cfg);
i2s_set_pin(0, &pin_config);
i2s_stream_set_clk(i2s_stream_reader, 44100, 16, 2);
//ESP_LOGI(TAG, "[3.3] Create a ringbuffer and insert it between mp3 decoder and i2s writer");
//ringbuf = rb_create(1024*2000, 1);
//audio_element_set_output_ringbuf(i2s_stream_reader, ringbuf);
//audio_element_set_input_ringbuf(http_stream_writer, ringbuf);
ESP_LOGI(TAG, "Register all elements to audio pipeline");
audio_pipeline_register(pipeline, i2s_stream_reader, "i2s");
audio_pipeline_register(pipeline, http_stream_writer, "http");
ESP_LOGI(TAG, "Link it together [codec_chip]-->i2s_stream->http_stream-->[http_server]");
const char *link_tag[2] = {"i2s", "http"};
audio_pipeline_link(pipeline, &link_tag[0], 2);
//
audio_element_set_uri(http_stream_writer, CONFIG_SERVER_URI);
}
Code: Select all
# SPI RAM config
#
CONFIG_SPIRAM_TYPE_AUTO=y
# CONFIG_SPIRAM_TYPE_ESPPSRAM32 is not set
# CONFIG_SPIRAM_TYPE_ESPPSRAM64 is not set
CONFIG_SPIRAM_SIZE=-1
CONFIG_SPIRAM_SPEED_40M=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_BOOT_INIT=y
# CONFIG_SPIRAM_USE_MEMMAP is not set
# CONFIG_SPIRAM_USE_CAPS_ALLOC is not set
CONFIG_SPIRAM_USE_MALLOC=y
CONFIG_SPIRAM_MEMTEST=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=y
CONFIG_SPIRAM_CACHE_WORKAROUND=y
#
# SPIRAM cache workaround debugging
#
CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_MEMW=y
# CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_DUPLDST is not set
# CONFIG_SPIRAM_CACHE_WORKAROUND_STRATEGY_NOPS is not set
# end of SPIRAM cache workaround debugging
CONFIG_SPIRAM_BANKSWITCH_ENABLE=y
CONFIG_SPIRAM_BANKSWITCH_RESERVE=8
# CONFIG_SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY is not set