old demo that i want to try in mbed studio

Dependencies:   mbed SDFileSystem_Copy_of_mbed_version I2S

Committer:
roryhand
Date:
Mon Jun 17 21:42:02 2019 +0000
Revision:
40:ba34990514fa
Parent:
39:69d5a5dd9163
Child:
41:5dca752e6c40
WIP - Can now print out members of vectors, and delete vector elements.  However, deleting an element does not leave an empty element.  Need to find a way to replace any given deleted element with a placeholder (low memory) element.

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 40:ba34990514fa 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 40:ba34990514fa 398
roryhand 40:ba34990514fa 399
roryhand 32:6ee488c97dcc 400
roryhand 39:69d5a5dd9163 401 std::vector<classSoundFile> v;
roryhand 39:69d5a5dd9163 402 v.push_back(Sound1);
roryhand 39:69d5a5dd9163 403 v.push_back(Sound2);
roryhand 39:69d5a5dd9163 404 v.push_back(Sound3);
roryhand 39:69d5a5dd9163 405 v.push_back(Sound4);
roryhand 39:69d5a5dd9163 406 v.push_back(Sound5);
roryhand 40:ba34990514fa 407 for(int c = 0; c<5; c++) {
roryhand 40:ba34990514fa 408 printf("This is Sound No.: %s\n\r",v.at(c).file_location);
roryhand 39:69d5a5dd9163 409
roryhand 39:69d5a5dd9163 410 }
roryhand 39:69d5a5dd9163 411 v.erase(v.begin() + 1);
roryhand 40:ba34990514fa 412 v.at(1);
roryhand 40:ba34990514fa 413 classSoundFile RandomSound;
roryhand 40:ba34990514fa 414 RandomSound.file_location = 'placeholder';
roryhand 40:ba34990514fa 415 v.push_back(RandomSound);
roryhand 40:ba34990514fa 416 for(int c = 0; c<5; c++) {
roryhand 40:ba34990514fa 417 printf("This is Sound No.: %s\n\r",v.at(c).file_location);
roryhand 39:69d5a5dd9163 418
roryhand 39:69d5a5dd9163 419 }
roryhand 39:69d5a5dd9163 420
roryhand 40:ba34990514fa 421
roryhand 39:69d5a5dd9163 422 /*
roryhand 39:69d5a5dd9163 423 int ArrayOfSounds[6];
roryhand 39:69d5a5dd9163 424 ArrayOfSounds[1] = classSoundFile Sound1;
roryhand 39:69d5a5dd9163 425 ArrayOfSounds[2] = classSoundFile Sound2;
roryhand 39:69d5a5dd9163 426 ArrayOfSounds[3] = classSoundFile Sound3;
roryhand 39:69d5a5dd9163 427 ArrayOfSounds[4] = classSoundFile Sound4;
roryhand 39:69d5a5dd9163 428 ArrayOfSounds[5] = classSoundFile Sound5;
roryhand 39:69d5a5dd9163 429 */
roryhand 39:69d5a5dd9163 430
roryhand 39:69d5a5dd9163 431 //ArrayOfSounds[1] = classSoundFile Sound1;
roryhand 0:e89d7a0bfa3b 432 NotchUp.mode(PullUp);
roryhand 38:3b4c05af5f36 433 NotchDown.mode(PullUp);
roryhand 0:e89d7a0bfa3b 434
roryhand 0:e89d7a0bfa3b 435 WAV_FILE_STRUCT WavInfo_Startup;
roryhand 0:e89d7a0bfa3b 436 WAV_FILE_STRUCT WavInfo_Idle;
roryhand 0:e89d7a0bfa3b 437
roryhand 0:e89d7a0bfa3b 438 pc.printf("Beginning of program\n");
roryhand 32:6ee488c97dcc 439
roryhand 0:e89d7a0bfa3b 440 FILE *IdleWav;
roryhand 1:aac37edee302 441
roryhand 3:6169aeeaeeb4 442
roryhand 37:a563899ac0df 443 char buf[10];
roryhand 37:a563899ac0df 444 int a = 1;
roryhand 37:a563899ac0df 445 sprintf(buf, "%d", a);
roryhand 13:8e93396a27c5 446
roryhand 37:a563899ac0df 447 string foo( "hello" );
roryhand 37:a563899ac0df 448 string test( "how are" );
roryhand 37:a563899ac0df 449 string hello;
roryhand 37:a563899ac0df 450 hello = foo + test;
roryhand 37:a563899ac0df 451 printf("%s\n\r",hello);
roryhand 37:a563899ac0df 452
roryhand 37:a563899ac0df 453 string RootFolder = "sd/mydir/SoundDecoder_second/";
roryhand 37:a563899ac0df 454 string folder = RootFolder + "0" + buf + ".wav";
roryhand 37:a563899ac0df 455 printf("FullFile location: %s\n\r",folder);
roryhand 13:8e93396a27c5 456
roryhand 32:6ee488c97dcc 457
roryhand 1:aac37edee302 458
roryhand 37:a563899ac0df 459 classSoundFile Sound[22];
roryhand 37:a563899ac0df 460 string file_names[22];
roryhand 38:3b4c05af5f36 461 const char* FileName;
roryhand 40:ba34990514fa 462 /*
roryhand 40:ba34990514fa 463 for(int aaa = 0; aaa < 20; aaa ++) {
roryhand 37:a563899ac0df 464 a = aaa+1;
roryhand 37:a563899ac0df 465 sprintf(buf, "%d", a);
roryhand 37:a563899ac0df 466 Sound[aaa].file_location = RootFolder + "0" + buf + ".wav";
roryhand 38:3b4c05af5f36 467 FileName = Sound[aaa].file_location.c_str();
roryhand 39:69d5a5dd9163 468 Sound[aaa].FileInfo.WavFile = fopen(FileName,"rb");
roryhand 39:69d5a5dd9163 469 if(Sound[aaa].FileInfo.WavFile == NULL) {
roryhand 39:69d5a5dd9163 470 printf("Cannot Open Sound[%d].FileInfo.WavFile\n\r",aaa);
roryhand 39:69d5a5dd9163 471
roryhand 39:69d5a5dd9163 472 }
roryhand 40:ba34990514fa 473 */
roryhand 39:69d5a5dd9163 474
roryhand 40:ba34990514fa 475 /*
roryhand 37:a563899ac0df 476 printf("FileName: %s\n\r",Sound[aaa].file_location);
roryhand 39:69d5a5dd9163 477 fclose(Sound[aaa].FileInfo.WavFile);
roryhand 39:69d5a5dd9163 478 free(Sound[aaa].FileInfo.WavFile);
roryhand 40:ba34990514fa 479 */
roryhand 38:3b4c05af5f36 480 //wait(1);
roryhand 40:ba34990514fa 481 // }
roryhand 38:3b4c05af5f36 482
roryhand 37:a563899ac0df 483 /*
roryhand 37:a563899ac0df 484 string RootFolder = "sd/mydir/SoundDecoder_second/";
roryhand 37:a563899ac0df 485 string folder = RootFolder + "01.wav";
roryhand 37:a563899ac0df 486 printf("Full file location: %s\n\r",folder);
roryhand 37:a563899ac0df 487 */
roryhand 32:6ee488c97dcc 488
roryhand 1:aac37edee302 489
roryhand 1:aac37edee302 490
roryhand 37:a563899ac0df 491 /*
roryhand 37:a563899ac0df 492 for(int aaa = 0;aaa < 21; aaa ++ )
roryhand 37:a563899ac0df 493 {
roryhand 37:a563899ac0df 494 folder = RootFolder + "\01.wav";//filename[aaa];
roryhand 37:a563899ac0df 495 FOLDER = folder.c_str();
roryhand 37:a563899ac0df 496 Sound[aaa].FileInfo.WavFile = fopen(FOLDER,"rb");
roryhand 37:a563899ac0df 497 //MyNewWav.WavFile = fopen("/sd/mydir/Startup.wav","rb");
roryhand 37:a563899ac0df 498 printf("we opened This file %d\n\r",aaa);
roryhand 37:a563899ac0df 499
roryhand 37:a563899ac0df 500 }
roryhand 37:a563899ac0df 501 */
roryhand 1:aac37edee302 502
roryhand 31:0f8c3adf09c3 503
roryhand 31:0f8c3adf09c3 504
roryhand 32:6ee488c97dcc 505 printf("About to Start ReadFileInfo Operations\n\r");
roryhand 39:69d5a5dd9163 506
roryhand 39:69d5a5dd9163 507 FILE* mywav1 = fopen("/sd/mydir/SoundDecoder_second/01.wav","rb");
roryhand 39:69d5a5dd9163 508 if(mywav1 == NULL) {
roryhand 39:69d5a5dd9163 509 printf("Cannot Open mywav1\n\r");
roryhand 39:69d5a5dd9163 510 }
roryhand 39:69d5a5dd9163 511 fclose(mywav1);
roryhand 39:69d5a5dd9163 512
roryhand 39:69d5a5dd9163 513 FILE* mywav2 = fopen("/sd/mydir/SoundDecoder_second/02.wav","rb");
roryhand 39:69d5a5dd9163 514 if(mywav2 == NULL) {
roryhand 39:69d5a5dd9163 515 printf("Cannot Open mywav2\n\r");
roryhand 39:69d5a5dd9163 516 }
roryhand 39:69d5a5dd9163 517 fclose(mywav2);
roryhand 39:69d5a5dd9163 518
roryhand 39:69d5a5dd9163 519 FILE* mywav3 = fopen("/sd/mydir/SoundDecoder_second/03.wav","rb");
roryhand 39:69d5a5dd9163 520 if(mywav3 == NULL) {
roryhand 39:69d5a5dd9163 521 printf("Cannot Open mywav3\n\r");
roryhand 39:69d5a5dd9163 522 }
roryhand 39:69d5a5dd9163 523 fclose(mywav3);
roryhand 39:69d5a5dd9163 524
roryhand 39:69d5a5dd9163 525 FILE* mywav4 = fopen("/sd/mydir/SoundDecoder_second/04.wav","rb");
roryhand 39:69d5a5dd9163 526 if(mywav4 == NULL) {
roryhand 39:69d5a5dd9163 527 printf("Cannot Open mywav4\n\r");
roryhand 39:69d5a5dd9163 528 }
roryhand 39:69d5a5dd9163 529 fclose(mywav4);
roryhand 39:69d5a5dd9163 530
roryhand 39:69d5a5dd9163 531 FILE* mywav5 = fopen("/sd/mydir/SoundDecoder_second/05.wav","rb");
roryhand 39:69d5a5dd9163 532 if(mywav5 == NULL) {
roryhand 39:69d5a5dd9163 533 printf("Cannot Open mywav5\n\r");
roryhand 39:69d5a5dd9163 534 }
roryhand 39:69d5a5dd9163 535 fclose(mywav5);
roryhand 39:69d5a5dd9163 536
roryhand 39:69d5a5dd9163 537 FILE* mywav6 = fopen("/sd/mydir/SoundDecoder_second/06.wav","rb");
roryhand 39:69d5a5dd9163 538 if(mywav6 == NULL) {
roryhand 39:69d5a5dd9163 539 printf("Cannot Open mywav6\n\r");
roryhand 39:69d5a5dd9163 540 }
roryhand 39:69d5a5dd9163 541 fclose(mywav6);
roryhand 39:69d5a5dd9163 542
roryhand 39:69d5a5dd9163 543 FILE* mywav7 = fopen("/sd/mydir/SoundDecoder_second/07.wav","rb");
roryhand 39:69d5a5dd9163 544 if(mywav7 == NULL) {
roryhand 39:69d5a5dd9163 545 printf("Cannot Open mywav7\n\r");
roryhand 39:69d5a5dd9163 546 }
roryhand 39:69d5a5dd9163 547 fclose(mywav7);
roryhand 13:8e93396a27c5 548
roryhand 39:69d5a5dd9163 549 FILE* mywav8 = fopen("/sd/mydir/SoundDecoder_second/08.wav","rb");
roryhand 39:69d5a5dd9163 550 if(mywav8 == NULL) {
roryhand 39:69d5a5dd9163 551 printf("Cannot Open mywav8\n\r");
roryhand 39:69d5a5dd9163 552 }
roryhand 39:69d5a5dd9163 553 fclose(mywav8);
roryhand 39:69d5a5dd9163 554
roryhand 39:69d5a5dd9163 555 FILE* mywav9 = fopen("/sd/mydir/SoundDecoder_second/09.wav","rb");
roryhand 39:69d5a5dd9163 556 if(mywav9 == NULL) {
roryhand 39:69d5a5dd9163 557 printf("Cannot Open mywav9\n\r");
roryhand 39:69d5a5dd9163 558 }
roryhand 39:69d5a5dd9163 559 fclose(mywav9);
roryhand 39:69d5a5dd9163 560
roryhand 39:69d5a5dd9163 561 FILE* mywav10 = fopen("/sd/mydir/SoundDecoder_second/10.wav","rb");
roryhand 39:69d5a5dd9163 562 if(mywav10 == NULL) {
roryhand 39:69d5a5dd9163 563 printf("Cannot Open mywav10\n\r");
roryhand 39:69d5a5dd9163 564 }
roryhand 39:69d5a5dd9163 565 fclose(mywav10);
roryhand 28:6b2353fad12d 566
roryhand 39:69d5a5dd9163 567 FILE* mywav11= fopen("/sd/mydir/SoundDecoder_second/11.wav","rb");
roryhand 39:69d5a5dd9163 568 if(mywav11 == NULL) {
roryhand 39:69d5a5dd9163 569 printf("Cannot Open mywav11\n\r");
roryhand 39:69d5a5dd9163 570 }
roryhand 39:69d5a5dd9163 571 fclose(mywav11);
roryhand 39:69d5a5dd9163 572
roryhand 39:69d5a5dd9163 573 FILE* mywav12 = fopen("/sd/mydir/SoundDecoder_second/12.wav","rb");
roryhand 39:69d5a5dd9163 574 if(mywav12 == NULL) {
roryhand 39:69d5a5dd9163 575 printf("Cannot Open mywav12\n\r");
roryhand 39:69d5a5dd9163 576 }
roryhand 39:69d5a5dd9163 577 fclose(mywav12);
roryhand 39:69d5a5dd9163 578
roryhand 39:69d5a5dd9163 579 FILE* mywav13 = fopen("/sd/mydir/SoundDecoder_second/13.wav","rb");
roryhand 39:69d5a5dd9163 580 if(mywav13 == NULL) {
roryhand 39:69d5a5dd9163 581 printf("Cannot Open mywav13\n\r");
roryhand 39:69d5a5dd9163 582 }
roryhand 39:69d5a5dd9163 583 fclose(mywav13);
roryhand 39:69d5a5dd9163 584
roryhand 39:69d5a5dd9163 585 FILE* mywav14 = fopen("/sd/mydir/SoundDecoder_second/14.wav","rb");
roryhand 39:69d5a5dd9163 586 if(mywav14 == NULL) {
roryhand 39:69d5a5dd9163 587 printf("Cannot Open mywav14\n\r");
roryhand 39:69d5a5dd9163 588 }
roryhand 39:69d5a5dd9163 589 fclose(mywav14);
roryhand 39:69d5a5dd9163 590
roryhand 39:69d5a5dd9163 591
roryhand 13:8e93396a27c5 592
roryhand 13:8e93396a27c5 593
roryhand 13:8e93396a27c5 594
roryhand 32:6ee488c97dcc 595 HeyWav = fopen("/sd/mydir/645Engine/EX_FlangeJoint1_11k_minus12dB.wav","rb");
roryhand 32:6ee488c97dcc 596 if(HeyWav == NULL) {
roryhand 32:6ee488c97dcc 597 printf("Cannot Open HeyWav\n\r");
roryhand 32:6ee488c97dcc 598 }
roryhand 32:6ee488c97dcc 599
roryhand 32:6ee488c97dcc 600 N3Wav = fopen("/sd/mydir/SoundDecoder_second/03.wav","rb");
roryhand 32:6ee488c97dcc 601 if(N3Wav == NULL) {
roryhand 32:6ee488c97dcc 602 printf("Cannot Open N3Wav\n\r");
roryhand 32:6ee488c97dcc 603 }
roryhand 32:6ee488c97dcc 604 WavInfo_N3 = ReadFileInfo(WavInfo_N3,N3Wav);
roryhand 32:6ee488c97dcc 605 fclose(N3Wav);
roryhand 25:5336e1cf38d6 606
roryhand 25:5336e1cf38d6 607
roryhand 13:8e93396a27c5 608
roryhand 22:706e86dc0d45 609 printf("About to Read HeyWav\n\r");
roryhand 28:6b2353fad12d 610
roryhand 32:6ee488c97dcc 611
roryhand 32:6ee488c97dcc 612
roryhand 25:5336e1cf38d6 613 WavInfo_Hey = ReadFileInfo(WavInfo_Hey,HeyWav);
roryhand 28:6b2353fad12d 614
roryhand 13:8e93396a27c5 615
roryhand 13:8e93396a27c5 616
roryhand 4:55fbbb049bae 617
roryhand 25:5336e1cf38d6 618 printf("Do we even get to this stupid bloody point\n\r");
roryhand 0:e89d7a0bfa3b 619 //Populate our class instances with some data (is there an implicit way to do this?)
roryhand 28:6b2353fad12d 620
roryhand 1:aac37edee302 621
roryhand 3:6169aeeaeeb4 622 printf("hello\n\r");
roryhand 0:e89d7a0bfa3b 623 //Set up the wolfson Audio Codec board
roryhand 0:e89d7a0bfa3b 624 wm8731_Config_setup();
roryhand 0:e89d7a0bfa3b 625 //i2s audio data transfer code??
roryhand 0:e89d7a0bfa3b 626 i2s.stereomono(I2S_STEREO);
roryhand 0:e89d7a0bfa3b 627 i2s.masterslave(I2S_MASTER);
roryhand 0:e89d7a0bfa3b 628 led3 = 1;
roryhand 0:e89d7a0bfa3b 629 led2 = 1;
roryhand 30:4a8e80b243c4 630 printf("Hello i2s has starrted!");
roryhand 30:4a8e80b243c4 631 i2s.start();
roryhand 0:e89d7a0bfa3b 632 sampletick.attach(&isr,1.0/sampling_freq); //1/16000
roryhand 32:6ee488c97dcc 633 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 634
roryhand 31:0f8c3adf09c3 635
roryhand 31:0f8c3adf09c3 636 timer_open.reset();
roryhand 32:6ee488c97dcc 637 timer_open.start();
roryhand 32:6ee488c97dcc 638 N3Wav = fopen("/sd/mydir/SoundDecoder_second/03.wav","rb");
roryhand 32:6ee488c97dcc 639 if(N3Wav == NULL) {
roryhand 32:6ee488c97dcc 640 printf("Cannot Open N3Wav\n\r");
roryhand 32:6ee488c97dcc 641 }
roryhand 35:4469b508dda3 642 fclose(N3Wav);
roryhand 30:4a8e80b243c4 643 StartupWav = fopen("/sd/mydir/Startup.wav","rb");
roryhand 31:0f8c3adf09c3 644 timer_open.reset();
roryhand 31:0f8c3adf09c3 645 printf("It took %d useconds to open file\n\r",timer_open.read_us());
roryhand 31:0f8c3adf09c3 646 //const char* folder2 = folder.c_str();
roryhand 31:0f8c3adf09c3 647
roryhand 31:0f8c3adf09c3 648
roryhand 31:0f8c3adf09c3 649
roryhand 28:6b2353fad12d 650 fseek(StartupWav,44,SEEK_SET);
roryhand 32:6ee488c97dcc 651 timer_open.reset();
roryhand 32:6ee488c97dcc 652 timer_open.start();
roryhand 28:6b2353fad12d 653 WavInfo_Startup = ReadFileInfo(WavInfo_Startup,StartupWav);
roryhand 32:6ee488c97dcc 654 timer_open.stop();
roryhand 32:6ee488c97dcc 655 printf("It took %d useconds to Read In File Info\n\r",timer_open.read_us());
roryhand 13:8e93396a27c5 656
roryhand 32:6ee488c97dcc 657
roryhand 32:6ee488c97dcc 658
roryhand 32:6ee488c97dcc 659
roryhand 31:0f8c3adf09c3 660
roryhand 20:9cc7d825c07b 661 printf("about to play wav file\n\r");
roryhand 32:6ee488c97dcc 662 Play_WaveFileDual(StartupWav,WavInfo_Startup);
roryhand 20:9cc7d825c07b 663 printf("finished playing Wav file\n\r");
roryhand 31:0f8c3adf09c3 664 timer_open.reset();
roryhand 31:0f8c3adf09c3 665 timer_open.start();
roryhand 31:0f8c3adf09c3 666 fclose(StartupWav);
roryhand 31:0f8c3adf09c3 667 timer_open.stop();
roryhand 31:0f8c3adf09c3 668 printf("It took %d useconds to close file\n\r",timer_open.read_us());
roryhand 9:dd9cae06b202 669 /************************************PLAY WAV FILE LOOP*******************/
roryhand 20:9cc7d825c07b 670 //Play_WaveFileLoop(Sound, NotchingSet);
roryhand 9:dd9cae06b202 671 /************************************END OF PLAY WAV FILE LOOP*************/
roryhand 13:8e93396a27c5 672
roryhand 13:8e93396a27c5 673
roryhand 13:8e93396a27c5 674
roryhand 9:dd9cae06b202 675
roryhand 3:6169aeeaeeb4 676
roryhand 0:e89d7a0bfa3b 677 fseek(IdleN2Wav,44,SEEK_SET);//reset for use in the Loop code
roryhand 0:e89d7a0bfa3b 678 slice = 0;
roryhand 0:e89d7a0bfa3b 679 fseek(IdleWav,44,SEEK_SET);
roryhand 3:6169aeeaeeb4 680 NotchingSet.Notch = 1;
roryhand 1:aac37edee302 681 //Play_WaveFileLoop(IdleWav, WavInfo_Idle);
roryhand 1:aac37edee302 682
roryhand 1:aac37edee302 683 i2s.stop();
roryhand 0:e89d7a0bfa3b 684
roryhand 0:e89d7a0bfa3b 685 }
roryhand 0:e89d7a0bfa3b 686
roryhand 0:e89d7a0bfa3b 687
roryhand 3:6169aeeaeeb4 688
roryhand 3:6169aeeaeeb4 689
roryhand 3:6169aeeaeeb4 690
roryhand 3:6169aeeaeeb4 691
roryhand 0:e89d7a0bfa3b 692 WAV_FILE_STRUCT ReadFileInfo(WAV_FILE_STRUCT FileInfo, FILE * wav_file)
roryhand 0:e89d7a0bfa3b 693 {
roryhand 0:e89d7a0bfa3b 694 fseek(wav_file,20,SEEK_SET);
roryhand 22:706e86dc0d45 695 printf("We have just seeked through this file\n\r");
roryhand 0:e89d7a0bfa3b 696 fread(&FileInfo.FileFormat,sizeof(FileInfo.FileFormat),1,wav_file);
roryhand 1:aac37edee302 697 //printf("wav_format.sample_rate: %d\n\r",FileInfo.FileFormat.sample_rate);
roryhand 1:aac37edee302 698
roryhand 0:e89d7a0bfa3b 699 fread(&FileInfo.FileData,sizeof(FileInfo.FileData),1,wav_file);
roryhand 1:aac37edee302 700 //printf("wav_data.subchunk2_size: %d\n\r",FileInfo.FileData.subchunk2_size);
roryhand 0:e89d7a0bfa3b 701 FileInfo.slice_buf = ( char *)malloc(FileInfo.FileFormat.block_align);
roryhand 0:e89d7a0bfa3b 702 fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,wav_file); //This isnt actually required, its just a test
roryhand 1:aac37edee302 703 FileInfo.num_slices = FileInfo.FileData.subchunk2_size/FileInfo.FileFormat.block_align;
roryhand 1:aac37edee302 704 //printf("Number of Slices: %d\n\r",FileInfo.num_slices);
roryhand 1:aac37edee302 705 return FileInfo;
roryhand 0:e89d7a0bfa3b 706 }
roryhand 1:aac37edee302 707
roryhand 1:aac37edee302 708 classSoundFile LoadFileStream(classSoundFile Sound, string filename)
roryhand 1:aac37edee302 709 {
roryhand 1:aac37edee302 710 //Declare RootFolder and the directory for the appropriate file.
roryhand 1:aac37edee302 711 //How we index into filename[] from the outside of this class is another
roryhand 1:aac37edee302 712 //issue...
roryhand 1:aac37edee302 713 //printf("FileName: %s\n\r",filename);
roryhand 1:aac37edee302 714 //string RootFolder = "/sd/mydir/SoundDecoder/";
roryhand 1:aac37edee302 715 //string Directory = RootFolder + "01.wav";// + filename[0];
roryhand 1:aac37edee302 716 //printf("%s\n\r",Directory);
roryhand 1:aac37edee302 717 //const char* DirectoryChar = Directory.c_str();
roryhand 1:aac37edee302 718 //Sound.FileInfo.WavFile = fopen(DirectoryChar,"rb");
roryhand 1:aac37edee302 719 Sound.FileInfo.WavFile = fopen("/sd/mydir/645Engine/Startup.wav","rb");
roryhand 1:aac37edee302 720 fseek(Sound.FileInfo.WavFile,20,SEEK_SET);
roryhand 1:aac37edee302 721 fread(&Sound.FileInfo.FileFormat,sizeof(Sound.FileInfo.FileFormat),1,Sound.FileInfo.WavFile);
roryhand 1:aac37edee302 722 printf("wav_format.sample_rate: %d\n\r",Sound.FileInfo.FileFormat.sample_rate);
roryhand 1:aac37edee302 723 fread(&Sound.FileInfo.FileData,sizeof(Sound.FileInfo.FileData),1,Sound.FileInfo.WavFile);
roryhand 1:aac37edee302 724 printf("wav_data.subchunk2_size: %d\n\r",Sound.FileInfo.FileData.subchunk2_size);
roryhand 1:aac37edee302 725 Sound.FileInfo.slice_buf = ( char *)malloc(Sound.FileInfo.FileFormat.block_align);
roryhand 1:aac37edee302 726 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 727 Sound.FileInfo.num_slices = Sound.FileInfo.FileData.subchunk2_size/Sound.FileInfo.FileFormat.block_align;
roryhand 1:aac37edee302 728 printf("Number of Slices: %d\n\r",Sound.FileInfo.num_slices);
roryhand 1:aac37edee302 729 return Sound;
roryhand 1:aac37edee302 730 }
roryhand 1:aac37edee302 731
roryhand 1:aac37edee302 732
roryhand 0:e89d7a0bfa3b 733 classFade FadeDataInitialise(classFade FadeData)
roryhand 0:e89d7a0bfa3b 734 {
roryhand 1:aac37edee302 735 FadeData.DecayFactor = 1.3;
roryhand 0:e89d7a0bfa3b 736 FadeData.FadeIteration = 1;
roryhand 0:e89d7a0bfa3b 737 //FadeData.Denom = 11025*FadeData.DecayFactor;
roryhand 0:e89d7a0bfa3b 738 FadeData.Denom = 11025*FadeData.DecayFactor;
roryhand 0:e89d7a0bfa3b 739 FadeData.Natural_Exp = 2.7183;
roryhand 0:e89d7a0bfa3b 740 FadeData.Length = 11025*FadeData.LengthSecs;
roryhand 0:e89d7a0bfa3b 741 //FadeData.Natural_Exp = 2.7;
roryhand 0:e89d7a0bfa3b 742 return FadeData;
roryhand 0:e89d7a0bfa3b 743 }
roryhand 0:e89d7a0bfa3b 744
roryhand 0:e89d7a0bfa3b 745 //Playing Files Code
roryhand 0:e89d7a0bfa3b 746 /*float FadeIn(void)
roryhand 0:e89d7a0bfa3b 747 {
roryhand 0:e89d7a0bfa3b 748 powervalFadeIn = FadeIterationIn/denom;
roryhand 0:e89d7a0bfa3b 749 FadeCoeffFadeIn
roryhand 1:aac37edee302 750
roryhand 1:aac37edee302 751
roryhand 0:e89d7a0bfa3b 752 }*/
roryhand 0:e89d7a0bfa3b 753 /*float FadeOut(void)
roryhand 0:e89d7a0bfa3b 754 {
roryhand 0:e89d7a0bfa3b 755 powerval = -FadeIteration/denom;
roryhand 0:e89d7a0bfa3b 756 FadeCoeff = pow(natural_exp,powerval);
roryhand 1:aac37edee302 757 FadeIteration = FadeIteration + 1;
roryhand 1:aac37edee302 758 return FadeCoeff;
roryhand 1:aac37edee302 759
roryhand 0:e89d7a0bfa3b 760 }*/
roryhand 0:e89d7a0bfa3b 761
roryhand 0:e89d7a0bfa3b 762
roryhand 0:e89d7a0bfa3b 763 void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo)
roryhand 0:e89d7a0bfa3b 764 {
roryhand 1:aac37edee302 765 while(slice<FileInfo.num_slices) {
roryhand 1:aac37edee302 766 fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav);
roryhand 1:aac37edee302 767 data_sptr=(short *)FileInfo.slice_buf; // 16 bit samples
roryhand 1:aac37edee302 768 for (channel=0; channel<FileInfo.FileFormat.num_channels; channel++) {
roryhand 1:aac37edee302 769 if(flag1 == 1) {
roryhand 1:aac37edee302 770 Buffer1[place_hold1] = data_sptr[channel];
roryhand 1:aac37edee302 771 place_hold1 = place_hold1 + 1;
roryhand 1:aac37edee302 772 if(place_hold1 >= BufferLen) {
roryhand 1:aac37edee302 773 while(1) {
roryhand 1:aac37edee302 774 if(flag1 == 0) {
roryhand 0:e89d7a0bfa3b 775
roryhand 1:aac37edee302 776 break;
roryhand 0:e89d7a0bfa3b 777 }
roryhand 1:aac37edee302 778
roryhand 0:e89d7a0bfa3b 779 }
roryhand 1:aac37edee302 780 }
roryhand 1:aac37edee302 781
roryhand 1:aac37edee302 782 } else if(flag2 == 1) {
roryhand 1:aac37edee302 783 Buffer2[place_hold2] = data_sptr[channel];
roryhand 1:aac37edee302 784 place_hold2 = place_hold2 + 1;
roryhand 1:aac37edee302 785 if(place_hold2 >= BufferLen) {
roryhand 1:aac37edee302 786
roryhand 1:aac37edee302 787 while(1) {
roryhand 1:aac37edee302 788 if(flag2 == 0) {
roryhand 1:aac37edee302 789
roryhand 1:aac37edee302 790 break;
roryhand 1:aac37edee302 791 }
roryhand 0:e89d7a0bfa3b 792 }
roryhand 1:aac37edee302 793 }
roryhand 0:e89d7a0bfa3b 794 }
roryhand 1:aac37edee302 795
roryhand 1:aac37edee302 796 }
roryhand 1:aac37edee302 797 slice = slice + 1;
roryhand 0:e89d7a0bfa3b 798 }
roryhand 0:e89d7a0bfa3b 799 }
roryhand 0:e89d7a0bfa3b 800
roryhand 0:e89d7a0bfa3b 801
roryhand 0:e89d7a0bfa3b 802
roryhand 0:e89d7a0bfa3b 803
roryhand 32:6ee488c97dcc 804 void Play_WaveFileDual(FILE * my_wav, WAV_FILE_STRUCT FileInfo)
roryhand 32:6ee488c97dcc 805 {
roryhand 32:6ee488c97dcc 806 while(slice<FileInfo.num_slices) {
roryhand 32:6ee488c97dcc 807 if(FileSwitchFlag == 1) {
roryhand 35:4469b508dda3 808
roryhand 33:a75f0a30fbdc 809 if(temp == 1) {
roryhand 34:26118c8f2e48 810 printf("Does it go to this point\n\r");
roryhand 35:4469b508dda3 811 N3Wav = fopen("/sd/mydir/SoundDecoder_second/03.wav","rb");
roryhand 33:a75f0a30fbdc 812 if(N3Wav == NULL) {
roryhand 33:a75f0a30fbdc 813 printf("Cannot Open testwav\n\r");
roryhand 33:a75f0a30fbdc 814 }
roryhand 33:a75f0a30fbdc 815 fclose(StartupWav);
roryhand 33:a75f0a30fbdc 816 temp = 0;
roryhand 33:a75f0a30fbdc 817 }
roryhand 35:4469b508dda3 818 fread(WavInfo_N3.slice_buf,WavInfo_N3.FileFormat.block_align,1,N3Wav);
roryhand 35:4469b508dda3 819 data_sptr=(short*)WavInfo_N3.slice_buf;
roryhand 32:6ee488c97dcc 820 } else {
roryhand 32:6ee488c97dcc 821 fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav);
roryhand 32:6ee488c97dcc 822 data_sptr=(short *)FileInfo.slice_buf; // 16 bit samples
roryhand 32:6ee488c97dcc 823 }
roryhand 32:6ee488c97dcc 824 for (channel=0; channel<FileInfo.FileFormat.num_channels; channel++) {
roryhand 32:6ee488c97dcc 825 if(flag1 == 1) {
roryhand 32:6ee488c97dcc 826 Buffer1[place_hold1] = data_sptr[channel];
roryhand 32:6ee488c97dcc 827 place_hold1 = place_hold1 + 1;
roryhand 32:6ee488c97dcc 828 if(place_hold1 >= BufferLen) {
roryhand 32:6ee488c97dcc 829 while(1) {
roryhand 32:6ee488c97dcc 830 if(flag1 == 0) {
roryhand 0:e89d7a0bfa3b 831
roryhand 32:6ee488c97dcc 832 break;
roryhand 32:6ee488c97dcc 833 }
roryhand 32:6ee488c97dcc 834
roryhand 32:6ee488c97dcc 835 }
roryhand 32:6ee488c97dcc 836 }
roryhand 32:6ee488c97dcc 837
roryhand 32:6ee488c97dcc 838 } else if(flag2 == 1) {
roryhand 32:6ee488c97dcc 839 Buffer2[place_hold2] = data_sptr[channel];
roryhand 32:6ee488c97dcc 840 place_hold2 = place_hold2 + 1;
roryhand 32:6ee488c97dcc 841 if(place_hold2 >= BufferLen) {
roryhand 32:6ee488c97dcc 842
roryhand 32:6ee488c97dcc 843 while(1) {
roryhand 32:6ee488c97dcc 844 if(flag2 == 0) {
roryhand 32:6ee488c97dcc 845
roryhand 32:6ee488c97dcc 846 break;
roryhand 32:6ee488c97dcc 847 }
roryhand 32:6ee488c97dcc 848 }
roryhand 32:6ee488c97dcc 849 }
roryhand 32:6ee488c97dcc 850 }
roryhand 32:6ee488c97dcc 851
roryhand 32:6ee488c97dcc 852 }
roryhand 32:6ee488c97dcc 853 slice = slice + 1;
roryhand 32:6ee488c97dcc 854 }
roryhand 32:6ee488c97dcc 855 }
roryhand 0:e89d7a0bfa3b 856
roryhand 38:3b4c05af5f36 857 //***************************************************************************//
roryhand 38:3b4c05af5f36 858 /*
roryhand 38:3b4c05af5f36 859 void Play_WaveFileNotchTest(FILE * my_wav, WAV_FILE_STRUCT FileInfo)
roryhand 38:3b4c05af5f36 860 {
roryhand 38:3b4c05af5f36 861 while(slice<FileInfo.num_slices) {
roryhand 38:3b4c05af5f36 862 if(notch_flag == 1) {
roryhand 38:3b4c05af5f36 863
roryhand 38:3b4c05af5f36 864 if(temp == 1) {
roryhand 38:3b4c05af5f36 865 //printf("Does it go to this point\n\r");
roryhand 38:3b4c05af5f36 866 SoundFile[notch].FileInfo.WavFile = fopen(Sound[aaa].file_location,"rb");
roryhand 38:3b4c05af5f36 867 if(SoundFile[notch].FileInfo.WavFile == NULL) {
roryhand 38:3b4c05af5f36 868 printf("Cannot Open testwav\n\r");
roryhand 38:3b4c05af5f36 869 }
roryhand 38:3b4c05af5f36 870 fclose(StartupWav);
roryhand 38:3b4c05af5f36 871 temp = 0;
roryhand 38:3b4c05af5f36 872 }
roryhand 38:3b4c05af5f36 873 fread(WavInfo_N3.slice_buf,WavInfo_N3.FileFormat.block_align,1,N3Wav);
roryhand 38:3b4c05af5f36 874 data_sptr=(short*)WavInfo_N3.slice_buf;
roryhand 38:3b4c05af5f36 875 } else {
roryhand 38:3b4c05af5f36 876 fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav);
roryhand 38:3b4c05af5f36 877 data_sptr=(short *)FileInfo.slice_buf; // 16 bit samples
roryhand 38:3b4c05af5f36 878 }
roryhand 38:3b4c05af5f36 879 for (channel=0; channel<FileInfo.FileFormat.num_channels; channel++) {
roryhand 38:3b4c05af5f36 880 if(flag1 == 1) {
roryhand 38:3b4c05af5f36 881 Buffer1[place_hold1] = data_sptr[channel];
roryhand 38:3b4c05af5f36 882 place_hold1 = place_hold1 + 1;
roryhand 38:3b4c05af5f36 883 if(place_hold1 >= BufferLen) {
roryhand 38:3b4c05af5f36 884 while(1) {
roryhand 38:3b4c05af5f36 885 if(flag1 == 0) {
roryhand 38:3b4c05af5f36 886
roryhand 38:3b4c05af5f36 887 break;
roryhand 38:3b4c05af5f36 888 }
roryhand 38:3b4c05af5f36 889
roryhand 38:3b4c05af5f36 890 }
roryhand 38:3b4c05af5f36 891 }
roryhand 38:3b4c05af5f36 892
roryhand 38:3b4c05af5f36 893 } else if(flag2 == 1) {
roryhand 38:3b4c05af5f36 894 Buffer2[place_hold2] = data_sptr[channel];
roryhand 38:3b4c05af5f36 895 place_hold2 = place_hold2 + 1;
roryhand 38:3b4c05af5f36 896 if(place_hold2 >= BufferLen) {
roryhand 38:3b4c05af5f36 897
roryhand 38:3b4c05af5f36 898 while(1) {
roryhand 38:3b4c05af5f36 899 if(flag2 == 0) {
roryhand 38:3b4c05af5f36 900
roryhand 38:3b4c05af5f36 901 break;
roryhand 38:3b4c05af5f36 902 }
roryhand 38:3b4c05af5f36 903 }
roryhand 38:3b4c05af5f36 904 }
roryhand 38:3b4c05af5f36 905 }
roryhand 38:3b4c05af5f36 906
roryhand 38:3b4c05af5f36 907 }
roryhand 38:3b4c05af5f36 908 slice = slice + 1;
roryhand 38:3b4c05af5f36 909 }
roryhand 38:3b4c05af5f36 910 }
roryhand 38:3b4c05af5f36 911 */
roryhand 38:3b4c05af5f36 912 //**************************************************************************//
roryhand 38:3b4c05af5f36 913
roryhand 38:3b4c05af5f36 914
roryhand 38:3b4c05af5f36 915
roryhand 38:3b4c05af5f36 916
roryhand 38:3b4c05af5f36 917
roryhand 2:957d3b2afff4 918 //void Play_WaveFileLoop(FILE * my_wav, WAV_FILE_STRUCT FileInfo)//(classSoundFile Sounds)
roryhand 9:dd9cae06b202 919
roryhand 9:dd9cae06b202 920 void Play_WaveFileLoop(classSoundFile Sounds[], Notch_STRUCT NotchingSet)
roryhand 0:e89d7a0bfa3b 921 {
roryhand 1:aac37edee302 922 while(1) { //might have to change this to a while(1) loop?
roryhand 1:aac37edee302 923 //New format!! This should be (roughly) the way that this is done, with the new structures and classes
roryhand 1:aac37edee302 924 ////fread(Sound[Notch].FileData.slice_buf,Sound[Notch].FileFormat.block_align,1,Sound[notch].WavFile);
roryhand 1:aac37edee302 925 //data_sptr=(short *)Sound[Notch].FileInfo.slice_buf;
roryhand 1:aac37edee302 926
roryhand 0:e89d7a0bfa3b 927
roryhand 2:957d3b2afff4 928 if( slice == (Sounds[NotchingSet.Notch].FileInfo.num_slices-1) ) {
roryhand 1:aac37edee302 929 slice = 0;
roryhand 2:957d3b2afff4 930 fseek(Sounds[NotchingSet.Notch].FileInfo.WavFile,44,SEEK_SET);
roryhand 1:aac37edee302 931 }
roryhand 1:aac37edee302 932
roryhand 2:957d3b2afff4 933 //fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav);
roryhand 2:957d3b2afff4 934 data_sptr=(short *)Sounds[NotchingSet.Notch].FileInfo.slice_buf; // 16 bit samples
roryhand 2:957d3b2afff4 935 //make sure we are reading in the correct "notch" here
roryhand 2:957d3b2afff4 936
roryhand 2:957d3b2afff4 937 if(FadeFlag) {
roryhand 2:957d3b2afff4 938 if(feof(Sounds[NotchingSet.Notch].FileInfo.WavFile)) {
roryhand 2:957d3b2afff4 939 fseek(Sounds[NotchingSet.Notch].FileInfo.WavFile,44,SEEK_SET);
roryhand 2:957d3b2afff4 940 }
roryhand 3:6169aeeaeeb4 941
roryhand 2:957d3b2afff4 942 //Read in data for current (i.e. now the previous notch, according to the index!!)
roryhand 2:957d3b2afff4 943 //We might not need this code here...as its probably done somewhere else??
roryhand 2:957d3b2afff4 944 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 945 Sounds[NotchingSet.Notch-1].data_sptr = (short *)Sounds[NotchingSet.Notch-1].FileInfo.slice_buf;
roryhand 3:6169aeeaeeb4 946
roryhand 2:957d3b2afff4 947 NotchFadeOut.FadeCoeff = NotchFadeOut.FadeOut();//compute new FadeOut Coeff value
roryhand 2:957d3b2afff4 948
roryhand 2:957d3b2afff4 949 //Read in the notch transition file for transitioning up
roryhand 2:957d3b2afff4 950 fread(Sounds[NotchingSet.NotchTransUp].FileInfo.slice_buf,Sounds[NotchingSet.NotchTransUp].FileInfo.FileFormat.block_align,1,Sounds[NotchingSet.NotchTransUp].FileInfo.WavFile);
roryhand 2:957d3b2afff4 951 Sounds[NotchingSet.NotchTransUp].data_sptr = (short*)Sounds[NotchingSet.NotchTransUp].FileInfo.slice_buf;
roryhand 3:6169aeeaeeb4 952
roryhand 2:957d3b2afff4 953 if( ((Sounds[NotchingSet.NotchTransUp].FileInfo.FileData.subchunk2_size) - NotchFadeIn.Length - 2*11025) <= (ftell(Sounds[NotchingSet.NotchTransUp].FileInfo.WavFile) + 44))
roryhand 2:957d3b2afff4 954 //if( (WavInfo_IdleN2.FileData.subchunk2_size)/8 <=ftell(IdleN2Wav) )
roryhand 2:957d3b2afff4 955 {
roryhand 2:957d3b2afff4 956
roryhand 2:957d3b2afff4 957 NotchFadeIn.FadeCoeff = NotchFadeIn.FadeIn();
roryhand 3:6169aeeaeeb4 958
roryhand 2:957d3b2afff4 959 //Read In the next Notch
roryhand 2:957d3b2afff4 960 fread(Sounds[NotchingSet.Notch].FileInfo.slice_buf,Sounds[NotchingSet.Notch].FileInfo.FileFormat.block_align,1,Sounds[NotchingSet.Notch].FileInfo.WavFile);
roryhand 2:957d3b2afff4 961 Sounds[NotchingSet.Notch].data_sptr = (short *)Sounds[NotchingSet.Notch].FileInfo.slice_buf;
roryhand 2:957d3b2afff4 962
roryhand 2:957d3b2afff4 963 if( (ftell(Sounds[NotchingSet.NotchTransUp].FileInfo.WavFile) + 44) >= Sounds[NotchingSet.NotchTransUp].FileInfo.FileData.subchunk2_size ) {
roryhand 3:6169aeeaeeb4 964
roryhand 2:957d3b2afff4 965 //need to explicitly test if this notation/syntax works for pointers....
roryhand 2:957d3b2afff4 966 *Sounds[NotchingSet.Notch].data_sptr = *Sounds[NotchingSet.Notch].data_sptr*NotchFadeIn.FadeCoeff;
roryhand 2:957d3b2afff4 967 } else {
roryhand 2:957d3b2afff4 968 *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 969 }
roryhand 2:957d3b2afff4 970
roryhand 2:957d3b2afff4 971 } else {
roryhand 2:957d3b2afff4 972 *Sounds[NotchingSet.Notch-1].data_sptr = *Sounds[NotchingSet.Notch-1].data_sptr*NotchFadeOut.FadeCoeff + *Sounds[NotchingSet.NotchTransUp].data_sptr;
roryhand 2:957d3b2afff4 973 }
roryhand 2:957d3b2afff4 974
roryhand 1:aac37edee302 975 }
roryhand 1:aac37edee302 976
roryhand 1:aac37edee302 977
roryhand 3:6169aeeaeeb4 978 /********************END OF DATA ASSIGNMENT SECTION*************************************************/
roryhand 9:dd9cae06b202 979
roryhand 2:957d3b2afff4 980 for (channel=0; channel<Sounds[NotchingSet.Notch].FileInfo.FileFormat.num_channels; channel++) {
roryhand 2:957d3b2afff4 981 switch (Sounds[NotchingSet.Notch].FileInfo.FileFormat.sig_bps) {
roryhand 0:e89d7a0bfa3b 982 case 16:
roryhand 1:aac37edee302 983 if(flag1 == 1) {
roryhand 2:957d3b2afff4 984 Buffer1[place_hold1] = Sounds[NotchingSet.Notch].data_sptr[channel];
roryhand 1:aac37edee302 985 place_hold1 = place_hold1 + 1;
roryhand 1:aac37edee302 986 if(place_hold1 >= BufferLen) {
roryhand 1:aac37edee302 987 while(1) {
roryhand 1:aac37edee302 988 if(flag1 == 0) {
roryhand 1:aac37edee302 989 break;
roryhand 1:aac37edee302 990 }//if(flag1 == 0)
roryhand 1:aac37edee302 991
roryhand 1:aac37edee302 992
roryhand 1:aac37edee302 993 }//while(1)
roryhand 1:aac37edee302 994 }//if(place_hold1 > = BufferLen)
roryhand 0:e89d7a0bfa3b 995
roryhand 1:aac37edee302 996 } else if(flag2 == 1) {
roryhand 2:957d3b2afff4 997 Buffer2[place_hold2] = Sounds[NotchingSet.Notch].data_sptr[channel];
roryhand 1:aac37edee302 998 place_hold2 = place_hold2 + 1;
roryhand 1:aac37edee302 999 if(place_hold2 >= BufferLen) {
roryhand 1:aac37edee302 1000 while(1) {
roryhand 1:aac37edee302 1001
roryhand 1:aac37edee302 1002 if(flag2 == 0) {
roryhand 1:aac37edee302 1003 break;
roryhand 1:aac37edee302 1004 }
roryhand 1:aac37edee302 1005 }
roryhand 0:e89d7a0bfa3b 1006 }
roryhand 1:aac37edee302 1007
roryhand 1:aac37edee302 1008 }
roryhand 0:e89d7a0bfa3b 1009 }
roryhand 0:e89d7a0bfa3b 1010 }
roryhand 0:e89d7a0bfa3b 1011 slice = slice + 1;
roryhand 0:e89d7a0bfa3b 1012 }
roryhand 0:e89d7a0bfa3b 1013 }
roryhand 0:e89d7a0bfa3b 1014
roryhand 0:e89d7a0bfa3b 1015
roryhand 0:e89d7a0bfa3b 1016
roryhand 0:e89d7a0bfa3b 1017
roryhand 0:e89d7a0bfa3b 1018
roryhand 0:e89d7a0bfa3b 1019
roryhand 0:e89d7a0bfa3b 1020
roryhand 9:dd9cae06b202 1021