Ai-Thinker-Open / ESP32-A1S-AudioKit

Ai-Thinker AudioKit Board SDK - 安信可 esp32-a1s 音频模组开发板
Other
132 stars 63 forks source link

ESP32 Audiokit microphone not recording/working #33

Closed prashvish005 closed 2 years ago

prashvish005 commented 2 years ago

Hello Everyone.

I am using ESP32 Audiokit V2.2 3378. I first ran the example pipeline_a2dp_source_stream example which was reading data from SD and playing music on remote bt headphones. It was working fine.

I then tried running the recording examples but none of them worked (pipeline_recording_to_sdcard).

My audio codec (ES8388) seems to be working. The Pin configurations for my particular board are as follows I2C => i2c_config->sda_io_num = GPIO_NUM_18; i2c_config->scl_io_num = GPIO_NUM_23; I2S => i2s_config->bck_io_num = GPIO_NUM_5; i2s_config->ws_io_num = GPIO_NUM_25; i2s_config->data_out_num = GPIO_NUM_26; i2s_config->data_in_num = GPIO_NUM_35;

from menuconfig, I selected Lyrat 4.3 option for Audio HAL.

Following is the Debug data

I (28) boot: ESP-IDF v4.3.2 2nd stage bootloader I (28) boot: compile time 21:56:13 I (28) boot: chip revision: 1 I (31) boot_comm: chip revision: 1, min. bootloader chip revision: 0 I (38) qio_mode: Enabling default flash chip QIO I (44) boot.esp32: SPI Speed : 80MHz I (48) boot.esp32: SPI Mode : QIO I (53) boot.esp32: SPI Flash Size : 4MB I (57) boot: Enabling RNG early entropy source... I (63) boot: Partition Table: I (66) boot: ## Label Usage Type ST Offset Length I (74) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (81) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (89) boot: 2 factory factory app 00 00 00010000 00100000 I (96) boot: End of partition table I (100) boot_comm: chip revision: 1, min. application chip revision: 0 I (107) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=3eff4h (258036) map I (192) esp_image: segment 1: paddr=0004f01c vaddr=3ffb0000 size=00ffch ( 4092) load I (194) esp_image: segment 2: paddr=00050020 vaddr=400d0020 size=357a0h (219040) map I (263) esp_image: segment 3: paddr=000857c8 vaddr=3ffb0ffc size=01c78h ( 7288) load I (266) esp_image: segment 4: paddr=00087448 vaddr=40080000 size=14ef4h ( 85748) load I (298) esp_image: segment 5: paddr=0009c344 vaddr=50000000 size=00010h ( 16) load I (309) boot: Loaded app from partition at offset 0x10000 I (309) boot: Disabling RNG early entropy source... I (321) psram: This chip is ESP32-D0WD I (322) spiram: Found 64MBit SPI RAM device I (322) spiram: SPI RAM mode: flash 80m sram 80m I (324) spiram: PSRAM initialized, cache is in low/high (2-core) mode. I (331) cpu_start: Pro cpu up. I (335) cpu_start: Starting app cpu, entry point is 0x40081730 0x40081730: call_start_cpu1 at D:/Work/ESP32_IDF/esp-idf/components/esp_system/port/cpu_start.c:150

