old demo that i want to try in mbed studio

Dependencies:   mbed SDFileSystem_Copy_of_mbed_version I2S

Committer:
roryhand
Date:
Mon Jun 17 20:54:09 2019 +0000
Revision:
39:69d5a5dd9163
Parent:
38:3b4c05af5f36
Child:
40:ba34990514fa
WIP - added in vector tests (not working at all, probably a stupid hardware issue as per usual)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
roryhand 1:aac37edee302 1
roryhand 0:e89d7a0bfa3b 2 // 24/03/2018 update - I appear to be able to address the device and write something, as I am getting an ACK returned from the i2c write() function.
roryhand 0:e89d7a0bfa3b 3 //however if i use the write function with 4 arguments (as opposed to just 1 argument) then it doesnt work
roryhand 0:e89d7a0bfa3b 4 //only works with the 1 argument version!!!
roryhand 0:e89d7a0bfa3b 5
roryhand 0:e89d7a0bfa3b 6
roryhand 0:e89d7a0bfa3b 7 //THIS VERSION WORKED, CHANGED SOME THINGS, THEN CHANGED THEM BACK. NOW IT NO LONGER WORKS!!!!
roryhand 0:e89d7a0bfa3b 8 #include "mbed.h"
roryhand 0:e89d7a0bfa3b 9 #include "math.h"
roryhand 1:aac37edee302 10 #include "I2S.h"
roryhand 1:aac37edee302 11 #include "SDFileSystem.h"
roryhand 0:e89d7a0bfa3b 12 #include "wm8731_Config_setup.h"
roryhand 0:e89d7a0bfa3b 13 #include "WOLFSON_config_consts.h"
roryhand 37:a563899ac0df 14 #include <string>
roryhand 0:e89d7a0bfa3b 15 #include <stdlib.h>
roryhand 27:a378f1f937ee 16 #include <fstream>
roryhand 27:a378f1f937ee 17 #include <iostream>
roryhand 0:e89d7a0bfa3b 18 #include <vector>
roryhand 0:e89d7a0bfa3b 19 #include <string>
roryhand 0:e89d7a0bfa3b 20 #define sample_freq 11025
roryhand 1:aac37edee302 21 #pragma import __use_two_region_memory
roryhand 0:e89d7a0bfa3b 22 DigitalOut myled(LED1);
roryhand 0:e89d7a0bfa3b 23 DigitalOut led2(LED2);
roryhand 0:e89d7a0bfa3b 24 DigitalOut led3(LED3);
roryhand 0:e89d7a0bfa3b 25 DigitalIn NotchUp(p16);
roryhand 38:3b4c05af5f36 26 DigitalIn NotchDown(p17);//check the pin!!! Dont know if this will actually work...
roryhand 0:e89d7a0bfa3b 27 InterruptIn Horn(p16);
roryhand 0:e89d7a0bfa3b 28 Ticker sampletick;
roryhand 32:6ee488c97dcc 29 Ticker fileswitch_tick;
roryhand 0:e89d7a0bfa3b 30 Ticker BellTick;
roryhand 0:e89d7a0bfa3b 31 Ticker EdTick;
roryhand 0:e89d7a0bfa3b 32 Ticker TickFadeOut;
roryhand 3:6169aeeaeeb4 33 Ticker TestTick;
roryhand 0:e89d7a0bfa3b 34 Timer t;
roryhand 0:e89d7a0bfa3b 35 Timer t2;
roryhand 3:6169aeeaeeb4 36 Timer NotchTimer;
roryhand 27:a378f1f937ee 37 Timer timer_open;
roryhand 0:e89d7a0bfa3b 38
roryhand 0:e89d7a0bfa3b 39 Serial pc(USBTX, USBRX); // tx, rx //FOR DEBUGGING PROGRAM USING GNU SCREEN
roryhand 0:e89d7a0bfa3b 40 DigitalOut cs(p8);
roryhand 0:e89d7a0bfa3b 41 I2S i2s(I2S_TRANSMIT, p5, p6, p7);
roryhand 0:e89d7a0bfa3b 42 SDFileSystem sd(p11, p12, p13, p8, "sd"); // the new pinout that i am using
roryhand 0:e89d7a0bfa3b 43
roryhand 0:e89d7a0bfa3b 44
roryhand 0:e89d7a0bfa3b 45 /*struct A {
roryhand 0:e89d7a0bfa3b 46 int data;
roryhand 0:e89d7a0bfa3b 47 B b;
roryhand 0:e89d7a0bfa3b 48 };*/
roryhand 0:e89d7a0bfa3b 49
roryhand 0:e89d7a0bfa3b 50
roryhand 0:e89d7a0bfa3b 51
roryhand 0:e89d7a0bfa3b 52
roryhand 0:e89d7a0bfa3b 53 class classFade
roryhand 0:e89d7a0bfa3b 54 {
roryhand 1:aac37edee302 55 public:
roryhand 1:aac37edee302 56
roryhand 0:e89d7a0bfa3b 57 float powerval;
roryhand 0:e89d7a0bfa3b 58 float FadeIteration;
roryhand 0:e89d7a0bfa3b 59 float DecayFactor;
roryhand 0:e89d7a0bfa3b 60 float Denom;
roryhand 0:e89d7a0bfa3b 61 float FadeCoeff;
roryhand 0:e89d7a0bfa3b 62 float Natural_Exp;
roryhand 0:e89d7a0bfa3b 63 int LengthSecs;
roryhand 0:e89d7a0bfa3b 64 int Length;
roryhand 1:aac37edee302 65
roryhand 0:e89d7a0bfa3b 66 //member Functions
roryhand 0:e89d7a0bfa3b 67 float FadeOut(void)
roryhand 0:e89d7a0bfa3b 68 {
roryhand 0:e89d7a0bfa3b 69 powerval = -FadeIteration/Denom;
roryhand 1:aac37edee302 70 if (FadeIteration >=Length) {
roryhand 1:aac37edee302 71 FadeCoeff = 0;
roryhand 1:aac37edee302 72
roryhand 1:aac37edee302 73 } else {
roryhand 0:e89d7a0bfa3b 74 FadeCoeff = (Length - FadeIteration)/Length;
roryhand 0:e89d7a0bfa3b 75 }
roryhand 1:aac37edee302 76 FadeIteration = FadeIteration + 1;
roryhand 1:aac37edee302 77 return FadeCoeff;
roryhand 1:aac37edee302 78
roryhand 1:aac37edee302 79 }
roryhand 1:aac37edee302 80 float FadeIn(void)
roryhand 0:e89d7a0bfa3b 81 {
roryhand 0:e89d7a0bfa3b 82 powerval = FadeIteration/Denom;
roryhand 1:aac37edee302 83 if (FadeIteration >=Length) {
roryhand 1:aac37edee302 84 FadeCoeff = 1;
roryhand 1:aac37edee302 85
roryhand 1:aac37edee302 86 } else {
roryhand 0:e89d7a0bfa3b 87 FadeCoeff = FadeIteration/Length;
roryhand 0:e89d7a0bfa3b 88 }
roryhand 0:e89d7a0bfa3b 89
roryhand 1:aac37edee302 90 FadeIteration = FadeIteration + 1;
roryhand 1:aac37edee302 91 return FadeCoeff;
roryhand 1:aac37edee302 92
roryhand 1:aac37edee302 93 }
roryhand 0:e89d7a0bfa3b 94 };
roryhand 0:e89d7a0bfa3b 95
roryhand 0:e89d7a0bfa3b 96 classFade IdleFadeOut;
roryhand 0:e89d7a0bfa3b 97 classFade N2FadeIn;
roryhand 0:e89d7a0bfa3b 98
roryhand 2:957d3b2afff4 99 classFade NotchFadeOut;
roryhand 2:957d3b2afff4 100 classFade NotchFadeIn;
roryhand 2:957d3b2afff4 101
roryhand 0:e89d7a0bfa3b 102
roryhand 0:e89d7a0bfa3b 103
roryhand 0:e89d7a0bfa3b 104
roryhand 0:e89d7a0bfa3b 105
roryhand 1:aac37edee302 106 typedef struct uFMT_STRUCT {
roryhand 1:aac37edee302 107 short comp_code;
roryhand 1:aac37edee302 108 short num_channels;
roryhand 1:aac37edee302 109 unsigned sample_rate;
roryhand 1:aac37edee302 110 unsigned avg_Bps;
roryhand 1:aac37edee302 111 short block_align;
roryhand 1:aac37edee302 112 short sig_bps;
roryhand 0:e89d7a0bfa3b 113 } FMT_STRUCT;
roryhand 0:e89d7a0bfa3b 114
roryhand 1:aac37edee302 115 typedef struct uNotch_STRUCT {
roryhand 1:aac37edee302 116 short Notch;
roryhand 1:aac37edee302 117 short NotchTransUp;
roryhand 1:aac37edee302 118 short NotchTransDown;
roryhand 1:aac37edee302 119 short NotchDirection;
roryhand 1:aac37edee302 120 } Notch_STRUCT;
roryhand 1:aac37edee302 121
roryhand 0:e89d7a0bfa3b 122 typedef struct uDATA_STRUCT {
roryhand 1:aac37edee302 123 unsigned subchunk2_ID;
roryhand 1:aac37edee302 124 unsigned subchunk2_size;
roryhand 1:aac37edee302 125 char * data_buf;
roryhand 1:aac37edee302 126 } DATA_STRUCT;
roryhand 0:e89d7a0bfa3b 127
roryhand 1:aac37edee302 128 typedef struct uWAV_FILE_STRUCT {
roryhand 1:aac37edee302 129 FILE *WavFile;
roryhand 1:aac37edee302 130 int id_number;
roryhand 1:aac37edee302 131 char *slice_buf;
roryhand 1:aac37edee302 132 int num_slices;
roryhand 1:aac37edee302 133 FMT_STRUCT FileFormat;
roryhand 1:aac37edee302 134 DATA_STRUCT FileData;
roryhand 0:e89d7a0bfa3b 135 } WAV_FILE_STRUCT;
roryhand 0:e89d7a0bfa3b 136
roryhand 0:e89d7a0bfa3b 137 /*typedef struct uWAV_FILE_STRUCT{
roryhand 1:aac37edee302 138 FILE* WavFile;
roryhand 1:aac37edee302 139
roryhand 1:aac37edee302 140
roryhand 0:e89d7a0bfa3b 141 }WAV_FILE_STRUCT;*/
roryhand 0:e89d7a0bfa3b 142 class classSoundFile
roryhand 0:e89d7a0bfa3b 143 {
roryhand 1:aac37edee302 144 public:
roryhand 1:aac37edee302 145
roryhand 1:aac37edee302 146 //add a class constructor
roryhand 1:aac37edee302 147 WAV_FILE_STRUCT FileInfo;
roryhand 2:957d3b2afff4 148 short * data_sptr;
roryhand 36:569ec4335f92 149 string file_location;
roryhand 1:aac37edee302 150 //classSoundFile(string filename);//this is the constructor
roryhand 1:aac37edee302 151 //string filename;
roryhand 0:e89d7a0bfa3b 152 };
roryhand 0:e89d7a0bfa3b 153
roryhand 1:aac37edee302 154 //class constructor;
roryhand 1:aac37edee302 155 /*classSoundFile::classSoundFile(string filename)
roryhand 1:aac37edee302 156 {
roryhand 1:aac37edee302 157 //Declare RootFolder and the directory for the appropriate file.
roryhand 1:aac37edee302 158 //How we index into filename[] from the outside of this class is another
roryhand 1:aac37edee302 159 //issue...
roryhand 1:aac37edee302 160 FileInfo.WavFile = fopen("/sd/mydir/645Engine/Startup.wav","rb");
roryhand 1:aac37edee302 161 fseek(FileInfo.WavFile,20,SEEK_SET);
roryhand 1:aac37edee302 162 fread(&FileInfo.FileFormat,sizeof(FileInfo.FileFormat),1,FileInfo.WavFile);
roryhand 1:aac37edee302 163 printf("wav_format.sample_rate: %d\n\r",FileInfo.FileFormat.sample_rate);
roryhand 1:aac37edee302 164 fread(&FileInfo.FileData,sizeof(FileInfo.FileData),1,FileInfo.WavFile);
roryhand 1:aac37edee302 165 printf("wav_data.subchunk2_size: %d\n\r",FileInfo.FileData.subchunk2_size);
roryhand 1:aac37edee302 166 FileInfo.slice_buf = ( char *)malloc(FileInfo.FileFormat.block_align);
roryhand 1:aac37edee302 167 fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,FileInfo.WavFile); //This isnt actually required, its just a test
roryhand 1:aac37edee302 168 FileInfo.num_slices = FileInfo.FileData.subchunk2_size/FileInfo.FileFormat.block_align;
roryhand 1:aac37edee302 169 }*/
roryhand 1:aac37edee302 170
roryhand 38:3b4c05af5f36 171 int notch_flag = 0;
roryhand 0:e89d7a0bfa3b 172 int i = 0;
roryhand 0:e89d7a0bfa3b 173 int h = 0;
roryhand 0:e89d7a0bfa3b 174 short bufflen = 1;
roryhand 0:e89d7a0bfa3b 175 int buffer[1];
roryhand 1:aac37edee302 176 int AudioFormat, NumChannels, SampleRate, BitsPerSample ;
roryhand 0:e89d7a0bfa3b 177 char *slice_buf;
roryhand 0:e89d7a0bfa3b 178 short *data_sptr;
roryhand 0:e89d7a0bfa3b 179 short *data_sptr_horn;
roryhand 0:e89d7a0bfa3b 180 short *data_sptr_IdleN2;
roryhand 0:e89d7a0bfa3b 181 short * data_sptr_bell;
roryhand 0:e89d7a0bfa3b 182 short * data_sptr_N2;
roryhand 0:e89d7a0bfa3b 183 short * data_sptr_Flange;
roryhand 0:e89d7a0bfa3b 184 unsigned char *data_bptr;
roryhand 0:e89d7a0bfa3b 185 int *data_wptr;
roryhand 0:e89d7a0bfa3b 186 unsigned channel;
roryhand 0:e89d7a0bfa3b 187 long slice, num_slices;
roryhand 0:e89d7a0bfa3b 188 int verbosity = 0;
roryhand 0:e89d7a0bfa3b 189 int verbosity2 = 0;
roryhand 0:e89d7a0bfa3b 190 int verbosity3 = 0;
roryhand 0:e89d7a0bfa3b 191 int verbosity4 = 0;
roryhand 0:e89d7a0bfa3b 192 int verbosity5 = 0;
roryhand 0:e89d7a0bfa3b 193 int interrupt_condition = 1;
roryhand 0:e89d7a0bfa3b 194 int sampling_freq = 11025;
roryhand 0:e89d7a0bfa3b 195 const int BufferLen = 2000;
roryhand 0:e89d7a0bfa3b 196 short Buffer1[BufferLen];
roryhand 0:e89d7a0bfa3b 197 short Buffer2[BufferLen];
roryhand 0:e89d7a0bfa3b 198 short place_hold1 = 0;
roryhand 0:e89d7a0bfa3b 199 short place_hold2 = 0;
roryhand 0:e89d7a0bfa3b 200
roryhand 3:6169aeeaeeb4 201
roryhand 3:6169aeeaeeb4 202 string FOLDER;
roryhand 3:6169aeeaeeb4 203 string RootFolder = "/sd/mydir/SoundDecoder/";
roryhand 3:6169aeeaeeb4 204 string filename[25];
roryhand 3:6169aeeaeeb4 205 classSoundFile Sound[22];
roryhand 3:6169aeeaeeb4 206
roryhand 0:e89d7a0bfa3b 207 volatile int flag1 = 1;
roryhand 0:e89d7a0bfa3b 208 volatile int flag2 = 0;
roryhand 0:e89d7a0bfa3b 209 volatile int flag3 = 1;
roryhand 0:e89d7a0bfa3b 210 volatile int flag4 = 0;
roryhand 0:e89d7a0bfa3b 211 int FLAGBUFF1 = 0;
roryhand 0:e89d7a0bfa3b 212 int FLAGBUFF2 = 0;
roryhand 0:e89d7a0bfa3b 213 int BellFlag = 0;
roryhand 0:e89d7a0bfa3b 214 int BellFlag2 = 0;
roryhand 0:e89d7a0bfa3b 215 int FadeFlag = 0;
roryhand 32:6ee488c97dcc 216 int FileSwitchFlag = 0;
roryhand 0:e89d7a0bfa3b 217
roryhand 0:e89d7a0bfa3b 218
roryhand 0:e89d7a0bfa3b 219 short value[1];
roryhand 0:e89d7a0bfa3b 220 FILE *HornWav;
roryhand 0:e89d7a0bfa3b 221 FILE *edsheeran_wav;
roryhand 0:e89d7a0bfa3b 222 FILE *Startup_wav;
roryhand 0:e89d7a0bfa3b 223 FILE *IdleN2Wav;
roryhand 0:e89d7a0bfa3b 224 FILE *N2Wav;
roryhand 0:e89d7a0bfa3b 225 FILE *BellWav;
roryhand 0:e89d7a0bfa3b 226 FILE *FlangeWav;
roryhand 16:5e3420d0509b 227 FILE *HeyWav;
roryhand 0:e89d7a0bfa3b 228 //long long slice_value;
roryhand 0:e89d7a0bfa3b 229 int slice_value[1];
roryhand 0:e89d7a0bfa3b 230
roryhand 0:e89d7a0bfa3b 231
roryhand 0:e89d7a0bfa3b 232 WAV_FILE_STRUCT WavInfo_Horn;
roryhand 0:e89d7a0bfa3b 233 WAV_FILE_STRUCT WavInfo_IdleN2;
roryhand 0:e89d7a0bfa3b 234 WAV_FILE_STRUCT WavInfo_N2;
roryhand 0:e89d7a0bfa3b 235 WAV_FILE_STRUCT WavInfo_Bell;
roryhand 0:e89d7a0bfa3b 236 WAV_FILE_STRUCT WavInfo_Flange;
roryhand 20:9cc7d825c07b 237 WAV_FILE_STRUCT WavInfo_Hey;
roryhand 32:6ee488c97dcc 238 WAV_FILE_STRUCT WavInfo_N3;
roryhand 16:5e3420d0509b 239 WAV_FILE_STRUCT WavInfo_Frustration;
roryhand 0:e89d7a0bfa3b 240 Ticker flipper;
roryhand 0:e89d7a0bfa3b 241 char * slice_buf_bell;
roryhand 0:e89d7a0bfa3b 242 char * slice_buf_ed;
roryhand 0:e89d7a0bfa3b 243 char * slice_buf_startup;
roryhand 0:e89d7a0bfa3b 244 char * slice_buf_N2;
roryhand 1:aac37edee302 245 Notch_STRUCT NotchingSet;
roryhand 0:e89d7a0bfa3b 246 //test
roryhand 0:e89d7a0bfa3b 247 //short *data_sptr_bell = 0;
roryhand 0:e89d7a0bfa3b 248 short *data_sptr_ed = 0;
roryhand 0:e89d7a0bfa3b 249 short *data_sptr_startup = 0;
roryhand 32:6ee488c97dcc 250 FILE *StartupWav;
roryhand 32:6ee488c97dcc 251 FILE *N3Wav;
roryhand 33:a75f0a30fbdc 252 int temp = 0;
roryhand 1:aac37edee302 253 void flip()
roryhand 1:aac37edee302 254 {
roryhand 0:e89d7a0bfa3b 255 led2 = !led2;
roryhand 0:e89d7a0bfa3b 256 }
roryhand 0:e89d7a0bfa3b 257
roryhand 0:e89d7a0bfa3b 258
roryhand 0:e89d7a0bfa3b 259 void isr()
roryhand 0:e89d7a0bfa3b 260 {
roryhand 1:aac37edee302 261 if(flag1 == 0) {
roryhand 0:e89d7a0bfa3b 262 value[0] = Buffer1[place_hold1]>>4;
roryhand 0:e89d7a0bfa3b 263 i2s.write(value,1);//Send next PWM value to amp
roryhand 0:e89d7a0bfa3b 264 place_hold1 = place_hold1 + 1;
roryhand 1:aac37edee302 265 if( (place_hold1 >= BufferLen)) {
roryhand 0:e89d7a0bfa3b 266 led2 = !led2;
roryhand 0:e89d7a0bfa3b 267 place_hold1 = 0;
roryhand 0:e89d7a0bfa3b 268 place_hold2 = 0;
roryhand 0:e89d7a0bfa3b 269 flag1 = 1;
roryhand 0:e89d7a0bfa3b 270 flag2 = 0;
roryhand 1:aac37edee302 271 }
roryhand 1:aac37edee302 272 } else if(flag2 == 0) {
roryhand 0:e89d7a0bfa3b 273 value[0] = Buffer2[place_hold2]>>4;
roryhand 0:e89d7a0bfa3b 274 i2s.write(value,1);//Send next PWM value to amp
roryhand 0:e89d7a0bfa3b 275 place_hold2 = place_hold2 + 1;
roryhand 1:aac37edee302 276 if( (place_hold2 >= BufferLen) ) {
roryhand 0:e89d7a0bfa3b 277 led2 = !led2;
roryhand 0:e89d7a0bfa3b 278 place_hold1 = 0;
roryhand 0:e89d7a0bfa3b 279 place_hold2 = 0;
roryhand 0:e89d7a0bfa3b 280 flag1 = 0;
roryhand 1:aac37edee302 281 flag2 = 1;
roryhand 0:e89d7a0bfa3b 282 FLAGBUFF2 = 0;
roryhand 1:aac37edee302 283 }
roryhand 0:e89d7a0bfa3b 284 }
roryhand 0:e89d7a0bfa3b 285 }
roryhand 1:aac37edee302 286
roryhand 0:e89d7a0bfa3b 287 void horn_sound()
roryhand 0:e89d7a0bfa3b 288 {
roryhand 0:e89d7a0bfa3b 289 BellFlag = 1;
roryhand 0:e89d7a0bfa3b 290 fseek(HornWav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 291 fseek(BellWav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 292 fseek(FlangeWav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 293 fseek(N2Wav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 294 }
roryhand 0:e89d7a0bfa3b 295
roryhand 0:e89d7a0bfa3b 296
roryhand 32:6ee488c97dcc 297 void FileSwitch_isr()
roryhand 0:e89d7a0bfa3b 298 {
roryhand 32:6ee488c97dcc 299 FileSwitchFlag = 1;
roryhand 33:a75f0a30fbdc 300 temp = 1;
roryhand 33:a75f0a30fbdc 301 /*FILE* testwav = fopen("/sd/mydir/SoundDecoder_second/05.wav","rb");
roryhand 33:a75f0a30fbdc 302 if(N3Wav == NULL) {
roryhand 33:a75f0a30fbdc 303 printf("Cannot Open testwav\n\r");
roryhand 33:a75f0a30fbdc 304 }
roryhand 33:a75f0a30fbdc 305 */
roryhand 32:6ee488c97dcc 306 fseek(N3Wav,44,SEEK_SET);
roryhand 32:6ee488c97dcc 307 // fclose(StartupWav);
roryhand 0:e89d7a0bfa3b 308 }
roryhand 0:e89d7a0bfa3b 309
roryhand 0:e89d7a0bfa3b 310
roryhand 0:e89d7a0bfa3b 311 void FadeOutIsr()
roryhand 0:e89d7a0bfa3b 312 {
roryhand 1:aac37edee302 313 FadeFlag = 1;
roryhand 1:aac37edee302 314 fseek(IdleN2Wav,44,SEEK_SET);
roryhand 1:aac37edee302 315 fseek(N2Wav,44,SEEK_SET);
roryhand 1:aac37edee302 316 fseek(HornWav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 317 fseek(FlangeWav,44,SEEK_SET);
roryhand 1:aac37edee302 318
roryhand 0:e89d7a0bfa3b 319 }
roryhand 38:3b4c05af5f36 320 /*
roryhand 38:3b4c05af5f36 321 void filenotch_isr()
roryhand 38:3b4c05af5f36 322 {
roryhand 38:3b4c05af5f36 323 if(up) {
roryhand 38:3b4c05af5f36 324 notch = notch+1;
roryhand 38:3b4c05af5f36 325 notchtrans_up = notch + 8;
roryhand 38:3b4c05af5f36 326
roryhand 38:3b4c05af5f36 327 } else if(down) {
roryhand 38:3b4c05af5f36 328 notch = notch-1;
roryhand 38:3b4c05af5f36 329 notchtrans_down = notch + 15;
roryhand 38:3b4c05af5f36 330 }
roryhand 38:3b4c05af5f36 331 notch_flag = 1;
roryhand 38:3b4c05af5f36 332
roryhand 38:3b4c05af5f36 333
roryhand 38:3b4c05af5f36 334 }
roryhand 38:3b4c05af5f36 335 */
roryhand 38:3b4c05af5f36 336
roryhand 38:3b4c05af5f36 337
roryhand 38:3b4c05af5f36 338
roryhand 0:e89d7a0bfa3b 339
roryhand 3:6169aeeaeeb4 340 classFade FadeDataInitialise(classFade FadeData);
roryhand 3:6169aeeaeeb4 341
roryhand 3:6169aeeaeeb4 342
roryhand 3:6169aeeaeeb4 343
roryhand 3:6169aeeaeeb4 344
roryhand 3:6169aeeaeeb4 345
roryhand 3:6169aeeaeeb4 346 //function prototypes
roryhand 3:6169aeeaeeb4 347 WAV_FILE_STRUCT ReadFileInfo(WAV_FILE_STRUCT FileInfo, FILE * wav_file);
roryhand 3:6169aeeaeeb4 348 classSoundFile LoadFileStream(classSoundFile FileInfo, string filename);
roryhand 3:6169aeeaeeb4 349
roryhand 3:6169aeeaeeb4 350 float FadeOut(void);
roryhand 3:6169aeeaeeb4 351 void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo);
roryhand 32:6ee488c97dcc 352 void Play_WaveFileDual(FILE * my_wav, WAV_FILE_STRUCT FileInfo);
roryhand 3:6169aeeaeeb4 353 //void Play_WaveFileLoop(FILE * my_wav, WAV_FILE_STRUCT FileInfo);
roryhand 3:6169aeeaeeb4 354 //*********************INTERRUPT ROUTINE FOR NOTCHING***************************
roryhand 0:e89d7a0bfa3b 355
roryhand 1:aac37edee302 356 void NotchUpIsr()
roryhand 0:e89d7a0bfa3b 357 {
roryhand 1:aac37edee302 358 if(1 <= NotchingSet.Notch < 8) {
roryhand 1:aac37edee302 359
roryhand 1:aac37edee302 360 NotchingSet.Notch = NotchingSet.Notch + 1;
roryhand 1:aac37edee302 361 NotchingSet.NotchTransUp = NotchingSet.Notch + 7;
roryhand 1:aac37edee302 362 NotchingSet.NotchDirection = 1;
roryhand 3:6169aeeaeeb4 363 FadeDataInitialise(NotchFadeIn);
roryhand 3:6169aeeaeeb4 364 FadeDataInitialise(NotchFadeOut);
roryhand 1:aac37edee302 365 }
roryhand 0:e89d7a0bfa3b 366 }
roryhand 0:e89d7a0bfa3b 367
roryhand 0:e89d7a0bfa3b 368 void NotchDownIsr()
roryhand 0:e89d7a0bfa3b 369 {
roryhand 1:aac37edee302 370 if(1 < NotchingSet.Notch <= 8) {
roryhand 1:aac37edee302 371 NotchingSet.Notch = NotchingSet.Notch - 1;
roryhand 1:aac37edee302 372 NotchingSet.NotchTransDown = NotchingSet.Notch + 15;;
roryhand 1:aac37edee302 373 NotchingSet.NotchDirection = 0;
roryhand 3:6169aeeaeeb4 374 FadeDataInitialise(NotchFadeIn);
roryhand 3:6169aeeaeeb4 375 FadeDataInitialise(NotchFadeOut);
roryhand 1:aac37edee302 376 }
roryhand 1:aac37edee302 377 }
roryhand 0:e89d7a0bfa3b 378
roryhand 0:e89d7a0bfa3b 379
roryhand 3:6169aeeaeeb4 380 /**********************END OF INTERRUPT ROUTINE FOR NOTCHING*******************/
roryhand 3:6169aeeaeeb4 381
roryhand 3:6169aeeaeeb4 382
roryhand 1:aac37edee302 383
roryhand 0:e89d7a0bfa3b 384
roryhand 3:6169aeeaeeb4 385
roryhand 3:6169aeeaeeb4 386
roryhand 9:dd9cae06b202 387 void Play_WaveFileLoop(classSoundFile Sounds[], Notch_STRUCT NotchingSet);
roryhand 1:aac37edee302 388 int main()
roryhand 1:aac37edee302 389 {
roryhand 39:69d5a5dd9163 390 //std::vector<classSoundFile> v = {Sound1, Sound2, Sound3, Sound4};
roryhand 39:69d5a5dd9163 391 classSoundFile Sound1,Sound2,Sound3,Sound4,Sound5;
roryhand 39:69d5a5dd9163 392 Sound1.file_location = '1';
roryhand 39:69d5a5dd9163 393 Sound2.file_location = '2';
roryhand 39:69d5a5dd9163 394 Sound3.file_location = '3';
roryhand 39:69d5a5dd9163 395 Sound4.file_location = '4';
roryhand 39:69d5a5dd9163 396 Sound5.file_location = '5';
roryhand 32:6ee488c97dcc 397
roryhand 39:69d5a5dd9163 398 std::vector<classSoundFile> v;
roryhand 39:69d5a5dd9163 399 v.push_back(Sound1);
roryhand 39:69d5a5dd9163 400 v.push_back(Sound2);
roryhand 39:69d5a5dd9163 401 v.push_back(Sound3);
roryhand 39:69d5a5dd9163 402 v.push_back(Sound4);
roryhand 39:69d5a5dd9163 403 v.push_back(Sound5);
roryhand 39:69d5a5dd9163 404 for(int c = 1; c<6; c++) {
roryhand 39:69d5a5dd9163 405 printf("This is Sound No.: %s\n\r",v.at(c));
roryhand 39:69d5a5dd9163 406
roryhand 39:69d5a5dd9163 407 }
roryhand 39:69d5a5dd9163 408 v.erase(v.begin() + 1);
roryhand 39:69d5a5dd9163 409 for(int c = 1; c<6; c++) {
roryhand 39:69d5a5dd9163 410 printf("This is Sound No.: %s\n\r",v.at(c));
roryhand 39:69d5a5dd9163 411
roryhand 39:69d5a5dd9163 412 }
roryhand 39:69d5a5dd9163 413
roryhand 39:69d5a5dd9163 414 /*
roryhand 39:69d5a5dd9163 415 int ArrayOfSounds[6];
roryhand 39:69d5a5dd9163 416 ArrayOfSounds[1] = classSoundFile Sound1;
roryhand 39:69d5a5dd9163 417 ArrayOfSounds[2] = classSoundFile Sound2;
roryhand 39:69d5a5dd9163 418 ArrayOfSounds[3] = classSoundFile Sound3;
roryhand 39:69d5a5dd9163 419 ArrayOfSounds[4] = classSoundFile Sound4;
roryhand 39:69d5a5dd9163 420 ArrayOfSounds[5] = classSoundFile Sound5;
roryhand 39:69d5a5dd9163 421 */
roryhand 39:69d5a5dd9163 422
roryhand 39:69d5a5dd9163 423 //ArrayOfSounds[1] = classSoundFile Sound1;
roryhand 0:e89d7a0bfa3b 424 NotchUp.mode(PullUp);
roryhand 38:3b4c05af5f36 425 NotchDown.mode(PullUp);
roryhand 0:e89d7a0bfa3b 426
roryhand 0:e89d7a0bfa3b 427 WAV_FILE_STRUCT WavInfo_Startup;
roryhand 0:e89d7a0bfa3b 428 WAV_FILE_STRUCT WavInfo_Idle;
roryhand 0:e89d7a0bfa3b 429
roryhand 0:e89d7a0bfa3b 430 pc.printf("Beginning of program\n");
roryhand 32:6ee488c97dcc 431
roryhand 0:e89d7a0bfa3b 432 FILE *IdleWav;
roryhand 1:aac37edee302 433
roryhand 3:6169aeeaeeb4 434
roryhand 37:a563899ac0df 435 char buf[10];
roryhand 37:a563899ac0df 436 int a = 1;
roryhand 37:a563899ac0df 437 sprintf(buf, "%d", a);
roryhand 13:8e93396a27c5 438
roryhand 37:a563899ac0df 439 string foo( "hello" );
roryhand 37:a563899ac0df 440 string test( "how are" );
roryhand 37:a563899ac0df 441 string hello;
roryhand 37:a563899ac0df 442 hello = foo + test;
roryhand 37:a563899ac0df 443 printf("%s\n\r",hello);
roryhand 37:a563899ac0df 444
roryhand 37:a563899ac0df 445 string RootFolder = "sd/mydir/SoundDecoder_second/";
roryhand 37:a563899ac0df 446 string folder = RootFolder + "0" + buf + ".wav";
roryhand 37:a563899ac0df 447 printf("FullFile location: %s\n\r",folder);
roryhand 13:8e93396a27c5 448
roryhand 32:6ee488c97dcc 449
roryhand 1:aac37edee302 450
roryhand 37:a563899ac0df 451 classSoundFile Sound[22];
roryhand 37:a563899ac0df 452 string file_names[22];
roryhand 38:3b4c05af5f36 453 const char* FileName;
roryhand 37:a563899ac0df 454 for(int aaa = 0; aaa < 20; aaa ++) {
roryhand 37:a563899ac0df 455 a = aaa+1;
roryhand 37:a563899ac0df 456 sprintf(buf, "%d", a);
roryhand 37:a563899ac0df 457 Sound[aaa].file_location = RootFolder + "0" + buf + ".wav";
roryhand 38:3b4c05af5f36 458 FileName = Sound[aaa].file_location.c_str();
roryhand 39:69d5a5dd9163 459 Sound[aaa].FileInfo.WavFile = fopen(FileName,"rb");
roryhand 39:69d5a5dd9163 460 if(Sound[aaa].FileInfo.WavFile == NULL) {
roryhand 39:69d5a5dd9163 461 printf("Cannot Open Sound[%d].FileInfo.WavFile\n\r",aaa);
roryhand 39:69d5a5dd9163 462
roryhand 39:69d5a5dd9163 463 }
roryhand 39:69d5a5dd9163 464
roryhand 37:a563899ac0df 465 printf("FileName: %s\n\r",Sound[aaa].file_location);
roryhand 39:69d5a5dd9163 466 fclose(Sound[aaa].FileInfo.WavFile);
roryhand 39:69d5a5dd9163 467 free(Sound[aaa].FileInfo.WavFile);
roryhand 38:3b4c05af5f36 468 //wait(1);
roryhand 37:a563899ac0df 469 }
roryhand 38:3b4c05af5f36 470
roryhand 37:a563899ac0df 471 /*
roryhand 37:a563899ac0df 472 string RootFolder = "sd/mydir/SoundDecoder_second/";
roryhand 37:a563899ac0df 473 string folder = RootFolder + "01.wav";
roryhand 37:a563899ac0df 474 printf("Full file location: %s\n\r",folder);
roryhand 37:a563899ac0df 475 */
roryhand 32:6ee488c97dcc 476
roryhand 1:aac37edee302 477
roryhand 1:aac37edee302 478
roryhand 37:a563899ac0df 479 /*
roryhand 37:a563899ac0df 480 for(int aaa = 0;aaa < 21; aaa ++ )
roryhand 37:a563899ac0df 481 {
roryhand 37:a563899ac0df 482 folder = RootFolder + "\01.wav";//filename[aaa];
roryhand 37:a563899ac0df 483 FOLDER = folder.c_str();
roryhand 37:a563899ac0df 484 Sound[aaa].FileInfo.WavFile = fopen(FOLDER,"rb");
roryhand 37:a563899ac0df 485 //MyNewWav.WavFile = fopen("/sd/mydir/Startup.wav","rb");
roryhand 37:a563899ac0df 486 printf("we opened This file %d\n\r",aaa);
roryhand 37:a563899ac0df 487
roryhand 37:a563899ac0df 488 }
roryhand 37:a563899ac0df 489 */
roryhand 1:aac37edee302 490
roryhand 31:0f8c3adf09c3 491
roryhand 31:0f8c3adf09c3 492
roryhand 32:6ee488c97dcc 493 printf("About to Start ReadFileInfo Operations\n\r");
roryhand 39:69d5a5dd9163 494
roryhand 39:69d5a5dd9163 495 FILE* mywav1 = fopen("/sd/mydir/SoundDecoder_second/01.wav","rb");
roryhand 39:69d5a5dd9163 496 if(mywav1 == NULL) {
roryhand 39:69d5a5dd9163 497 printf("Cannot Open mywav1\n\r");
roryhand 39:69d5a5dd9163 498 }
roryhand 39:69d5a5dd9163 499 fclose(mywav1);
roryhand 39:69d5a5dd9163 500
roryhand 39:69d5a5dd9163 501 FILE* mywav2 = fopen("/sd/mydir/SoundDecoder_second/02.wav","rb");
roryhand 39:69d5a5dd9163 502 if(mywav2 == NULL) {
roryhand 39:69d5a5dd9163 503 printf("Cannot Open mywav2\n\r");
roryhand 39:69d5a5dd9163 504 }
roryhand 39:69d5a5dd9163 505 fclose(mywav2);
roryhand 39:69d5a5dd9163 506
roryhand 39:69d5a5dd9163 507 FILE* mywav3 = fopen("/sd/mydir/SoundDecoder_second/03.wav","rb");
roryhand 39:69d5a5dd9163 508 if(mywav3 == NULL) {
roryhand 39:69d5a5dd9163 509 printf("Cannot Open mywav3\n\r");
roryhand 39:69d5a5dd9163 510 }
roryhand 39:69d5a5dd9163 511 fclose(mywav3);
roryhand 39:69d5a5dd9163 512
roryhand 39:69d5a5dd9163 513 FILE* mywav4 = fopen("/sd/mydir/SoundDecoder_second/04.wav","rb");
roryhand 39:69d5a5dd9163 514 if(mywav4 == NULL) {
roryhand 39:69d5a5dd9163 515 printf("Cannot Open mywav4\n\r");
roryhand 39:69d5a5dd9163 516 }
roryhand 39:69d5a5dd9163 517 fclose(mywav4);
roryhand 39:69d5a5dd9163 518
roryhand 39:69d5a5dd9163 519 FILE* mywav5 = fopen("/sd/mydir/SoundDecoder_second/05.wav","rb");
roryhand 39:69d5a5dd9163 520 if(mywav5 == NULL) {
roryhand 39:69d5a5dd9163 521 printf("Cannot Open mywav5\n\r");
roryhand 39:69d5a5dd9163 522 }
roryhand 39:69d5a5dd9163 523 fclose(mywav5);
roryhand 39:69d5a5dd9163 524
roryhand 39:69d5a5dd9163 525 FILE* mywav6 = fopen("/sd/mydir/SoundDecoder_second/06.wav","rb");
roryhand 39:69d5a5dd9163 526 if(mywav6 == NULL) {
roryhand 39:69d5a5dd9163 527 printf("Cannot Open mywav6\n\r");
roryhand 39:69d5a5dd9163 528 }
roryhand 39:69d5a5dd9163 529 fclose(mywav6);
roryhand 39:69d5a5dd9163 530
roryhand 39:69d5a5dd9163 531 FILE* mywav7 = fopen("/sd/mydir/SoundDecoder_second/07.wav","rb");
roryhand 39:69d5a5dd9163 532 if(mywav7 == NULL) {
roryhand 39:69d5a5dd9163 533 printf("Cannot Open mywav7\n\r");
roryhand 39:69d5a5dd9163 534 }
roryhand 39:69d5a5dd9163 535 fclose(mywav7);
roryhand 13:8e93396a27c5 536
roryhand 39:69d5a5dd9163 537 FILE* mywav8 = fopen("/sd/mydir/SoundDecoder_second/08.wav","rb");
roryhand 39:69d5a5dd9163 538 if(mywav8 == NULL) {
roryhand 39:69d5a5dd9163 539 printf("Cannot Open mywav8\n\r");
roryhand 39:69d5a5dd9163 540 }
roryhand 39:69d5a5dd9163 541 fclose(mywav8);
roryhand 39:69d5a5dd9163 542
roryhand 39:69d5a5dd9163 543 FILE* mywav9 = fopen("/sd/mydir/SoundDecoder_second/09.wav","rb");
roryhand 39:69d5a5dd9163 544 if(mywav9 == NULL) {
roryhand 39:69d5a5dd9163 545 printf("Cannot Open mywav9\n\r");
roryhand 39:69d5a5dd9163 546 }
roryhand 39:69d5a5dd9163 547 fclose(mywav9);
roryhand 39:69d5a5dd9163 548
roryhand 39:69d5a5dd9163 549 FILE* mywav10 = fopen("/sd/mydir/SoundDecoder_second/10.wav","rb");
roryhand 39:69d5a5dd9163 550 if(mywav10 == NULL) {
roryhand 39:69d5a5dd9163 551 printf("Cannot Open mywav10\n\r");
roryhand 39:69d5a5dd9163 552 }
roryhand 39:69d5a5dd9163 553 fclose(mywav10);
roryhand 28:6b2353fad12d 554
roryhand 39:69d5a5dd9163 555 FILE* mywav11= fopen("/sd/mydir/SoundDecoder_second/11.wav","rb");
roryhand 39:69d5a5dd9163 556 if(mywav11 == NULL) {
roryhand 39:69d5a5dd9163 557 printf("Cannot Open mywav11\n\r");
roryhand 39:69d5a5dd9163 558 }
roryhand 39:69d5a5dd9163 559 fclose(mywav11);
roryhand 39:69d5a5dd9163 560
roryhand 39:69d5a5dd9163 561 FILE* mywav12 = fopen("/sd/mydir/SoundDecoder_second/12.wav","rb");
roryhand 39:69d5a5dd9163 562 if(mywav12 == NULL) {
roryhand 39:69d5a5dd9163 563 printf("Cannot Open mywav12\n\r");
roryhand 39:69d5a5dd9163 564 }
roryhand 39:69d5a5dd9163 565 fclose(mywav12);
roryhand 39:69d5a5dd9163 566
roryhand 39:69d5a5dd9163 567 FILE* mywav13 = fopen("/sd/mydir/SoundDecoder_second/13.wav","rb");
roryhand 39:69d5a5dd9163 568 if(mywav13 == NULL) {
roryhand 39:69d5a5dd9163 569 printf("Cannot Open mywav13\n\r");
roryhand 39:69d5a5dd9163 570 }
roryhand 39:69d5a5dd9163 571 fclose(mywav13);
roryhand 39:69d5a5dd9163 572
roryhand 39:69d5a5dd9163 573 FILE* mywav14 = fopen("/sd/mydir/SoundDecoder_second/14.wav","rb");
roryhand 39:69d5a5dd9163 574 if(mywav14 == NULL) {
roryhand 39:69d5a5dd9163 575 printf("Cannot Open mywav14\n\r");
roryhand 39:69d5a5dd9163 576 }
roryhand 39:69d5a5dd9163 577 fclose(mywav14);
roryhand 39:69d5a5dd9163 578
roryhand 39:69d5a5dd9163 579
roryhand 13:8e93396a27c5 580
roryhand 13:8e93396a27c5 581
roryhand 13:8e93396a27c5 582
roryhand 32:6ee488c97dcc 583 HeyWav = fopen("/sd/mydir/645Engine/EX_FlangeJoint1_11k_minus12dB.wav","rb");
roryhand 32:6ee488c97dcc 584 if(HeyWav == NULL) {
roryhand 32:6ee488c97dcc 585 printf("Cannot Open HeyWav\n\r");
roryhand 32:6ee488c97dcc 586 }
roryhand 32:6ee488c97dcc 587
roryhand 32:6ee488c97dcc 588 N3Wav = fopen("/sd/mydir/SoundDecoder_second/03.wav","rb");
roryhand 32:6ee488c97dcc 589 if(N3Wav == NULL) {
roryhand 32:6ee488c97dcc 590 printf("Cannot Open N3Wav\n\r");
roryhand 32:6ee488c97dcc 591 }
roryhand 32:6ee488c97dcc 592 WavInfo_N3 = ReadFileInfo(WavInfo_N3,N3Wav);
roryhand 32:6ee488c97dcc 593 fclose(N3Wav);
roryhand 25:5336e1cf38d6 594
roryhand 25:5336e1cf38d6 595
roryhand 13:8e93396a27c5 596
roryhand 22:706e86dc0d45 597 printf("About to Read HeyWav\n\r");
roryhand 28:6b2353fad12d 598
roryhand 32:6ee488c97dcc 599
roryhand 32:6ee488c97dcc 600
roryhand 25:5336e1cf38d6 601 WavInfo_Hey = ReadFileInfo(WavInfo_Hey,HeyWav);
roryhand 28:6b2353fad12d 602
roryhand 13:8e93396a27c5 603
roryhand 13:8e93396a27c5 604
roryhand 4:55fbbb049bae 605
roryhand 25:5336e1cf38d6 606 printf("Do we even get to this stupid bloody point\n\r");
roryhand 0:e89d7a0bfa3b 607 //Populate our class instances with some data (is there an implicit way to do this?)
roryhand 28:6b2353fad12d 608
roryhand 1:aac37edee302 609
roryhand 3:6169aeeaeeb4 610 printf("hello\n\r");
roryhand 0:e89d7a0bfa3b 611 //Set up the wolfson Audio Codec board
roryhand 0:e89d7a0bfa3b 612 wm8731_Config_setup();
roryhand 0:e89d7a0bfa3b 613 //i2s audio data transfer code??
roryhand 0:e89d7a0bfa3b 614 i2s.stereomono(I2S_STEREO);
roryhand 0:e89d7a0bfa3b 615 i2s.masterslave(I2S_MASTER);
roryhand 0:e89d7a0bfa3b 616 led3 = 1;
roryhand 0:e89d7a0bfa3b 617 led2 = 1;
roryhand 30:4a8e80b243c4 618 printf("Hello i2s has starrted!");
roryhand 30:4a8e80b243c4 619 i2s.start();
roryhand 0:e89d7a0bfa3b 620 sampletick.attach(&isr,1.0/sampling_freq); //1/16000
roryhand 32:6ee488c97dcc 621 fileswitch_tick.attach(&FileSwitch_isr,6.0);//So we can switch between playing file 1 and file 2, including opening and closing
roryhand 31:0f8c3adf09c3 622
roryhand 31:0f8c3adf09c3 623
roryhand 31:0f8c3adf09c3 624 timer_open.reset();
roryhand 32:6ee488c97dcc 625 timer_open.start();
roryhand 32:6ee488c97dcc 626 N3Wav = fopen("/sd/mydir/SoundDecoder_second/03.wav","rb");
roryhand 32:6ee488c97dcc 627 if(N3Wav == NULL) {
roryhand 32:6ee488c97dcc 628 printf("Cannot Open N3Wav\n\r");
roryhand 32:6ee488c97dcc 629 }
roryhand 35:4469b508dda3 630 fclose(N3Wav);
roryhand 30:4a8e80b243c4 631 StartupWav = fopen("/sd/mydir/Startup.wav","rb");
roryhand 31:0f8c3adf09c3 632 timer_open.reset();
roryhand 31:0f8c3adf09c3 633 printf("It took %d useconds to open file\n\r",timer_open.read_us());
roryhand 31:0f8c3adf09c3 634 //const char* folder2 = folder.c_str();
roryhand 31:0f8c3adf09c3 635
roryhand 31:0f8c3adf09c3 636
roryhand 31:0f8c3adf09c3 637
roryhand 28:6b2353fad12d 638 fseek(StartupWav,44,SEEK_SET);
roryhand 32:6ee488c97dcc 639 timer_open.reset();
roryhand 32:6ee488c97dcc 640 timer_open.start();
roryhand 28:6b2353fad12d 641 WavInfo_Startup = ReadFileInfo(WavInfo_Startup,StartupWav);
roryhand 32:6ee488c97dcc 642 timer_open.stop();
roryhand 32:6ee488c97dcc 643 printf("It took %d useconds to Read In File Info\n\r",timer_open.read_us());
roryhand 13:8e93396a27c5 644
roryhand 32:6ee488c97dcc 645
roryhand 32:6ee488c97dcc 646
roryhand 32:6ee488c97dcc 647
roryhand 31:0f8c3adf09c3 648
roryhand 20:9cc7d825c07b 649 printf("about to play wav file\n\r");
roryhand 32:6ee488c97dcc 650 Play_WaveFileDual(StartupWav,WavInfo_Startup);
roryhand 20:9cc7d825c07b 651 printf("finished playing Wav file\n\r");
roryhand 31:0f8c3adf09c3 652 timer_open.reset();
roryhand 31:0f8c3adf09c3 653 timer_open.start();
roryhand 31:0f8c3adf09c3 654 fclose(StartupWav);
roryhand 31:0f8c3adf09c3 655 timer_open.stop();
roryhand 31:0f8c3adf09c3 656 printf("It took %d useconds to close file\n\r",timer_open.read_us());
roryhand 9:dd9cae06b202 657 /************************************PLAY WAV FILE LOOP*******************/
roryhand 20:9cc7d825c07b 658 //Play_WaveFileLoop(Sound, NotchingSet);
roryhand 9:dd9cae06b202 659 /************************************END OF PLAY WAV FILE LOOP*************/
roryhand 13:8e93396a27c5 660
roryhand 13:8e93396a27c5 661
roryhand 13:8e93396a27c5 662
roryhand 9:dd9cae06b202 663
roryhand 3:6169aeeaeeb4 664
roryhand 0:e89d7a0bfa3b 665 fseek(IdleN2Wav,44,SEEK_SET);//reset for use in the Loop code
roryhand 0:e89d7a0bfa3b 666 slice = 0;
roryhand 0:e89d7a0bfa3b 667 fseek(IdleWav,44,SEEK_SET);
roryhand 3:6169aeeaeeb4 668 NotchingSet.Notch = 1;
roryhand 1:aac37edee302 669 //Play_WaveFileLoop(IdleWav, WavInfo_Idle);
roryhand 1:aac37edee302 670
roryhand 1:aac37edee302 671 i2s.stop();
roryhand 0:e89d7a0bfa3b 672
roryhand 0:e89d7a0bfa3b 673 }
roryhand 0:e89d7a0bfa3b 674
roryhand 0:e89d7a0bfa3b 675
roryhand 3:6169aeeaeeb4 676
roryhand 3:6169aeeaeeb4 677
roryhand 3:6169aeeaeeb4 678
roryhand 3:6169aeeaeeb4 679
roryhand 0:e89d7a0bfa3b 680 WAV_FILE_STRUCT ReadFileInfo(WAV_FILE_STRUCT FileInfo, FILE * wav_file)
roryhand 0:e89d7a0bfa3b 681 {
roryhand 0:e89d7a0bfa3b 682 fseek(wav_file,20,SEEK_SET);
roryhand 22:706e86dc0d45 683 printf("We have just seeked through this file\n\r");
roryhand 0:e89d7a0bfa3b 684 fread(&FileInfo.FileFormat,sizeof(FileInfo.FileFormat),1,wav_file);
roryhand 1:aac37edee302 685 //printf("wav_format.sample_rate: %d\n\r",FileInfo.FileFormat.sample_rate);
roryhand 1:aac37edee302 686
roryhand 0:e89d7a0bfa3b 687 fread(&FileInfo.FileData,sizeof(FileInfo.FileData),1,wav_file);
roryhand 1:aac37edee302 688 //printf("wav_data.subchunk2_size: %d\n\r",FileInfo.FileData.subchunk2_size);
roryhand 0:e89d7a0bfa3b 689 FileInfo.slice_buf = ( char *)malloc(FileInfo.FileFormat.block_align);
roryhand 0:e89d7a0bfa3b 690 fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,wav_file); //This isnt actually required, its just a test
roryhand 1:aac37edee302 691 FileInfo.num_slices = FileInfo.FileData.subchunk2_size/FileInfo.FileFormat.block_align;
roryhand 1:aac37edee302 692 //printf("Number of Slices: %d\n\r",FileInfo.num_slices);
roryhand 1:aac37edee302 693 return FileInfo;
roryhand 0:e89d7a0bfa3b 694 }
roryhand 1:aac37edee302 695
roryhand 1:aac37edee302 696 classSoundFile LoadFileStream(classSoundFile Sound, string filename)
roryhand 1:aac37edee302 697 {
roryhand 1:aac37edee302 698 //Declare RootFolder and the directory for the appropriate file.
roryhand 1:aac37edee302 699 //How we index into filename[] from the outside of this class is another
roryhand 1:aac37edee302 700 //issue...
roryhand 1:aac37edee302 701 //printf("FileName: %s\n\r",filename);
roryhand 1:aac37edee302 702 //string RootFolder = "/sd/mydir/SoundDecoder/";
roryhand 1:aac37edee302 703 //string Directory = RootFolder + "01.wav";// + filename[0];
roryhand 1:aac37edee302 704 //printf("%s\n\r",Directory);
roryhand 1:aac37edee302 705 //const char* DirectoryChar = Directory.c_str();
roryhand 1:aac37edee302 706 //Sound.FileInfo.WavFile = fopen(DirectoryChar,"rb");
roryhand 1:aac37edee302 707 Sound.FileInfo.WavFile = fopen("/sd/mydir/645Engine/Startup.wav","rb");
roryhand 1:aac37edee302 708 fseek(Sound.FileInfo.WavFile,20,SEEK_SET);
roryhand 1:aac37edee302 709 fread(&Sound.FileInfo.FileFormat,sizeof(Sound.FileInfo.FileFormat),1,Sound.FileInfo.WavFile);
roryhand 1:aac37edee302 710 printf("wav_format.sample_rate: %d\n\r",Sound.FileInfo.FileFormat.sample_rate);
roryhand 1:aac37edee302 711 fread(&Sound.FileInfo.FileData,sizeof(Sound.FileInfo.FileData),1,Sound.FileInfo.WavFile);
roryhand 1:aac37edee302 712 printf("wav_data.subchunk2_size: %d\n\r",Sound.FileInfo.FileData.subchunk2_size);
roryhand 1:aac37edee302 713 Sound.FileInfo.slice_buf = ( char *)malloc(Sound.FileInfo.FileFormat.block_align);
roryhand 1:aac37edee302 714 fread(Sound.FileInfo.slice_buf,Sound.FileInfo.FileFormat.block_align,1,Sound.FileInfo.WavFile); //This isnt actually required, its just a test
roryhand 1:aac37edee302 715 Sound.FileInfo.num_slices = Sound.FileInfo.FileData.subchunk2_size/Sound.FileInfo.FileFormat.block_align;
roryhand 1:aac37edee302 716 printf("Number of Slices: %d\n\r",Sound.FileInfo.num_slices);
roryhand 1:aac37edee302 717 return Sound;
roryhand 1:aac37edee302 718 }
roryhand 1:aac37edee302 719
roryhand 1:aac37edee302 720
roryhand 0:e89d7a0bfa3b 721 classFade FadeDataInitialise(classFade FadeData)
roryhand 0:e89d7a0bfa3b 722 {
roryhand 1:aac37edee302 723 FadeData.DecayFactor = 1.3;
roryhand 0:e89d7a0bfa3b 724 FadeData.FadeIteration = 1;
roryhand 0:e89d7a0bfa3b 725 //FadeData.Denom = 11025*FadeData.DecayFactor;
roryhand 0:e89d7a0bfa3b 726 FadeData.Denom = 11025*FadeData.DecayFactor;
roryhand 0:e89d7a0bfa3b 727 FadeData.Natural_Exp = 2.7183;
roryhand 0:e89d7a0bfa3b 728 FadeData.Length = 11025*FadeData.LengthSecs;
roryhand 0:e89d7a0bfa3b 729 //FadeData.Natural_Exp = 2.7;
roryhand 0:e89d7a0bfa3b 730 return FadeData;
roryhand 0:e89d7a0bfa3b 731 }
roryhand 0:e89d7a0bfa3b 732
roryhand 0:e89d7a0bfa3b 733 //Playing Files Code
roryhand 0:e89d7a0bfa3b 734 /*float FadeIn(void)
roryhand 0:e89d7a0bfa3b 735 {
roryhand 0:e89d7a0bfa3b 736 powervalFadeIn = FadeIterationIn/denom;
roryhand 0:e89d7a0bfa3b 737 FadeCoeffFadeIn
roryhand 1:aac37edee302 738
roryhand 1:aac37edee302 739
roryhand 0:e89d7a0bfa3b 740 }*/
roryhand 0:e89d7a0bfa3b 741 /*float FadeOut(void)
roryhand 0:e89d7a0bfa3b 742 {
roryhand 0:e89d7a0bfa3b 743 powerval = -FadeIteration/denom;
roryhand 0:e89d7a0bfa3b 744 FadeCoeff = pow(natural_exp,powerval);
roryhand 1:aac37edee302 745 FadeIteration = FadeIteration + 1;
roryhand 1:aac37edee302 746 return FadeCoeff;
roryhand 1:aac37edee302 747
roryhand 0:e89d7a0bfa3b 748 }*/
roryhand 0:e89d7a0bfa3b 749
roryhand 0:e89d7a0bfa3b 750
roryhand 0:e89d7a0bfa3b 751 void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo)
roryhand 0:e89d7a0bfa3b 752 {
roryhand 1:aac37edee302 753 while(slice<FileInfo.num_slices) {
roryhand 1:aac37edee302 754 fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav);
roryhand 1:aac37edee302 755 data_sptr=(short *)FileInfo.slice_buf; // 16 bit samples
roryhand 1:aac37edee302 756 for (channel=0; channel<FileInfo.FileFormat.num_channels; channel++) {
roryhand 1:aac37edee302 757 if(flag1 == 1) {
roryhand 1:aac37edee302 758 Buffer1[place_hold1] = data_sptr[channel];
roryhand 1:aac37edee302 759 place_hold1 = place_hold1 + 1;
roryhand 1:aac37edee302 760 if(place_hold1 >= BufferLen) {
roryhand 1:aac37edee302 761 while(1) {
roryhand 1:aac37edee302 762 if(flag1 == 0) {
roryhand 0:e89d7a0bfa3b 763
roryhand 1:aac37edee302 764 break;
roryhand 0:e89d7a0bfa3b 765 }
roryhand 1:aac37edee302 766
roryhand 0:e89d7a0bfa3b 767 }
roryhand 1:aac37edee302 768 }
roryhand 1:aac37edee302 769
roryhand 1:aac37edee302 770 } else if(flag2 == 1) {
roryhand 1:aac37edee302 771 Buffer2[place_hold2] = data_sptr[channel];
roryhand 1:aac37edee302 772 place_hold2 = place_hold2 + 1;
roryhand 1:aac37edee302 773 if(place_hold2 >= BufferLen) {
roryhand 1:aac37edee302 774
roryhand 1:aac37edee302 775 while(1) {
roryhand 1:aac37edee302 776 if(flag2 == 0) {
roryhand 1:aac37edee302 777
roryhand 1:aac37edee302 778 break;
roryhand 1:aac37edee302 779 }
roryhand 0:e89d7a0bfa3b 780 }
roryhand 1:aac37edee302 781 }
roryhand 0:e89d7a0bfa3b 782 }
roryhand 1:aac37edee302 783
roryhand 1:aac37edee302 784 }
roryhand 1:aac37edee302 785 slice = slice + 1;
roryhand 0:e89d7a0bfa3b 786 }
roryhand 0:e89d7a0bfa3b 787 }
roryhand 0:e89d7a0bfa3b 788
roryhand 0:e89d7a0bfa3b 789
roryhand 0:e89d7a0bfa3b 790
roryhand 0:e89d7a0bfa3b 791
roryhand 32:6ee488c97dcc 792 void Play_WaveFileDual(FILE * my_wav, WAV_FILE_STRUCT FileInfo)
roryhand 32:6ee488c97dcc 793 {
roryhand 32:6ee488c97dcc 794 while(slice<FileInfo.num_slices) {
roryhand 32:6ee488c97dcc 795 if(FileSwitchFlag == 1) {
roryhand 35:4469b508dda3 796
roryhand 33:a75f0a30fbdc 797 if(temp == 1) {
roryhand 34:26118c8f2e48 798 printf("Does it go to this point\n\r");
roryhand 35:4469b508dda3 799 N3Wav = fopen("/sd/mydir/SoundDecoder_second/03.wav","rb");
roryhand 33:a75f0a30fbdc 800 if(N3Wav == NULL) {
roryhand 33:a75f0a30fbdc 801 printf("Cannot Open testwav\n\r");
roryhand 33:a75f0a30fbdc 802 }
roryhand 33:a75f0a30fbdc 803 fclose(StartupWav);
roryhand 33:a75f0a30fbdc 804 temp = 0;
roryhand 33:a75f0a30fbdc 805 }
roryhand 35:4469b508dda3 806 fread(WavInfo_N3.slice_buf,WavInfo_N3.FileFormat.block_align,1,N3Wav);
roryhand 35:4469b508dda3 807 data_sptr=(short*)WavInfo_N3.slice_buf;
roryhand 32:6ee488c97dcc 808 } else {
roryhand 32:6ee488c97dcc 809 fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav);
roryhand 32:6ee488c97dcc 810 data_sptr=(short *)FileInfo.slice_buf; // 16 bit samples
roryhand 32:6ee488c97dcc 811 }
roryhand 32:6ee488c97dcc 812 for (channel=0; channel<FileInfo.FileFormat.num_channels; channel++) {
roryhand 32:6ee488c97dcc 813 if(flag1 == 1) {
roryhand 32:6ee488c97dcc 814 Buffer1[place_hold1] = data_sptr[channel];
roryhand 32:6ee488c97dcc 815 place_hold1 = place_hold1 + 1;
roryhand 32:6ee488c97dcc 816 if(place_hold1 >= BufferLen) {
roryhand 32:6ee488c97dcc 817 while(1) {
roryhand 32:6ee488c97dcc 818 if(flag1 == 0) {
roryhand 0:e89d7a0bfa3b 819
roryhand 32:6ee488c97dcc 820 break;
roryhand 32:6ee488c97dcc 821 }
roryhand 32:6ee488c97dcc 822
roryhand 32:6ee488c97dcc 823 }
roryhand 32:6ee488c97dcc 824 }
roryhand 32:6ee488c97dcc 825
roryhand 32:6ee488c97dcc 826 } else if(flag2 == 1) {
roryhand 32:6ee488c97dcc 827 Buffer2[place_hold2] = data_sptr[channel];
roryhand 32:6ee488c97dcc 828 place_hold2 = place_hold2 + 1;
roryhand 32:6ee488c97dcc 829 if(place_hold2 >= BufferLen) {
roryhand 32:6ee488c97dcc 830
roryhand 32:6ee488c97dcc 831 while(1) {
roryhand 32:6ee488c97dcc 832 if(flag2 == 0) {
roryhand 32:6ee488c97dcc 833
roryhand 32:6ee488c97dcc 834 break;
roryhand 32:6ee488c97dcc 835 }
roryhand 32:6ee488c97dcc 836 }
roryhand 32:6ee488c97dcc 837 }
roryhand 32:6ee488c97dcc 838 }
roryhand 32:6ee488c97dcc 839
roryhand 32:6ee488c97dcc 840 }
roryhand 32:6ee488c97dcc 841 slice = slice + 1;
roryhand 32:6ee488c97dcc 842 }
roryhand 32:6ee488c97dcc 843 }
roryhand 0:e89d7a0bfa3b 844
roryhand 38:3b4c05af5f36 845 //***************************************************************************//
roryhand 38:3b4c05af5f36 846 /*
roryhand 38:3b4c05af5f36 847 void Play_WaveFileNotchTest(FILE * my_wav, WAV_FILE_STRUCT FileInfo)
roryhand 38:3b4c05af5f36 848 {
roryhand 38:3b4c05af5f36 849 while(slice<FileInfo.num_slices) {
roryhand 38:3b4c05af5f36 850 if(notch_flag == 1) {
roryhand 38:3b4c05af5f36 851
roryhand 38:3b4c05af5f36 852 if(temp == 1) {
roryhand 38:3b4c05af5f36 853 //printf("Does it go to this point\n\r");
roryhand 38:3b4c05af5f36 854 SoundFile[notch].FileInfo.WavFile = fopen(Sound[aaa].file_location,"rb");
roryhand 38:3b4c05af5f36 855 if(SoundFile[notch].FileInfo.WavFile == NULL) {
roryhand 38:3b4c05af5f36 856 printf("Cannot Open testwav\n\r");
roryhand 38:3b4c05af5f36 857 }
roryhand 38:3b4c05af5f36 858 fclose(StartupWav);
roryhand 38:3b4c05af5f36 859 temp = 0;
roryhand 38:3b4c05af5f36 860 }
roryhand 38:3b4c05af5f36 861 fread(WavInfo_N3.slice_buf,WavInfo_N3.FileFormat.block_align,1,N3Wav);
roryhand 38:3b4c05af5f36 862 data_sptr=(short*)WavInfo_N3.slice_buf;
roryhand 38:3b4c05af5f36 863 } else {
roryhand 38:3b4c05af5f36 864 fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav);
roryhand 38:3b4c05af5f36 865 data_sptr=(short *)FileInfo.slice_buf; // 16 bit samples
roryhand 38:3b4c05af5f36 866 }
roryhand 38:3b4c05af5f36 867 for (channel=0; channel<FileInfo.FileFormat.num_channels; channel++) {
roryhand 38:3b4c05af5f36 868 if(flag1 == 1) {
roryhand 38:3b4c05af5f36 869 Buffer1[place_hold1] = data_sptr[channel];
roryhand 38:3b4c05af5f36 870 place_hold1 = place_hold1 + 1;
roryhand 38:3b4c05af5f36 871 if(place_hold1 >= BufferLen) {
roryhand 38:3b4c05af5f36 872 while(1) {
roryhand 38:3b4c05af5f36 873 if(flag1 == 0) {
roryhand 38:3b4c05af5f36 874
roryhand 38:3b4c05af5f36 875 break;
roryhand 38:3b4c05af5f36 876 }
roryhand 38:3b4c05af5f36 877
roryhand 38:3b4c05af5f36 878 }
roryhand 38:3b4c05af5f36 879 }
roryhand 38:3b4c05af5f36 880
roryhand 38:3b4c05af5f36 881 } else if(flag2 == 1) {
roryhand 38:3b4c05af5f36 882 Buffer2[place_hold2] = data_sptr[channel];
roryhand 38:3b4c05af5f36 883 place_hold2 = place_hold2 + 1;
roryhand 38:3b4c05af5f36 884 if(place_hold2 >= BufferLen) {
roryhand 38:3b4c05af5f36 885
roryhand 38:3b4c05af5f36 886 while(1) {
roryhand 38:3b4c05af5f36 887 if(flag2 == 0) {
roryhand 38:3b4c05af5f36 888
roryhand 38:3b4c05af5f36 889 break;
roryhand 38:3b4c05af5f36 890 }
roryhand 38:3b4c05af5f36 891 }
roryhand 38:3b4c05af5f36 892 }
roryhand 38:3b4c05af5f36 893 }
roryhand 38:3b4c05af5f36 894
roryhand 38:3b4c05af5f36 895 }
roryhand 38:3b4c05af5f36 896 slice = slice + 1;
roryhand 38:3b4c05af5f36 897 }
roryhand 38:3b4c05af5f36 898 }
roryhand 38:3b4c05af5f36 899 */
roryhand 38:3b4c05af5f36 900 //**************************************************************************//
roryhand 38:3b4c05af5f36 901
roryhand 38:3b4c05af5f36 902
roryhand 38:3b4c05af5f36 903
roryhand 38:3b4c05af5f36 904
roryhand 38:3b4c05af5f36 905
roryhand 2:957d3b2afff4 906 //void Play_WaveFileLoop(FILE * my_wav, WAV_FILE_STRUCT FileInfo)//(classSoundFile Sounds)
roryhand 9:dd9cae06b202 907
roryhand 9:dd9cae06b202 908 void Play_WaveFileLoop(classSoundFile Sounds[], Notch_STRUCT NotchingSet)
roryhand 0:e89d7a0bfa3b 909 {
roryhand 1:aac37edee302 910 while(1) { //might have to change this to a while(1) loop?
roryhand 1:aac37edee302 911 //New format!! This should be (roughly) the way that this is done, with the new structures and classes
roryhand 1:aac37edee302 912 ////fread(Sound[Notch].FileData.slice_buf,Sound[Notch].FileFormat.block_align,1,Sound[notch].WavFile);
roryhand 1:aac37edee302 913 //data_sptr=(short *)Sound[Notch].FileInfo.slice_buf;
roryhand 1:aac37edee302 914
roryhand 0:e89d7a0bfa3b 915
roryhand 2:957d3b2afff4 916 if( slice == (Sounds[NotchingSet.Notch].FileInfo.num_slices-1) ) {
roryhand 1:aac37edee302 917 slice = 0;
roryhand 2:957d3b2afff4 918 fseek(Sounds[NotchingSet.Notch].FileInfo.WavFile,44,SEEK_SET);
roryhand 1:aac37edee302 919 }
roryhand 1:aac37edee302 920
roryhand 2:957d3b2afff4 921 //fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav);
roryhand 2:957d3b2afff4 922 data_sptr=(short *)Sounds[NotchingSet.Notch].FileInfo.slice_buf; // 16 bit samples
roryhand 2:957d3b2afff4 923 //make sure we are reading in the correct "notch" here
roryhand 2:957d3b2afff4 924
roryhand 2:957d3b2afff4 925 if(FadeFlag) {
roryhand 2:957d3b2afff4 926 if(feof(Sounds[NotchingSet.Notch].FileInfo.WavFile)) {
roryhand 2:957d3b2afff4 927 fseek(Sounds[NotchingSet.Notch].FileInfo.WavFile,44,SEEK_SET);
roryhand 2:957d3b2afff4 928 }
roryhand 3:6169aeeaeeb4 929
roryhand 2:957d3b2afff4 930 //Read in data for current (i.e. now the previous notch, according to the index!!)
roryhand 2:957d3b2afff4 931 //We might not need this code here...as its probably done somewhere else??
roryhand 2:957d3b2afff4 932 fread(Sounds[NotchingSet.Notch-1].FileInfo.slice_buf,Sounds[NotchingSet.Notch-1].FileInfo.FileFormat.block_align,1,Sounds[NotchingSet.Notch-1].FileInfo.WavFile);
roryhand 2:957d3b2afff4 933 Sounds[NotchingSet.Notch-1].data_sptr = (short *)Sounds[NotchingSet.Notch-1].FileInfo.slice_buf;
roryhand 3:6169aeeaeeb4 934
roryhand 2:957d3b2afff4 935 NotchFadeOut.FadeCoeff = NotchFadeOut.FadeOut();//compute new FadeOut Coeff value
roryhand 2:957d3b2afff4 936
roryhand 2:957d3b2afff4 937 //Read in the notch transition file for transitioning up
roryhand 2:957d3b2afff4 938 fread(Sounds[NotchingSet.NotchTransUp].FileInfo.slice_buf,Sounds[NotchingSet.NotchTransUp].FileInfo.FileFormat.block_align,1,Sounds[NotchingSet.NotchTransUp].FileInfo.WavFile);
roryhand 2:957d3b2afff4 939 Sounds[NotchingSet.NotchTransUp].data_sptr = (short*)Sounds[NotchingSet.NotchTransUp].FileInfo.slice_buf;
roryhand 3:6169aeeaeeb4 940
roryhand 2:957d3b2afff4 941 if( ((Sounds[NotchingSet.NotchTransUp].FileInfo.FileData.subchunk2_size) - NotchFadeIn.Length - 2*11025) <= (ftell(Sounds[NotchingSet.NotchTransUp].FileInfo.WavFile) + 44))
roryhand 2:957d3b2afff4 942 //if( (WavInfo_IdleN2.FileData.subchunk2_size)/8 <=ftell(IdleN2Wav) )
roryhand 2:957d3b2afff4 943 {
roryhand 2:957d3b2afff4 944
roryhand 2:957d3b2afff4 945 NotchFadeIn.FadeCoeff = NotchFadeIn.FadeIn();
roryhand 3:6169aeeaeeb4 946
roryhand 2:957d3b2afff4 947 //Read In the next Notch
roryhand 2:957d3b2afff4 948 fread(Sounds[NotchingSet.Notch].FileInfo.slice_buf,Sounds[NotchingSet.Notch].FileInfo.FileFormat.block_align,1,Sounds[NotchingSet.Notch].FileInfo.WavFile);
roryhand 2:957d3b2afff4 949 Sounds[NotchingSet.Notch].data_sptr = (short *)Sounds[NotchingSet.Notch].FileInfo.slice_buf;
roryhand 2:957d3b2afff4 950
roryhand 2:957d3b2afff4 951 if( (ftell(Sounds[NotchingSet.NotchTransUp].FileInfo.WavFile) + 44) >= Sounds[NotchingSet.NotchTransUp].FileInfo.FileData.subchunk2_size ) {
roryhand 3:6169aeeaeeb4 952
roryhand 2:957d3b2afff4 953 //need to explicitly test if this notation/syntax works for pointers....
roryhand 2:957d3b2afff4 954 *Sounds[NotchingSet.Notch].data_sptr = *Sounds[NotchingSet.Notch].data_sptr*NotchFadeIn.FadeCoeff;
roryhand 2:957d3b2afff4 955 } else {
roryhand 2:957d3b2afff4 956 *Sounds[NotchingSet.Notch-1].data_sptr = *Sounds[NotchingSet.Notch - 1].data_sptr*NotchFadeOut.FadeCoeff + *Sounds[NotchingSet.NotchTransUp].data_sptr + *Sounds[NotchingSet.Notch].data_sptr*NotchFadeIn.FadeCoeff;// + *data_sptr_N2;
roryhand 2:957d3b2afff4 957 }
roryhand 2:957d3b2afff4 958
roryhand 2:957d3b2afff4 959 } else {
roryhand 2:957d3b2afff4 960 *Sounds[NotchingSet.Notch-1].data_sptr = *Sounds[NotchingSet.Notch-1].data_sptr*NotchFadeOut.FadeCoeff + *Sounds[NotchingSet.NotchTransUp].data_sptr;
roryhand 2:957d3b2afff4 961 }
roryhand 2:957d3b2afff4 962
roryhand 1:aac37edee302 963 }
roryhand 1:aac37edee302 964
roryhand 1:aac37edee302 965
roryhand 3:6169aeeaeeb4 966 /********************END OF DATA ASSIGNMENT SECTION*************************************************/
roryhand 9:dd9cae06b202 967
roryhand 2:957d3b2afff4 968 for (channel=0; channel<Sounds[NotchingSet.Notch].FileInfo.FileFormat.num_channels; channel++) {
roryhand 2:957d3b2afff4 969 switch (Sounds[NotchingSet.Notch].FileInfo.FileFormat.sig_bps) {
roryhand 0:e89d7a0bfa3b 970 case 16:
roryhand 1:aac37edee302 971 if(flag1 == 1) {
roryhand 2:957d3b2afff4 972 Buffer1[place_hold1] = Sounds[NotchingSet.Notch].data_sptr[channel];
roryhand 1:aac37edee302 973 place_hold1 = place_hold1 + 1;
roryhand 1:aac37edee302 974 if(place_hold1 >= BufferLen) {
roryhand 1:aac37edee302 975 while(1) {
roryhand 1:aac37edee302 976 if(flag1 == 0) {
roryhand 1:aac37edee302 977 break;
roryhand 1:aac37edee302 978 }//if(flag1 == 0)
roryhand 1:aac37edee302 979
roryhand 1:aac37edee302 980
roryhand 1:aac37edee302 981 }//while(1)
roryhand 1:aac37edee302 982 }//if(place_hold1 > = BufferLen)
roryhand 0:e89d7a0bfa3b 983
roryhand 1:aac37edee302 984 } else if(flag2 == 1) {
roryhand 2:957d3b2afff4 985 Buffer2[place_hold2] = Sounds[NotchingSet.Notch].data_sptr[channel];
roryhand 1:aac37edee302 986 place_hold2 = place_hold2 + 1;
roryhand 1:aac37edee302 987 if(place_hold2 >= BufferLen) {
roryhand 1:aac37edee302 988 while(1) {
roryhand 1:aac37edee302 989
roryhand 1:aac37edee302 990 if(flag2 == 0) {
roryhand 1:aac37edee302 991 break;
roryhand 1:aac37edee302 992 }
roryhand 1:aac37edee302 993 }
roryhand 0:e89d7a0bfa3b 994 }
roryhand 1:aac37edee302 995
roryhand 1:aac37edee302 996 }
roryhand 0:e89d7a0bfa3b 997 }
roryhand 0:e89d7a0bfa3b 998 }
roryhand 0:e89d7a0bfa3b 999 slice = slice + 1;
roryhand 0:e89d7a0bfa3b 1000 }
roryhand 0:e89d7a0bfa3b 1001 }
roryhand 0:e89d7a0bfa3b 1002
roryhand 0:e89d7a0bfa3b 1003
roryhand 0:e89d7a0bfa3b 1004
roryhand 0:e89d7a0bfa3b 1005
roryhand 0:e89d7a0bfa3b 1006
roryhand 0:e89d7a0bfa3b 1007
roryhand 0:e89d7a0bfa3b 1008
roryhand 9:dd9cae06b202 1009