TAKESHI OGAWA / Mbed 2 deprecated unzen_delay_sample_nucleo_f746

Dependencies:   mbed-dsp mbed shimabara unzen_nucleo_f746

Fork of unzen_sample_nucleo_f746 by seiichi horie

Revision:
1:5b735bc30c17
Parent:
0:a837eeab3ca6
Child:
3:d9fd88ea0ff5
diff -r a837eeab3ca6 -r 5b735bc30c17 main.cpp
--- a/main.cpp	Sun Jun 19 05:47:06 2016 +0000
+++ b/main.cpp	Mon Dec 12 09:26:41 2016 +0000
@@ -1,12 +1,17 @@
 #include "unzen.h"          // audio framework include file
 #include "umb_adau1361a.h"     // audio codec contoler include file
 #include "mbed.h"
- 
+#include "arm_math.h"
 #define CODEC_I2C_ADDR 0x38
  
 DigitalOut myled1(LED1);
- 
- 
+DigitalIn User_b1(PC_13);
+Serial uart(SERIAL_TX,SERIAL_RX);
+float32_t delay_buf[1];
+float32_t delay_buf1[1];
+float32_t delay_buf2[1];
+int flag = 1;
+char uart_read_value = 0;
    // customer signal processing initialization call back.
 void init_callback(
            unsigned int block_size     // block size [sample]
@@ -25,12 +30,23 @@
            unsigned int block_size     // block size [sample]
            )
 {
+       
+   if(flag == 1){  
        // Sample processing
-   for ( int i=0; i<block_size; i++)   // for all sample
-   {
-       tx_left_buffer[i] = rx_left_buffer[i];      // copy from input to output
-       tx_right_buffer[i] = rx_right_buffer[i];
-       
+       for ( int i=0; i<block_size; i++)   // for all sample
+       {
+           tx_left_buffer[i] = rx_left_buffer[i];      // copy from input to output
+           tx_right_buffer[i] = rx_right_buffer[i];
+           
+       }
+    }   
+    else if(flag == 0){
+       for ( int i=0; i<block_size; i++)   // for all sample
+       {
+           tx_left_buffer[i] = 0;      // copy from input to output
+           tx_right_buffer[i] = 0;
+           
+       } 
    }
 }
  
@@ -40,10 +56,11 @@
 {    
        // I2C is essential to talk with ADAU1361
    I2C i2c(D14, D15);
- 
+   
+    
        // create an audio codec contoler
-   shimabara::UMB_ADAU1361A codec(shimabara::Fs_32, i2c, CODEC_I2C_ADDR ); // Default Fs is 48kHz
-//    shimabara::UMB_ADAU1361A codec(shimabara::Fs_441, i2c, CODEC_I2C_ADDR );
+   //shimabara::UMB_ADAU1361A codec(shimabara::Fs_32, i2c, CODEC_I2C_ADDR ); // Default Fs is 48kHz
+    shimabara::UMB_ADAU1361A codec(shimabara::Fs_441, i2c, CODEC_I2C_ADDR );
 //    shimabara::UMB_ADAU1361A codec(shimabara::Fs_48, i2c, CODEC_I2C_ADDR );
 //    shimabara::UMB_ADAU1361A codec(shimabara::Fs_96, i2c, CODEC_I2C_ADDR );
  
@@ -55,7 +72,7 @@
  
  
        // Configure the optional block size of signal processing. By default, it is 1[Sample] 
-//    audio.set_block_size(16);
+    audio.set_block_size(16);
  
    
        // Start the ADAU1361. Audio codec starts to generate the I2C signals 
@@ -68,14 +85,21 @@
        // periodically changing gain for test
    while(1)     
    {
-       for ( int i=-15; i<4; i++ )
-       {
-           codec.set_hp_output_gain( i, i );
-           codec.set_line_output_gain( i, i );
-           myled1 = 1;
-           wait(0.2);
-           myled1 = 0;
-           wait(0.2);
-       }
+           
+           delay_buf[0] = 1.0;
+           codec.set_hp_output_gain( 3, 3);
+           codec.set_line_output_gain( 3, 3 );
+           arm_add_f32( delay_buf, delay_buf1, delay_buf2, 1 );
+           if(User_b1 == 1){
+               if(flag == 1){flag = 0;}
+               else if(flag == 0){flag = 1;}
+               if(flag == 1){myled1 =1;uart.printf("Effect On \r\n");}
+               else if(flag == 0){myled1 =0;uart.printf("Effect Off \r\n");}
+               while(User_b1==1){}
+               }
+           if(uart.readable()== 1){uart_read_value = uart.getc();
+               if(uart_read_value == 'e'){flag = 1;uart.printf("Effect On \r\n");}
+               if(uart_read_value == 'd'){flag = 0;uart.printf("Effect Off \r\n");} 
+           }
    }
 }
\ No newline at end of file