Sample program of the mbed Audio Framework for the Nucleo F746ZG

Dependencies:   mbed shimabara unzen_nucleo_f746 amakusa

Files at this revision

API Documentation at this revision

Comitter:
shorie
Date:
Sun Dec 11 21:05:20 2016 +0000
Parent:
0:a837eeab3ca6
Commit message:
Beta establishment. Demonstration of Unzen.

Changed in this revision

amakusa.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r a837eeab3ca6 -r 98ddcbbe10ba amakusa.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/amakusa.lib	Sun Dec 11 21:05:20 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/shorie/code/amakusa/#058daa59980d
diff -r a837eeab3ca6 -r 98ddcbbe10ba main.cpp
--- a/main.cpp	Sun Jun 19 05:47:06 2016 +0000
+++ b/main.cpp	Sun Dec 11 21:05:20 2016 +0000
@@ -1,11 +1,15 @@
+#include "mbed.h"
+
+
 #include "unzen.h"          // audio framework include file
-#include "umb_adau1361a.h"     // audio codec contoler include file
-#include "mbed.h"
+#include "umb_adau1361a.h"  // audio codec contoler include file
+#include "amakusa.h"   // audio signal processing class library.
  
-#define CODEC_I2C_ADDR 0x38
+#define CODEC_I2C_ADDR 0x38 // Address of the ADAU-1361A
  
 DigitalOut myled1(LED1);
  
+amakusa::OSCSinCos osc( 440.0, 48000 );    // freq=440Hz, Fs=48kHz.
  
    // customer signal processing initialization call back.
 void init_callback(
@@ -25,11 +29,13 @@
            unsigned int block_size     // block size [sample]
            )
 {
-       // Sample processing
+       // generate tone.
+   osc.run( tx_left_buffer, block_size );
+
+        // copy left to right   
    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];
+       tx_right_buffer[i] = tx_left_buffer[i] *= 0.5F;
        
    }
 }
@@ -42,10 +48,7 @@
    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_48, i2c, CODEC_I2C_ADDR );
-//    shimabara::UMB_ADAU1361A codec(shimabara::Fs_96, i2c, CODEC_I2C_ADDR );
+    shimabara::UMB_ADAU1361A codec(shimabara::Fs_48, i2c, CODEC_I2C_ADDR );     // Fs can be Fs_32, Fs_441, Fs_48, Fs_96
  
       // create an audio framework by singlton pattern
    unzen::Framework audio;
@@ -64,18 +67,17 @@
        // Start the audio framework on ARM processor.  
    audio.start( init_callback, process_callback);     // path the initializaiton and process call back to framework 
  
+   codec.set_hp_output_gain( -3, -3 );
+   codec.set_line_output_gain( -3, -3 );
  
        // 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);
-       }
+       /*
+       myled1 = 1;
+       wait(0.2);
+       myled1 = 0;
+       wait(0.2);
+       */
    }
 }
\ No newline at end of file
diff -r a837eeab3ca6 -r 98ddcbbe10ba mbed.bld
--- a/mbed.bld	Sun Jun 19 05:47:06 2016 +0000
+++ b/mbed.bld	Sun Dec 11 21:05:20 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb
\ No newline at end of file