does not work yet. Sound starts but then stops after a few seconds, whole thing hangs. Published so as I can import through mbed CLI.

Dependencies:   mbed sinelookup SDFileSystem_Copy_of_mbed_version I2S

Files at this revision

API Documentation at this revision

Comitter:
roryhand
Date:
Sun Oct 28 22:01:16 2018 +0000
Parent:
7:fb47ff047ac7
Child:
9:4d6b9a554550
Child:
10:5048aebc394e
Commit message:
latest revision

Changed in this revision

WOLFSON_config.h Show annotated file Show diff for this revision Revisions of this file
wolfson_3_wav.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/WOLFSON_config.h	Sun Oct 28 21:31:58 2018 +0000
+++ b/WOLFSON_config.h	Sun Oct 28 22:01:16 2018 +0000
@@ -33,9 +33,9 @@
 const int _WM8731_DIGITALAUDIO       = 0X00;        //11011
 const int _WM8731_POWER              = 0X00;       // DISABLE POWER DOWN
 const int _WM8731_DAIF               = 0X02;       // ENABLE SLAVE MODE, 16BIT DATA AND I2S DATA
-const int _WM8731_SAMPLING           = 0X00;       // 48000HZ,12.288MHz oscillator.
+//const int _WM8731_SAMPLING           = 0X00;       // 48000HZ,12.288MHz oscillator.
 //const int _WM8731_SAMPLING           = 0X2E;       // 8000HZ,12.288MHz oscillator.
-//const int _WM8731_SAMPLING           = 0X18;       // 8000HZ,12.288MHz oscillator.
+const int _WM8731_SAMPLING           = 0X18;       // 8000HZ,12.288MHz oscillator.
 const int _WM8731_ACTIVATE           = 0X01;       // MODULE IS ON
 const int _WM8731_DEACTIVATE         = 0X00;       // MODULE IS OFF
 const int _WM8731_RESET              = 0X00;       // RESET VALUE
--- a/wolfson_3_wav.cpp	Sun Oct 28 21:31:58 2018 +0000
+++ b/wolfson_3_wav.cpp	Sun Oct 28 22:01:16 2018 +0000
@@ -8,7 +8,7 @@
 #include "mbed.h"
 #include "sinelookup.h" 
 #include "I2S.h"   
-#define sample_freq 48000
+#define sample_freq 8000
 DigitalOut myled(LED1);
 DigitalOut led2(LED2);
 DigitalOut led3(LED3);
@@ -52,8 +52,9 @@
 int newvar;
 long slice, num_slices;
 int verbosity = 0;
+int verbosity2 = 0;
 int interrupt_condition = 1;
-int sampling_freq = 48000;
+int sampling_freq = 8000;
 short Buffer1[8];
 short Buffer2[8];
 short place_hold1 = 0;
@@ -107,7 +108,7 @@
             flag2 = 0;
             flag3 = 1;
         }   
-        if(verbosity == 1)
+        if(verbosity2 == 1)
         {
           printf("value Buffer1: %d\n\r",value[0]);    
         }        
@@ -126,7 +127,7 @@
             flag2 = 1;
             flag3 = 1;
         }   
-        if(verbosity == 1)
+        if(verbosity2 == 1)
         {
          printf("value Buffer2: %d\n\r",value[0]);      
         }        
@@ -311,10 +312,10 @@
     data[1] = 0x00;
     FILE *my_wav;
     //my_wav = fopen("/sd/mydir/gp40.wav", "rb");//i think that it is "w" for write, "r"  for read.    
-    my_wav = fopen("/sd/mydir/gp40_48K.wav", "rb");//i think that it is "w" for write, "r"  for read.    
+    //my_wav = fopen("/sd/mydir/gp40_48K.wav", "rb");//i think that it is "w" for write, "r"  for read.    
     //my_wav = fopen("/sd/mydir/gp40_48K_quieter.wav", "rb");//i think that it is "w" for write, "r"  for read.    
     //my_wav = fopen("/sd/mydir/gp40_8K.wav","rb");
-    //my_wav = fopen("/sd/mydir/gp40_8K_2018.wav","rb");
+    my_wav = fopen("/sd/mydir/gp40_8K_2018.wav","rb");
     //my_wav = fopen("/sd/mydir/emd_645.wav", "rb");
     fseek(my_wav, 20, SEEK_SET); // set pointer to byte 20
     fread(&AudioFormat, 2, 1, my_wav); // check file is PCM
@@ -338,15 +339,8 @@
     printf("DATA chunck\n");
     printf("  %d subchunk 2 ID\n",wav_data.subchunk2_ID);
     printf("  %d subchunk 2 size\n",wav_data.subchunk2_size);
-    
-    
-
-    
-
-
     i2c.frequency(100000);
     long j = 0;
-    
     printf("set up the codec\n\r");
     while(j <1000){
     wm8731_configTEST();
@@ -369,8 +363,7 @@
     //while (1) {
     fread(&wav_format,sizeof(wav_format),1,my_wav);
     printf("wav_format %d\n\r",wav_format);
-
-            
+       
     fseek(my_wav,20,SEEK_SET);
     fread(&wav_format,sizeof(wav_format),1,my_wav);
     fseek(my_wav,36,SEEK_SET);
@@ -389,8 +382,9 @@
       sampletick.attach(&isr,1.0/16000);  //1/16000
     }       
     slice_buf=(char *)malloc(wav_format.block_align);
+    slice = 0;
     while(1){
-              slice = 0;
+
               while(flag3 == 1)
               {
               //for (slice=0;slice<num_slices;slice+=1)