funzionicchia male thread

Dependencies:   Freetronics_16x2_LCD

Fork of HelloWorld_CCA01M1_mbedOS by vincenzo di capua

Revision:
14:244ec24ee6dd
Parent:
12:d847a3c0cf76
Child:
15:3624055fac29
--- a/main.cpp	Fri Jan 19 10:31:48 2018 +0000
+++ b/main.cpp	Fri Jan 19 15:03:29 2018 +0000
@@ -13,19 +13,20 @@
 /* My song header file. */
 #include "my_song.h"
 
+//SDBlockDevice bd(PB_5, PB_4, PB_3, PA_15);
 SDBlockDevice bd(PA_7, PA_6, PA_5, PA_8);
 FATFileSystem fs("fs");
 freetronicsLCDShield lcd(D8, D9, D4, D5, D6, D2, D3, A0);
 
 #define PLAY_STOP_EVENT      (0x1)
-
+ int16_t buff[3000] = {0};
 
 /* Variables -----------------------------------------------------------------*/
 
 /* Initialization parameters. */
 STA350BW_init_t init =
 {
-    32000,   /* Default Sampling Frequency [Hz]. */
+    48000,   /* Default Sampling Frequency [Hz]. */
     100      /* Default Volume. */
 };
 
@@ -154,43 +155,33 @@
   error = fs.mount(&bd);
   return_error(error);
 
-  printf("Opening a new file, numbers.txt.");
-  FILE* fd = fopen("/fs/numbers.txt", "w");
-  errno_error(fd);
 
-  for (int i = 0; i < 20; i++){
-    printf("Writing decimal numbers to a file (%d/20)\r", i);
-    fprintf(fd, "%d\r\n", i);
-  }
-  printf("Writing decimal numbers to a file (20/20) done.\r\n");
-
-  printf("Closing file.");
-  fclose(fd);
   printf(" done.\r\n");
 
   printf("Re-opening file read-only.");
-  fd = fopen("/fs/campagnola.wav", "r");
+ FILE* fd = fopen("/fs/campagnola.wav", "r");
   errno_error(fd);
-char a;
+int16_t a;
 char c;
   printf("Dumping file to screen.\r\n");
-  int buff[160] = {0};
+ 
   while (!feof(fd)){
-     for( int i=0;i<160;i++){
+     
      // printf("inizo file to screen.\r\n");
-fscanf( fd , "%c" , & a ) ;
-fscanf( fd , "%c" , & c) ;
-int b=(((int)a*256)+((int )c));
-b=b-32768;
-printf("%d \r\n",b);
+//fscanf( fd , "%c%c" , & a ) ;
+//fscanf( fd , "%c" , & c) ;
+fread(buff,sizeof(int16_t),3000,fd);
+//int b=(((int)a*256)+((int )c));
+//b=b-32768;
+//printf("%d \r\n",b);
 //printf ( "%c-" , a[1]) ;printf ( "%c\r\n" , a[0]) ;
 //printf("--> Playing...\r\n");
-//lcd.printf ( "%d " , a ) ;
+//printf ( "%d\r\n " , buff[i] ) ;
 
-    buff[i]=b;
+    //buff[i]=a;
     
-    }
-int size=160;
+    
+
    // int size = fread(&buff[0], 1, 159, fd);
     //fwrite(&buff[0], 1, size, stdout);