Experimental implementation of the adaptive filter of "Interface" magazine in 2016-2017

Dependencies:   amakusa mbed-dsp mbed shimabara ukifune unzen_nucleo_f746

Fork of skeleton_unzen_nucleo_f746 by seiichi horie

ハードウェアおよびソフトウェアはskelton_unzen_nucleo_f746を基本にしています。

Committer:
shorie
Date:
Sat Jan 28 12:51:50 2017 +0000
Revision:
11:7d8740437e6a
Parent:
10:a00c73efc6c3
Child:
13:b33cb5925113
Sample program is working. Gain control of the talk through and the SWM1,2,3 usage demo.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shorie 6:486b1cb03e61 1 #include "signal_processing.h"
shorie 6:486b1cb03e61 2
shorie 10:a00c73efc6c3 3 /*========================= Project Dependent Method =========================*/
shorie 10:a00c73efc6c3 4 // Modify this constructor to initialize your audio algorithm.
shorie 6:486b1cb03e61 5 SignalProcessing::SignalProcessing( unsigned int block_size )
shorie 6:486b1cb03e61 6 {
shorie 6:486b1cb03e61 7 // place the signal processing initializing code here.
shorie 6:486b1cb03e61 8 this->volume_level = 0.0; // sample initializaiton
shorie 10:a00c73efc6c3 9 } // End of constructor()
shorie 6:486b1cb03e61 10
shorie 10:a00c73efc6c3 11
shorie 10:a00c73efc6c3 12 // Modify this method to implement your audio algorithm.
shorie 6:486b1cb03e61 13 void SignalProcessing::run(
shorie 6:486b1cb03e61 14 float rx_left_buffer[], // array of the left input samples
shorie 6:486b1cb03e61 15 float rx_right_buffer[], // array of the right input samples
shorie 6:486b1cb03e61 16 float tx_left_buffer[], // place to write the left output samples
shorie 6:486b1cb03e61 17 float tx_right_buffer[], // place to write the left output samples
shorie 6:486b1cb03e61 18 unsigned int block_size // block size [sample]
shorie 6:486b1cb03e61 19 )
shorie 6:486b1cb03e61 20 {
shorie 6:486b1cb03e61 21 // place the signal processing coce here
shorie 6:486b1cb03e61 22 for ( int i= 0; i< block_size; i++ )
shorie 6:486b1cb03e61 23 {
shorie 11:7d8740437e6a 24 tx_left_buffer[i] = rx_left_buffer[i] * this->volume_level;
shorie 11:7d8740437e6a 25 tx_right_buffer[i] = rx_right_buffer[i] * this->volume_level;
shorie 6:486b1cb03e61 26 }
shorie 10:a00c73efc6c3 27 } // End of run()
shorie 10:a00c73efc6c3 28
shorie 6:486b1cb03e61 29
shorie 10:a00c73efc6c3 30 // Sample method. Set the volume level to the object.
shorie 6:486b1cb03e61 31 void SignalProcessing::set_volume( float vol )
shorie 6:486b1cb03e61 32 {
shorie 6:486b1cb03e61 33 this->enter_critical_section(); // forbidden interrrupt.
shorie 6:486b1cb03e61 34 this->volume_level = vol;
shorie 6:486b1cb03e61 35 this->leave_critical_section(); // now, ok to accept interrupt.
shorie 6:486b1cb03e61 36 }
shorie 6:486b1cb03e61 37
shorie 6:486b1cb03e61 38
shorie 6:486b1cb03e61 39
shorie 10:a00c73efc6c3 40 /************************** skeleton dependent methond. ***********************/
shorie 6:486b1cb03e61 41 // essential members. Do not touch.
shorie 6:486b1cb03e61 42 void SignalProcessing::enter_critical_section(void)
shorie 6:486b1cb03e61 43 {
shorie 6:486b1cb03e61 44 __disable_irq(); // globaly forbid all interrupt
shorie 6:486b1cb03e61 45 }
shorie 6:486b1cb03e61 46
shorie 6:486b1cb03e61 47 void SignalProcessing::leave_critical_section(void)
shorie 6:486b1cb03e61 48 {
shorie 6:486b1cb03e61 49 __enable_irq(); // globaly allow all interrupts
shorie 6:486b1cb03e61 50 }
shorie 6:486b1cb03e61 51