old demo that i want to try in mbed studio

Dependencies:   mbed SDFileSystem_Copy_of_mbed_version I2S

Branch:
LargeFile_Tests
Revision:
86:404ce47e1e6e
Parent:
85:e0c9ba778ae0
Child:
87:f5c9beae06ac
--- a/NotchingDemo.cpp	Wed Oct 02 19:22:05 2019 +0000
+++ b/NotchingDemo.cpp	Wed Oct 02 20:25:42 2019 +0000
@@ -105,28 +105,7 @@
 
 //Dont require the class below.  Turns out I had already made a Structure to hold the same information.
 //If in the futre I need to embed functions then I will switch to using this class
-/*
-class classNotchingValue{
-   public:
 
-   int Notch, Previous_Notch;
-   int NotchDirection;
-   int NotchTransUp;
-    classNotchingValue()
-    {
-        Notch = 1;
-        Previous_Notch = 0;
-        NotchDirection = 1;
-        NotchTransUp = 0;
-    }
-
-};
-
-
-
-classNotchingValue NotchingSet;
-
-*/
 
 typedef struct uFMT_STRUCT {
     short comp_code;
@@ -324,23 +303,14 @@
 int h = 0;
 short bufflen = 1;
 int buffer[1];
-int AudioFormat, NumChannels, SampleRate, BitsPerSample ;
+
 char *slice_buf;
 short *data_sptr;
-short *data_sptr_horn;
-short *data_sptr_IdleN2;
-short * data_sptr_bell;
-short * data_sptr_N2;
-short * data_sptr_Flange;
-unsigned char *data_bptr;
-int *data_wptr;
+
+
+
 unsigned channel;
 long slice, slice1, slice2, slice3, num_slices;
-int verbosity  = 0;
-int verbosity2 = 0;
-int verbosity3 = 0;
-int verbosity4 = 0;
-int verbosity5 = 0;
 int interrupt_condition = 1;
 int sampling_freq = 11025;
 const int BufferLen = 2000;
@@ -350,10 +320,7 @@
 short place_hold2 = 0;
 
 
-string FOLDER;
-string RootFolder = "/sd/mydir/SoundDecoder/";
-string  filename[25];
-classSoundFile Sound[22];
+
 
 volatile int flag1 = 1;
 volatile int flag2 = 0;
@@ -365,7 +332,7 @@
 int BellFlag2 = 0;
 int FadeFlag = 0;
 int BlockFlag = 0;
-int FileSwitchFlag = 0;
+
 
 
 short value[1];
@@ -374,13 +341,7 @@
 int slice_value[1];
 
 
-FILE *wavfile1;
-FILE *wavfile2;
-FILE *wavfile3;
 
-classSoundFile Sound1;
-classSoundFile Sound2;
-classSoundFile Sound3;
 
 
 void isr()
@@ -485,16 +446,19 @@
     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* wavfile2 = fopen("/sd/mydir/SoundDecoder_second/04.wav","rb");
+    FILE* wavfile3 = fopen("/sd/mydir/SoundDecoder_second/05.wav","rb");
     
     //FILE* wavfile1 = fopen("/sd/mydir/SoundDecoder_second/01.wav","rb");
     classSoundFile Sound1;
     classSoundFile Sound2;
-    classSoundFile Sound3;
-    Sound3 = ReadFileInfo(Sound3, wavfile2);
+    classSoundFile Sound4;
+
+    
+    Sound4 = ReadFileInfo(Sound4, wavfile3);
     Sound2 = ReadFileInfo(Sound2, wavfile2);
     Sound1 = ReadFileInfo(Sound1, wavfile1);
+    printf("sizeof(Sound1): %d bytes\n\r",sizeof(Sound1));
     NotchingSet.Notch = 1;
     //Positions.notch_position_indicators[1] = 44;
     fseek(wavfile1,Positions.notch_start_pts[1],SEEK_SET);
@@ -627,131 +591,7 @@
             slice1 = Positions.notch_start_pts[NotchingSet.Notch];
             fseek(wavfile1,Positions.notch_start_pts[NotchingSet.Notch],SEEK_SET);
         }
-    if(TransitionFlag)
-    {
-      
-            //printf("TransitionFlag == 1, so now we are going to do some other processing\n\r");
-            //NOTCH 1
-            //OperationsTimer.reset();
-            //OperationsTimer.start();
-            //fpos_t position;
-            //fgetpos(wavfile1,&position);
-            //printf("Positions.notch_position_indicators[NotchingSet.Notch]: %d\n\r",Positions.notch_position_indicators[NotchingSet.Notch]);
-            fseek(wavfile1,Positions.notch_position_indicators[NotchingSet.Notch-1],Positions.notch_position_indicators[NotchingSet.Notch-1]);
-            ////fsetpos(wavfile1, &position);
-            //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());
-            */
-            //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;
-            Positions.notch_position_indicators[NotchingSet.Notch] = Positions.notch_position_indicators[NotchingSet.Notch] + 2;
-            */
-            //increment up the position indicator!
-            
-            /*
-            if(NotchingSet.NotchDirection)
-
-            {
-                //printf("Reached if(NotchingSet.NotchDirection)\n\r");
-
-                //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;                
-                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);
-                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))
-            {
-                NotchFadeIn.FadeIn();
-                if(Positions.notch_transitions_position_indicators[NotchingSet.NotchTransUp] >= Positions.notch_transitions_start_pts[NotchingSet.NotchTransUp+1])
-                {
-                    *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;    
-                }
-                
-                
-            }
-            */
-            //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!!!    
-            //}
-            
-            
-
-        
-        
-
-    }
-    else
-    {
-            
-            /*fseek(wavfile1,Positions.notch_position_indicators[1],SEEK_SET);
-            OperationsTimer.reset();
-            OperationsTimer.start();
-            */
+   
             fread(Sound1.FileInfo.slice_buf,Sound1.FileInfo.FileFormat.block_align,1,wavfile1);
             /*OperationsTimer.stop();
             printf("It took %d useconds to perform fread operation.\n\r",OperationsTimer.read_us());
@@ -761,7 +601,7 @@
             *Sound1.data_sptr = *data_sptr1;
             //Sound1.data_sptr=(short *)Sound1.FileInfo.slice_buf;     // 16 bit samples
         
-    }
+  
 //=============================================================================================