old demo that i want to try in mbed studio

Dependencies:   mbed SDFileSystem_Copy_of_mbed_version I2S

Branch:
LargeFile_Tests
Revision:
58:a174e7a8f5f2
Parent:
57:0c76b15cabaf
Child:
59:8e7c25a915a0
--- a/NotchingDemo.cpp	Fri Sep 27 19:15:46 2019 +0000
+++ b/NotchingDemo.cpp	Fri Sep 27 19:30:06 2019 +0000
@@ -141,14 +141,14 @@
 
 
 }WAV_FILE_STRUCT;*/
-class PositionIndicators
+class classPositionIndicators
 {
 public:
     int notch1_indicator, notch2_indicator, notch3_indicator, notch4_indicator;
     int notch5_indicator, notch6_indicator, notch7_indicator, notch8_indicator;
     int notch1_start_pt, notch2_start_pt, notch3_start_pt, notch4_start_pt;
     int notch5_start_pt, notch6_start_pt, notch7_start_pt, notch8_start_pt;
-    PositionIndicators()
+    classPositionIndicators()
     {
         notch1_start_pt = 44;
         notch2_start_pt = 220884+44;
@@ -440,7 +440,7 @@
 
 
 
-void Play_WaveFileLoop(classSoundFile Sound1, classSoundFile Sound2, classSoundFile Sound3, FILE* wavfile1,FILE* wavfile2, FILE* wavfile3);
+void Play_WaveFileLoop(classSoundFile Sound1, FILE* wavfile1,classPositionIndicators Positions);
 int main()
 {
 
@@ -481,12 +481,13 @@
 
     TickFadeOut.attach(&FadeOutIsr,10.0);
 
-
-//timer_interrupt.reset();
-    fopen("/sd/);
+    classPositionIndicators Positions;
+    slice1 = 0;
+    FILE* wavfile1 = fopen("/sd/mydir/SoundDecoder_second/All_eight_notches.wav","rb");
+    classSoundFile Sound1;
+    Sound1 = ReadFileInfo(Sound1, wavfile1);
     printf("about to play wav file\n\r");
-    Play_WaveFileLoop(Sound1,wavfile1,PositionIndicators);
-    //Play_WaveFileDual(StartupWav,WavInfo_Startup);
+    //Play_WaveFileLoop(Sound1,wavfile1,Positions);
     printf("finished playing Wav file\n\r");
 
 
@@ -500,7 +501,6 @@
 
 
     /************************************PLAY WAV FILE LOOP*******************/
-    //Play_WaveFileLoop(Sound, NotchingSet);
     /************************************END OF PLAY WAV FILE LOOP*************/
 
 
@@ -529,61 +529,10 @@
     return Sound;
 }
 
-classSoundFile LoadFileStream(classSoundFile Sound, string filename)
-{
-    //Declare RootFolder and the directory for the appropriate file.
-    //How we index into filename[] from the outside of this class is another
-    //issue...
-    //printf("FileName: %s\n\r",filename);
-    //string RootFolder = "/sd/mydir/SoundDecoder/";
-    //string Directory =  RootFolder + "01.wav";// + filename[0];
-    //printf("%s\n\r",Directory);
-    //const char* DirectoryChar = Directory.c_str();
-    //Sound.FileInfo.WavFile = fopen(DirectoryChar,"rb");
-    Sound.FileInfo.WavFile = fopen("/sd/mydir/645Engine/Startup.wav","rb");
-    fseek(Sound.FileInfo.WavFile,20,SEEK_SET);
-    fread(&Sound.FileInfo.FileFormat,sizeof(Sound.FileInfo.FileFormat),1,Sound.FileInfo.WavFile);
-    printf("wav_format.sample_rate: %d\n\r",Sound.FileInfo.FileFormat.sample_rate);
-    fread(&Sound.FileInfo.FileData,sizeof(Sound.FileInfo.FileData),1,Sound.FileInfo.WavFile);
-    printf("wav_data.subchunk2_size: %d\n\r",Sound.FileInfo.FileData.subchunk2_size);
-    Sound.FileInfo.slice_buf = ( char *)malloc(Sound.FileInfo.FileFormat.block_align);
-    fread(Sound.FileInfo.slice_buf,Sound.FileInfo.FileFormat.block_align,1,Sound.FileInfo.WavFile);   //This isnt actually required, its just a test
-    Sound.FileInfo.num_slices = Sound.FileInfo.FileData.subchunk2_size/Sound.FileInfo.FileFormat.block_align;
-    printf("Number of Slices: %d\n\r",Sound.FileInfo.num_slices);
-    return Sound;
-}
 
 
-classFade FadeDataInitialise(classFade FadeData)
-{
-    FadeData.DecayFactor = 1.3;
-    FadeData.FadeIteration = 1;
-    //FadeData.Denom = 11025*FadeData.DecayFactor;
-    FadeData.Denom = 11025*FadeData.DecayFactor;
-    FadeData.Natural_Exp = 2.7183;
-    FadeData.Length = 11025*FadeData.LengthSecs;
-    //FadeData.Natural_Exp = 2.7;
-    return FadeData;
-}
-
-//Playing Files Code
-/*
-float FadeIn(void)
-{
-    powervalFadeIn = FadeIterationIn/denom;
-    FadeCoeffFadeIn
 
 
-}
-float FadeOut(void)
-{
-    powerval = -FadeIteration/denom;
-    FadeCoeff = pow(natural_exp,powerval);
-    FadeIteration = FadeIteration + 1;
-    return FadeCoeff;
-
-}
-*/
 
 void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo)
 {
@@ -626,59 +575,6 @@
 
 
 
-void Play_WaveFileDual(FILE * my_wav, WAV_FILE_STRUCT FileInfo)
-{
-    while(slice<FileInfo.num_slices) {
-        if(FileSwitchFlag == 1) {
-
-            if(temp == 1) {
-                printf("Does it go to this point\n\r");
-                N3Wav = fopen("/sd/mydir/SoundDecoder_second/03.wav","rb");
-                if(N3Wav == NULL) {
-                    printf("Cannot Open testwav\n\r");
-                }
-                fclose(StartupWav);
-                temp = 0;
-            }
-            fread(WavInfo_N3.slice_buf,WavInfo_N3.FileFormat.block_align,1,N3Wav);
-            data_sptr=(short*)WavInfo_N3.slice_buf;
-        } else {
-            fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav);
-            data_sptr=(short *)FileInfo.slice_buf;     // 16 bit samples
-        }
-        for (channel=0; channel<FileInfo.FileFormat.num_channels; channel++) {
-            if(flag1 == 1) {
-                Buffer1[place_hold1] = data_sptr[channel];
-                place_hold1 = place_hold1 + 1;
-                if(place_hold1 >= BufferLen) {
-                    while(1) {
-                        if(flag1 == 0) {
-
-                            break;
-                        }
-
-                    }
-                }
-
-            } else if(flag2 == 1) {
-                Buffer2[place_hold2] = data_sptr[channel];
-                place_hold2 = place_hold2 + 1;
-                if(place_hold2 >= BufferLen) {
-
-                    while(1) {
-                        if(flag2 == 0) {
-
-                            break;
-                        }
-                    }
-                }
-            }
-
-        }
-        slice = slice + 1;
-    }
-}
-
 //***************************************************************************//
 
 //**************************************************************************//
@@ -687,40 +583,30 @@
 
 
 
-
+/*
 
 void Play_WaveFileLoop(classSoundFile Sound1, FILE *wavfile1, classPositionIndicators Positions)
 {
     while(1) { //might have to change this to a while(1) loop?
-        //New format!!  This should be (roughly) the way that this is done, with the new structures and classes
 
-//Block 1 of code.  We need to pass in 3x classSoundFile objects, and 3x FILE* pointer objects.
-//This will allow us to switch between the 3 different files (using "cross-fades") as needed.
-        /*Remember that these will need to be global varaibles to work properly*/
-
-
-        //make sure we are reading in the correct "notch" here
 
 
 
 
 //Sound1=======================================================================================
-            if( slice == (PositionIndicators.notch2_start_pt) ) {
+            if( slice1 == (Positions.notch2_start_pt) ) {
                 slice1 = 0;
-                fseek(Engine,notch1_start_pt,SEEK_SET);
+                fseek(wavfile1,Positions.notch1_start_pt,SEEK_SET);
             }
 
             fread(Sound1.FileInfo.slice_buf,Sound1.FileInfo.FileFormat.block_align,1,wavfile1);
             Sound1.data_sptr=(short *)Sound1.FileInfo.slice_buf;     // 16 bit samples
 //=============================================================================================
 
-            /********************END OF DATA ASSIGNMENT SECTION***********************************************
+            
 
 
 
-        /**********************************************************************************************************/
-        /****************************DATA OUTPUT SECTION***********************************************************/
-        /**********************************************************************************************************/
         for (channel=0; channel<Sound1.FileInfo.FileFormat.num_channels; channel++) {
             switch (Sound1.FileInfo.FileFormat.sig_bps) {
                 case 16:
@@ -758,10 +644,10 @@
     }
 }
 
+*/
 
 
 
 
 
 
-