old demo that i want to try in mbed studio

Dependencies:   mbed SDFileSystem_Copy_of_mbed_version I2S

Committer:
roryhand
Date:
Sat Sep 07 14:59:23 2019 +0000
Revision:
42:f481dcabdc34
Parent:
41:5dca752e6c40
Child:
43:890d76ffe627
WIP - Some vector junk removed, in prep for new method after conv. with Tristan

Who changed what in which revision?

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