123 static int fftResultReady = 0;
128 static char sHanningWindow = 0;
130 static uint16_t prevFftY[2][
FFT_SIZE / 2 + 1];
142 static const float32_t sHanningWindowCoeff[] = {
300 *result = fftResult + (
FFT_SIZE / 2);
315 static void DC_BlockerSample(int32_t *inOutPtr,
int ch)
320 #define ROUND(x) ((x)>=0?(q31_t)((x)+0.5):(q31_t)((x)-0.5)) 321 #define ALPHA 0.9999 //the factor - the larger the faster to reach DC free signal: 0.999 results in -3dB @ 10Hz 323 static double lastIn[2] = {0.0, 0.0};
324 static double lastOut[2] = {0.0, 0.0};
325 register double tmp, res;
327 tmp = (double)*inOutPtr;
329 res = tmp - lastIn[
ch] +
ALPHA * lastOut[
ch];
333 *inOutPtr =
ROUND(res);
339 q31_t *inBuf = sFFTBuf;
349 sampleBuf += bufLen / (2 +
sizeof(int16_t));
365 *inBuf = (
q31_t)(*sampleBuf++) << 16;
367 DC_BlockerSample(inBuf++, ch);
376 for (i = 0, j = 0; i <
FFT_SIZE; i++)
380 input_c32[2 * i] = input_f32[i] * sHanningWindowCoeff[j];
390 input_c32[2 * i] = input_f32[i];
392 input_c32[2 * i + 1] = 0.0f;
398 #elif FFT_SIZE == 512 400 #elif FFT_SIZE == 256 403 #warning "Error: NOT supported FFT size" 412 for (i = 0; i < 8; i++)
414 fftResult[i] = fftResult[i] * sHanningWindowCoeff[i + 120-1];
419 arm_max_f32(&fftResult[skipFFTBins], FFT_SIZE / 2 - skipFFTBins, &sFFTmaxValue, &testIndex);
420 arm_min_f32(&fftResult[skipFFTBins], FFT_SIZE / 2 - skipFFTBins, &sFFTminValue, &testIndex);
462 if (FFTmaxValue > 0.00005f)
466 dBInt = (int)(dB * 100.0);
467 sprintf(s,
"%4d.%2ddB", dBInt / 100, dBInt % 100);
475 if (FFTminValue > 0.00001f)
477 dB = sFFTmaxValue / sFFTminValue;
479 dBInt = (int)(dB * 100.0);
480 sprintf(s,
"%4d.%2ddB", dBInt / 100, dBInt % 100);
492 const uint8_t
lookupInd[] = {25, 27, 30, 34, 39, 45, 52, 60, 69, 79, 90, 102, 115, 127};
511 valInd = skipFFTBins;
526 fFftVal /= sFFTmaxValue;
527 fftVal = (int)fFftVal;
554 while (valInd < nextInd)
558 if (maxFftVal < fFftVal)
565 maxFftVal /= sFFTmaxValue;
566 fftVal = (int)maxFftVal;
590 if (tsState.
touchX[0] < 100)
594 if (tsState.
touchX[0] > (800 - 100))
603 FFT_DisplayMagnitude(ch, sFFTmaxValue, sFFTminValue);
623 valInd = skipFFTBins;
634 fFftVal /= sFFTmaxValue;
635 fftVal = (int)fFftVal;
649 prevFftY[
ch][valInd] = fftVal;
665 if (tsState.
touchX[0] < 100)
669 if (tsState.
touchX[0] > (800 - 100))
677 FFT_DisplayMagnitude(ch, sFFTmaxValue, sFFTminValue);
689 int fftVal, fftValNext;
690 float fFftVal, fFftValNext;
699 if ((tsState.
touchX[0] > 100) && (tsState.
touchX[0] < (800 - 100)))
713 valInd = skipFFTBins;
722 fFftVal /= sFFTmaxValue;
723 fftVal = (int)fFftVal;
726 fFftValNext /= sFFTmaxValue;
727 fftValNext = (int)fFftValNext;
741 prevFftY[
ch][valInd] = fftVal;
751 prevFftY[
ch][valInd] = fftValNext;
759 if (tsState.
touchX[0] < 100)
763 if (tsState.
touchX[0] > (800 - 100))
771 FFT_DisplayMagnitude(ch, sFFTmaxValue, sFFTminValue);
void FFT_Display_Lines(int ch)
Draw FFT as (connected) lines (default)
void arm_cfft_f32(const arm_cfft_instance_f32 *S, float32_t *p1, uint8_t ifftFlag, uint8_t bitReverseFlag)
Processing function for the floating-point complex FFT.
void BSP_LCD_SetFont(sFONT *fonts)
Sets the LCD text font.
float float32_t
32-bit floating-point type definition.
TS_StateTypeDef Define TS State structure.
void BSP_LCD_FillRect(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
Draws a full rectangle in currently active layer.
const arm_cfft_instance_f32 arm_cfft_sR_f32_len256
void BSP_LCD_SetBackColor(uint32_t Color)
Sets the LCD background color.
void BSP_LCD_DisplayStringAt(uint16_t Xpos, uint16_t Ypos, uint8_t *Text, Text_AlignModeTypdef Mode)
Displays characters in currently active layer.
int32_t FFT_Filter(int ch)
void arm_min_f32(float32_t *pSrc, uint32_t blockSize, float32_t *pResult, uint32_t *pIndex)
Minimum value of a floating-point vector.
This file contains the common defines and functions prototypes for the stm32469i_discovery_lcd.c driver.
void arm_q31_to_float(q31_t *pSrc, float32_t *pDst, uint32_t blockSize)
Converts the elements of the Q31 vector to floating-point vector.
void BSP_LCD_DrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
Draws an uni-line (between two points) in currently active layer.
#define LCD_COLOR_BLACK
Black value in ARGB8888 format.
const arm_cfft_instance_f32 arm_cfft_sR_f32_len512
const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024
void BSP_LCD_SetTextColor(uint32_t Color)
Sets the LCD text color.
uint8_t BSP_TS_GetState(TS_StateTypeDef *TS_State)
Returns status and positions of the touch screen.
uint16_t touchY[TS_MAX_NB_TOUCH]
int AUDIO_PLAYER_GetState(void)
void AUDIO_Player_UDANTERestart(void)
Restart and sync audio for Network Audio.
int32_t q31_t
32-bit fractional data type in 1.31 format.
const uint8_t lookupInd[]
void arm_cmplx_mag_f32(float32_t *pSrc, float32_t *pDst, uint32_t numSamples)
Floating-point complex magnitude.
void FFT_DisplayGraph(int ch)
Display the FFT, depending on the barType - which type we want to display.
int AUDIO_PLAYER_GetBuffer(uint8_t **out_BufAddr)
void FFT_Display_BarGraph(int ch)
Draw FFT as bar graph.
void arm_max_f32(float32_t *pSrc, uint32_t blockSize, float32_t *pResult, uint32_t *pIndex)
Maximum value of a floating-point vector.
void FFT_Display_Points(int ch)
Draw FFT as points.
int32_t FFT_Ready(float32_t **result, int *numResults)
uint16_t touchX[TS_MAX_NB_TOUCH]