演示参考下方视频 介绍 本项目使用esp32s3,ifd4.2,声音传感器以及tft显示屏构成使用快速傅里叶变换算法处理采集到的音频数据fft处理后的数据使用lvgl显示在tft屏幕上 电路图 源码 登录后复制 void FFT_Task(void *arg) { static int8_t i2s_readraw_buff[1024]; size_t bytesread; int16_t *buffptr; int16_t *samples_sc16 = (int16_t *)i2s_readraw_buff; float *samples_fc32 = (float *)calloc(SAMPLES_NUM, sizeof(float)); double data = 0; i2s_init(); while (1) { if (fft_en == 1) { i2s_read(I2S_NUM_0, (char *)i2s_readraw_buff, SAMPLES_NUM * 2, &bytesread, (100 / portTICK_RATE_MS)); fft_config_t *real_fft_plan = fft_init(512, FFT_REAL, FFT_FORWARD, NULL, NULL); buffptr = (int16_t *)i2s_readraw_buff; for (uint16_t count_n = 0; count_n < real_fft_plan->size; count_n++) { real_fft_plan->input[count_n] = (float)map(buffptr[count_n], INT16_MIN, INT16_MAX, -1000, 1000); } fft_execute(real_fft_plan); for (uint16_t count_n = 1; count_n < CANVAS_HEIGHT; count_n++) { data = sqrt(real_fft_plan->output[2 * count_n] * real_fft_plan->output[2 * count_n] + real_fft_plan->output[2 * count_n + 1] * real_fft_plan->output[2 * count_n + 1]); fft_dis_buff[CANVAS_HEIGHT - count_n] = map(data, 0, 2000, 0, CANVAS_HEIGHT); } fft_destroy(real_fft_plan); for (uint16_t count_y = 0; count_y < CANVAS_HEIGHT;) { lv_chart_set_next(chart_fft, series_fft, fft_dis_buff[count_y]); count_y += 5; } } else { i2s_driver_uninstall(I2S_NUM_0); vTaskDelete(NULL); } } } 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44. 原创作者: u_14938734 转载于: https://blog.51cto.com/u_14938734/11576200