I (0) cpu_start: App cpu up. I (832) spiram: SPI SRAM memory test OK I (840) cpu_start: Pro cpu start user code I (840) cpu_start: cpu freq: 240000000 I (840) cpu_start: Application information: I (843) cpu_start: Project name: recording_to_sdcard I (849) cpu_start: App version: 1 I (853) cpu_start: Compile time: Dec 29 2021 11:39:44 I (859) cpu_start: ELF file SHA256: ec3f8778a274cfd2... I (865) cpu_start: ESP-IDF: v4.3.2 I (870) heap_init: Initializing. RAM available for dynamic allocation: I (878) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM I (884) heap_init: At 3FFB3848 len 0002C7B8 (177 KiB): DRAM I (890) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM I (896) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (903) heap_init: At 40094EF4 len 0000B10C (44 KiB): IRAM I (909) spiram: Adding pool of 4096K of external SPI memory to heap allocator I (917) spi_flash: detected chip: generic I (921) spi_flash: flash io: qio I (926) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. I (941) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations I (949) RECORD_TO_SDCARD: [ 1 ] Mount sdcard I (1455) RECORD_TO_SDCARD: [ 2 ] Start codec chip E (1455) gpio: gpio_install_isr_service(460): GPIO isr service already installed I (1476) RECORD_TO_SDCARD: [3.0] Create audio pipeline for recording I (1476) RECORD_TO_SDCARD: [3.1] Create fatfs stream to write data to sdcard I (1480) RECORD_TO_SDCARD: [3.2] Create i2s stream to read audio data from codec chip I (1507) RECORD_TO_SDCARD: [3.3] Create audio encoder to handle data I (1507) RECORD_TO_SDCARD: [3.4] Register all elements to audio pipeline I (1511) RECORD_TO_SDCARD: [3.5] Link it together [codec_chip]-->i2s_stream-->audio_encoder-->fatfs_stream-->[sdcard] I (1523) RECORD_TO_SDCARD: [3.6] Set music info to fatfs I (1528) RECORD_TO_SDCARD: [ * ] Save the recording info to the fatfs stream writer, sample_rates=44100, bits=16, ch=2 I (1539) RECORD_TO_SDCARD: [3.7] Set up uri I (1544) RECORD_TO_SDCARD: [ 4 ] Set up event listener I (1550) RECORD_TO_SDCARD: [4.1] Listening event from pipeline I (1557) RECORD_TO_SDCARD: [4.2] Listening event from peripherals I (1563) RECORD_TO_SDCARD: [ 5 ] Start audio_pipeline W (1570) AUIDO_MEM: Can't support stack on external memory due to ESP32 chip is 1 I (1597) RECORD_TO_SDCARD: [ 6 ] Listen for all pipeline events, record for 10 Seconds I (2612) RECORD_TO_SDCARD: [ * ] Recording ... 1 I (3613) RECORD_TO_SDCARD: [ * ] Recording ... 2 I (4613) RECORD_TO_SDCARD: [ * ] Recording ... 3 I (5613) RECORD_TO_SDCARD: [ * ] Recording ... 4 I (6613) RECORD_TO_SDCARD: [ * ] Recording ... 5 I (7614) RECORD_TO_SDCARD: [ * ] Recording ... 6 I (8616) RECORD_TO_SDCARD: [ * ] Recording ... 7 I (9617) RECORD_TO_SDCARD: [ * ] Recording ... 8 I (10618) RECORD_TO_SDCARD: [ * ] Recording ... 9 I (11619) RECORD_TO_SDCARD: [ * ] Recording ... 10 W (11633) RECORD_TO_SDCARD: [ * ] Stop event received I (11633) RECORD_TO_SDCARD: [ 7 ] Stop audio_pipeline E (11634) AUDIO_ELEMENT: [wav] Element already stopped E (11639) AUDIO_ELEMENT: [file] Element already stopped W (11646) AUDIO_PIPELINE: There are no listener registered W (11652) AUDIO_ELEMENT: [file] Element has not create when AUDIO_ELEMENT_TERMINATE W (11660) AUDIO_ELEMENT: [i2s] Element has not create when AUDIO_ELEMENT_TERMINATE W (11668) AUDIO_ELEMENT: [wav] Element has not create when AUDIO_ELEMENT_TERMINATE

The file is getting stored in SD card however there is no voice.

Note: The same example is working when I run it over my Lyrat mini V1.2 which seems to be using different codecs.

Can someone help me with this?

prashvish005 commented 2 years ago

So I got it working after some trials.

I replaced this code to the file and it started working for me file location: esp-adf/components/audio_board/lyrat_v4_3/board.c

audio_hal_handle_t audio_board_codec_init(void) { audio_hal_codec_config_t audio_codec_cfg = AUDIO_CODEC_DEFAULT_CONFIG(); audio_codec_cfg.adc_input = AUDIO_HAL_ADC_INPUT_LINE2; audio_hal_handle_t codec_hal = audio_hal_init(&audio_codec_cfg, &AUDIO_CODEC_ES8388_DEFAULT_HANDLE); AUDIO_NULL_CHECK(TAG, codec_hal, return NULL); return codec_hal; }