old demo that i want to try in mbed studio

Dependencies:   mbed SDFileSystem_Copy_of_mbed_version I2S

Committer:
roryhand
Date:
Sat Mar 16 21:51:10 2019 +0000
Revision:
3:6169aeeaeeb4
Parent:
2:957d3b2afff4
Child:
4:55fbbb049bae
Seemed to find -> can open multiple files but only if NOT in an array.  Now taking all this out and just trying to play a simple file again.  NOT working

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