old demo that i want to try in mbed studio
Dependencies: mbed SDFileSystem_Copy_of_mbed_version I2S
Diff: NotchingDemo.cpp
- Revision:
- 29:d2139f3f7ba1
- Parent:
- 20:9cc7d825c07b
diff -r 9cc7d825c07b -r d2139f3f7ba1 NotchingDemo.cpp --- a/NotchingDemo.cpp Mon Apr 01 20:30:35 2019 +0000 +++ b/NotchingDemo.cpp Mon May 20 12:03:11 2019 +0000 @@ -145,21 +145,7 @@ }; //class constructor; -/*classSoundFile::classSoundFile(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... - FileInfo.WavFile = fopen("/sd/mydir/645Engine/Startup.wav","rb"); - fseek(FileInfo.WavFile,20,SEEK_SET); - fread(&FileInfo.FileFormat,sizeof(FileInfo.FileFormat),1,FileInfo.WavFile); - printf("wav_format.sample_rate: %d\n\r",FileInfo.FileFormat.sample_rate); - fread(&FileInfo.FileData,sizeof(FileInfo.FileData),1,FileInfo.WavFile); - printf("wav_data.subchunk2_size: %d\n\r",FileInfo.FileData.subchunk2_size); - FileInfo.slice_buf = ( char *)malloc(FileInfo.FileFormat.block_align); - fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,FileInfo.WavFile); //This isnt actually required, its just a test - FileInfo.num_slices = FileInfo.FileData.subchunk2_size/FileInfo.FileFormat.block_align; -}*/ + int i = 0; @@ -375,36 +361,9 @@ - printf("Directory is about to be opened? Still dont really Get this concept\n\r"); - //if i try to open folder SoundDecoder2, it gets stuck after file 13... WHY - if ((dir = opendir ("/sd/mydir/SoundDecoder_second")) != NULL) { - - // print all the files and directories within directory - while ((ent = readdir (dir)) != NULL) { - //printf("%s\r\n",string(ent->d_name)); - filename[iterator] = (ent->d_name); - printf("Filename: %s\n\r",filename[iterator]); - //printf("%s\r\n",filename[iterator]); - iterator = iterator + 1; - //printf("%s\r\n", ent->d_name); - //filenames.push_back(string(dirp->d_name)); - } - closedir (dir); - } - /* - printf("Now printing all the files"); - for(iterator = 0; iterator < 21; iterator ++) { - printf("All the Files: %s\r\n",filename[iterator]); - //printf("All the Files: %s\r\n",ent[iterator]); - } - */ - - //strcat(RootFolder,qdfilename[0]); - //string folder = RootFolder + filename[9]; - //printf("Folder: %s\n\r",folder); - //printf("Files and Folders contained here: %d\n\r",readdir(dp)); + StartupWav = fopen("/sd/mydir/Startup.wav","rb"); @@ -415,297 +374,15 @@ //vector <classSoundFile> Sound (27); const char* FOLDER; - /* - WAV_FILE_STRUCT MyNewWav; - - string folder; - - for(int aaa = 0;aaa < 21; aaa ++ ) - { - folder = RootFolder + filename[aaa]; - FOLDER = folder.c_str(); - Sound[aaa].FileInfo.WavFile = fopen(FOLDER,"rb"); - //MyNewWav.WavFile = fopen("/sd/mydir/Startup.wav","rb"); - printf("we opened This file %d\n\r",aaa); - - /* - printf("Size of FILE* %d\n\r ",sizeof(Sound[aaa].FileInfo.WavFile)); - fseek(Sound[aaa].FileInfo.WavFile,20,SEEK_SET); - fread(&Sound[aaa].FileInfo.FileFormat,sizeof(Sound[aaa].FileInfo.FileFormat),1,Sound[aaa].FileInfo.WavFile); - fread(&Sound[aaa].FileInfo.FileData,sizeof(Sound[aaa].FileInfo.FileData),1,Sound[aaa].FileInfo.WavFile); - */ - - - //fseek(Sound[aaa].FileInfo.WavFile,20,SEEK_SET); - - //fseek(MyNewWav.WavFile,20,SEEK_SET); - //fread(&WavInfo_Horn.FileFormat,sizeof(WavInfo_Horn.FileFormat),1,MyNewWav.WavFile); - /* - fread(&Sound[aaa].FileInfo.FileData,sizeof(Sound[aaa].FileInfo.FileData),1,Sound[aaa].FileInfo.WavFile); - - Sound[aaa].FileInfo.slice_buf = ( char *)malloc(Sound[aaa].FileInfo.FileFormat.block_align); - fread(Sound[aaa].FileInfo.slice_buf,Sound[aaa].FileInfo.FileFormat.block_align,1,Sound[aaa].FileInfo.WavFile); //This isnt actually required, its just a test - Sound[aaa].FileInfo.num_slices = Sound[aaa].FileInfo.FileData.subchunk2_size/Sound[aaa].FileInfo.FileFormat.block_align; - */ - - /* - Sound[aaa].FileInfo.slice_buf = ( char *)malloc(Sound[aaa].FileInfo.FileFormat.block_align); - fread(Sound[aaa].FileInfo.slice_buf,Sound[aaa].FileInfo.FileFormat.block_align,1,Sound[aaa].FileInfo.WavFile); //This isnt actually required, its just a test - Sound[aaa].FileInfo.num_slices = Sound[aaa].FileInfo.FileData.subchunk2_size/Sound[aaa].FileInfo.FileFormat.block_align; - - - } - */ - - int aaa = 0; - string folder = RootFolder + filename[0]; - FOLDER = folder.c_str(); - WAV_FILE_STRUCT WavStruct0; - WAV_FILE_STRUCT WavStruct1; - WAV_FILE_STRUCT WavStruct2; - WAV_FILE_STRUCT WavStruct3; - WAV_FILE_STRUCT WavStruct4; - WAV_FILE_STRUCT WavStruct5; - WAV_FILE_STRUCT WavStruct6; - WAV_FILE_STRUCT WavStruct7; - WAV_FILE_STRUCT WavStruct8; - WAV_FILE_STRUCT WavStruct9; - WAV_FILE_STRUCT WavStruct10; - WAV_FILE_STRUCT WavStruct11; - WAV_FILE_STRUCT WavStruct12; - WAV_FILE_STRUCT WavStruct13; - WAV_FILE_STRUCT WavStruct14; - WAV_FILE_STRUCT WavStruct15; - WAV_FILE_STRUCT WavStruct16; - WAV_FILE_STRUCT WavStruct17; - WAV_FILE_STRUCT WavStruct18; - WAV_FILE_STRUCT WavStruct19; - WAV_FILE_STRUCT WavStruct20; - WAV_FILE_STRUCT WavStruct21; - WAV_FILE_STRUCT WavStruct22; - //WavStruct0.WavFile = fopen(FOLDER,"rb"); - FILE* mywav0 = fopen(FOLDER,"rb"); - printf("we opened This file %d\n\r",aaa); - - aaa = aaa+1; - - - folder = RootFolder + filename[1]; - FOLDER = folder.c_str(); - FILE* mywav1 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - printf("Size of WavStruct1: %d\n\r",sizeof(WavStruct1)); - aaa = aaa+1; - - folder = RootFolder + filename[2]; - FOLDER = folder.c_str(); - FILE* mywav2 = fopen(FOLDER,"rb"); - - - printf("we opened This file %d\n\r",aaa); - - - - - - aaa = aaa+1; - - folder = RootFolder + filename[3]; - FOLDER = folder.c_str(); - FILE* mywav3 = fopen(FOLDER,"rb"); - - - printf("we opened This file %d\n\r",aaa); - - - - - - aaa = aaa+1; - - folder = RootFolder + filename[4]; - FOLDER = folder.c_str(); - FILE* mywav4 = fopen(FOLDER,"rb"); - - - printf("we opened This file %d\n\r",aaa); - aaa = aaa+1; - - folder = RootFolder + filename[5]; - FOLDER = folder.c_str(); - - FILE* mywav5 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - - aaa = aaa+1; - - folder = RootFolder + filename[6]; - FOLDER = folder.c_str(); - FILE* mywav6 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - aaa = aaa+1; - - folder = RootFolder + filename[7]; - FOLDER = folder.c_str(); - FILE* mywav7 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - - - aaa = aaa+1; - - folder = RootFolder + filename[8]; - FOLDER = folder.c_str(); - FILE* mywav8 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - - aaa = aaa+1; - - folder = RootFolder + filename[9]; - FOLDER = folder.c_str(); - FILE* mywav9 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - aaa = aaa+1; - - folder = RootFolder + filename[10]; - FOLDER = folder.c_str(); - FILE* mywav10 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - - aaa = aaa+1; - - folder = RootFolder + filename[11]; - FOLDER = folder.c_str(); - FILE* mywav11 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - aaa = aaa+1; - - folder = RootFolder + filename[12]; - FOLDER = folder.c_str(); - FILE* mywav12 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - - aaa = aaa+1; - - folder = RootFolder + filename[13]; - FOLDER = folder.c_str(); - FILE* mywav13 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - - aaa = aaa+1; - - folder = RootFolder + filename[14]; - FOLDER = folder.c_str(); - FILE* mywav14 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - - aaa = aaa+1; - - folder = RootFolder + filename[15]; - FOLDER = folder.c_str(); - FILE* mywav15 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - - aaa = aaa+1; - - folder = RootFolder + filename[16]; - FOLDER = folder.c_str(); - FILE* mywav16 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - - aaa = aaa+1; - - folder = RootFolder + filename[17]; - FOLDER = folder.c_str(); - FILE* mywav17 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - - aaa = aaa+1; - - folder = RootFolder + filename[18]; - FOLDER = folder.c_str(); - FILE* mywav18 = fopen(FOLDER,"rb"); - - printf("we opened This file %d\n\r",aaa); - - - - printf("We performed all ReadFileInfo Operations!\n\r"); - aaa = aaa+1; - - printf("DO WE GET PAST THE ALLOCATION POINT\n\r"); - - -/* - StartupWav = fopen("/sd/mydir/645Engine/Startup.wav","rb"); - IdleWav = fopen("/sd/mydir/645Engine/N2_11k_minus10dB.wav","rb"); - IdleN2Wav = fopen("/sd/mydir/645Engine/N2N3_11k_minus10dB.wav","rb"); - HornWav = fopen("/sd/mydir/645Engine/K3H_1_A_short_quiet.wav","rb"); - N2Wav = fopen("/sd/mydir/645Engine/N3_11k_minus11dB.wav","rb"); - BellWav = fopen("/sd/mydir/645Engine/EMD_BRONZE_BELL_1_11k_minus10dB.wav","rb"); - FlangeWav = fopen("/sd/mydir/645Engine/EX_FlangeJoint1_11k_minus12dB.wav","rb"); - - - - - WavInfo_Startup = ReadFileInfo(WavInfo_Startup, StartupWav); - printf("WavInfo_Startup Size: %d\n\r",sizeof(WavInfo_Startup)); - WavInfo_Idle = ReadFileInfo(WavInfo_Idle, IdleWav); - WavInfo_Horn = ReadFileInfo(WavInfo_Horn, HornWav); - WavInfo_IdleN2 = ReadFileInfo(WavInfo_IdleN2, IdleN2Wav); - WavInfo_N2 = ReadFileInfo(WavInfo_N2, N2Wav); - WavInfo_Bell = ReadFileInfo(WavInfo_Bell, BellWav); - WavInfo_Flange = ReadFileInfo(WavInfo_Flange, FlangeWav); -*/ - printf("About to Start ReadFileInfo Operations\n\r"); @@ -729,17 +406,10 @@ WavInfo_IdleN2 = ReadFileInfo(WavInfo_IdleN2, IdleN2Wav); WavInfo_N2 = ReadFileInfo(WavInfo_N2, N2Wav); WavInfo_Bell = ReadFileInfo(WavInfo_Bell, BellWav); - //WavInfo_Flange = ReadFileInfo(WavInfo_Flange, HeyWav); - //WavInfo_Hey = ReadFileInfo(WavInfo_Hey,HeyWav); -//WAV_FILE_STRUCT WavInfo_Frustration; -//FILE* FrustrationWav = fopen("/sd/mydir/645Engine/EX_FlangeJoint1_11k_minus12dB.wav","rb"); -//WAV_FILE_STRUCT WavInfo_Hey; + + WavInfo_Hey = ReadFileInfo(WavInfo_Hey,HeyWav); -//FlangeWav - this one works. -//HeyWav - this one doesn't. Despite the fact they reference teh exact same file. -//WavInfo_Bell = ReadFileInfo(WavInfo_Bell,HeyWav); -//WavInfo_Frustration = ReadFileInfo(WavInfo_Frustration,FlangeWav); -//printf("Frustration\n\r"); + @@ -832,15 +502,7 @@ 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); @@ -867,23 +529,8 @@ 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) {