old demo that i want to try in mbed studio

Dependencies:   mbed SDFileSystem_Copy_of_mbed_version I2S

Branch:
LargeFile_Tests
Revision:
79:00cc7799407f
Parent:
78:69a0c7a5fbdf
Child:
80:9c70dc3fc16b
--- a/NotchingDemo.cpp	Tue Oct 01 20:14:26 2019 +0000
+++ b/NotchingDemo.cpp	Tue Oct 01 20:40:43 2019 +0000
@@ -295,6 +295,15 @@
         NotchFadeIn.FadeDataInitialise();
         NotchFadeOut.FadeDataInitialise();
         TransitionFlag = 1;
+        /*
+        if(SoundFlag == 1) {
+            SoundFlag = 3;
+        } else {
+
+
+            SoundFlag = 1;
+        }
+        */
         //printf("We are in the NotchUpIsr() section \n\r");
         //NotchFadeOut.FadeDataInitialise;
     }
@@ -436,7 +445,7 @@
 classSoundFile LoadFileStream(classSoundFile FileInfo, string filename);
 void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo);
 void Play_WaveFileDual(FILE * my_wav, WAV_FILE_STRUCT FileInfo);
-void Play_WaveFileLoop(classSoundFile Sound1, classSoundFile Sound2, FILE* wavfile1, FILE* wavfile2,classPositionIndicators Positions);
+void Play_WaveFileLoop(classSoundFile Sound1, classSoundFile Sound2, classSoundFile Sound3, FILE* wavfile1, FILE* wavfile2,classPositionIndicators Positions);
 
 int main()
 {
@@ -455,8 +464,8 @@
 
     printf("hello\n\r");
     //Set up the wolfson Audio Codec board
-    
-    
+
+
     wm8731_Config_setup();
     //i2s audio data transfer code??
     i2s.stereomono(I2S_STEREO);
@@ -466,7 +475,7 @@
     printf("Hello i2s has started!");
     i2s.start();
     sampletick.attach(&isr,1.0/sampling_freq);  //1/16000
-    NotchUpTick.attach(&NotchUpIsr,10.0);
+    NotchUpTick.attach(&NotchUpIsr,8.0);
 
 
 
@@ -479,25 +488,27 @@
 
     classPositionIndicators Positions;
     slice1 = Positions.notch_start_pts[1];
-    
-    
-    
+
+
+
     TransitionFlag = 0;
-    
+
     FILE* wavfile1 = fopen("/sd/mydir/SoundDecoder_second/All_eight_notches.wav","rb");
     FILE* wavfile2 = fopen("/sd/mydir/SoundDecoder_second/All_14_Notch_Transitions.wav","rb");
-    
+    FILE* wavfile3 = fopen("/sd/mydir/SoundDecoder_second/All_eight_notches.wav","rb");
     //FILE* wavfile1 = fopen("/sd/mydir/SoundDecoder_second/01.wav","rb");
     classSoundFile Sound1;
     classSoundFile Sound2;
+    Sound3 = ReadFileInfo(Sound1, wavfile3);
     Sound2 = ReadFileInfo(Sound2, wavfile2);
     Sound1 = ReadFileInfo(Sound1, wavfile1);
     NotchingSet.Notch = 1;
     //Positions.notch_position_indicators[1] = 44;
     fseek(wavfile1,Positions.notch_start_pts[1],SEEK_SET);
     fseek(wavfile2,Positions.notch_transitions_start_pts[1],SEEK_SET);
+    fseek(wavfile3,Positions.notch_transitions_start_pts[2],Positions.notch_transitions_start_pts[2]);
     printf("about to play wav file\n\r");
-    Play_WaveFileLoop(Sound1,Sound2, wavfile1,wavfile2, Positions);
+    Play_WaveFileLoop(Sound1,Sound2, Sound3, wavfile1,wavfile2, Positions);
     printf("finished playing Wav file\n\r");
 
 
@@ -515,7 +526,7 @@
 
 
     i2s.stop();
-    
+
 
 }
 
@@ -611,7 +622,7 @@
 
 
 
-void Play_WaveFileLoop(classSoundFile Sound1, classSoundFile Sound2, FILE *wavfile1, FILE* wavfile2, classPositionIndicators Positions)
+void Play_WaveFileLoop(classSoundFile Sound1, classSoundFile Sound2, classSoundFile Sound3, FILE *wavfile1, FILE* wavfile2, classPositionIndicators Positions)
 {
     while(1) { //might have to change this to a while(1) loop?
 
@@ -624,9 +635,8 @@
             slice1 = Positions.notch_start_pts[NotchingSet.Notch];
             fseek(wavfile1,Positions.notch_start_pts[NotchingSet.Notch],SEEK_SET);
         }
-    if(TransitionFlag)
-    {
-      
+        if(TransitionFlag) {
+
             //printf("TransitionFlag == 1, so now we are going to do some other processing\n\r");
             //NOTCH 1
             //OperationsTimer.reset();
@@ -639,25 +649,22 @@
             //OperationsTimer.stop();
             //printf("It took %d useconds to perform fseek operation.\n\r",OperationsTimer.read_us());
             //printf("We have seeked through the file\n\r");
-            
-            
+
+
             //printf("Size of Sound1.FileInfo.FileFormat.block_align: %d\n\r",Sound1.FileInfo.FileFormat.block_align);
-            
+
             /*
             OperationsTimer.reset();
             OperationsTimer.start();
             */
+
             fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch-1],Positions.notch_position_indicators[NotchingSet.Notch-1]);
             fread(Sound1.FileInfo.slice_buf, Sound1.FileInfo.FileFormat.block_align,1,wavfile1);
             data_sptr1=(short *)Sound1.FileInfo.slice_buf;
             Positions.notch_position_indicators[NotchingSet.Notch-1] = Positions.notch_position_indicators[NotchingSet.Notch-1] + 2;
-            
-            fseek(wavfile2,Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp],Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp]);
-            fread(Sound2.FileInfo.slice_buf, Sound2.FileInfo.FileFormat.block_align,1,wavfile2);
-            data_sptr2=(short *)Sound2.FileInfo.slice_buf; 
-            Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] = Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] + 2;
+
 
