old demo that i want to try in mbed studio

Dependencies:   mbed SDFileSystem_Copy_of_mbed_version I2S

Committer:
roryhand
Date:
Sun May 19 19:20:16 2019 +0000
Revision:
27:a378f1f937ee
Parent:
26:82a31e2bafd0
Child:
28:6b2353fad12d
Does this have changes to SDCard file system?  not sure. CHECK

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 27:a378f1f937ee 15 #include <fstream>
roryhand 27:a378f1f937ee 16 #include <iostream>
roryhand 0:e89d7a0bfa3b 17 #include <vector>
roryhand 0:e89d7a0bfa3b 18 #include <string>
roryhand 0:e89d7a0bfa3b 19 #define sample_freq 11025
roryhand 1:aac37edee302 20 #pragma import __use_two_region_memory
roryhand 0:e89d7a0bfa3b 21 DigitalOut myled(LED1);
roryhand 0:e89d7a0bfa3b 22 DigitalOut led2(LED2);
roryhand 0:e89d7a0bfa3b 23 DigitalOut led3(LED3);
roryhand 0:e89d7a0bfa3b 24 DigitalIn NotchUp(p16);
roryhand 0:e89d7a0bfa3b 25 InterruptIn Horn(p16);
roryhand 0:e89d7a0bfa3b 26 Ticker sampletick;
roryhand 0:e89d7a0bfa3b 27 Ticker BellTick;
roryhand 0:e89d7a0bfa3b 28 Ticker EdTick;
roryhand 0:e89d7a0bfa3b 29 Ticker TickFadeOut;
roryhand 3:6169aeeaeeb4 30 Ticker TestTick;
roryhand 0:e89d7a0bfa3b 31 Timer t;
roryhand 0:e89d7a0bfa3b 32 Timer t2;
roryhand 3:6169aeeaeeb4 33 Timer NotchTimer;
roryhand 27:a378f1f937ee 34 Timer timer_open;
roryhand 0:e89d7a0bfa3b 35
roryhand 0:e89d7a0bfa3b 36 Serial pc(USBTX, USBRX); // tx, rx //FOR DEBUGGING PROGRAM USING GNU SCREEN
roryhand 0:e89d7a0bfa3b 37 DigitalOut cs(p8);
roryhand 0:e89d7a0bfa3b 38 I2S i2s(I2S_TRANSMIT, p5, p6, p7);
roryhand 0:e89d7a0bfa3b 39 SDFileSystem sd(p11, p12, p13, p8, "sd"); // the new pinout that i am using
roryhand 0:e89d7a0bfa3b 40
roryhand 0:e89d7a0bfa3b 41
roryhand 0:e89d7a0bfa3b 42 /*struct A {
roryhand 0:e89d7a0bfa3b 43 int data;
roryhand 0:e89d7a0bfa3b 44 B b;
roryhand 0:e89d7a0bfa3b 45 };*/
roryhand 0:e89d7a0bfa3b 46
roryhand 0:e89d7a0bfa3b 47
roryhand 0:e89d7a0bfa3b 48
roryhand 0:e89d7a0bfa3b 49
roryhand 0:e89d7a0bfa3b 50 class classFade
roryhand 0:e89d7a0bfa3b 51 {
roryhand 1:aac37edee302 52 public:
roryhand 1:aac37edee302 53
roryhand 0:e89d7a0bfa3b 54 float powerval;
roryhand 0:e89d7a0bfa3b 55 float FadeIteration;
roryhand 0:e89d7a0bfa3b 56 float DecayFactor;
roryhand 0:e89d7a0bfa3b 57 float Denom;
roryhand 0:e89d7a0bfa3b 58 float FadeCoeff;
roryhand 0:e89d7a0bfa3b 59 float Natural_Exp;
roryhand 0:e89d7a0bfa3b 60 int LengthSecs;
roryhand 0:e89d7a0bfa3b 61 int Length;
roryhand 1:aac37edee302 62
roryhand 0:e89d7a0bfa3b 63 //member Functions
roryhand 0:e89d7a0bfa3b 64 float FadeOut(void)
roryhand 0:e89d7a0bfa3b 65 {
roryhand 0:e89d7a0bfa3b 66 powerval = -FadeIteration/Denom;
roryhand 1:aac37edee302 67 if (FadeIteration >=Length) {
roryhand 1:aac37edee302 68 FadeCoeff = 0;
roryhand 1:aac37edee302 69
roryhand 1:aac37edee302 70 } else {
roryhand 0:e89d7a0bfa3b 71 FadeCoeff = (Length - FadeIteration)/Length;
roryhand 0:e89d7a0bfa3b 72 }
roryhand 1:aac37edee302 73 FadeIteration = FadeIteration + 1;
roryhand 1:aac37edee302 74 return FadeCoeff;
roryhand 1:aac37edee302 75
roryhand 1:aac37edee302 76 }
roryhand 1:aac37edee302 77 float FadeIn(void)
roryhand 0:e89d7a0bfa3b 78 {
roryhand 0:e89d7a0bfa3b 79 powerval = FadeIteration/Denom;
roryhand 1:aac37edee302 80 if (FadeIteration >=Length) {
roryhand 1:aac37edee302 81 FadeCoeff = 1;
roryhand 1:aac37edee302 82
roryhand 1:aac37edee302 83 } else {
roryhand 0:e89d7a0bfa3b 84 FadeCoeff = FadeIteration/Length;
roryhand 0:e89d7a0bfa3b 85 }
roryhand 0:e89d7a0bfa3b 86
roryhand 1:aac37edee302 87 FadeIteration = FadeIteration + 1;
roryhand 1:aac37edee302 88 return FadeCoeff;
roryhand 1:aac37edee302 89
roryhand 1:aac37edee302 90 }
roryhand 0:e89d7a0bfa3b 91 };
roryhand 0:e89d7a0bfa3b 92
roryhand 0:e89d7a0bfa3b 93 classFade IdleFadeOut;
roryhand 0:e89d7a0bfa3b 94 classFade N2FadeIn;
roryhand 0:e89d7a0bfa3b 95
roryhand 2:957d3b2afff4 96 classFade NotchFadeOut;
roryhand 2:957d3b2afff4 97 classFade NotchFadeIn;
roryhand 2:957d3b2afff4 98
roryhand 0:e89d7a0bfa3b 99
roryhand 0:e89d7a0bfa3b 100
roryhand 0:e89d7a0bfa3b 101
roryhand 0:e89d7a0bfa3b 102
roryhand 1:aac37edee302 103 typedef struct uFMT_STRUCT {
roryhand 1:aac37edee302 104 short comp_code;
roryhand 1:aac37edee302 105 short num_channels;
roryhand 1:aac37edee302 106 unsigned sample_rate;
roryhand 1:aac37edee302 107 unsigned avg_Bps;
roryhand 1:aac37edee302 108 short block_align;
roryhand 1:aac37edee302 109 short sig_bps;
roryhand 0:e89d7a0bfa3b 110 } FMT_STRUCT;
roryhand 0:e89d7a0bfa3b 111
roryhand 1:aac37edee302 112 typedef struct uNotch_STRUCT {
roryhand 1:aac37edee302 113 short Notch;
roryhand 1:aac37edee302 114 short NotchTransUp;
roryhand 1:aac37edee302 115 short NotchTransDown;
roryhand 1:aac37edee302 116 short NotchDirection;
roryhand 1:aac37edee302 117 } Notch_STRUCT;
roryhand 1:aac37edee302 118
roryhand 0:e89d7a0bfa3b 119 typedef struct uDATA_STRUCT {
roryhand 1:aac37edee302 120 unsigned subchunk2_ID;
roryhand 1:aac37edee302 121 unsigned subchunk2_size;
roryhand 1:aac37edee302 122 char * data_buf;
roryhand 1:aac37edee302 123 } DATA_STRUCT;
roryhand 0:e89d7a0bfa3b 124
roryhand 1:aac37edee302 125 typedef struct uWAV_FILE_STRUCT {
roryhand 1:aac37edee302 126 FILE *WavFile;
roryhand 1:aac37edee302 127 int id_number;
roryhand 1:aac37edee302 128 char *slice_buf;
roryhand 1:aac37edee302 129 int num_slices;
roryhand 1:aac37edee302 130 FMT_STRUCT FileFormat;
roryhand 1:aac37edee302 131 DATA_STRUCT FileData;
roryhand 0:e89d7a0bfa3b 132 } WAV_FILE_STRUCT;
roryhand 0:e89d7a0bfa3b 133
roryhand 0:e89d7a0bfa3b 134 /*typedef struct uWAV_FILE_STRUCT{
roryhand 1:aac37edee302 135 FILE* WavFile;
roryhand 1:aac37edee302 136
roryhand 1:aac37edee302 137
roryhand 0:e89d7a0bfa3b 138 }WAV_FILE_STRUCT;*/
roryhand 0:e89d7a0bfa3b 139 class classSoundFile
roryhand 0:e89d7a0bfa3b 140 {
roryhand 1:aac37edee302 141 public:
roryhand 1:aac37edee302 142
roryhand 1:aac37edee302 143 //add a class constructor
roryhand 1:aac37edee302 144 WAV_FILE_STRUCT FileInfo;
roryhand 2:957d3b2afff4 145 short * data_sptr;
roryhand 1:aac37edee302 146 //classSoundFile(string filename);//this is the constructor
roryhand 1:aac37edee302 147 //string filename;
roryhand 0:e89d7a0bfa3b 148 };
roryhand 0:e89d7a0bfa3b 149
roryhand 1:aac37edee302 150 //class constructor;
roryhand 1:aac37edee302 151 /*classSoundFile::classSoundFile(string filename)
roryhand 1:aac37edee302 152 {
roryhand 1:aac37edee302 153 //Declare RootFolder and the directory for the appropriate file.
roryhand 1:aac37edee302 154 //How we index into filename[] from the outside of this class is another
roryhand 1:aac37edee302 155 //issue...
roryhand 1:aac37edee302 156 FileInfo.WavFile = fopen("/sd/mydir/645Engine/Startup.wav","rb");
roryhand 1:aac37edee302 157 fseek(FileInfo.WavFile,20,SEEK_SET);
roryhand 1:aac37edee302 158 fread(&FileInfo.FileFormat,sizeof(FileInfo.FileFormat),1,FileInfo.WavFile);
roryhand 1:aac37edee302 159 printf("wav_format.sample_rate: %d\n\r",FileInfo.FileFormat.sample_rate);
roryhand 1:aac37edee302 160 fread(&FileInfo.FileData,sizeof(FileInfo.FileData),1,FileInfo.WavFile);
roryhand 1:aac37edee302 161 printf("wav_data.subchunk2_size: %d\n\r",FileInfo.FileData.subchunk2_size);
roryhand 1:aac37edee302 162 FileInfo.slice_buf = ( char *)malloc(FileInfo.FileFormat.block_align);
roryhand 1:aac37edee302 163 fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,FileInfo.WavFile); //This isnt actually required, its just a test
roryhand 1:aac37edee302 164 FileInfo.num_slices = FileInfo.FileData.subchunk2_size/FileInfo.FileFormat.block_align;
roryhand 1:aac37edee302 165 }*/
roryhand 1:aac37edee302 166
roryhand 0:e89d7a0bfa3b 167
roryhand 0:e89d7a0bfa3b 168 int i = 0;
roryhand 0:e89d7a0bfa3b 169 int h = 0;
roryhand 0:e89d7a0bfa3b 170 short bufflen = 1;
roryhand 0:e89d7a0bfa3b 171 int buffer[1];
roryhand 1:aac37edee302 172 int AudioFormat, NumChannels, SampleRate, BitsPerSample ;
roryhand 0:e89d7a0bfa3b 173 char *slice_buf;
roryhand 0:e89d7a0bfa3b 174 short *data_sptr;
roryhand 0:e89d7a0bfa3b 175 short *data_sptr_horn;
roryhand 0:e89d7a0bfa3b 176 short *data_sptr_IdleN2;
roryhand 0:e89d7a0bfa3b 177 short * data_sptr_bell;
roryhand 0:e89d7a0bfa3b 178 short * data_sptr_N2;
roryhand 0:e89d7a0bfa3b 179 short * data_sptr_Flange;
roryhand 0:e89d7a0bfa3b 180 unsigned char *data_bptr;
roryhand 0:e89d7a0bfa3b 181 int *data_wptr;
roryhand 0:e89d7a0bfa3b 182 unsigned channel;
roryhand 0:e89d7a0bfa3b 183 long slice, num_slices;
roryhand 0:e89d7a0bfa3b 184 int verbosity = 0;
roryhand 0:e89d7a0bfa3b 185 int verbosity2 = 0;
roryhand 0:e89d7a0bfa3b 186 int verbosity3 = 0;
roryhand 0:e89d7a0bfa3b 187 int verbosity4 = 0;
roryhand 0:e89d7a0bfa3b 188 int verbosity5 = 0;
roryhand 0:e89d7a0bfa3b 189 int interrupt_condition = 1;
roryhand 0:e89d7a0bfa3b 190 int sampling_freq = 11025;
roryhand 0:e89d7a0bfa3b 191 const int BufferLen = 2000;
roryhand 0:e89d7a0bfa3b 192 short Buffer1[BufferLen];
roryhand 0:e89d7a0bfa3b 193 short Buffer2[BufferLen];
roryhand 0:e89d7a0bfa3b 194 short place_hold1 = 0;
roryhand 0:e89d7a0bfa3b 195 short place_hold2 = 0;
roryhand 0:e89d7a0bfa3b 196
roryhand 3:6169aeeaeeb4 197
roryhand 3:6169aeeaeeb4 198 string FOLDER;
roryhand 3:6169aeeaeeb4 199 string RootFolder = "/sd/mydir/SoundDecoder/";
roryhand 3:6169aeeaeeb4 200 string filename[25];
roryhand 3:6169aeeaeeb4 201 classSoundFile Sound[22];
roryhand 3:6169aeeaeeb4 202
roryhand 0:e89d7a0bfa3b 203 volatile int flag1 = 1;
roryhand 0:e89d7a0bfa3b 204 volatile int flag2 = 0;
roryhand 0:e89d7a0bfa3b 205 volatile int flag3 = 1;
roryhand 0:e89d7a0bfa3b 206 volatile int flag4 = 0;
roryhand 0:e89d7a0bfa3b 207 int FLAGBUFF1 = 0;
roryhand 0:e89d7a0bfa3b 208 int FLAGBUFF2 = 0;
roryhand 0:e89d7a0bfa3b 209 int BellFlag = 0;
roryhand 0:e89d7a0bfa3b 210 int BellFlag2 = 0;
roryhand 0:e89d7a0bfa3b 211 int FadeFlag = 0;
roryhand 0:e89d7a0bfa3b 212 int DualEngineFlag = 0;
roryhand 0:e89d7a0bfa3b 213
roryhand 0:e89d7a0bfa3b 214
roryhand 0:e89d7a0bfa3b 215 short value[1];
roryhand 0:e89d7a0bfa3b 216 FILE *HornWav;
roryhand 0:e89d7a0bfa3b 217 FILE *edsheeran_wav;
roryhand 0:e89d7a0bfa3b 218 FILE *Startup_wav;
roryhand 0:e89d7a0bfa3b 219 FILE *IdleN2Wav;
roryhand 0:e89d7a0bfa3b 220 FILE *N2Wav;
roryhand 0:e89d7a0bfa3b 221 FILE *BellWav;
roryhand 0:e89d7a0bfa3b 222 FILE *FlangeWav;
roryhand 16:5e3420d0509b 223 FILE *HeyWav;
roryhand 0:e89d7a0bfa3b 224 //long long slice_value;
roryhand 0:e89d7a0bfa3b 225 int slice_value[1];
roryhand 0:e89d7a0bfa3b 226
roryhand 0:e89d7a0bfa3b 227
roryhand 0:e89d7a0bfa3b 228 WAV_FILE_STRUCT WavInfo_Horn;
roryhand 0:e89d7a0bfa3b 229 WAV_FILE_STRUCT WavInfo_IdleN2;
roryhand 0:e89d7a0bfa3b 230 WAV_FILE_STRUCT WavInfo_N2;
roryhand 0:e89d7a0bfa3b 231 WAV_FILE_STRUCT WavInfo_Bell;
roryhand 0:e89d7a0bfa3b 232 WAV_FILE_STRUCT WavInfo_Flange;
roryhand 20:9cc7d825c07b 233 WAV_FILE_STRUCT WavInfo_Hey;
roryhand 16:5e3420d0509b 234 WAV_FILE_STRUCT WavInfo_Frustration;
roryhand 0:e89d7a0bfa3b 235 Ticker flipper;
roryhand 0:e89d7a0bfa3b 236 char * slice_buf_bell;
roryhand 0:e89d7a0bfa3b 237 char * slice_buf_ed;
roryhand 0:e89d7a0bfa3b 238 char * slice_buf_startup;
roryhand 0:e89d7a0bfa3b 239 char * slice_buf_N2;
roryhand 1:aac37edee302 240 Notch_STRUCT NotchingSet;
roryhand 0:e89d7a0bfa3b 241 //test
roryhand 0:e89d7a0bfa3b 242 //short *data_sptr_bell = 0;
roryhand 0:e89d7a0bfa3b 243 short *data_sptr_ed = 0;
roryhand 0:e89d7a0bfa3b 244 short *data_sptr_startup = 0;
roryhand 1:aac37edee302 245 void flip()
roryhand 1:aac37edee302 246 {
roryhand 0:e89d7a0bfa3b 247 led2 = !led2;
roryhand 0:e89d7a0bfa3b 248 }
roryhand 0:e89d7a0bfa3b 249
roryhand 0:e89d7a0bfa3b 250
roryhand 0:e89d7a0bfa3b 251 void isr()
roryhand 0:e89d7a0bfa3b 252 {
roryhand 1:aac37edee302 253 if(flag1 == 0) {
roryhand 0:e89d7a0bfa3b 254 value[0] = Buffer1[place_hold1]>>4;
roryhand 0:e89d7a0bfa3b 255 i2s.write(value,1);//Send next PWM value to amp
roryhand 0:e89d7a0bfa3b 256 place_hold1 = place_hold1 + 1;
roryhand 1:aac37edee302 257 if( (place_hold1 >= BufferLen)) {
roryhand 0:e89d7a0bfa3b 258 led2 = !led2;
roryhand 0:e89d7a0bfa3b 259 place_hold1 = 0;
roryhand 0:e89d7a0bfa3b 260 place_hold2 = 0;
roryhand 0:e89d7a0bfa3b 261 flag1 = 1;
roryhand 0:e89d7a0bfa3b 262 flag2 = 0;
roryhand 1:aac37edee302 263 }
roryhand 1:aac37edee302 264 } else if(flag2 == 0) {
roryhand 0:e89d7a0bfa3b 265 value[0] = Buffer2[place_hold2]>>4;
roryhand 0:e89d7a0bfa3b 266 i2s.write(value,1);//Send next PWM value to amp
roryhand 0:e89d7a0bfa3b 267 place_hold2 = place_hold2 + 1;
roryhand 1:aac37edee302 268 if( (place_hold2 >= BufferLen) ) {
roryhand 0:e89d7a0bfa3b 269 led2 = !led2;
roryhand 0:e89d7a0bfa3b 270 place_hold1 = 0;
roryhand 0:e89d7a0bfa3b 271 place_hold2 = 0;
roryhand 0:e89d7a0bfa3b 272 flag1 = 0;
roryhand 1:aac37edee302 273 flag2 = 1;
roryhand 0:e89d7a0bfa3b 274 FLAGBUFF2 = 0;
roryhand 1:aac37edee302 275 }
roryhand 0:e89d7a0bfa3b 276 }
roryhand 0:e89d7a0bfa3b 277 }
roryhand 1:aac37edee302 278
roryhand 0:e89d7a0bfa3b 279 void horn_sound()
roryhand 0:e89d7a0bfa3b 280 {
roryhand 0:e89d7a0bfa3b 281 BellFlag = 1;
roryhand 0:e89d7a0bfa3b 282 fseek(HornWav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 283 fseek(BellWav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 284 fseek(FlangeWav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 285 fseek(N2Wav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 286 }
roryhand 0:e89d7a0bfa3b 287
roryhand 0:e89d7a0bfa3b 288
roryhand 0:e89d7a0bfa3b 289 void N2SoundIsr()
roryhand 0:e89d7a0bfa3b 290 {
roryhand 0:e89d7a0bfa3b 291 DualEngineFlag = 1;
roryhand 0:e89d7a0bfa3b 292 fseek(N2Wav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 293 fseek(HornWav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 294 //TickFadeOut.detach(&N2SoundIsr);//,5.0);
roryhand 0:e89d7a0bfa3b 295 }
roryhand 0:e89d7a0bfa3b 296
roryhand 0:e89d7a0bfa3b 297
roryhand 0:e89d7a0bfa3b 298 void FadeOutIsr()
roryhand 0:e89d7a0bfa3b 299 {
roryhand 1:aac37edee302 300 FadeFlag = 1;
roryhand 1:aac37edee302 301 fseek(IdleN2Wav,44,SEEK_SET);
roryhand 1:aac37edee302 302 fseek(N2Wav,44,SEEK_SET);
roryhand 1:aac37edee302 303 fseek(HornWav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 304 fseek(FlangeWav,44,SEEK_SET);
roryhand 1:aac37edee302 305
roryhand 0:e89d7a0bfa3b 306 }
roryhand 0:e89d7a0bfa3b 307
roryhand 3:6169aeeaeeb4 308 classFade FadeDataInitialise(classFade FadeData);
roryhand 3:6169aeeaeeb4 309
roryhand 3:6169aeeaeeb4 310
roryhand 3:6169aeeaeeb4 311
roryhand 3:6169aeeaeeb4 312
roryhand 3:6169aeeaeeb4 313
roryhand 3:6169aeeaeeb4 314 //function prototypes
roryhand 3:6169aeeaeeb4 315 WAV_FILE_STRUCT ReadFileInfo(WAV_FILE_STRUCT FileInfo, FILE * wav_file);
roryhand 3:6169aeeaeeb4 316 classSoundFile LoadFileStream(classSoundFile FileInfo, string filename);
roryhand 3:6169aeeaeeb4 317
roryhand 3:6169aeeaeeb4 318 float FadeOut(void);
roryhand 3:6169aeeaeeb4 319 void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo);
roryhand 3:6169aeeaeeb4 320 //void Play_WaveFileLoop(FILE * my_wav, WAV_FILE_STRUCT FileInfo);
roryhand 3:6169aeeaeeb4 321 //*********************INTERRUPT ROUTINE FOR NOTCHING***************************
roryhand 0:e89d7a0bfa3b 322
roryhand 1:aac37edee302 323 void NotchUpIsr()
roryhand 0:e89d7a0bfa3b 324 {
roryhand 1:aac37edee302 325 if(1 <= NotchingSet.Notch < 8) {
roryhand 1:aac37edee302 326
roryhand 1:aac37edee302 327 NotchingSet.Notch = NotchingSet.Notch + 1;
roryhand 1:aac37edee302 328 NotchingSet.NotchTransUp = NotchingSet.Notch + 7;
roryhand 1:aac37edee302 329 NotchingSet.NotchDirection = 1;
roryhand 3:6169aeeaeeb4 330 FadeDataInitialise(NotchFadeIn);
roryhand 3:6169aeeaeeb4 331 FadeDataInitialise(NotchFadeOut);
roryhand 1:aac37edee302 332 }
roryhand 0:e89d7a0bfa3b 333 }
roryhand 0:e89d7a0bfa3b 334
roryhand 0:e89d7a0bfa3b 335 void NotchDownIsr()
roryhand 0:e89d7a0bfa3b 336 {
roryhand 1:aac37edee302 337 if(1 < NotchingSet.Notch <= 8) {
roryhand 1:aac37edee302 338 NotchingSet.Notch = NotchingSet.Notch - 1;
roryhand 1:aac37edee302 339 NotchingSet.NotchTransDown = NotchingSet.Notch + 15;;
roryhand 1:aac37edee302 340 NotchingSet.NotchDirection = 0;
roryhand 3:6169aeeaeeb4 341 FadeDataInitialise(NotchFadeIn);
roryhand 3:6169aeeaeeb4 342 FadeDataInitialise(NotchFadeOut);
roryhand 1:aac37edee302 343 }
roryhand 1:aac37edee302 344 }
roryhand 0:e89d7a0bfa3b 345
roryhand 0:e89d7a0bfa3b 346
roryhand 3:6169aeeaeeb4 347 /**********************END OF INTERRUPT ROUTINE FOR NOTCHING*******************/
roryhand 3:6169aeeaeeb4 348
roryhand 3:6169aeeaeeb4 349
roryhand 1:aac37edee302 350
roryhand 0:e89d7a0bfa3b 351
roryhand 3:6169aeeaeeb4 352
roryhand 3:6169aeeaeeb4 353
roryhand 9:dd9cae06b202 354 void Play_WaveFileLoop(classSoundFile Sounds[], Notch_STRUCT NotchingSet);
roryhand 1:aac37edee302 355 int main()
roryhand 1:aac37edee302 356 {
roryhand 0:e89d7a0bfa3b 357 //LocalFileSystem local("local");
roryhand 0:e89d7a0bfa3b 358 NotchUp.mode(PullUp);
roryhand 0:e89d7a0bfa3b 359
roryhand 0:e89d7a0bfa3b 360
roryhand 0:e89d7a0bfa3b 361 //classSoundFile Sounds[4];
roryhand 1:aac37edee302 362 /* for(int iii = 0; iii < 3; iii ++)
roryhand 1:aac37edee302 363 {
roryhand 1:aac37edee302 364 Sounds[iii].setX(iii);
roryhand 1:aac37edee302 365 }*/
roryhand 0:e89d7a0bfa3b 366 WAV_FILE_STRUCT WavInfo_Startup;
roryhand 0:e89d7a0bfa3b 367 WAV_FILE_STRUCT WavInfo_Idle;
roryhand 0:e89d7a0bfa3b 368
roryhand 0:e89d7a0bfa3b 369 pc.printf("Beginning of program\n");
roryhand 0:e89d7a0bfa3b 370 FILE *StartupWav;
roryhand 0:e89d7a0bfa3b 371 FILE *IdleWav;
roryhand 1:aac37edee302 372
roryhand 3:6169aeeaeeb4 373
roryhand 0:e89d7a0bfa3b 374 DIR *dir;
roryhand 23:49c10427a1cd 375 dirent *ent;
roryhand 0:e89d7a0bfa3b 376 int iterator = 0;
roryhand 13:8e93396a27c5 377
roryhand 13:8e93396a27c5 378
roryhand 13:8e93396a27c5 379
roryhand 13:8e93396a27c5 380
roryhand 3:6169aeeaeeb4 381 printf("Directory is about to be opened? Still dont really Get this concept\n\r");
roryhand 3:6169aeeaeeb4 382 //if i try to open folder SoundDecoder2, it gets stuck after file 13... WHY
roryhand 3:6169aeeaeeb4 383 if ((dir = opendir ("/sd/mydir/SoundDecoder_second")) != NULL) {
roryhand 1:aac37edee302 384
roryhand 0:e89d7a0bfa3b 385 // print all the files and directories within directory
roryhand 1:aac37edee302 386 while ((ent = readdir (dir)) != NULL) {
roryhand 3:6169aeeaeeb4 387 //printf("%s\r\n",string(ent->d_name));
roryhand 3:6169aeeaeeb4 388 filename[iterator] = (ent->d_name);
roryhand 23:49c10427a1cd 389 printf("Filename: %s\n\r",filename[iterator]);
roryhand 0:e89d7a0bfa3b 390 //printf("%s\r\n",filename[iterator]);
roryhand 0:e89d7a0bfa3b 391 iterator = iterator + 1;
roryhand 0:e89d7a0bfa3b 392 //printf("%s\r\n", ent->d_name);
roryhand 1:aac37edee302 393 //filenames.push_back(string(dirp->d_name));
roryhand 0:e89d7a0bfa3b 394 }
roryhand 0:e89d7a0bfa3b 395 closedir (dir);
roryhand 1:aac37edee302 396 }
roryhand 4:55fbbb049bae 397 /*
roryhand 3:6169aeeaeeb4 398 printf("Now printing all the files");
roryhand 3:6169aeeaeeb4 399 for(iterator = 0; iterator < 21; iterator ++) {
roryhand 1:aac37edee302 400 printf("All the Files: %s\r\n",filename[iterator]);
roryhand 1:aac37edee302 401 //printf("All the Files: %s\r\n",ent[iterator]);
roryhand 1:aac37edee302 402 }
roryhand 4:55fbbb049bae 403 */
roryhand 13:8e93396a27c5 404
roryhand 1:aac37edee302 405 //strcat(RootFolder,qdfilename[0]);
roryhand 3:6169aeeaeeb4 406 //string folder = RootFolder + filename[9];
roryhand 3:6169aeeaeeb4 407 //printf("Folder: %s\n\r",folder);
roryhand 1:aac37edee302 408
roryhand 1:aac37edee302 409
roryhand 0:e89d7a0bfa3b 410 //printf("Files and Folders contained here: %d\n\r",readdir(dp));
roryhand 1:aac37edee302 411
roryhand 27:a378f1f937ee 412 timer_open.reset();
roryhand 27:a378f1f937ee 413 timer_open.start();
roryhand 9:dd9cae06b202 414 StartupWav = fopen("/sd/mydir/Startup.wav","rb");
roryhand 27:a378f1f937ee 415 timer_open.reset();
roryhand 27:a378f1f937ee 416 printf("It took %d useconds to open file\n\r",timer_open.read_us());
roryhand 3:6169aeeaeeb4 417 //const char* folder2 = folder.c_str();
roryhand 27:a378f1f937ee 418 timer_open.reset();
roryhand 27:a378f1f937ee 419 timer_open.start();
roryhand 27:a378f1f937ee 420 fclose(StartupWav);
roryhand 27:a378f1f937ee 421 timer_open.stop();
roryhand 27:a378f1f937ee 422 printf("It took %d useconds to close file\n\r",timer_open.read_us());
roryhand 27:a378f1f937ee 423
roryhand 27:a378f1f937ee 424
roryhand 1:aac37edee302 425 string FileName;
roryhand 1:aac37edee302 426 //vector <classSoundFile> Sound (27);
roryhand 3:6169aeeaeeb4 427 const char* FOLDER;
roryhand 13:8e93396a27c5 428
roryhand 13:8e93396a27c5 429 /*
roryhand 13:8e93396a27c5 430 WAV_FILE_STRUCT MyNewWav;
roryhand 13:8e93396a27c5 431
roryhand 13:8e93396a27c5 432 string folder;
roryhand 9:dd9cae06b202 433
roryhand 13:8e93396a27c5 434 for(int aaa = 0;aaa < 21; aaa ++ )
roryhand 13:8e93396a27c5 435 {
roryhand 13:8e93396a27c5 436 folder = RootFolder + filename[aaa];
roryhand 13:8e93396a27c5 437 FOLDER = folder.c_str();
roryhand 13:8e93396a27c5 438 //MyNewWav.WavFile = fopen("/sd/mydir/Startup.wav","rb");
roryhand 13:8e93396a27c5 439 printf("we opened This file %d\n\r",aaa);
roryhand 9:dd9cae06b202 440
roryhand 13:8e93396a27c5 441 /*
roryhand 13:8e93396a27c5 442 printf("Size of FILE* %d\n\r ",sizeof(Sound[aaa].FileInfo.WavFile));
roryhand 13:8e93396a27c5 443 fseek(Sound[aaa].FileInfo.WavFile,20,SEEK_SET);
roryhand 13:8e93396a27c5 444 fread(&Sound[aaa].FileInfo.FileFormat,sizeof(Sound[aaa].FileInfo.FileFormat),1,Sound[aaa].FileInfo.WavFile);
roryhand 13:8e93396a27c5 445 fread(&Sound[aaa].FileInfo.FileData,sizeof(Sound[aaa].FileInfo.FileData),1,Sound[aaa].FileInfo.WavFile);
roryhand 13:8e93396a27c5 446 */
roryhand 13:8e93396a27c5 447
roryhand 13:8e93396a27c5 448
roryhand 9:dd9cae06b202 449 //fseek(Sound[aaa].FileInfo.WavFile,20,SEEK_SET);
roryhand 9:dd9cae06b202 450
roryhand 9:dd9cae06b202 451 //fseek(MyNewWav.WavFile,20,SEEK_SET);
roryhand 9:dd9cae06b202 452 //fread(&WavInfo_Horn.FileFormat,sizeof(WavInfo_Horn.FileFormat),1,MyNewWav.WavFile);
roryhand 13:8e93396a27c5 453 /*
roryhand 13:8e93396a27c5 454 fread(&Sound[aaa].FileInfo.FileData,sizeof(Sound[aaa].FileInfo.FileData),1,Sound[aaa].FileInfo.WavFile);
roryhand 9:dd9cae06b202 455
roryhand 7:131ac4231c46 456 Sound[aaa].FileInfo.slice_buf = ( char *)malloc(Sound[aaa].FileInfo.FileFormat.block_align);
roryhand 7:131ac4231c46 457 fread(Sound[aaa].FileInfo.slice_buf,Sound[aaa].FileInfo.FileFormat.block_align,1,Sound[aaa].FileInfo.WavFile); //This isnt actually required, its just a test
roryhand 7:131ac4231c46 458 Sound[aaa].FileInfo.num_slices = Sound[aaa].FileInfo.FileData.subchunk2_size/Sound[aaa].FileInfo.FileFormat.block_align;
roryhand 13:8e93396a27c5 459 */
roryhand 8:c2faf06e7240 460
roryhand 13:8e93396a27c5 461 /*
roryhand 13:8e93396a27c5 462 Sound[aaa].FileInfo.slice_buf = ( char *)malloc(Sound[aaa].FileInfo.FileFormat.block_align);
roryhand 13:8e93396a27c5 463 fread(Sound[aaa].FileInfo.slice_buf,Sound[aaa].FileInfo.FileFormat.block_align,1,Sound[aaa].FileInfo.WavFile); //This isnt actually required, its just a test
roryhand 13:8e93396a27c5 464 Sound[aaa].FileInfo.num_slices = Sound[aaa].FileInfo.FileData.subchunk2_size/Sound[aaa].FileInfo.FileFormat.block_align;
roryhand 13:8e93396a27c5 465
roryhand 13:8e93396a27c5 466
roryhand 13:8e93396a27c5 467 }
roryhand 13:8e93396a27c5 468 */
roryhand 13:8e93396a27c5 469
roryhand 10:ce38f2e9e80e 470 int aaa = 0;
roryhand 10:ce38f2e9e80e 471 string folder = RootFolder + filename[0];
roryhand 10:ce38f2e9e80e 472 FOLDER = folder.c_str();
roryhand 12:e386150cefd3 473 WAV_FILE_STRUCT WavStruct0;
roryhand 12:e386150cefd3 474 WAV_FILE_STRUCT WavStruct1;
roryhand 12:e386150cefd3 475 WAV_FILE_STRUCT WavStruct2;
roryhand 12:e386150cefd3 476 WAV_FILE_STRUCT WavStruct3;
roryhand 12:e386150cefd3 477 WAV_FILE_STRUCT WavStruct4;
roryhand 12:e386150cefd3 478 WAV_FILE_STRUCT WavStruct5;
roryhand 12:e386150cefd3 479 WAV_FILE_STRUCT WavStruct6;
roryhand 12:e386150cefd3 480 WAV_FILE_STRUCT WavStruct7;
roryhand 12:e386150cefd3 481 WAV_FILE_STRUCT WavStruct8;
roryhand 12:e386150cefd3 482 WAV_FILE_STRUCT WavStruct9;
roryhand 12:e386150cefd3 483 WAV_FILE_STRUCT WavStruct10;
roryhand 12:e386150cefd3 484 WAV_FILE_STRUCT WavStruct11;
roryhand 12:e386150cefd3 485 WAV_FILE_STRUCT WavStruct12;
roryhand 12:e386150cefd3 486 WAV_FILE_STRUCT WavStruct13;
roryhand 12:e386150cefd3 487 WAV_FILE_STRUCT WavStruct14;
roryhand 12:e386150cefd3 488 WAV_FILE_STRUCT WavStruct15;
roryhand 12:e386150cefd3 489 WAV_FILE_STRUCT WavStruct16;
roryhand 12:e386150cefd3 490 WAV_FILE_STRUCT WavStruct17;
roryhand 12:e386150cefd3 491 WAV_FILE_STRUCT WavStruct18;
roryhand 12:e386150cefd3 492 WAV_FILE_STRUCT WavStruct19;
roryhand 12:e386150cefd3 493 WAV_FILE_STRUCT WavStruct20;
roryhand 12:e386150cefd3 494 WAV_FILE_STRUCT WavStruct21;
roryhand 12:e386150cefd3 495 WAV_FILE_STRUCT WavStruct22;
roryhand 12:e386150cefd3 496 //WavStruct0.WavFile = fopen(FOLDER,"rb");
roryhand 25:5336e1cf38d6 497
roryhand 25:5336e1cf38d6 498 /*
roryhand 25:5336e1cf38d6 499 FILE* mywav0 = fopen(FOLDER,"rb");
roryhand 25:5336e1cf38d6 500 printf("we opened This file %d\n\r",aaa);
roryhand 25:5336e1cf38d6 501 aaa = aaa+1;
roryhand 13:8e93396a27c5 502
roryhand 13:8e93396a27c5 503
roryhand 25:5336e1cf38d6 504 folder = RootFolder + filename[1];
roryhand 25:5336e1cf38d6 505 printf("filename[1]: %s\n\r", filename[1]);
roryhand 25:5336e1cf38d6 506 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 507 FILE* mywav1 = fopen("/sd/mydir/SoundDecoder_second/01.wav","rb");
roryhand 25:5336e1cf38d6 508 if(mywav1 == NULL){
roryhand 25:5336e1cf38d6 509 printf("CANNOT OPEN mywav 1\n\r");
roryhand 25:5336e1cf38d6 510 }
roryhand 25:5336e1cf38d6 511 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 512
roryhand 25:5336e1cf38d6 513 printf("Size of WavStruct1: %d\n\r",sizeof(WavStruct1));
roryhand 25:5336e1cf38d6 514 aaa = aaa+1;
roryhand 13:8e93396a27c5 515
roryhand 25:5336e1cf38d6 516 folder = RootFolder + filename[2];
roryhand 25:5336e1cf38d6 517 printf("filename[2]: %s\n\r", filename[2]);
roryhand 25:5336e1cf38d6 518 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 519 FILE* mywav2 = fopen("/sd/mydir/SoundDecoder_second/02.wav","rb");
roryhand 25:5336e1cf38d6 520 if(mywav2 == NULL){
roryhand 25:5336e1cf38d6 521 printf("CANNOT OPEN mywav 2\n\r");
roryhand 25:5336e1cf38d6 522 }
roryhand 13:8e93396a27c5 523
roryhand 25:5336e1cf38d6 524 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 525
roryhand 13:8e93396a27c5 526
roryhand 13:8e93396a27c5 527
roryhand 13:8e93396a27c5 528
roryhand 13:8e93396a27c5 529
roryhand 25:5336e1cf38d6 530 aaa = aaa+1;
roryhand 13:8e93396a27c5 531
roryhand 25:5336e1cf38d6 532 folder = RootFolder + filename[3];
roryhand 25:5336e1cf38d6 533 printf("filename[3]: %s\n\r", filename[3]);
roryhand 25:5336e1cf38d6 534 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 535 FILE* mywav3 = fopen("/sd/mydir/SoundDecoder_second/03.wav","rb");
roryhand 25:5336e1cf38d6 536 if(mywav3 == NULL){
roryhand 25:5336e1cf38d6 537 printf("CANNOT OPEN mywav 3\n\r");
roryhand 25:5336e1cf38d6 538 }
roryhand 13:8e93396a27c5 539
roryhand 25:5336e1cf38d6 540 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 541
roryhand 13:8e93396a27c5 542
roryhand 12:e386150cefd3 543
roryhand 12:e386150cefd3 544
roryhand 12:e386150cefd3 545
roryhand 25:5336e1cf38d6 546 aaa = aaa+1;
roryhand 13:8e93396a27c5 547
roryhand 25:5336e1cf38d6 548 string folder4 = RootFolder + filename[4];
roryhand 25:5336e1cf38d6 549 printf("filename[4]: %s\n\r", filename[4]);
roryhand 25:5336e1cf38d6 550 FOLDER = folder4.c_str();
roryhand 25:5336e1cf38d6 551 FILE * mywav4 = fopen("/sd/mydir/SoundDecoder_second/04.wav","rb");
roryhand 25:5336e1cf38d6 552 //FILE* mywav4 = fopen("sd/mydir/SoundDecoder_second/07.wav","rb");
roryhand 25:5336e1cf38d6 553 if(mywav4 == NULL){
roryhand 25:5336e1cf38d6 554 printf("Cannot Open mywav4\n\r");
roryhand 25:5336e1cf38d6 555 }
roryhand 13:8e93396a27c5 556
roryhand 25:5336e1cf38d6 557 printf("we opened This file %d\n\r",aaa);
roryhand 11:34136ff82179 558
roryhand 13:8e93396a27c5 559
roryhand 13:8e93396a27c5 560
roryhand 13:8e93396a27c5 561
roryhand 13:8e93396a27c5 562
roryhand 25:5336e1cf38d6 563 aaa = aaa+1;
roryhand 12:e386150cefd3 564
roryhand 25:5336e1cf38d6 565 folder = RootFolder + filename[5];
roryhand 25:5336e1cf38d6 566 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 567 printf("filename[5]: %s\n\r", filename[5]);
roryhand 25:5336e1cf38d6 568 FILE* mywav5 = fopen("/sd/mydir/SoundDecoder_second/05.wav","rb");
roryhand 13:8e93396a27c5 569
roryhand 25:5336e1cf38d6 570 printf("we opened This file %d\n\r",aaa);
roryhand 25:5336e1cf38d6 571 if(mywav5 == NULL){
roryhand 25:5336e1cf38d6 572 printf("Cannot Open mywav5\n\r");
roryhand 25:5336e1cf38d6 573 }
roryhand 12:e386150cefd3 574
roryhand 11:34136ff82179 575
roryhand 25:5336e1cf38d6 576 aaa = aaa+1;
roryhand 13:8e93396a27c5 577
roryhand 25:5336e1cf38d6 578 folder = RootFolder + filename[6];
roryhand 25:5336e1cf38d6 579 printf("filename[6]: %s\n\r", filename[6].c_str());
roryhand 25:5336e1cf38d6 580 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 581 FILE* mywav6 = fopen("/sd/mydir/SoundDecoder_second/06.wav","rb");
roryhand 25:5336e1cf38d6 582 if(mywav6 == NULL){
roryhand 25:5336e1cf38d6 583 printf("Cannot Open mywav6\n\r");
roryhand 25:5336e1cf38d6 584 }
roryhand 25:5336e1cf38d6 585 printf("we opened This file %d\n\r",aaa);
roryhand 12:e386150cefd3 586
roryhand 25:5336e1cf38d6 587 aaa = aaa+1;
roryhand 13:8e93396a27c5 588
roryhand 25:5336e1cf38d6 589 folder = RootFolder + filename[7];
roryhand 25:5336e1cf38d6 590 printf("filename[7]: %s\n\r", filename[7].c_str());
roryhand 25:5336e1cf38d6 591 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 592 FILE* mywav7 = fopen("/sd/mydir/SoundDecoder_second/07.wav","rb");
roryhand 25:5336e1cf38d6 593 if(mywav7 == NULL){
roryhand 25:5336e1cf38d6 594 printf("Cannot Open mywav7\n\r");
roryhand 25:5336e1cf38d6 595 }
roryhand 25:5336e1cf38d6 596 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 597
roryhand 13:8e93396a27c5 598
roryhand 13:8e93396a27c5 599
roryhand 13:8e93396a27c5 600
roryhand 25:5336e1cf38d6 601 aaa = aaa+1;
roryhand 13:8e93396a27c5 602
roryhand 25:5336e1cf38d6 603 folder = RootFolder + filename[8];
roryhand 25:5336e1cf38d6 604 printf("filename[8]: %s\n\r", filename[8].c_str());
roryhand 25:5336e1cf38d6 605 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 606 FILE* mywav8 = fopen("/sd/mydir/SoundDecoder_second/08.wav","rb");
roryhand 25:5336e1cf38d6 607 if(mywav8 == NULL){
roryhand 25:5336e1cf38d6 608 printf("Cannot Open mywav8\n\r");
roryhand 25:5336e1cf38d6 609 }
roryhand 25:5336e1cf38d6 610 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 611
roryhand 12:e386150cefd3 612
roryhand 11:34136ff82179 613
roryhand 25:5336e1cf38d6 614 aaa = aaa+1;
roryhand 13:8e93396a27c5 615
roryhand 25:5336e1cf38d6 616 folder = RootFolder + filename[9];
roryhand 25:5336e1cf38d6 617 printf("filename[9]: %s\n\r", filename[9].c_str());
roryhand 25:5336e1cf38d6 618 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 619 FILE* mywav9 = fopen("/sd/mydir/SoundDecoder_second/09.wav","rb");
roryhand 25:5336e1cf38d6 620 if(mywav9 == NULL){
roryhand 25:5336e1cf38d6 621 printf("Cannot Open mywav9\n\r");
roryhand 25:5336e1cf38d6 622 }
roryhand 25:5336e1cf38d6 623 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 624
roryhand 13:8e93396a27c5 625
roryhand 25:5336e1cf38d6 626 aaa = aaa+1;
roryhand 13:8e93396a27c5 627
roryhand 25:5336e1cf38d6 628 folder = RootFolder + filename[10];
roryhand 25:5336e1cf38d6 629 printf("filename[10]: %s\n\r", filename[10].c_str());
roryhand 25:5336e1cf38d6 630 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 631 FILE* mywav10 = fopen("/sd/mydir/SoundDecoder_second/10.wav","rb");
roryhand 25:5336e1cf38d6 632 if(mywav10 == NULL){
roryhand 25:5336e1cf38d6 633 printf("Cannot Open mywav10\n\r");
roryhand 25:5336e1cf38d6 634 }
roryhand 25:5336e1cf38d6 635 printf("we opened This file %d\n\r",aaa);
roryhand 11:34136ff82179 636
roryhand 13:8e93396a27c5 637
roryhand 11:34136ff82179 638
roryhand 25:5336e1cf38d6 639 aaa = aaa+1;
roryhand 13:8e93396a27c5 640
roryhand 25:5336e1cf38d6 641 folder = RootFolder + filename[11];
roryhand 25:5336e1cf38d6 642 printf("filename[11]: %s\n\r", filename[11].c_str());
roryhand 25:5336e1cf38d6 643 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 644 FILE* mywav11 = fopen("/sd/mydir/SoundDecoder_second/11.wav","rb");
roryhand 25:5336e1cf38d6 645 if(mywav11 == NULL){
roryhand 25:5336e1cf38d6 646 printf("Cannot Open mywav11\n\r");
roryhand 25:5336e1cf38d6 647 }
roryhand 25:5336e1cf38d6 648 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 649
roryhand 13:8e93396a27c5 650
roryhand 25:5336e1cf38d6 651 aaa = aaa+1;
roryhand 13:8e93396a27c5 652
roryhand 25:5336e1cf38d6 653 folder = RootFolder + filename[12];
roryhand 25:5336e1cf38d6 654 printf("filename[12]: %s\n\r", filename[12].c_str());
roryhand 25:5336e1cf38d6 655 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 656 FILE* mywav12 = fopen("/sd/mydir/SoundDecoder_second/12.wav","rb");
roryhand 25:5336e1cf38d6 657 if(mywav12 == NULL){
roryhand 25:5336e1cf38d6 658 printf("Cannot Open mywav12\n\r");
roryhand 25:5336e1cf38d6 659 }
roryhand 25:5336e1cf38d6 660 printf("we opened This file %d\n\r",aaa);
roryhand 11:34136ff82179 661
roryhand 13:8e93396a27c5 662
roryhand 13:8e93396a27c5 663
roryhand 25:5336e1cf38d6 664 aaa = aaa+1;
roryhand 13:8e93396a27c5 665
roryhand 25:5336e1cf38d6 666 folder = RootFolder + filename[13];
roryhand 25:5336e1cf38d6 667 printf("filename[13]: %s\n\r", filename[13].c_str());
roryhand 25:5336e1cf38d6 668 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 669 FILE* mywav13 = fopen("/sd/mydir/SoundDecoder_second/13.wav","rb");
roryhand 25:5336e1cf38d6 670 if(mywav13 == NULL){
roryhand 25:5336e1cf38d6 671 printf("Cannot Open mywav13\n\r");
roryhand 25:5336e1cf38d6 672 }
roryhand 25:5336e1cf38d6 673 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 674
roryhand 13:8e93396a27c5 675
roryhand 11:34136ff82179 676
roryhand 25:5336e1cf38d6 677 aaa = aaa+1;
roryhand 13:8e93396a27c5 678
roryhand 25:5336e1cf38d6 679 folder = RootFolder + filename[14];
roryhand 25:5336e1cf38d6 680 printf("filename[14]: %s\n\r", filename[14].c_str());
roryhand 25:5336e1cf38d6 681 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 682 FILE* mywav14 = fopen("/sd/mydir/SoundDecoder_second/14.wav","rb");
roryhand 25:5336e1cf38d6 683 if(mywav14 == NULL){
roryhand 25:5336e1cf38d6 684 printf("Cannot Open mywav14\n\r");
roryhand 25:5336e1cf38d6 685 }
roryhand 25:5336e1cf38d6 686 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 687
roryhand 13:8e93396a27c5 688
roryhand 13:8e93396a27c5 689
roryhand 25:5336e1cf38d6 690 aaa = aaa+1;
roryhand 13:8e93396a27c5 691
roryhand 25:5336e1cf38d6 692 /*
roryhand 25:5336e1cf38d6 693 folder = RootFolder + filename[15];
roryhand 25:5336e1cf38d6 694 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 695 FILE* mywav15 = fopen(FOLDER,"rb");
roryhand 25:5336e1cf38d6 696
roryhand 25:5336e1cf38d6 697 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 698
roryhand 13:8e93396a27c5 699
roryhand 13:8e93396a27c5 700
roryhand 25:5336e1cf38d6 701 aaa = aaa+1;
roryhand 13:8e93396a27c5 702
roryhand 25:5336e1cf38d6 703 folder = RootFolder + filename[16];
roryhand 25:5336e1cf38d6 704 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 705 FILE* mywav16 = fopen(FOLDER,"rb");
roryhand 13:8e93396a27c5 706
roryhand 25:5336e1cf38d6 707 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 708
roryhand 13:8e93396a27c5 709
roryhand 13:8e93396a27c5 710
roryhand 25:5336e1cf38d6 711 aaa = aaa+1;
roryhand 13:8e93396a27c5 712
roryhand 25:5336e1cf38d6 713 folder = RootFolder + filename[17];
roryhand 25:5336e1cf38d6 714 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 715 FILE* mywav17 = fopen(FOLDER,"rb");
roryhand 13:8e93396a27c5 716
roryhand 25:5336e1cf38d6 717 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 718
roryhand 13:8e93396a27c5 719
roryhand 13:8e93396a27c5 720
roryhand 25:5336e1cf38d6 721 aaa = aaa+1;
roryhand 13:8e93396a27c5 722
roryhand 25:5336e1cf38d6 723 folder = RootFolder + filename[18];
roryhand 25:5336e1cf38d6 724 FOLDER = folder.c_str();
roryhand 25:5336e1cf38d6 725 FILE* mywav18 = fopen(FOLDER,"rb");
roryhand 13:8e93396a27c5 726
roryhand 25:5336e1cf38d6 727 printf("we opened This file %d\n\r",aaa);
roryhand 13:8e93396a27c5 728
roryhand 13:8e93396a27c5 729
roryhand 13:8e93396a27c5 730
roryhand 25:5336e1cf38d6 731 printf("We performed all ReadFileInfo Operations!\n\r");
roryhand 25:5336e1cf38d6 732 aaa = aaa+1;
roryhand 25:5336e1cf38d6 733 */
roryhand 1:aac37edee302 734
roryhand 1:aac37edee302 735 printf("DO WE GET PAST THE ALLOCATION POINT\n\r");
roryhand 1:aac37edee302 736
roryhand 1:aac37edee302 737
roryhand 1:aac37edee302 738
roryhand 1:aac37edee302 739
roryhand 1:aac37edee302 740
roryhand 25:5336e1cf38d6 741 /*
roryhand 25:5336e1cf38d6 742 StartupWav = fopen("/sd/mydir/645Engine/Startup.wav","rb");
roryhand 25:5336e1cf38d6 743 IdleWav = fopen("/sd/mydir/645Engine/N2_11k_minus10dB.wav","rb");
roryhand 25:5336e1cf38d6 744 IdleN2Wav = fopen("/sd/mydir/645Engine/N2N3_11k_minus10dB.wav","rb");
roryhand 25:5336e1cf38d6 745 HornWav = fopen("/sd/mydir/645Engine/K3H_1_A_short_quiet.wav","rb");
roryhand 25:5336e1cf38d6 746 N2Wav = fopen("/sd/mydir/645Engine/N3_11k_minus11dB.wav","rb");
roryhand 25:5336e1cf38d6 747 BellWav = fopen("/sd/mydir/645Engine/EMD_BRONZE_BELL_1_11k_minus10dB.wav","rb");
roryhand 25:5336e1cf38d6 748 FlangeWav = fopen("/sd/mydir/645Engine/EX_FlangeJoint1_11k_minus12dB.wav","rb");
roryhand 13:8e93396a27c5 749
roryhand 13:8e93396a27c5 750
roryhand 13:8e93396a27c5 751
roryhand 1:aac37edee302 752
roryhand 25:5336e1cf38d6 753 WavInfo_Startup = ReadFileInfo(WavInfo_Startup, StartupWav);
roryhand 25:5336e1cf38d6 754 printf("WavInfo_Startup Size: %d\n\r",sizeof(WavInfo_Startup));
roryhand 25:5336e1cf38d6 755 WavInfo_Idle = ReadFileInfo(WavInfo_Idle, IdleWav);
roryhand 25:5336e1cf38d6 756 WavInfo_Horn = ReadFileInfo(WavInfo_Horn, HornWav);
roryhand 25:5336e1cf38d6 757 WavInfo_IdleN2 = ReadFileInfo(WavInfo_IdleN2, IdleN2Wav);
roryhand 25:5336e1cf38d6 758 WavInfo_N2 = ReadFileInfo(WavInfo_N2, N2Wav);
roryhand 25:5336e1cf38d6 759 WavInfo_Bell = ReadFileInfo(WavInfo_Bell, BellWav);
roryhand 25:5336e1cf38d6 760 WavInfo_Flange = ReadFileInfo(WavInfo_Flange, FlangeWav);
roryhand 25:5336e1cf38d6 761 */
roryhand 25:5336e1cf38d6 762 /*
roryhand 25:5336e1cf38d6 763 WavStruct0 = ReadFileInfo(WavStruct0,mywav0);
roryhand 25:5336e1cf38d6 764 WavStruct1 = ReadFileInfo(WavStruct1,mywav1);
roryhand 25:5336e1cf38d6 765 WavStruct2 = ReadFileInfo(WavStruct2,mywav2);
roryhand 25:5336e1cf38d6 766 */
roryhand 22:706e86dc0d45 767 //WavStruct3 = ReadFileInfo(WavStruct3,mywav3);
roryhand 22:706e86dc0d45 768 /*WavStruct4 = ReadFileInfo(WavStruct4,mywav4);
roryhand 21:1aacd67d19c1 769 WavStruct5 = ReadFileInfo(WavStruct5,mywav5);
roryhand 21:1aacd67d19c1 770 WavStruct6 = ReadFileInfo(WavStruct6,mywav6);
roryhand 21:1aacd67d19c1 771 WavStruct7 = ReadFileInfo(WavStruct7,mywav7);
roryhand 21:1aacd67d19c1 772 WavStruct8 = ReadFileInfo(WavStruct8,mywav8);
roryhand 21:1aacd67d19c1 773 WavStruct9 = ReadFileInfo(WavStruct9,mywav9);
roryhand 21:1aacd67d19c1 774 WavStruct10 = ReadFileInfo(WavStruct10,mywav10);
roryhand 21:1aacd67d19c1 775 WavStruct11 = ReadFileInfo(WavStruct11,mywav11);
roryhand 21:1aacd67d19c1 776 WavStruct12 = ReadFileInfo(WavStruct12,mywav12);
roryhand 21:1aacd67d19c1 777 WavStruct13 = ReadFileInfo(WavStruct13,mywav13);
roryhand 21:1aacd67d19c1 778 WavStruct14 = ReadFileInfo(WavStruct14,mywav14);
roryhand 21:1aacd67d19c1 779 WavStruct15 = ReadFileInfo(WavStruct15,mywav15);
roryhand 21:1aacd67d19c1 780 WavStruct16 = ReadFileInfo(WavStruct16,mywav16);
roryhand 21:1aacd67d19c1 781 WavStruct17 = ReadFileInfo(WavStruct17,mywav17);
roryhand 21:1aacd67d19c1 782 WavStruct18 = ReadFileInfo(WavStruct18,mywav18);*/
roryhand 25:5336e1cf38d6 783
roryhand 25:5336e1cf38d6 784
roryhand 13:8e93396a27c5 785 printf("About to Start ReadFileInfo Operations\n\r");
roryhand 27:a378f1f937ee 786
roryhand 27:a378f1f937ee 787
roryhand 27:a378f1f937ee 788 /*
roryhand 27:a378f1f937ee 789 FILE* mywav1 = fopen("/sd/mydir/SoundDecoder_second/01.wav","r");
roryhand 26:82a31e2bafd0 790 if(mywav1 == NULL){
roryhand 26:82a31e2bafd0 791 printf("Cannot Open mywav1\n\r");
roryhand 26:82a31e2bafd0 792 }
roryhand 27:a378f1f937ee 793 FILE* mywav2 = fopen("/sd/mydir/SoundDecoder_second/02.wav","r");
roryhand 26:82a31e2bafd0 794 if(mywav2 == NULL){
roryhand 26:82a31e2bafd0 795 printf("Cannot Open mywav2\n\r");
roryhand 26:82a31e2bafd0 796 }
roryhand 27:a378f1f937ee 797 FILE* mywav3 = fopen("/sd/mydir/SoundDecoder_second/03.wav","r");
roryhand 26:82a31e2bafd0 798 if(mywav3 == NULL){
roryhand 26:82a31e2bafd0 799 printf("Cannot Open mywav3\n\r");
roryhand 26:82a31e2bafd0 800 }
roryhand 27:a378f1f937ee 801 FILE* mywav4 = fopen("/sd/mydir/SoundDecoder_second/04.wav","r");
roryhand 26:82a31e2bafd0 802 if(mywav4 == NULL){
roryhand 26:82a31e2bafd0 803 printf("Cannot Open mywav4\n\r");
roryhand 26:82a31e2bafd0 804 }
roryhand 27:a378f1f937ee 805
roryhand 27:a378f1f937ee 806 FILE* mywav5 = fopen("/sd/mydir/SoundDecoder_second/01.wav","r");
roryhand 26:82a31e2bafd0 807 if(mywav5 == NULL){
roryhand 26:82a31e2bafd0 808 printf("Cannot Open mywav5\n\r");
roryhand 26:82a31e2bafd0 809 }
roryhand 27:a378f1f937ee 810
roryhand 27:a378f1f937ee 811 FILE* mywav6 = fopen("/sd/mydir/SoundDecoder_second/01.wav","r");
roryhand 26:82a31e2bafd0 812 if(mywav6 == NULL){
roryhand 26:82a31e2bafd0 813 printf("Cannot Open mywav6\n\r");
roryhand 26:82a31e2bafd0 814 }
roryhand 27:a378f1f937ee 815 FILE* mywav7 = fopen("/sd/mydir/SoundDecoder_second/01.wav","r");
roryhand 26:82a31e2bafd0 816 if(mywav7 == NULL){
roryhand 26:82a31e2bafd0 817 printf("Cannot Open mywav7\n\r");
roryhand 26:82a31e2bafd0 818 }
roryhand 27:a378f1f937ee 819 FILE* mywav8 = fopen("/sd/mydir/SoundDecoder_second/01.wav","r");
roryhand 26:82a31e2bafd0 820 if(mywav8 == NULL){
roryhand 26:82a31e2bafd0 821 printf("Cannot Open mywav8\n\r");
roryhand 26:82a31e2bafd0 822 }
roryhand 27:a378f1f937ee 823 FILE* mywav9 = fopen("/sd/mydir/SoundDecoder_second/01.wav","r");
roryhand 26:82a31e2bafd0 824 if(mywav9 == NULL){
roryhand 26:82a31e2bafd0 825 printf("Cannot Open mywav9\n\r");
roryhand 26:82a31e2bafd0 826 }
roryhand 27:a378f1f937ee 827 FILE* mywav10 = fopen("/sd/mydir/SoundDecoder_second/01.wav","r");
roryhand 26:82a31e2bafd0 828 if(mywav10 == NULL){
roryhand 26:82a31e2bafd0 829 printf("Cannot Open mywav10\n\r");
roryhand 26:82a31e2bafd0 830 }
roryhand 27:a378f1f937ee 831 /*
roryhand 26:82a31e2bafd0 832 FILE* mywav11= fopen("/sd/mydir/SoundDecoder_second/01.wav","rb");
roryhand 26:82a31e2bafd0 833 if(mywav11 == NULL){
roryhand 26:82a31e2bafd0 834 printf("Cannot Open mywav11\n\r");
roryhand 26:82a31e2bafd0 835 }
roryhand 27:a378f1f937ee 836 FILE* mywav12 = fopen("/sd/mydir/SoundDecoder_second/01.wav","r");
roryhand 26:82a31e2bafd0 837 if(mywav12 == NULL){
roryhand 26:82a31e2bafd0 838 printf("Cannot Open mywav12\n\r");
roryhand 26:82a31e2bafd0 839 }
roryhand 27:a378f1f937ee 840 FILE* mywav13 = fopen("/sd/mydir/SoundDecoder_second/01.wav","r");
roryhand 26:82a31e2bafd0 841 if(mywav13 == NULL){
roryhand 26:82a31e2bafd0 842 printf("Cannot Open mywav13\n\r");
roryhand 26:82a31e2bafd0 843 }
roryhand 27:a378f1f937ee 844 FILE* mywav14 = fopen("/sd/mydir/SoundDecoder_second/01.wav","r");
roryhand 26:82a31e2bafd0 845 if(mywav14 == NULL){
roryhand 26:82a31e2bafd0 846 printf("Cannot Open mywav14\n\r");
roryhand 26:82a31e2bafd0 847 }
roryhand 26:82a31e2bafd0 848 */
roryhand 13:8e93396a27c5 849
roryhand 27:a378f1f937ee 850
roryhand 27:a378f1f937ee 851
roryhand 27:a378f1f937ee 852 /*
roryhand 27:a378f1f937ee 853 StartupWav = fopen("/sd/mydir/645Engine/Startup.wav","r");
roryhand 26:82a31e2bafd0 854 if(StartupWav == NULL){
roryhand 26:82a31e2bafd0 855 printf("Cannot Open StartupWav\n\r");
roryhand 26:82a31e2bafd0 856 }
roryhand 27:a378f1f937ee 857 IdleWav = fopen("/sd/mydir/645Engine/N2_11k_minus10dB.wav","r");
roryhand 26:82a31e2bafd0 858 if(IdleWav == NULL){
roryhand 26:82a31e2bafd0 859 printf("Cannot Open IdleWav\n\r");
roryhand 26:82a31e2bafd0 860 }
roryhand 27:a378f1f937ee 861 IdleN2Wav = fopen("/sd/mydir/645Engine/N2N3_11k_minus10dB.wav","r");
roryhand 26:82a31e2bafd0 862 if(IdleN2Wav == NULL){
roryhand 26:82a31e2bafd0 863 printf("Cannot Open IdleN2Wav\n\r");
roryhand 26:82a31e2bafd0 864 }
roryhand 27:a378f1f937ee 865 HornWav = fopen("/sd/mydir/645Engine/K3H_1_A_short_quiet.wav","r");
roryhand 26:82a31e2bafd0 866 if(HornWav == NULL){
roryhand 26:82a31e2bafd0 867 printf("Cannot Open HornWav\n\r");
roryhand 26:82a31e2bafd0 868 }
roryhand 27:a378f1f937ee 869 N2Wav = fopen("/sd/mydir/645Engine/N3_11k_minus11dB.wav","r");
roryhand 26:82a31e2bafd0 870 if(N2Wav == NULL){
roryhand 26:82a31e2bafd0 871 printf("Cannot Open N2Wav\n\r");
roryhand 26:82a31e2bafd0 872 }
roryhand 27:a378f1f937ee 873 BellWav = fopen("/sd/mydir/645Engine/EMD_BRONZE_BELL_1_11k_minus10dB.wav","r");
roryhand 26:82a31e2bafd0 874 if(BellWav == NULL){
roryhand 26:82a31e2bafd0 875 printf("Cannot Open BellWav\n\r");
roryhand 26:82a31e2bafd0 876 }
roryhand 27:a378f1f937ee 877
roryhand 27:a378f1f937ee 878 */
roryhand 27:a378f1f937ee 879
roryhand 27:a378f1f937ee 880
roryhand 20:9cc7d825c07b 881 //FlangeWav = fopen("/sd/mydir/645Engine/EX_FlangeJoint1_11k_minus12dB.wav","rb");
roryhand 25:5336e1cf38d6 882
roryhand 27:a378f1f937ee 883 HeyWav = fopen("/sd/mydir/645Engine/EX_FlangeJoint1_11k_minus12dB.wav","r");
roryhand 26:82a31e2bafd0 884 if(HeyWav == NULL){
roryhand 27:a378f1f937ee 885 printf("Cannot Open HeyWav\n\r");
roryhand 26:82a31e2bafd0 886 }
roryhand 16:5e3420d0509b 887 //HeyWav = fopen("/sd/mydir/edsheeran.wav","rb");
roryhand 13:8e93396a27c5 888
roryhand 13:8e93396a27c5 889
roryhand 27:a378f1f937ee 890 /*
roryhand 13:8e93396a27c5 891 WavInfo_Startup = ReadFileInfo(WavInfo_Startup, StartupWav);
roryhand 17:832eb9a75c05 892 //printf("WavInfo_Startup Size: %d\n\r",sizeof(WavInfo_Startup));
roryhand 13:8e93396a27c5 893 WavInfo_Idle = ReadFileInfo(WavInfo_Idle, IdleWav);
roryhand 13:8e93396a27c5 894 WavInfo_Horn = ReadFileInfo(WavInfo_Horn, HornWav);
roryhand 13:8e93396a27c5 895 WavInfo_IdleN2 = ReadFileInfo(WavInfo_IdleN2, IdleN2Wav);
roryhand 13:8e93396a27c5 896 WavInfo_N2 = ReadFileInfo(WavInfo_N2, N2Wav);
roryhand 13:8e93396a27c5 897 WavInfo_Bell = ReadFileInfo(WavInfo_Bell, BellWav);
roryhand 27:a378f1f937ee 898 */
roryhand 27:a378f1f937ee 899
roryhand 27:a378f1f937ee 900
roryhand 22:706e86dc0d45 901 printf("About to Read HeyWav\n\r");
roryhand 25:5336e1cf38d6 902 //printf("SizeOf mywav4: %d\n\r",sizeof(mywav4));
roryhand 25:5336e1cf38d6 903 //fseek(mywav4,1,SEEK_SET);
roryhand 27:a378f1f937ee 904 //WavInfo_Flange = ReadFileInfo(WavInfo_Flange, HeyWav);
roryhand 20:9cc7d825c07b 905 //WavInfo_Hey = ReadFileInfo(WavInfo_Hey,HeyWav);
roryhand 16:5e3420d0509b 906 //WAV_FILE_STRUCT WavInfo_Frustration;
roryhand 16:5e3420d0509b 907 //FILE* FrustrationWav = fopen("/sd/mydir/645Engine/EX_FlangeJoint1_11k_minus12dB.wav","rb");
roryhand 17:832eb9a75c05 908 //WAV_FILE_STRUCT WavInfo_Hey;
roryhand 27:a378f1f937ee 909
roryhand 27:a378f1f937ee 910
roryhand 25:5336e1cf38d6 911 WavInfo_Hey = ReadFileInfo(WavInfo_Hey,HeyWav);
roryhand 16:5e3420d0509b 912 //FlangeWav - this one works.
roryhand 16:5e3420d0509b 913 //HeyWav - this one doesn't. Despite the fact they reference teh exact same file.
roryhand 16:5e3420d0509b 914 //WavInfo_Bell = ReadFileInfo(WavInfo_Bell,HeyWav);
roryhand 16:5e3420d0509b 915 //WavInfo_Frustration = ReadFileInfo(WavInfo_Frustration,FlangeWav);
roryhand 17:832eb9a75c05 916 //printf("Frustration\n\r");
roryhand 13:8e93396a27c5 917
roryhand 13:8e93396a27c5 918
roryhand 4:55fbbb049bae 919
roryhand 25:5336e1cf38d6 920 printf("Do we even get to this stupid bloody point\n\r");
roryhand 0:e89d7a0bfa3b 921 //Populate our class instances with some data (is there an implicit way to do this?)
roryhand 0:e89d7a0bfa3b 922 N2FadeIn.LengthSecs = 4;
roryhand 0:e89d7a0bfa3b 923 IdleFadeOut.LengthSecs = 2;
roryhand 0:e89d7a0bfa3b 924 N2FadeIn = FadeDataInitialise(N2FadeIn);
roryhand 0:e89d7a0bfa3b 925 IdleFadeOut = FadeDataInitialise(IdleFadeOut);
roryhand 1:aac37edee302 926
roryhand 3:6169aeeaeeb4 927 printf("hello\n\r");
roryhand 0:e89d7a0bfa3b 928 //Set up the wolfson Audio Codec board
roryhand 0:e89d7a0bfa3b 929 wm8731_Config_setup();
roryhand 0:e89d7a0bfa3b 930 //i2s audio data transfer code??
roryhand 0:e89d7a0bfa3b 931 i2s.stereomono(I2S_STEREO);
roryhand 0:e89d7a0bfa3b 932 i2s.masterslave(I2S_MASTER);
roryhand 0:e89d7a0bfa3b 933 led3 = 1;
roryhand 0:e89d7a0bfa3b 934 led2 = 1;
roryhand 13:8e93396a27c5 935
roryhand 0:e89d7a0bfa3b 936 sampletick.attach(&isr,1.0/sampling_freq); //1/16000
roryhand 0:e89d7a0bfa3b 937 //TickFadeOut.attach(&FadeOutIsr,10.0);
roryhand 27:a378f1f937ee 938
roryhand 27:a378f1f937ee 939
roryhand 27:a378f1f937ee 940 /*
roryhand 3:6169aeeaeeb4 941 printf("SamplingFreq: %d\n\r",sampling_freq);
roryhand 0:e89d7a0bfa3b 942 i2s.start();
roryhand 3:6169aeeaeeb4 943 printf("Hello i2s has starrted!!");
roryhand 0:e89d7a0bfa3b 944 Horn.rise(&FadeOutIsr);
roryhand 0:e89d7a0bfa3b 945 slice = 0;
roryhand 0:e89d7a0bfa3b 946 fseek(IdleN2Wav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 947 //Play_WaveFile(IdleN2Wav,WavInfo_IdleN2);
roryhand 0:e89d7a0bfa3b 948 //Play_WaveFile(N2Wav,WavInfo_N2);
roryhand 0:e89d7a0bfa3b 949 t.reset();
roryhand 0:e89d7a0bfa3b 950 t.start();
roryhand 0:e89d7a0bfa3b 951 N2FadeIn.FadeCoeff = N2FadeIn.FadeOut();
roryhand 0:e89d7a0bfa3b 952 t.stop();
roryhand 0:e89d7a0bfa3b 953 printf("Time to Calcualte Fade Coeff: %d\n\r",t.read_us());
roryhand 0:e89d7a0bfa3b 954 t.reset();
roryhand 1:aac37edee302 955
roryhand 0:e89d7a0bfa3b 956 fseek(IdleN2Wav,44,SEEK_SET);
roryhand 0:e89d7a0bfa3b 957 t.start();
roryhand 1:aac37edee302 958 fread(WavInfo_IdleN2.slice_buf,WavInfo_IdleN2.FileFormat.block_align,1,IdleN2Wav);
roryhand 0:e89d7a0bfa3b 959 data_sptr_IdleN2 = (short *)WavInfo_IdleN2.slice_buf;
roryhand 0:e89d7a0bfa3b 960 t.stop();
roryhand 0:e89d7a0bfa3b 961 printf("Time to Read in a slice: %dus\n\r",t.read_us());
roryhand 0:e89d7a0bfa3b 962 t.reset();
roryhand 1:aac37edee302 963
roryhand 0:e89d7a0bfa3b 964 printf("point to start sound: %d\n\r",((WavInfo_IdleN2.FileData.subchunk2_size) - N2FadeIn.Length));
roryhand 0:e89d7a0bfa3b 965 printf("Size of Data: %d\n\r",WavInfo_IdleN2.FileData.subchunk2_size);
roryhand 27:a378f1f937ee 966 */
roryhand 1:aac37edee302 967
roryhand 20:9cc7d825c07b 968 fseek(HeyWav,44,SEEK_SET);
roryhand 13:8e93396a27c5 969
roryhand 20:9cc7d825c07b 970 printf("about to play wav file\n\r");
roryhand 20:9cc7d825c07b 971 Play_WaveFile(HeyWav,WavInfo_Hey);
roryhand 20:9cc7d825c07b 972 printf("finished playing Wav file\n\r");
roryhand 9:dd9cae06b202 973 /************************************PLAY WAV FILE LOOP*******************/
roryhand 20:9cc7d825c07b 974 //Play_WaveFileLoop(Sound, NotchingSet);
roryhand 9:dd9cae06b202 975 /************************************END OF PLAY WAV FILE LOOP*************/
roryhand 13:8e93396a27c5 976
roryhand 13:8e93396a27c5 977
roryhand 13:8e93396a27c5 978
roryhand 9:dd9cae06b202 979
roryhand 3:6169aeeaeeb4 980
roryhand 0:e89d7a0bfa3b 981 fseek(IdleN2Wav,44,SEEK_SET);//reset for use in the Loop code
roryhand 0:e89d7a0bfa3b 982 slice = 0;
roryhand 0:e89d7a0bfa3b 983 fseek(IdleWav,44,SEEK_SET);
roryhand 3:6169aeeaeeb4 984 NotchingSet.Notch = 1;
roryhand 1:aac37edee302 985 //Play_WaveFileLoop(IdleWav, WavInfo_Idle);
roryhand 1:aac37edee302 986
roryhand 1:aac37edee302 987 i2s.stop();
roryhand 0:e89d7a0bfa3b 988
roryhand 0:e89d7a0bfa3b 989 }
roryhand 0:e89d7a0bfa3b 990
roryhand 0:e89d7a0bfa3b 991
roryhand 3:6169aeeaeeb4 992
roryhand 3:6169aeeaeeb4 993
roryhand 3:6169aeeaeeb4 994
roryhand 3:6169aeeaeeb4 995
roryhand 0:e89d7a0bfa3b 996 WAV_FILE_STRUCT ReadFileInfo(WAV_FILE_STRUCT FileInfo, FILE * wav_file)
roryhand 0:e89d7a0bfa3b 997 {
roryhand 0:e89d7a0bfa3b 998 fseek(wav_file,20,SEEK_SET);
roryhand 22:706e86dc0d45 999 printf("We have just seeked through this file\n\r");
roryhand 0:e89d7a0bfa3b 1000 fread(&FileInfo.FileFormat,sizeof(FileInfo.FileFormat),1,wav_file);
roryhand 1:aac37edee302 1001 //printf("wav_format.sample_rate: %d\n\r",FileInfo.FileFormat.sample_rate);
roryhand 1:aac37edee302 1002
roryhand 0:e89d7a0bfa3b 1003 fread(&FileInfo.FileData,sizeof(FileInfo.FileData),1,wav_file);
roryhand 1:aac37edee302 1004 //printf("wav_data.subchunk2_size: %d\n\r",FileInfo.FileData.subchunk2_size);
roryhand 0:e89d7a0bfa3b 1005 FileInfo.slice_buf = ( char *)malloc(FileInfo.FileFormat.block_align);
roryhand 0:e89d7a0bfa3b 1006 fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,wav_file); //This isnt actually required, its just a test
roryhand 1:aac37edee302 1007 FileInfo.num_slices = FileInfo.FileData.subchunk2_size/FileInfo.FileFormat.block_align;
roryhand 1:aac37edee302 1008 //printf("Number of Slices: %d\n\r",FileInfo.num_slices);
roryhand 1:aac37edee302 1009 return FileInfo;
roryhand 0:e89d7a0bfa3b 1010 }
roryhand 1:aac37edee302 1011
roryhand 1:aac37edee302 1012 classSoundFile LoadFileStream(classSoundFile Sound, string filename)
roryhand 1:aac37edee302 1013 {
roryhand 1:aac37edee302 1014 //Declare RootFolder and the directory for the appropriate file.
roryhand 1:aac37edee302 1015 //How we index into filename[] from the outside of this class is another
roryhand 1:aac37edee302 1016 //issue...
roryhand 1:aac37edee302 1017 //printf("FileName: %s\n\r",filename);
roryhand 1:aac37edee302 1018 //string RootFolder = "/sd/mydir/SoundDecoder/";
roryhand 1:aac37edee302 1019 //string Directory = RootFolder + "01.wav";// + filename[0];
roryhand 1:aac37edee302 1020 //printf("%s\n\r",Directory);
roryhand 1:aac37edee302 1021 //const char* DirectoryChar = Directory.c_str();
roryhand 1:aac37edee302 1022 //Sound.FileInfo.WavFile = fopen(DirectoryChar,"rb");
roryhand 1:aac37edee302 1023 Sound.FileInfo.WavFile = fopen("/sd/mydir/645Engine/Startup.wav","rb");
roryhand 1:aac37edee302 1024 fseek(Sound.FileInfo.WavFile,20,SEEK_SET);
roryhand 1:aac37edee302 1025 fread(&Sound.FileInfo.FileFormat,sizeof(Sound.FileInfo.FileFormat),1,Sound.FileInfo.WavFile);
roryhand 1:aac37edee302 1026 printf("wav_format.sample_rate: %d\n\r",Sound.FileInfo.FileFormat.sample_rate);
roryhand 1:aac37edee302 1027 fread(&Sound.FileInfo.FileData,sizeof(Sound.FileInfo.FileData),1,Sound.FileInfo.WavFile);
roryhand 1:aac37edee302 1028 printf("wav_data.subchunk2_size: %d\n\r",Sound.FileInfo.FileData.subchunk2_size);
roryhand 1:aac37edee302 1029 Sound.FileInfo.slice_buf = ( char *)malloc(Sound.FileInfo.FileFormat.block_align);
roryhand 1:aac37edee302 1030 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 1031 Sound.FileInfo.num_slices = Sound.FileInfo.FileData.subchunk2_size/Sound.FileInfo.FileFormat.block_align;
roryhand 1:aac37edee302 1032 printf("Number of Slices: %d\n\r",Sound.FileInfo.num_slices);
roryhand 1:aac37edee302 1033 return Sound;
roryhand 1:aac37edee302 1034 }
roryhand 1:aac37edee302 1035
roryhand 1:aac37edee302 1036
roryhand 0:e89d7a0bfa3b 1037 classFade FadeDataInitialise(classFade FadeData)
roryhand 0:e89d7a0bfa3b 1038 {
roryhand 1:aac37edee302 1039 FadeData.DecayFactor = 1.3;
roryhand 0:e89d7a0bfa3b 1040 FadeData.FadeIteration = 1;
roryhand 0:e89d7a0bfa3b 1041 //FadeData.Denom = 11025*FadeData.DecayFactor;
roryhand 0:e89d7a0bfa3b 1042 FadeData.Denom = 11025*FadeData.DecayFactor;
roryhand 0:e89d7a0bfa3b 1043 FadeData.Natural_Exp = 2.7183;
roryhand 0:e89d7a0bfa3b 1044 FadeData.Length = 11025*FadeData.LengthSecs;
roryhand 0:e89d7a0bfa3b 1045 //FadeData.Natural_Exp = 2.7;
roryhand 0:e89d7a0bfa3b 1046 return FadeData;
roryhand 0:e89d7a0bfa3b 1047 }
roryhand 0:e89d7a0bfa3b 1048
roryhand 0:e89d7a0bfa3b 1049 //Playing Files Code
roryhand 0:e89d7a0bfa3b 1050 /*float FadeIn(void)
roryhand 0:e89d7a0bfa3b 1051 {
roryhand 0:e89d7a0bfa3b 1052 powervalFadeIn = FadeIterationIn/denom;
roryhand 0:e89d7a0bfa3b 1053 FadeCoeffFadeIn
roryhand 1:aac37edee302 1054
roryhand 1:aac37edee302 1055
roryhand 0:e89d7a0bfa3b 1056 }*/
roryhand 0:e89d7a0bfa3b 1057 /*float FadeOut(void)
roryhand 0:e89d7a0bfa3b 1058 {
roryhand 0:e89d7a0bfa3b 1059 powerval = -FadeIteration/denom;
roryhand 0:e89d7a0bfa3b 1060 FadeCoeff = pow(natural_exp,powerval);
roryhand 1:aac37edee302 1061 FadeIteration = FadeIteration + 1;
roryhand 1:aac37edee302 1062 return FadeCoeff;
roryhand 1:aac37edee302 1063
roryhand 0:e89d7a0bfa3b 1064 }*/
roryhand 0:e89d7a0bfa3b 1065
roryhand 0:e89d7a0bfa3b 1066
roryhand 0:e89d7a0bfa3b 1067 void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo)
roryhand 0:e89d7a0bfa3b 1068 {
roryhand 1:aac37edee302 1069 while(slice<FileInfo.num_slices) {
roryhand 1:aac37edee302 1070 fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav);
roryhand 1:aac37edee302 1071 data_sptr=(short *)FileInfo.slice_buf; // 16 bit samples
roryhand 1:aac37edee302 1072 for (channel=0; channel<FileInfo.FileFormat.num_channels; channel++) {
roryhand 1:aac37edee302 1073 if(flag1 == 1) {
roryhand 1:aac37edee302 1074 Buffer1[place_hold1] = data_sptr[channel];
roryhand 1:aac37edee302 1075 place_hold1 = place_hold1 + 1;
roryhand 1:aac37edee302 1076 if(place_hold1 >= BufferLen) {
roryhand 1:aac37edee302 1077 while(1) {
roryhand 1:aac37edee302 1078 if(flag1 == 0) {
roryhand 0:e89d7a0bfa3b 1079
roryhand 1:aac37edee302 1080 break;
roryhand 0:e89d7a0bfa3b 1081 }
roryhand 1:aac37edee302 1082
roryhand 0:e89d7a0bfa3b 1083 }
roryhand 1:aac37edee302 1084 }
roryhand 1:aac37edee302 1085
roryhand 1:aac37edee302 1086 } else if(flag2 == 1) {
roryhand 1:aac37edee302 1087 Buffer2[place_hold2] = data_sptr[channel];
roryhand 1:aac37edee302 1088 place_hold2 = place_hold2 + 1;
roryhand 1:aac37edee302 1089 if(place_hold2 >= BufferLen) {
roryhand 1:aac37edee302 1090
roryhand 1:aac37edee302 1091 while(1) {
roryhand 1:aac37edee302 1092 if(flag2 == 0) {
roryhand 1:aac37edee302 1093
roryhand 1:aac37edee302 1094 break;
roryhand 1:aac37edee302 1095 }
roryhand 0:e89d7a0bfa3b 1096 }
roryhand 1:aac37edee302 1097 }
roryhand 0:e89d7a0bfa3b 1098 }
roryhand 1:aac37edee302 1099
roryhand 1:aac37edee302 1100 }
roryhand 1:aac37edee302 1101 slice = slice + 1;
roryhand 0:e89d7a0bfa3b 1102 }
roryhand 0:e89d7a0bfa3b 1103 }
roryhand 0:e89d7a0bfa3b 1104
roryhand 0:e89d7a0bfa3b 1105
roryhand 0:e89d7a0bfa3b 1106
roryhand 0:e89d7a0bfa3b 1107
roryhand 0:e89d7a0bfa3b 1108
roryhand 0:e89d7a0bfa3b 1109
roryhand 2:957d3b2afff4 1110 //void Play_WaveFileLoop(FILE * my_wav, WAV_FILE_STRUCT FileInfo)//(classSoundFile Sounds)
roryhand 9:dd9cae06b202 1111
roryhand 9:dd9cae06b202 1112 void Play_WaveFileLoop(classSoundFile Sounds[], Notch_STRUCT NotchingSet)
roryhand 0:e89d7a0bfa3b 1113 {
roryhand 1:aac37edee302 1114 while(1) { //might have to change this to a while(1) loop?
roryhand 1:aac37edee302 1115 //New format!! This should be (roughly) the way that this is done, with the new structures and classes
roryhand 1:aac37edee302 1116 ////fread(Sound[Notch].FileData.slice_buf,Sound[Notch].FileFormat.block_align,1,Sound[notch].WavFile);
roryhand 1:aac37edee302 1117 //data_sptr=(short *)Sound[Notch].FileInfo.slice_buf;
roryhand 1:aac37edee302 1118
roryhand 0:e89d7a0bfa3b 1119
roryhand 2:957d3b2afff4 1120 if( slice == (Sounds[NotchingSet.Notch].FileInfo.num_slices-1) ) {
roryhand 1:aac37edee302 1121 slice = 0;
roryhand 2:957d3b2afff4 1122 fseek(Sounds[NotchingSet.Notch].FileInfo.WavFile,44,SEEK_SET);
roryhand 1:aac37edee302 1123 }
roryhand 1:aac37edee302 1124
roryhand 2:957d3b2afff4 1125 //fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav);
roryhand 2:957d3b2afff4 1126 data_sptr=(short *)Sounds[NotchingSet.Notch].FileInfo.slice_buf; // 16 bit samples
roryhand 2:957d3b2afff4 1127 //make sure we are reading in the correct "notch" here
roryhand 2:957d3b2afff4 1128
roryhand 2:957d3b2afff4 1129 if(FadeFlag) {
roryhand 2:957d3b2afff4 1130 if(feof(Sounds[NotchingSet.Notch].FileInfo.WavFile)) {
roryhand 2:957d3b2afff4 1131 fseek(Sounds[NotchingSet.Notch].FileInfo.WavFile,44,SEEK_SET);
roryhand 2:957d3b2afff4 1132 }
roryhand 3:6169aeeaeeb4 1133
roryhand 2:957d3b2afff4 1134 //Read in data for current (i.e. now the previous notch, according to the index!!)
roryhand 2:957d3b2afff4 1135 //We might not need this code here...as its probably done somewhere else??
roryhand 2:957d3b2afff4 1136 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 1137 Sounds[NotchingSet.Notch-1].data_sptr = (short *)Sounds[NotchingSet.Notch-1].FileInfo.slice_buf;
roryhand 3:6169aeeaeeb4 1138
roryhand 2:957d3b2afff4 1139 NotchFadeOut.FadeCoeff = NotchFadeOut.FadeOut();//compute new FadeOut Coeff value
roryhand 2:957d3b2afff4 1140
roryhand 2:957d3b2afff4 1141 //Read in the notch transition file for transitioning up
roryhand 2:957d3b2afff4 1142 fread(Sounds[NotchingSet.NotchTransUp].FileInfo.slice_buf,Sounds[NotchingSet.NotchTransUp].FileInfo.FileFormat.block_align,1,Sounds[NotchingSet.NotchTransUp].FileInfo.WavFile);
roryhand 2:957d3b2afff4 1143 Sounds[NotchingSet.NotchTransUp].data_sptr = (short*)Sounds[NotchingSet.NotchTransUp].FileInfo.slice_buf;
roryhand 3:6169aeeaeeb4 1144
roryhand 2:957d3b2afff4 1145 if( ((Sounds[NotchingSet.NotchTransUp].FileInfo.FileData.subchunk2_size) - NotchFadeIn.Length - 2*11025) <= (ftell(Sounds[NotchingSet.NotchTransUp].FileInfo.WavFile) + 44))
roryhand 2:957d3b2afff4 1146 //if( (WavInfo_IdleN2.FileData.subchunk2_size)/8 <=ftell(IdleN2Wav) )
roryhand 2:957d3b2afff4 1147 {
roryhand 2:957d3b2afff4 1148
roryhand 2:957d3b2afff4 1149 NotchFadeIn.FadeCoeff = NotchFadeIn.FadeIn();
roryhand 3:6169aeeaeeb4 1150
roryhand 2:957d3b2afff4 1151 //Read In the next Notch
roryhand 2:957d3b2afff4 1152 fread(Sounds[NotchingSet.Notch].FileInfo.slice_buf,Sounds[NotchingSet.Notch].FileInfo.FileFormat.block_align,1,Sounds[NotchingSet.Notch].FileInfo.WavFile);
roryhand 2:957d3b2afff4 1153 Sounds[NotchingSet.Notch].data_sptr = (short *)Sounds[NotchingSet.Notch].FileInfo.slice_buf;
roryhand 2:957d3b2afff4 1154
roryhand 2:957d3b2afff4 1155 if( (ftell(Sounds[NotchingSet.NotchTransUp].FileInfo.WavFile) + 44) >= Sounds[NotchingSet.NotchTransUp].FileInfo.FileData.subchunk2_size ) {
roryhand 3:6169aeeaeeb4 1156
roryhand 2:957d3b2afff4 1157 //need to explicitly test if this notation/syntax works for pointers....
roryhand 2:957d3b2afff4 1158 *Sounds[NotchingSet.Notch].data_sptr = *Sounds[NotchingSet.Notch].data_sptr*NotchFadeIn.FadeCoeff;
roryhand 2:957d3b2afff4 1159 } else {
roryhand 2:957d3b2afff4 1160 *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 1161 }
roryhand 2:957d3b2afff4 1162
roryhand 2:957d3b2afff4 1163 } else {
roryhand 2:957d3b2afff4 1164 *Sounds[NotchingSet.Notch-1].data_sptr = *Sounds[NotchingSet.Notch-1].data_sptr*NotchFadeOut.FadeCoeff + *Sounds[NotchingSet.NotchTransUp].data_sptr;
roryhand 2:957d3b2afff4 1165 }
roryhand 2:957d3b2afff4 1166
roryhand 1:aac37edee302 1167 }
roryhand 1:aac37edee302 1168
roryhand 1:aac37edee302 1169
roryhand 3:6169aeeaeeb4 1170 /********************END OF DATA ASSIGNMENT SECTION*************************************************/
roryhand 9:dd9cae06b202 1171
roryhand 2:957d3b2afff4 1172 for (channel=0; channel<Sounds[NotchingSet.Notch].FileInfo.FileFormat.num_channels; channel++) {
roryhand 2:957d3b2afff4 1173 switch (Sounds[NotchingSet.Notch].FileInfo.FileFormat.sig_bps) {
roryhand 0:e89d7a0bfa3b 1174 case 16:
roryhand 1:aac37edee302 1175 if(flag1 == 1) {
roryhand 2:957d3b2afff4 1176 Buffer1[place_hold1] = Sounds[NotchingSet.Notch].data_sptr[channel];
roryhand 1:aac37edee302 1177 place_hold1 = place_hold1 + 1;
roryhand 1:aac37edee302 1178 if(place_hold1 >= BufferLen) {
roryhand 1:aac37edee302 1179 while(1) {
roryhand 1:aac37edee302 1180 if(flag1 == 0) {
roryhand 1:aac37edee302 1181 break;
roryhand 1:aac37edee302 1182 }//if(flag1 == 0)
roryhand 1:aac37edee302 1183
roryhand 1:aac37edee302 1184
roryhand 1:aac37edee302 1185 }//while(1)
roryhand 1:aac37edee302 1186 }//if(place_hold1 > = BufferLen)
roryhand 0:e89d7a0bfa3b 1187
roryhand 1:aac37edee302 1188 } else if(flag2 == 1) {
roryhand 2:957d3b2afff4 1189 Buffer2[place_hold2] = Sounds[NotchingSet.Notch].data_sptr[channel];
roryhand 1:aac37edee302 1190 place_hold2 = place_hold2 + 1;
roryhand 1:aac37edee302 1191 if(place_hold2 >= BufferLen) {
roryhand 1:aac37edee302 1192 while(1) {
roryhand 1:aac37edee302 1193
roryhand 1:aac37edee302 1194 if(flag2 == 0) {
roryhand 1:aac37edee302 1195 break;
roryhand 1:aac37edee302 1196 }
roryhand 1:aac37edee302 1197 }
roryhand 0:e89d7a0bfa3b 1198 }
roryhand 1:aac37edee302 1199
roryhand 1:aac37edee302 1200 }
roryhand 0:e89d7a0bfa3b 1201 }
roryhand 0:e89d7a0bfa3b 1202 }
roryhand 0:e89d7a0bfa3b 1203 slice = slice + 1;
roryhand 0:e89d7a0bfa3b 1204 }
roryhand 0:e89d7a0bfa3b 1205 }
roryhand 0:e89d7a0bfa3b 1206
roryhand 0:e89d7a0bfa3b 1207
roryhand 0:e89d7a0bfa3b 1208
roryhand 0:e89d7a0bfa3b 1209
roryhand 0:e89d7a0bfa3b 1210
roryhand 0:e89d7a0bfa3b 1211
roryhand 0:e89d7a0bfa3b 1212
roryhand 9:dd9cae06b202 1213