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
ハードウェアおよびソフトウェアはskelton_unzen_nucleo_f746を基本にしています。
Diff: main.cpp
- Revision:
- 3:1b420050bdda
- Parent:
- 2:d5028a37f17b
- Child:
- 6:486b1cb03e61
diff -r d5028a37f17b -r 1b420050bdda main.cpp --- a/main.cpp Mon Jan 02 11:05:36 2017 +0000 +++ b/main.cpp Sat Jan 21 07:17:14 2017 +0000 @@ -1,18 +1,24 @@ #include "mbed.h" - #include "unzen.h" // audio framework include file #include "umb_adau1361a.h" // audio codec contoler include file -#include "amakusa.h" // audio signal processing class library. +#include "amakusa.h" // audio signal processing class library. +#include "ukifune.h" // UI board support routines + +#define BLOCKSIZE 1 +#define TAPS 200 #define CODEC_I2C_ADDR 0x38 // Address of the ADAU-1361A #define AD7999 (0x29<<1) #define ADCBUFSIZE 8 + DigitalOut myled1(LED1); float gain = 1.0; -amakusa::OSCSinCos osc( 440.0, 48000 ); // freq=440Hz, Fs=48kHz. +amakusa::OSCSinCos *osc; +amakusa::FIRFilter *filter; +float coeff[TAPS]; void parse_adc( char * buf, int &ch, int &data ); @@ -22,6 +28,9 @@ ) { // place initialization code here + osc = new amakusa::OSCSinCos( 440.0, 48000, block_size ); // freq=440Hz, Fs=48kHz. + + filter = new amakusa::FIRFilter( TAPS, coeff, block_size ); // } @@ -34,8 +43,19 @@ unsigned int block_size // block size [sample] ) { +#if 0 // generate tone. - osc.run( tx_left_buffer, block_size ); + osc->run( tx_left_buffer ); +#elif 0 + filter->run( rx_left_buffer, tx_left_buffer ); +#else + for ( int i=0; i<block_size; i++) // for all sample + { + tx_right_buffer[i] = atan2( rx_right_buffer[i], rx_left_buffer[i] ); + + } + +#endif // copy left to right for ( int i=0; i<block_size; i++) // for all sample @@ -72,6 +92,10 @@ // Start the ADAU1361. Audio codec starts to generate the I2C signals codec.start(); + ukifune::init( & audio ); + + audio.set_block_size(BLOCKSIZE); + // Start the audio framework on ARM processor. audio.start( init_callback, process_callback); // path the initializaiton and process call back to framework