lab 1 code

Dependencies:   CMSIS-DSP_for_STM32F746G BSP_DISCO_F746NG

Revision:
27:0d65cfcc9001
Parent:
25:5412779376a7
Child:
28:fe7747b89fb3
--- a/signal_processing.cpp	Wed Jan 01 17:17:36 2020 +0000
+++ b/signal_processing.cpp	Wed Jan 01 17:31:05 2020 +0000
@@ -20,30 +20,13 @@
 
 
 /* ---------------------------------------------------------------------- 
-** Macro Defines  
+** Defines for signal processing
 ** ------------------------------------------------------------------- */ 
 
 #define AUDIO_BLOCK_SAMPLES             ((uint32_t)128)         // Number of samples (L and R) in audio block (each samples is 16 bits)
-#define TEST_LENGTH_SAMPLES 320 
-#define SNR_THRESHOLD_F32       140.0f 
-#define BLOCK_SIZE                      32 
 #define NUM_TAPS                        29 
 
 /* ---------------------------------------------------------------------- 
-** FIR Coefficients buffer generated using fir1() MATLAB function. 
-** fir1(28, 6/24)
-** ------------------------------------------------------------------- */ 
-
-/* 
-const float32_t firCoeffs32[NUM_TAPS] = { 
--0.0018225230f, -0.0015879294f, +0.0000000000f, +0.0036977508f, +0.0080754303f, +0.0085302217f, -0.0000000000f, -0.0173976984f, 
--0.0341458607f, -0.0333591565f, +0.0000000000f, +0.0676308395f, +0.1522061835f, +0.2229246956f, +0.2504960933f, +0.2229246956f, 
-+0.1522061835f, +0.0676308395f, +0.0000000000f, -0.0333591565f, -0.0341458607f, -0.0173976984f, -0.0000000000f, +0.0085302217f, 
-+0.0080754303f, +0.0036977508f, +0.0000000000f, -0.0015879294f, -0.0018225230f 
-}; 
-*/
-
-/* ---------------------------------------------------------------------- 
 ** FIR Coefficients buffer generated using fdatool MATLAB function. 
 ** lowpass filter to passband 1 kHz, stopband 2 kHz
 ** ------------------------------------------------------------------- */ 
@@ -62,22 +45,10 @@
  * Declare State buffer of size (numTaps + blockSize - 1) 
  * ------------------------------------------------------------------- */ 
 
-static float32_t firStateF32[BLOCK_SIZE + NUM_TAPS - 1]; 
+static float32_t firStateF32[AUDIO_BLOCK_SAMPLES + NUM_TAPS - 1];
 
-/* ------------------------------------------------------------------- 
- * Declare Test output buffer 
- * ------------------------------------------------------------------- */ 
-
-static float32_t testOutput[BLOCK_SIZE]; 
 static float32_t output_array_F32[AUDIO_BLOCK_SAMPLES];
 
-/* ------------------------------------------------------------------ 
- * Global variables for FIR LPF Example 
- * ------------------------------------------------------------------- */ 
-
-uint32_t blockSize = BLOCK_SIZE; 
-//uint32_t numBlocks = TEST_LENGTH_SAMPLES/BLOCK_SIZE; 
-uint32_t numBlocks = AUDIO_BLOCK_SAMPLES/BLOCK_SIZE; 
 
 /* Important to have the structure outside of the execution so it can be initialized */
 arm_fir_instance_f32 S; 
@@ -89,7 +60,7 @@
 void initalize_signal_processing(void) {
 
   /* Call FIR init function to initialize the instance structure. */
-  arm_fir_init_f32(&S, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32[0], blockSize); 
+  arm_fir_init_f32(&S, NUM_TAPS, (float32_t *)&firCoeffs32[0], &firStateF32[0], AUDIO_BLOCK_SAMPLES);
 
 }
 
@@ -113,24 +84,16 @@
   arm_status status; 
   float32_t  *inputF32, *outputF32; 
  
-  /* Initialize input and output buffer pointers */ 
-  //inputF32 = &testInput_f32_1kHz_15kHz[0];       
-  //outputF32 = &testOutput[0]; 
   inputF32 = L_channel;
   outputF32 = &output_array_F32[0];
 
- 
   /* ---------------------------------------------------------------------- 
   ** Call the FIR process function for every blockSize samples  
   ** ------------------------------------------------------------------- */ 
 
-  for(i=0; i < numBlocks; i++)  
-    {    
-      arm_fir_f32(&S, inputF32 + (i * blockSize), outputF32 + (i * blockSize), blockSize);  
-    } 
+    arm_fir_f32(&S, inputF32, outputF32, AUDIO_BLOCK_SAMPLES);
 
     /* The following just passes things from the input to the output */
-    //uint16_t i;
     float32_t* L_chan_mem_address;
     float32_t* R_chan_mem_address;
     float32_t L_audio_value;