|
18 | 18 | #include "core/os.h"
|
19 | 19 | #include "chip/i2s.h"
|
20 | 20 |
|
| 21 | +#include "user/fft.h" |
21 | 22 | #include "user/bt_av.h"
|
22 |
| -#include "user/vfx_fft.h" |
23 | 23 |
|
24 | 24 | #define TAG "audio_render"
|
25 | 25 |
|
26 | 26 | RingbufHandle_t audio_buff = NULL;
|
27 | 27 |
|
| 28 | +static uint8_t buff_data[10 * 1024] = {0}; |
28 | 29 | static StaticRingbuffer_t buff_struct = {0};
|
29 |
| -static uint8_t buff_data[FFT_BLOCK_SIZE * 5] = {0}; |
30 | 30 |
|
31 | 31 | /* render callback for the libmad synth */
|
32 | 32 | void render_sample_block(short *sample_buff_ch0, short *sample_buff_ch1, int num_samples, unsigned int num_channels)
|
@@ -73,7 +73,7 @@ static void audio_render_task(void *pvParameter)
|
73 | 73 | if (!(uxBits & AUDIO_RENDER_CLR_BIT)) {
|
74 | 74 | #ifdef CONFIG_ENABLE_VFX
|
75 | 75 | if (!(uxBits & AUDIO_INPUT_RUN_BIT) && (uxBits & AUDIO_INPUT_FFT_BIT)) {
|
76 |
| - memset(vfx_fft_data, 0x00, sizeof(vfx_fft_data)); |
| 76 | + fft_init(); |
77 | 77 | xEventGroupClearBits(user_event_group, VFX_FFT_IDLE_BIT);
|
78 | 78 | }
|
79 | 79 | #endif
|
@@ -143,32 +143,13 @@ static void audio_render_task(void *pvParameter)
|
143 | 143 | continue;
|
144 | 144 | }
|
145 | 145 |
|
146 |
| - // copy data to FFT input buffer |
147 |
| - uint32_t idx = 0; |
148 |
| - |
149 |
| -#ifdef CONFIG_BT_AUDIO_FFT_ONLY_LEFT |
150 |
| - int16_t data_l = 0; |
151 |
| - for (uint16_t k = 0; k < FFT_N; k++, idx += 4) { |
152 |
| - data_l = data[idx + 1] << 8 | data[idx]; |
153 |
| - |
154 |
| - vfx_fft_data[k] = (float)data_l; |
155 |
| - } |
156 |
| -#elif defined(CONFIG_BT_AUDIO_FFT_ONLY_RIGHT) |
157 |
| - int16_t data_r = 0; |
158 |
| - for (uint16_t k = 0; k < FFT_N; k++, idx += 4) { |
159 |
| - data_r = data[idx + 3] << 8 | data[idx + 2]; |
160 |
| - |
161 |
| - vfx_fft_data[k] = (float)data_r; |
162 |
| - } |
163 |
| -#else |
164 |
| - int16_t data_l = 0, data_r = 0; |
165 |
| - for (uint16_t k = 0; k < FFT_N; k++, idx += 4) { |
166 |
| - data_l = data[idx + 1] << 8 | data[idx]; |
167 |
| - data_r = data[idx + 3] << 8 | data[idx + 2]; |
168 |
| - |
169 |
| - vfx_fft_data[k] = (float)((data_l + data_r) / 2); |
170 |
| - } |
171 |
| -#endif |
| 146 | + #ifdef CONFIG_BT_AUDIO_FFT_ONLY_LEFT |
| 147 | + fft_load_data(data, FFT_CHANNEL_L); |
| 148 | + #elif defined(CONFIG_BT_AUDIO_FFT_ONLY_RIGHT) |
| 149 | + fft_load_data(data, FFT_CHANNEL_R); |
| 150 | + #else |
| 151 | + fft_load_data(data, FFT_CHANNEL_LR); |
| 152 | + #endif |
172 | 153 |
|
173 | 154 | xEventGroupClearBits(user_event_group, VFX_FFT_IDLE_BIT);
|
174 | 155 | #endif
|
|
0 commit comments