rst:0x1 (POWERON_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:7084
ho 0 tail 12 room 4
load:0x40078000,len:15576
ho 0 tail 12 room 4
load:0x40080400,len:4
load:0x40080404,len:3876
entry 0x4008064c
I (33) boot: ESP-IDF v5.1-dirty 2nd stage bootloader
I (33) boot: compile time Aug 15 2023 08:36:22
I (33) boot: Multicore bootloader
I (38) boot: chip revision: v3.0
I (41) boot.esp32: SPI Speed : 40MHz
I (46) boot.esp32: SPI Mode : DIO
I (51) boot.esp32: SPI Flash Size : 8MB
I (55) boot: Enabling RNG early entropy source...
I (61) boot: Partition Table:
I (64) boot: ## Label Usage Type ST Offset Length
I (71) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (79) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (86) boot: 2 factory factory app 00 00 00010000 005a0000
I (94) boot: End of partition table
I (98) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=364b0h (222384) map
I (152) esp_image: segment 1: paddr=000464d8 vaddr=3ffb0000 size=04304h ( 17156) load
I (157) esp_image: segment 2: paddr=0004a7e4 vaddr=40080000 size=05834h ( 22580) load
I (164) esp_image: segment 3: paddr=00050020 vaddr=400d0020 size=d2bd8h (863192) map
I (344) esp_image: segment 4: paddr=00122c00 vaddr=40085834 size=1215ch ( 74076) load
I (376) boot: Loaded app from partition at offset 0x10000
I (376) boot: Disabling RNG early entropy source...
I (387) cpu_start: Multicore app
I (388) quad_psram: This chip is ESP32-D0WD
I (390) esp_psram: Found 8MB PSRAM device
I (390) esp_psram: Speed: 40MHz
I (393) esp_psram: PSRAM initialized, cache is in low/high (2-core) mode.
W (401) esp_psram: Virtual address not enough for PSRAM, map as much as we can. 4MB is mapped
I (410) cpu_start: Pro cpu up.
I (414) cpu_start: Starting app cpu, entry point is 0x4008198c
I (0) cpu_start: App cpu up.
I (1326) esp_psram: SPI SRAM memory test OK
I (1334) cpu_start: Pro cpu start user code
I (1334) cpu_start: cpu freq: 240000000 Hz
I (1334) cpu_start: Application information:
I (1337) cpu_start: Project name: play_http_mp3
I (1343) cpu_start: App version: 1
I (1347) cpu_start: Compile time: Aug 15 2023 08:34:42
I (1354) cpu_start: ELF file SHA256: 911aba91c697095b...
I (1360) cpu_start: ESP-IDF: v5.1-dirty
I (1365) cpu_start: Min chip rev: v0.0
I (1370) cpu_start: Max chip rev: v3.99
I (1375) cpu_start: Chip rev: v3.0
I (1380) heap_init: Initializing. RAM available for dynamic allocation:
I (1387) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (1393) heap_init: At 3FFB8D40 len 000272C0 (156 KiB): DRAM
I (1399) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (1406) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1412) heap_init: At 40097990 len 00008670 (33 KiB): IRAM
I (1419) esp_psram: Adding pool of 4096K of PSRAM memory to heap allocator
I (1427) spi_flash: detected chip: gd
I (1430) spi_flash: flash io: dio
W (1435) ADC: legacy driver is deprecated, please migrate to esp_adc/adc_oneshot.h
W (1443) i2s(legacy): legacy i2s driver is deprecated, please migrate to use driver/i2s_std.h, driver/i2s_pdm.h or driver/i2s_tdm.h
I (1456) app_start: Starting scheduler on CPU0
I (1461) app_start: Starting scheduler on CPU1
I (1461) main_task: Started on CPU0
I (1471) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (1471) main_task: Calling app_main()
I (1481) code: [ 1 ] nvs flash
I (1521) code: [ 2 ] Start codec chip
E (1551) gpio: gpio_install_isr_service(498): GPIO isr service already installed
I (1551) code: [ 3 ] Start and wait for Wi-Fi network
W (3861) PERIPH_WIFI: WiFi Event cb, Unhandle event_base:WIFI_EVENT, event_id:4
I (4861) code: [4] Mount sdcard
I (5361) code: [ 5 ] Initialize Button peripheral with board init
I (5361) code: [ 6 ] Create and start input key service
W (5361) code: [ 7 ] Waiting for a button to be pressed ...
W (5381) PERIPH_TOUCH: _touch_init
I (9851) code: Selected mode: Play from HTTP
E (9851) code: Pipeline initialization failed
I (9851) code: Initializing HTTP Stream Element
E (9851) code: Pipeline initialization failed
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
rst:0x1 (POWERON_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT) configsip: 0, SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 mode:DIO, clock div:2 load:0x3fff0030,len:7084 ho 0 tail 12 room 4 load:0x40078000,len:15576 ho 0 tail 12 room 4 load:0x40080400,len:4 load:0x40080404,len:3876 entry 0x4008064c I (33) boot: ESP-IDF v5.1-dirty 2nd stage bootloader I (33) boot: compile time Aug 15 2023 08:36:22 I (33) boot: Multicore bootloader I (38) boot: chip revision: v3.0 I (41) boot.esp32: SPI Speed : 40MHz I (46) boot.esp32: SPI Mode : DIO I (51) boot.esp32: SPI Flash Size : 8MB I (55) boot: Enabling RNG early entropy source... I (61) boot: Partition Table: I (64) boot: ## Label Usage Type ST Offset Length I (71) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (79) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (86) boot: 2 factory factory app 00 00 00010000 005a0000 I (94) boot: End of partition table I (98) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=364b0h (222384) map I (152) esp_image: segment 1: paddr=000464d8 vaddr=3ffb0000 size=04304h ( 17156) load I (157) esp_image: segment 2: paddr=0004a7e4 vaddr=40080000 size=05834h ( 22580) load I (164) esp_image: segment 3: paddr=00050020 vaddr=400d0020 size=d2bd8h (863192) map I (344) esp_image: segment 4: paddr=00122c00 vaddr=40085834 size=1215ch ( 74076) load I (376) boot: Loaded app from partition at offset 0x10000 I (376) boot: Disabling RNG early entropy source... I (387) cpu_start: Multicore app I (388) quad_psram: This chip is ESP32-D0WD I (390) esp_psram: Found 8MB PSRAM device I (390) esp_psram: Speed: 40MHz I (393) esp_psram: PSRAM initialized, cache is in low/high (2-core) mode. W (401) esp_psram: Virtual address not enough for PSRAM, map as much as we can. 4MB is mapped I (410) cpu_start: Pro cpu up. I (414) cpu_start: Starting app cpu, entry point is 0x4008198c I (0) cpu_start: App cpu up. I (1326) esp_psram: SPI SRAM memory test OK I (1334) cpu_start: Pro cpu start user code I (1334) cpu_start: cpu freq: 240000000 Hz I (1334) cpu_start: Application information: I (1337) cpu_start: Project name: play_http_mp3 I (1343) cpu_start: App version: 1 I (1347) cpu_start: Compile time: Aug 15 2023 08:34:42 I (1354) cpu_start: ELF file SHA256: 911aba91c697095b... I (1360) cpu_start: ESP-IDF: v5.1-dirty I (1365) cpu_start: Min chip rev: v0.0 I (1370) cpu_start: Max chip rev: v3.99 I (1375) cpu_start: Chip rev: v3.0 I (1380) heap_init: Initializing. RAM available for dynamic allocation: I (1387) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM I (1393) heap_init: At 3FFB8D40 len 000272C0 (156 KiB): DRAM I (1399) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM I (1406) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (1412) heap_init: At 40097990 len 00008670 (33 KiB): IRAM I (1419) esp_psram: Adding pool of 4096K of PSRAM memory to heap allocator I (1427) spi_flash: detected chip: gd I (1430) spi_flash: flash io: dio W (1435) ADC: legacy driver is deprecated, please migrate to
esp_adc/adc_oneshot.h
W (1443) i2s(legacy): legacy i2s driver is deprecated, please migrate to use driver/i2s_std.h, driver/i2s_pdm.h or driver/i2s_tdm.h I (1456) app_start: Starting scheduler on CPU0 I (1461) app_start: Starting scheduler on CPU1 I (1461) main_task: Started on CPU0 I (1471) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations I (1471) main_task: Calling app_main() I (1481) code: [ 1 ] nvs flash I (1521) code: [ 2 ] Start codec chip E (1551) gpio: gpio_install_isr_service(498): GPIO isr service already installed I (1551) code: [ 3 ] Start and wait for Wi-Fi network W (3861) PERIPH_WIFI: WiFi Event cb, Unhandle event_base:WIFI_EVENT, event_id:4 I (4861) code: [4] Mount sdcard I (5361) code: [ 5 ] Initialize Button peripheral with board init I (5361) code: [ 6 ] Create and start input key service W (5361) code: [ 7 ] Waiting for a button to be pressed ... W (5381) PERIPH_TOUCH: _touch_init I (9851) code: Selected mode: Play from HTTP E (9851) code: Pipeline initialization failed I (9851) code: Initializing HTTP Stream Element E (9851) code: Pipeline initialization failed Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.Core 1 register dump: PC : 0x4018a46b PS : 0x00060630 A0 : 0x800df934 A1 : 0x3ffd6840
A2 : 0x0000000c A3 : 0x0000000c A4 : 0x00000020 A5 : 0x3f816ab8
A6 : 0x00000000 A7 : 0x00000002 A8 : 0x800931cf A9 : 0x3ffd6820
A10 : 0x00001068 A11 : 0x00000000 A12 : 0x00000010 A13 : 0x3f816b94
A14 : 0x00000000 A15 : 0x00000001 SAR : 0x0000000c EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000068 LBEG : 0x4008be3a LEND : 0x4008be45 LCOUNT : 0x00000000
Backtrace: 0x4018a468:0x3ffd6840 0x400df931:0x3ffd6860 0x400dff8d:0x3ffd6890 0x400dd160:0x3ffd68e0 0x400dd4df:0x3ffd69a0 0x400dd809:0x3ffd69c0 0x400e4f79:0x3ffd69f0 0x40090b96:0x3ffd6a40
`#include "esp_log.h"
include "board.h"
include "esp_wifi.h"
include "nvs_flash.h"
include "esp_peripherals.h"
include "periph_adc_button.h"
include "input_key_service.h"
include "periph_wifi.h"
include "periph_sdcard.h"
include "audio_pipeline.h"
include
include "freertos/FreeRTOS.h"
include "freertos/task.h"
include "freertos/timers.h"
include "sdkconfig.h"
include "audio_element.h"
include "audio_event_iface.h"
include "audio_mem.h"
include "audio_common.h"
include "http_stream.h"
include "fatfs_stream.h"
include "i2s_stream.h"
include "wav_encoder.h"
include "wav_decoder.h"
include "filter_resample.h"
include "periph_button.h"
include "esp_netif.h"
define RECORD_TIME_SECONDS 130
define RECORD_RATE 48000
define RECORD_CHANNEL 2
define RECORD_BITS 16
define SAVE_FILE_RATE 16000
define SAVE_FILE_CHANNEL 1
define SAVE_FILE_BITS 16
define PLAYBACK_RATE 48000
define PLAYBACK_CHANNEL 2
define PLAYBACK_BITS 16
define CONFIG_WIFI_SSID "Pixel_2261"
define CONFIG_WIFI_PASSWORD "123412341234"
static const char *TAG = "code"; static bool r = false; esp_periph_set_handle_t set; esp_periph_config_t periph_cfg = DEFAULT_ESP_PERIPH_SET_CONFIG();
/***/
static audio_element_handle_t create_filter(int source_rate, int source_channel, int dest_rate, int dest_channel, int mode) { rsp_filter_cfg_t rsp_cfg = DEFAULT_RESAMPLE_FILTER_CONFIG(); rsp_cfg.src_rate = source_rate; rsp_cfg.src_ch = source_channel; rsp_cfg.dest_rate = dest_rate; rsp_cfg.dest_ch = dest_channel; rsp_cfg.mode = mode; rsp_cfg.complexity = 0; return rsp_filter_init(&rsp_cfg); }
static audio_element_handle_t create_fatfs_stream(int sample_rates, int bits, int channels, audio_stream_type_t type) { fatfs_stream_cfg_t fatfs_cfg = FATFS_STREAM_CFG_DEFAULT(); fatfs_cfg.type = type; audio_element_handle_t fatfs_stream = fatfs_stream_init(&fatfs_cfg); mem_assert(fatfs_stream); audio_element_info_t writer_info = {0}; audio_element_getinfo(fatfs_stream, &writer_info); writer_info.bits = bits; writer_info.channels = channels; writer_info.sample_rates = sample_rates; audio_element_setinfo(fatfs_stream, &writer_info); return fatfs_stream; }
static audio_element_handle_t create_i2s_stream(int sample_rates, int bits, int channels, audio_stream_type_t type) { i2s_stream_cfg_t i2s_cfg = I2S_STREAM_CFG_DEFAULT(); i2s_cfg.type = type; audio_element_handle_t i2s_stream = i2s_stream_init(&i2s_cfg); mem_assert(i2s_stream); audio_element_set_music_info(i2s_stream, sample_rates, channels, bits); return i2s_stream; }
static audio_element_handle_t create_wav_encoder() { wav_encoder_cfg_t wav_cfg = DEFAULT_WAV_ENCODER_CONFIG(); return wav_encoder_init(&wav_cfg); }
static audio_element_handle_t create_wav_decoder() { wav_decoder_cfg_t wav_cfg = DEFAULT_WAV_DECODER_CONFIG(); return wav_decoder_init(&wav_cfg); }
static audio_element_handle_t create_http_stream() { ESP_LOGI(TAG, "Initializing HTTP Stream Element"); http_stream_cfg_t http_cfg = HTTP_STREAM_CFG_DEFAULT(); http_cfg.multi_out_num = 1; audio_element_handle_t http_stream = http_stream_init(&http_cfg); audio_element_set_uri(http_stream,"https://dl.espressif.com/dl/audio/ff-16b-2c-44100hz.mp3"); return http_stream; }
//*listening**///
static void sd(const char *filename) { // Create audio elements audio_element_handle_t fatfas = create_fatfs_stream(SAVE_FILE_RATE, SAVE_FILE_BITS, SAVE_FILE_CHANNEL, AUDIO_STREAM_WRITER); audio_element_handle_t wav_decoder = create_wav_decoder(); audio_element_handle_t filter = create_filter(SAVE_FILE_RATE, SAVE_FILE_CHANNEL, PLAYBACK_RATE, PLAYBACK_CHANNEL, RESAMPLE_DECODE_MODE); audio_element_handle_t i2s_stream_writer = create_i2s_stream(PLAYBACK_RATE, PLAYBACK_BITS, PLAYBACK_CHANNEL, AUDIO_STREAM_WRITER);
}
static void rec(){ audio_element_handle_t i2s_reader = create_i2s_stream(RECORD_RATE, RECORD_BITS, RECORD_CHANNEL, AUDIO_STREAM_READER); audio_element_handle_t filter = create_filter(RECORD_RATE, RECORD_CHANNEL, SAVE_FILE_RATE, SAVE_FILE_CHANNEL, RESAMPLE_ENCODE_MODE); audio_element_handle_t wav_encoder = create_wav_encoder(); audio_element_handle_t fatfas_writer = create_fatfs_stream(SAVE_FILE_RATE, SAVE_FILE_BITS, SAVE_FILE_CHANNEL, AUDIO_STREAM_WRITER); audio_pipeline_cfg_t pipeline_cfg = DEFAULT_AUDIO_PIPELINE_CONFIG(); audio_pipeline_handle_t pipeline = audio_pipeline_init(&pipeline_cfg); if (pipeline == NULL) { ESP_LOGE(TAG, "Pipeline initialization failed"); }; // Register and link audio elements audio_pipeline_register_more(pipeline, i2s_reader,filter,wav_encoder,fatfas_writer); esp_err_t link_result = audio_pipeline_link_more(pipeline,i2s_reader,filter,wav_encoder,fatfas_writer); if (link_result != ESP_OK) { ESP_LOGE(TAG, "Pipeline link failed: %d", link_result); }; audio_element_set_uri(fatfas_writer, "/sdcard/rec.wav"); // Set up event listeners and process based on stream type audio_event_iface_cfg_t evt_cfg = AUDIO_EVENT_IFACE_DEFAULT_CFG(); audio_event_iface_handle_t evt = audio_event_iface_init(&evt_cfg); audio_pipeline_set_listener(pipeline, evt); audio_pipeline_run(pipeline); int second_recorded = 0;
}
static void http() { ESP_LOGE(TAG, "Pipeline initialization failed"); audio_element_handle_t http_stream = create_http_stream(); ESP_LOGE(TAG, "Pipeline initialization failed"); audio_element_handle_t wav_decoder = create_wav_decoder(); audio_element_handle_t i2s_stream_writer = create_i2s_stream(PLAYBACK_RATE, PLAYBACK_BITS, PLAYBACK_CHANNEL, AUDIO_STREAM_WRITER); audio_element_handle_t fatfas_writer = create_fatfs_stream(SAVE_FILE_RATE, SAVE_FILE_BITS, SAVE_FILE_CHANNEL, AUDIO_STREAM_WRITER);
}
static esp_err_t input_key_service_cb(periph_service_handle_t handle, periph_service_event_t evt, void ctx) { audio_element_handle_t wav_encoder = (audio_element_handle_t)ctx;
}
//**** //****
void app_main(void) { esp_log_level_set("*", ESP_LOG_WARN); esp_log_level_set(TAG, ESP_LOG_INFO);
}`
CMakeLists.txt