# HeadFi ## ESP32 ### Settings ![](https://hackmd.io/_uploads/rkrmKJ_Jp.png) ![](https://hackmd.io/_uploads/rkONKkuk6.png) > https://www.dev2qa.com/how-to-fix-python-error-certificate-verify-failed-unable-to-get-local-issuer-certificate-in-mac-os/?expand_article=1 ERROR: tool xtensa-esp32s2-elf has no installed versions. Please run '/Users/macbook_qiuchonghao/esp/esp-idf/install.sh' to install it. ERROR: tool esp32s2ulp-elf has no installed versions. Please run '/Users/macbook_qiuchonghao/esp/esp-idf/install.sh' to install it. idf version: 5.1 esp-adf: https://github.com/espressif/esp-adf pipeline-record-to-sd-card: https://github.com/espressif/esp-adf/tree/release/v2.4/examples/recorder/pipeline_recording_to_sdcard#default-idf-branch adf - official guide: https://docs.espressif.com/projects/esp-adf/en/v2.0/get-started/index.html ### Recording Audio ringbuffer: 1. 初始化阶段: * 通过 esp_log_level_set 设置日志级别。 * 初始化音频硬件,包括SD卡(audio_board_sdcard_init)和音频编解码芯片(audio_board_init 和 audio_hal_ctrl_codec)。 2. 创建音频管道: * 使用 audio_pipeline_init 创建音频处理管道,它是一个音频处理元素的链表,每个元素代表音频处理的一个步骤。 3. 创建音频元素: * 创建不同的音频元素,包括: * fatfs_stream_writer:用于将音频数据写入SD卡的音频元素。 * i2s_stream_reader:从音频输入(通常是麦克风)读取音频数据的音频元素。 * audio_encoder:音频编码器,根据配置选择不同的编码器(如WAV、Opus、AAC等)。 5. 注册音频元素: * 使用 audio_pipeline_register 将创建的音频元素注册到音频处理管道中。 6. 连接音频元素: * 使用 audio_pipeline_link 将注册的音频元素链接在一起,构建音频数据流的路径。 7. 设置音频元素的URI: * 使用 audio_element_set_uri 设置 fatfs_stream_writer 的URI,以指定音频数据写入的目标文件。 8. 设置事件监听器: * 创建音频事件接口(audio_event_iface_t)并将其设置为音频管道的监听器,以监听音频事件(如开始、停止等)。 9. 开始音频管道: * 使用 audio_pipeline_run 启动音频管道。 10. 录制音频: * 在 while 循环中,使用 audio_event_iface_listen 从事件接口中获取事件消息。如果没有事件消息,表示正在录制音频,会输出录制的时间。如果收到停止事件或达到预定的录制时间,会停止录制。 11. 停止音频管道: * 使用 audio_pipeline_stop 和相关函数停止音频管道。 12. 释放资源: * 对所有音频元素和管道进行反初始化和销毁,释放相关资源。 至于通信协议,主要涉及到音频数据的传输和编解码。在这个示例中,主要的数据传输是通过I2S(Inter-IC Sound)接口完成的,这是一种用于数字音频数据传输的通信协议。此外,音频编码器根据不同的配置选择不同的音频编码协议,如WAV、Opus、AAC等。 ## MAX78000 ### Official Example Projects ##### HELLO WORLD plan: print: ```cpp ``` GPIO button sd card read write: [Analyze example code](https://hackmd.io/@0ZlJMdaXT3OhXvi6qrxFBA/r1k2QOIxT) audio input and write