initial
Dependencies: mbed BSP_DISCO_F746NG mbed-dsp
signal_processing.cpp@0:c0f52e8223fe, 2020-01-31 (annotated)
- Committer:
- bmazzeo
- Date:
- Fri Jan 31 21:41:25 2020 +0000
- Revision:
- 0:c0f52e8223fe
- Child:
- 1:103e3e426b55
Code prepared for distribution to ECEn 487 Class.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bmazzeo | 0:c0f52e8223fe | 1 | /** |
bmazzeo | 0:c0f52e8223fe | 2 | ****************************************************************************** |
bmazzeo | 0:c0f52e8223fe | 3 | * @file signal_processing.c |
bmazzeo | 0:c0f52e8223fe | 4 | * @author Brian Mazzeo |
bmazzeo | 0:c0f52e8223fe | 5 | * @date 2020 |
bmazzeo | 0:c0f52e8223fe | 6 | * @brief This file provides a set of code for signal processing in 487. |
bmazzeo | 0:c0f52e8223fe | 7 | * Parts are taken from example code from STMIcroelectronics |
bmazzeo | 0:c0f52e8223fe | 8 | ****************************************************************************** |
bmazzeo | 0:c0f52e8223fe | 9 | * @attention |
bmazzeo | 0:c0f52e8223fe | 10 | * This code was specifically developed for BYU ECEn 487 course |
bmazzeo | 0:c0f52e8223fe | 11 | * Introduction to Digital Signal Processing. |
bmazzeo | 0:c0f52e8223fe | 12 | * |
bmazzeo | 0:c0f52e8223fe | 13 | * |
bmazzeo | 0:c0f52e8223fe | 14 | ****************************************************************************** |
bmazzeo | 0:c0f52e8223fe | 15 | */ |
bmazzeo | 0:c0f52e8223fe | 16 | |
bmazzeo | 0:c0f52e8223fe | 17 | #include "mbed.h" |
bmazzeo | 0:c0f52e8223fe | 18 | #include "stm32746g_discovery_lcd.h" |
bmazzeo | 0:c0f52e8223fe | 19 | #include "arm_math.h" |
bmazzeo | 0:c0f52e8223fe | 20 | #include "arm_const_structs.h" |
bmazzeo | 0:c0f52e8223fe | 21 | #include "filter_coefficients.h" |
bmazzeo | 0:c0f52e8223fe | 22 | |
bmazzeo | 0:c0f52e8223fe | 23 | |
bmazzeo | 0:c0f52e8223fe | 24 | /* ---------------------------------------------------------------------- |
bmazzeo | 0:c0f52e8223fe | 25 | ** Defines for signal processing |
bmazzeo | 0:c0f52e8223fe | 26 | ** ------------------------------------------------------------------- */ |
bmazzeo | 0:c0f52e8223fe | 27 | |
bmazzeo | 0:c0f52e8223fe | 28 | #define AUDIO_BLOCK_SAMPLES ((uint32_t)128) // Number of samples (L and R) in audio block (each samples is 16 bits) |
bmazzeo | 0:c0f52e8223fe | 29 | |
bmazzeo | 0:c0f52e8223fe | 30 | /* For Lab Exercise */ |
bmazzeo | 0:c0f52e8223fe | 31 | #define Lab_Execution_Type 0 |
bmazzeo | 0:c0f52e8223fe | 32 | |
bmazzeo | 0:c0f52e8223fe | 33 | |
bmazzeo | 0:c0f52e8223fe | 34 | |
bmazzeo | 0:c0f52e8223fe | 35 | /* FUNCTION DEFINITIONS BELOW */ |
bmazzeo | 0:c0f52e8223fe | 36 | |
bmazzeo | 0:c0f52e8223fe | 37 | /** |
bmazzeo | 0:c0f52e8223fe | 38 | * @brief Initialize filter structures to be used in loops later |
bmazzeo | 0:c0f52e8223fe | 39 | * @retval None |
bmazzeo | 0:c0f52e8223fe | 40 | */ |
bmazzeo | 0:c0f52e8223fe | 41 | void initalize_signal_processing(void) { |
bmazzeo | 0:c0f52e8223fe | 42 | |
bmazzeo | 0:c0f52e8223fe | 43 | switch (Lab_Execution_Type) |
bmazzeo | 0:c0f52e8223fe | 44 | { |
bmazzeo | 0:c0f52e8223fe | 45 | case 0: // Passthrough case |
bmazzeo | 0:c0f52e8223fe | 46 | break; |
bmazzeo | 0:c0f52e8223fe | 47 | |
bmazzeo | 0:c0f52e8223fe | 48 | case 1: // FIR case (ARM) |
bmazzeo | 0:c0f52e8223fe | 49 | break; |
bmazzeo | 0:c0f52e8223fe | 50 | |
bmazzeo | 0:c0f52e8223fe | 51 | case 2: // FIR case (student) |
bmazzeo | 0:c0f52e8223fe | 52 | break; |
bmazzeo | 0:c0f52e8223fe | 53 | |
bmazzeo | 0:c0f52e8223fe | 54 | case 3: // FFT Overlap-add |
bmazzeo | 0:c0f52e8223fe | 55 | break; |
bmazzeo | 0:c0f52e8223fe | 56 | |
bmazzeo | 0:c0f52e8223fe | 57 | case 4: // FFT Overlap-add with real-imag efficiency |
bmazzeo | 0:c0f52e8223fe | 58 | break; |
bmazzeo | 0:c0f52e8223fe | 59 | |
bmazzeo | 0:c0f52e8223fe | 60 | |
bmazzeo | 0:c0f52e8223fe | 61 | } |
bmazzeo | 0:c0f52e8223fe | 62 | } |
bmazzeo | 0:c0f52e8223fe | 63 | |
bmazzeo | 0:c0f52e8223fe | 64 | /** |
bmazzeo | 0:c0f52e8223fe | 65 | * @brief Process audio channel signals |
bmazzeo | 0:c0f52e8223fe | 66 | * @param L_channel_in: Pointer to Left channel data input (float32_t) |
bmazzeo | 0:c0f52e8223fe | 67 | * @param R_channel_in: Pointer to Right channel data input (float32_t) |
bmazzeo | 0:c0f52e8223fe | 68 | * @param L_channel_out: Pointer to Left channel data output (float32_t) |
bmazzeo | 0:c0f52e8223fe | 69 | * @param R_channel_out: Pointer to Right channel data output (float32_t) |
bmazzeo | 0:c0f52e8223fe | 70 | * @param Signal_Length: length of data to process |
bmazzeo | 0:c0f52e8223fe | 71 | * @retval None |
bmazzeo | 0:c0f52e8223fe | 72 | */ |
bmazzeo | 0:c0f52e8223fe | 73 | 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) |
bmazzeo | 0:c0f52e8223fe | 74 | { |
bmazzeo | 0:c0f52e8223fe | 75 | char buf[70]; |
bmazzeo | 0:c0f52e8223fe | 76 | BSP_LCD_SetFont(&Font8); |
bmazzeo | 0:c0f52e8223fe | 77 | BSP_LCD_SetTextColor(LCD_COLOR_CYAN); |
bmazzeo | 0:c0f52e8223fe | 78 | sprintf(buf, "Processing Signals" ); |
bmazzeo | 0:c0f52e8223fe | 79 | BSP_LCD_DisplayStringAt(0, 200, (uint8_t *) buf, LEFT_MODE); |
bmazzeo | 0:c0f52e8223fe | 80 | |
bmazzeo | 0:c0f52e8223fe | 81 | switch(Lab_Execution_Type) |
bmazzeo | 0:c0f52e8223fe | 82 | { |
bmazzeo | 0:c0f52e8223fe | 83 | case 0: // Passthrough case |
bmazzeo | 0:c0f52e8223fe | 84 | arm_copy_f32(L_channel_in, L_channel_out, AUDIO_BLOCK_SAMPLES); |
bmazzeo | 0:c0f52e8223fe | 85 | arm_copy_f32(R_channel_in, R_channel_out, AUDIO_BLOCK_SAMPLES); |
bmazzeo | 0:c0f52e8223fe | 86 | break; |
bmazzeo | 0:c0f52e8223fe | 87 | |
bmazzeo | 0:c0f52e8223fe | 88 | case 1: // FIR case (ARM) |
bmazzeo | 0:c0f52e8223fe | 89 | break; |
bmazzeo | 0:c0f52e8223fe | 90 | |
bmazzeo | 0:c0f52e8223fe | 91 | case 2: // FIR case (student) |
bmazzeo | 0:c0f52e8223fe | 92 | break; |
bmazzeo | 0:c0f52e8223fe | 93 | |
bmazzeo | 0:c0f52e8223fe | 94 | case 3: // FFT Overlap-add |
bmazzeo | 0:c0f52e8223fe | 95 | break; |
bmazzeo | 0:c0f52e8223fe | 96 | |
bmazzeo | 0:c0f52e8223fe | 97 | case 4: // FFT Overlap-add with real-imag efficiency |
bmazzeo | 0:c0f52e8223fe | 98 | break; |
bmazzeo | 0:c0f52e8223fe | 99 | |
bmazzeo | 0:c0f52e8223fe | 100 | |
bmazzeo | 0:c0f52e8223fe | 101 | } |
bmazzeo | 0:c0f52e8223fe | 102 | /* Change font back */ |
bmazzeo | 0:c0f52e8223fe | 103 | BSP_LCD_SetFont(&Font16); |
bmazzeo | 0:c0f52e8223fe | 104 | } |