lab 1 code

Dependencies:   CMSIS-DSP_for_STM32F746G BSP_DISCO_F746NG

Revision:
22:f36d7a53bb7e
Parent:
21:4dbfda694c0d
Child:
23:d938f87dd1ee
--- a/main.cpp	Tue Dec 31 19:50:33 2019 +0000
+++ b/main.cpp	Tue Dec 31 20:10:06 2019 +0000
@@ -52,7 +52,7 @@
 float       *R_channel_float_p = &R_channel_float[0];
 
 /* Back conversion to integer */
-uint16_t    Processed_audio[AUDIO_BLOCK_SAMPLES * 2];
+uint16_t    Processed_audio[AUDIO_BLOCK_SAMPLES];
 uint16_t    *Processed_audio_p = &Processed_audio[0];
 
 /* Useful variables during looping */
@@ -116,14 +116,17 @@
         
         /* Convert data to floating point representation for processing */
         Audio_to_Float((uint16_t *) AUDIO_BUFFER_IN, L_channel_float_p, R_channel_float_p, AUDIO_BLOCK_SAMPLES);
+
+        /* Here is where signal processing can be done on the floating point arrays */
+
+
         
-        sprintf(buf, "Lf[0]:%8.1f Ai[0]:%6d ", L_channel_float[0], ((int16_t) *((uint16_t *) AUDIO_BUFFER_IN)));
-        BSP_LCD_DisplayStringAt(0, 150, (uint8_t *) buf, LEFT_MODE);
+        /* Here is where signal processing can end on the floating point arrays */        
                 
+        /* Covert floating point data back to fixed point audio format */
         Float_to_Audio(L_channel_float_p, R_channel_float_p, (uint16_t *) Processed_audio, AUDIO_BLOCK_SAMPLES);
 
         /* Copy recorded 1st half block into the audio buffer that goes out */
-        //memcpy((uint16_t *)(AUDIO_BUFFER_OUT), (uint16_t *)(AUDIO_BUFFER_IN), AUDIO_BLOCK_SIZE);
         memcpy((uint16_t *)(AUDIO_BUFFER_OUT), (uint16_t *)(Processed_audio), AUDIO_BLOCK_SIZE);
 
         /* Capture the timing of the first half processing */
@@ -137,6 +140,21 @@
         /* Plot traces of second half block recording */
         Erase_Trace(OSC_START_X_POS+AUDIO_BLOCK_SAMPLES, OSC_Y_POS, AUDIO_BLOCK_SAMPLES);
         Draw_Trace( OSC_START_X_POS+AUDIO_BLOCK_SAMPLES, OSC_Y_POS, (uint16_t *) (AUDIO_BUFFER_IN + (AUDIO_BLOCK_SIZE)), AUDIO_BLOCK_SAMPLES);
+
+        /* Convert data to floating point representation for processing */
+        Audio_to_Float((uint16_t *) (AUDIO_BUFFER_IN + (AUDIO_BLOCK_SIZE)), L_channel_float_p, R_channel_float_p, AUDIO_BLOCK_SAMPLES);
+
+        /* Here is where signal processing can be done on the floating point arrays */
+
+
+        
+        /* Here is where signal processing can end on the floating point arrays */        
+                
+        /* Covert floating point data back to fixed point audio format */
+        Float_to_Audio(L_channel_float_p, R_channel_float_p, (uint16_t *) Processed_audio, AUDIO_BLOCK_SAMPLES);
+
+        /* Copy recorded 2nd half block into the audio buffer that goes out */
+        memcpy((uint16_t *)(AUDIO_BUFFER_OUT + (AUDIO_BLOCK_SIZE)), (uint16_t *) (Processed_audio), AUDIO_BLOCK_SIZE);
                 
         /* Compute important cycle information and display it*/
         counter++;
@@ -147,7 +165,7 @@
         BSP_LCD_DisplayStringAt(0, 20, (uint8_t *) buf, LEFT_MODE);
 
         /* Copy recorded 2nd half block into audio output buffer */
-        memcpy((uint16_t *)(AUDIO_BUFFER_OUT + (AUDIO_BLOCK_SIZE)), (uint16_t *)(AUDIO_BUFFER_IN + (AUDIO_BLOCK_SIZE)), AUDIO_BLOCK_SIZE);
+        //memcpy((uint16_t *)(AUDIO_BUFFER_OUT + (AUDIO_BLOCK_SIZE)), (uint16_t *)(AUDIO_BUFFER_IN + (AUDIO_BLOCK_SIZE)), AUDIO_BLOCK_SIZE);
             
         /* Change the recording buffer state to reflect the status of the buffer */   
         audio_rec_buffer_state = BUFFER_OFFSET_NONE;
@@ -170,10 +188,12 @@
   */
 void Erase_Trace(uint16_t Xpos, uint16_t Ypos, uint16_t Length)
 {
+    /* Creates a brown rectangle above and below the axis */
     BSP_LCD_SetTextColor(LCD_COLOR_BROWN);
     BSP_LCD_FillRect(Xpos, Ypos - AUDIO_DRAW_LIMIT, Length, AUDIO_DRAW_LIMIT);
     BSP_LCD_FillRect(Xpos, Ypos+1, Length, AUDIO_DRAW_LIMIT);
     
+    /* Draw axis for plotting */
     BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
     BSP_LCD_DrawHLine(Xpos, Ypos, Length);