-           
+
             /*
             OperationsTimer.stop();
             printf("It took %d useconds to perform fread operation.\n\r",OperationsTimer.read_us());
@@ -665,24 +672,24 @@
             //printf("We have now read in 2 bytes of data (i.e. 1 sample)\n\r");
 
             //printf("We have now cast this data to a short data type\n\r");
-            
-            
+
+
 
-            
-            
+
+
             //printf("We have incremented up the Positions.notch_position_indicator");
             //increment up the position indicator!
-            
+
             //NOTCH 2
             /*
             fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch],Positions.notch_position_indicators[NotchingSet.Notch]);
-            fread(Sound1.FileInfo.slice_buf, Sound1.FileInfo.FileFormat.block_align,1,wavfile1);
-            data_sptr3=(short *)Sound1.FileInfo.slice_buf;
+            fread(Sound3.FileInfo.slice_buf, Sound3.FileInfo.FileFormat.block_align,1,wavfile1);
+            data_sptr3=(short *)Sound3.FileInfo.slice_buf;
             Positions.notch_position_indicators[NotchingSet.Notch] = Positions.notch_position_indicators[NotchingSet.Notch] + 2;
             */
             //increment up the position indicator!
-            
-            /*
+
+
             if(NotchingSet.NotchDirection)
 
             {
@@ -691,21 +698,21 @@
                 //N1 N2 Transition
                 fseek(wavfile2,Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp],Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp]);
                 fread(Sound1.FileInfo.slice_buf, Sound1.FileInfo.FileFormat.block_align,1,wavfile2);
-                data_sptr2=(short *)Sound2.FileInfo.slice_buf;                
+                data_sptr2=(short *)Sound2.FileInfo.slice_buf;
                 Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] = Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] + 2;
 
             } else {
                 //N1 N2 Transition
                 fseek(wavfile2,Positions.notch_transitions_position_indicators[NotchingSet.NotchTransDown],Positions.notch_position_indicators[NotchingSet.NotchTransDown]);
-                fread(Sound1.FileInfo.slice_buf, Sound1.FileInfo.FileFormat.block_align,1,wavfile2);
+                fread(Sound2.FileInfo.slice_buf, Sound2.FileInfo.FileFormat.block_align,1,wavfile2);
                 data_sptr2=(short *)Sound2.FileInfo.slice_buf;
                 Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] = Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] + 2;
 
             }
-            */
-            
-            
-            
+
+
+
+
             NotchFadeOut.FadeOut();
             /*
             if(Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] >= (Positions.notch_transitions_start_pts[NotchingSet.NotchTransUp+1] - NotchFadeIn.Length))
@@ -716,35 +723,34 @@
                     *Sound1.data_sptr = *data_sptr2*NotchFadeIn.FadeCoeff;
                     TransitionFlag = 0;
                     fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch],Positions.notch_position_indicators[NotchingSet.Notch]);
-                    
-                }    
+
+                }
                 else
                 {
-                    *Sound1.data_sptr = *data_sptr1*NotchFadeOut.FadeCoeff + *data_sptr2 + *data_sptr3*NotchFadeIn.FadeCoeff;    
+                    *Sound1.data_sptr = *data_sptr1*NotchFadeOut.FadeCoeff + *data_sptr2 + *data_sptr3*NotchFadeIn.FadeCoeff;
                 }
-                
-                
+
+
             }
             */
+
             //else
             //{
-                *Sound1.data_sptr = *data_sptr1*NotchFadeOut.FadeCoeff + *data_sptr2;
-                //*Sound1.data_sptr = *data_sptr1;// + *data_sptr2;
-                 
-                 
-             
-                //include a flag here, to hand over control.  Going to get a bit complicated!!!    
+            *Sound1.data_sptr = *data_sptr1;//*NotchFadeOut.FadeCoeff;// + *data_sptr2;
+            //*Sound1.data_sptr = *data_sptr1;// + *data_sptr2;
+
+
+
+            //include a flag here, to hand over control.  Going to get a bit complicated!!!
             //}
-            
-            
+
+
+
 
-        
-        
+
 
-    }
-    else
-    {
-            
+        } else {
+
             /*fseek(wavfile1,Positions.notch_position_indicators[1],SEEK_SET);
             OperationsTimer.reset();
             OperationsTimer.start();
@@ -755,8 +761,8 @@
             Positions.notch_position_indicators[1] = Positions.notch_position_indicators[1] + 2;//i.e. 2 bytes, per sample, for 2-byte (16-bit) data
             */
             Sound1.data_sptr=(short *)Sound1.FileInfo.slice_buf;     // 16 bit samples
-        
-    }
+
+        }
 //=============================================================================================