R&J / Mbed 2 deprecated 487_Laboratory_3

Dependencies:   mbed BSP_DISCO_F746NG mbed-dsp

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers signal_processing.cpp Source File

signal_processing.cpp

00001 /**
00002   ******************************************************************************
00003   * @file    signal_processing.c
00004   * @author  Brian Mazzeo
00005   * @date    2020
00006   * @brief   This file provides a set of code for signal processing in 487.
00007   *          Parts are taken from example code from STMIcroelectronics
00008   ******************************************************************************
00009   * @attention
00010   *          This code was specifically developed for BYU ECEn 487 course 
00011   *          Introduction to Digital Signal Processing.
00012   *
00013   *
00014   ******************************************************************************
00015   */ 
00016 
00017 #include "mbed.h"
00018 #include "stm32746g_discovery_lcd.h"
00019 #include "arm_math.h"
00020 #include "arm_const_structs.h"
00021 
00022 
00023 /* ---------------------------------------------------------------------- 
00024 ** Defines for signal processing
00025 ** ------------------------------------------------------------------- */ 
00026 
00027 #define AUDIO_BLOCK_SAMPLES             ((uint32_t)128)         // Number of samples (L and R) in audio block (each samples is 16 bits)
00028 #define DFT_SIZE                        1024
00029 #define DFT_CMPLX_DATA_SIZE             2048
00030 #define FFT_TYPE                        arm_cfft_sR_f32_len1024
00031 
00032 /* For Lab Exercise */
00033 #define Lab_Execution_Type              0
00034 
00035 
00036 /* Declare the array needed for the data */
00037 
00038 uint32_t X_position_index;
00039 
00040 /* FUNCTION DEFINITIONS BELOW */
00041 
00042 /**
00043   * @brief  Initialize filter structures to be used in loops later
00044   * @retval None
00045   */
00046 void initalize_signal_processing(void) {
00047     char buf[70];    
00048 
00049   switch (Lab_Execution_Type)
00050   {
00051   case 0: // Passthrough case
00052     break;
00053   
00054   case 1: // Direct computation of DFT
00055     break;
00056   
00057   case 2: // ARM version of DFT (FFT)
00058     break;
00059     
00060   case 3: // Two-channel spectrum analyzer - magnitude-squared version
00061     break;
00062 
00063   case 4: // Two-channel spectrum analyzer - dB version
00064     break;
00065 
00066   case 5: // Two-channel spectrum analyzer - dB Exponentially averaging version
00067     break;
00068 
00069   case 6: // Single-channel spectrum analyzer
00070     break;
00071 
00072 
00073 
00074   }
00075 }
00076 
00077 /**
00078   * @brief  Process audio channel signals
00079   * @param  L_channel_in: Pointer to Left channel data input (float32_t)
00080   * @param  R_channel_in: Pointer to Right channel data input (float32_t)
00081   * @param  L_channel_out: Pointer to Left channel data output (float32_t)
00082   * @param  R_channel_out: Pointer to Right channel data output (float32_t)
00083   * @param  Signal_Length: length of data to process
00084   * @retval None
00085   */
00086 void process_audio_channel_signals(float32_t* L_channel_in, float32_t* R_channel_in, float32_t* L_channel_out, float32_t* R_channel_out, uint16_t Signal_Length)
00087 {
00088     char buf[70];    
00089     BSP_LCD_SetFont(&Font8);
00090     BSP_LCD_SetTextColor(LCD_COLOR_CYAN);
00091     sprintf(buf, "Processing Signals" );
00092     BSP_LCD_DisplayStringAt(0, 125, (uint8_t *) buf, LEFT_MODE);
00093       
00094   switch(Lab_Execution_Type)
00095   {
00096   case 0: // Passthrough case
00097     arm_copy_f32(L_channel_in, L_channel_out, AUDIO_BLOCK_SAMPLES);
00098     arm_copy_f32(R_channel_in, R_channel_out, AUDIO_BLOCK_SAMPLES);
00099     break;
00100   
00101   case 1: // Direct computation of DFT
00102     break;
00103     
00104   case 2: // ARM version of DFT 
00105     break;
00106     
00107   case 3: // Two-channel spectrum analyzer - magnitude-squared version
00108     break;
00109 
00110   case 4: // Two-channel spectrum analyzer - dB version
00111     break;
00112 
00113   case 5: // Two-channel spectrum analyzer - dB Exponentially averaging version
00114     break;
00115     
00116   case 6: // Single-channel spectrogram
00117     break;
00118 
00119    
00120   }
00121     /* Change font back */  
00122     BSP_LCD_SetFont(&Font16);
00123 }