old demo that i want to try in mbed studio
Dependencies: mbed SDFileSystem_Copy_of_mbed_version I2S
NotchingDemo.cpp@58:a174e7a8f5f2, 2019-09-27 (annotated)
- Committer:
- roryhand
- Date:
- Fri Sep 27 19:30:06 2019 +0000
- Branch:
- LargeFile_Tests
- Revision:
- 58:a174e7a8f5f2
- Parent:
- 57:0c76b15cabaf
- Child:
- 59:8e7c25a915a0
WIP getting a mad error. Warning L6320W: Ignoring --keep command. Cannot find argument 'os_cb_sections'.
Who changed what in which revision?
User | Revision | Line number | New 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 | 54:606a83fff291 | 14 | //#include "BlockDevice.h" |
roryhand | 37:a563899ac0df | 15 | #include <string> |
roryhand | 0:e89d7a0bfa3b | 16 | #include <stdlib.h> |
roryhand | 27:a378f1f937ee | 17 | #include <fstream> |
roryhand | 27:a378f1f937ee | 18 | #include <iostream> |
roryhand | 0:e89d7a0bfa3b | 19 | #include <vector> |
roryhand | 0:e89d7a0bfa3b | 20 | #include <string> |
roryhand | 0:e89d7a0bfa3b | 21 | #define sample_freq 11025 |
roryhand | 1:aac37edee302 | 22 | #pragma import __use_two_region_memory |
roryhand | 54:606a83fff291 | 23 | //BlockDevice *bd = BlockDevice::get_default_instance(); |
roryhand | 54:606a83fff291 | 24 | //#include "LittleFileSystem.h" |
roryhand | 54:606a83fff291 | 25 | //LittleFileSystem fs("fs"); |
roryhand | 54:606a83fff291 | 26 | |
roryhand | 0:e89d7a0bfa3b | 27 | DigitalOut myled(LED1); |
roryhand | 0:e89d7a0bfa3b | 28 | DigitalOut led2(LED2); |
roryhand | 0:e89d7a0bfa3b | 29 | DigitalOut led3(LED3); |
roryhand | 0:e89d7a0bfa3b | 30 | DigitalIn NotchUp(p16); |
roryhand | 38:3b4c05af5f36 | 31 | DigitalIn NotchDown(p17);//check the pin!!! Dont know if this will actually work... |
roryhand | 0:e89d7a0bfa3b | 32 | InterruptIn Horn(p16); |
roryhand | 0:e89d7a0bfa3b | 33 | Ticker sampletick; |
roryhand | 45:0e8e1f2ec5d2 | 34 | |
roryhand | 0:e89d7a0bfa3b | 35 | Ticker TickFadeOut; |
roryhand | 0:e89d7a0bfa3b | 36 | Timer t; |
roryhand | 0:e89d7a0bfa3b | 37 | Timer t2; |
roryhand | 3:6169aeeaeeb4 | 38 | Timer NotchTimer; |
roryhand | 27:a378f1f937ee | 39 | Timer timer_open; |
roryhand | 0:e89d7a0bfa3b | 40 | |
roryhand | 0:e89d7a0bfa3b | 41 | Serial pc(USBTX, USBRX); // tx, rx //FOR DEBUGGING PROGRAM USING GNU SCREEN |
roryhand | 0:e89d7a0bfa3b | 42 | DigitalOut cs(p8); |
roryhand | 0:e89d7a0bfa3b | 43 | I2S i2s(I2S_TRANSMIT, p5, p6, p7); |
roryhand | 0:e89d7a0bfa3b | 44 | SDFileSystem sd(p11, p12, p13, p8, "sd"); // the new pinout that i am using |
roryhand | 0:e89d7a0bfa3b | 45 | |
roryhand | 0:e89d7a0bfa3b | 46 | |
roryhand | 0:e89d7a0bfa3b | 47 | /*struct A { |
roryhand | 0:e89d7a0bfa3b | 48 | int data; |
roryhand | 0:e89d7a0bfa3b | 49 | B b; |
roryhand | 0:e89d7a0bfa3b | 50 | };*/ |
roryhand | 0:e89d7a0bfa3b | 51 | |
roryhand | 0:e89d7a0bfa3b | 52 | |
roryhand | 0:e89d7a0bfa3b | 53 | |
roryhand | 0:e89d7a0bfa3b | 54 | |
roryhand | 0:e89d7a0bfa3b | 55 | class classFade |
roryhand | 0:e89d7a0bfa3b | 56 | { |
roryhand | 1:aac37edee302 | 57 | public: |
roryhand | 1:aac37edee302 | 58 | |
roryhand | 0:e89d7a0bfa3b | 59 | float powerval; |
roryhand | 0:e89d7a0bfa3b | 60 | float FadeIteration; |
roryhand | 0:e89d7a0bfa3b | 61 | float DecayFactor; |
roryhand | 0:e89d7a0bfa3b | 62 | float Denom; |
roryhand | 0:e89d7a0bfa3b | 63 | float FadeCoeff; |
roryhand | 0:e89d7a0bfa3b | 64 | float Natural_Exp; |
roryhand | 0:e89d7a0bfa3b | 65 | int LengthSecs; |
roryhand | 0:e89d7a0bfa3b | 66 | int Length; |
roryhand | 1:aac37edee302 | 67 | |
roryhand | 0:e89d7a0bfa3b | 68 | //member Functions |
roryhand | 0:e89d7a0bfa3b | 69 | float FadeOut(void) |
roryhand | 0:e89d7a0bfa3b | 70 | { |
roryhand | 0:e89d7a0bfa3b | 71 | powerval = -FadeIteration/Denom; |
roryhand | 1:aac37edee302 | 72 | if (FadeIteration >=Length) { |
roryhand | 1:aac37edee302 | 73 | FadeCoeff = 0; |
roryhand | 1:aac37edee302 | 74 | |
roryhand | 1:aac37edee302 | 75 | } else { |
roryhand | 0:e89d7a0bfa3b | 76 | FadeCoeff = (Length - FadeIteration)/Length; |
roryhand | 0:e89d7a0bfa3b | 77 | } |
roryhand | 1:aac37edee302 | 78 | FadeIteration = FadeIteration + 1; |
roryhand | 1:aac37edee302 | 79 | return FadeCoeff; |
roryhand | 1:aac37edee302 | 80 | |
roryhand | 1:aac37edee302 | 81 | } |
roryhand | 1:aac37edee302 | 82 | float FadeIn(void) |
roryhand | 0:e89d7a0bfa3b | 83 | { |
roryhand | 0:e89d7a0bfa3b | 84 | powerval = FadeIteration/Denom; |
roryhand | 1:aac37edee302 | 85 | if (FadeIteration >=Length) { |
roryhand | 1:aac37edee302 | 86 | FadeCoeff = 1; |
roryhand | 1:aac37edee302 | 87 | |
roryhand | 1:aac37edee302 | 88 | } else { |
roryhand | 0:e89d7a0bfa3b | 89 | FadeCoeff = FadeIteration/Length; |
roryhand | 0:e89d7a0bfa3b | 90 | } |
roryhand | 0:e89d7a0bfa3b | 91 | |
roryhand | 1:aac37edee302 | 92 | FadeIteration = FadeIteration + 1; |
roryhand | 1:aac37edee302 | 93 | return FadeCoeff; |
roryhand | 1:aac37edee302 | 94 | |
roryhand | 1:aac37edee302 | 95 | } |
roryhand | 0:e89d7a0bfa3b | 96 | }; |
roryhand | 0:e89d7a0bfa3b | 97 | |
roryhand | 0:e89d7a0bfa3b | 98 | classFade IdleFadeOut; |
roryhand | 0:e89d7a0bfa3b | 99 | classFade N2FadeIn; |
roryhand | 0:e89d7a0bfa3b | 100 | |
roryhand | 2:957d3b2afff4 | 101 | classFade NotchFadeOut; |
roryhand | 2:957d3b2afff4 | 102 | classFade NotchFadeIn; |
roryhand | 2:957d3b2afff4 | 103 | |
roryhand | 0:e89d7a0bfa3b | 104 | |
roryhand | 0:e89d7a0bfa3b | 105 | |
roryhand | 0:e89d7a0bfa3b | 106 | |
roryhand | 0:e89d7a0bfa3b | 107 | |
roryhand | 1:aac37edee302 | 108 | typedef struct uFMT_STRUCT { |
roryhand | 1:aac37edee302 | 109 | short comp_code; |
roryhand | 1:aac37edee302 | 110 | short num_channels; |
roryhand | 1:aac37edee302 | 111 | unsigned sample_rate; |
roryhand | 1:aac37edee302 | 112 | unsigned avg_Bps; |
roryhand | 1:aac37edee302 | 113 | short block_align; |
roryhand | 1:aac37edee302 | 114 | short sig_bps; |
roryhand | 0:e89d7a0bfa3b | 115 | } FMT_STRUCT; |
roryhand | 0:e89d7a0bfa3b | 116 | |
roryhand | 1:aac37edee302 | 117 | typedef struct uNotch_STRUCT { |
roryhand | 1:aac37edee302 | 118 | short Notch; |
roryhand | 1:aac37edee302 | 119 | short NotchTransUp; |
roryhand | 1:aac37edee302 | 120 | short NotchTransDown; |
roryhand | 1:aac37edee302 | 121 | short NotchDirection; |
roryhand | 1:aac37edee302 | 122 | } Notch_STRUCT; |
roryhand | 1:aac37edee302 | 123 | |
roryhand | 0:e89d7a0bfa3b | 124 | typedef struct uDATA_STRUCT { |
roryhand | 1:aac37edee302 | 125 | unsigned subchunk2_ID; |
roryhand | 1:aac37edee302 | 126 | unsigned subchunk2_size; |
roryhand | 1:aac37edee302 | 127 | char * data_buf; |
roryhand | 1:aac37edee302 | 128 | } DATA_STRUCT; |
roryhand | 0:e89d7a0bfa3b | 129 | |
roryhand | 1:aac37edee302 | 130 | typedef struct uWAV_FILE_STRUCT { |
roryhand | 1:aac37edee302 | 131 | FILE *WavFile; |
roryhand | 1:aac37edee302 | 132 | int id_number; |
roryhand | 1:aac37edee302 | 133 | char *slice_buf; |
roryhand | 1:aac37edee302 | 134 | int num_slices; |
roryhand | 1:aac37edee302 | 135 | FMT_STRUCT FileFormat; |
roryhand | 1:aac37edee302 | 136 | DATA_STRUCT FileData; |
roryhand | 0:e89d7a0bfa3b | 137 | } WAV_FILE_STRUCT; |
roryhand | 0:e89d7a0bfa3b | 138 | |
roryhand | 0:e89d7a0bfa3b | 139 | /*typedef struct uWAV_FILE_STRUCT{ |
roryhand | 1:aac37edee302 | 140 | FILE* WavFile; |
roryhand | 1:aac37edee302 | 141 | |
roryhand | 1:aac37edee302 | 142 | |
roryhand | 0:e89d7a0bfa3b | 143 | }WAV_FILE_STRUCT;*/ |
roryhand | 58:a174e7a8f5f2 | 144 | class classPositionIndicators |
roryhand | 57:0c76b15cabaf | 145 | { |
roryhand | 57:0c76b15cabaf | 146 | public: |
roryhand | 57:0c76b15cabaf | 147 | int notch1_indicator, notch2_indicator, notch3_indicator, notch4_indicator; |
roryhand | 57:0c76b15cabaf | 148 | int notch5_indicator, notch6_indicator, notch7_indicator, notch8_indicator; |
roryhand | 57:0c76b15cabaf | 149 | int notch1_start_pt, notch2_start_pt, notch3_start_pt, notch4_start_pt; |
roryhand | 57:0c76b15cabaf | 150 | int notch5_start_pt, notch6_start_pt, notch7_start_pt, notch8_start_pt; |
roryhand | 58:a174e7a8f5f2 | 151 | classPositionIndicators() |
roryhand | 57:0c76b15cabaf | 152 | { |
roryhand | 57:0c76b15cabaf | 153 | notch1_start_pt = 44; |
roryhand | 57:0c76b15cabaf | 154 | notch2_start_pt = 220884+44; |
roryhand | 57:0c76b15cabaf | 155 | notch3_start_pt = notch2_start_pt+217698; |
roryhand | 57:0c76b15cabaf | 156 | notch4_start_pt = notch3_start_pt + 193060; |
roryhand | 57:0c76b15cabaf | 157 | notch5_start_pt = notch4_start_pt + 92010; |
roryhand | 57:0c76b15cabaf | 158 | notch6_start_pt = notch5_start_pt + 216642; |
roryhand | 57:0c76b15cabaf | 159 | notch7_start_pt = notch6_start_pt + 250316; |
roryhand | 57:0c76b15cabaf | 160 | notch8_start_pt = notch7_start_pt + 165084; |
roryhand | 57:0c76b15cabaf | 161 | notch1_indicator = notch1_start_pt; |
roryhand | 57:0c76b15cabaf | 162 | notch2_indicator = notch2_start_pt; |
roryhand | 57:0c76b15cabaf | 163 | notch3_indicator = notch3_start_pt; |
roryhand | 57:0c76b15cabaf | 164 | notch4_indicator = notch4_start_pt; |
roryhand | 57:0c76b15cabaf | 165 | notch5_indicator = notch5_start_pt; |
roryhand | 57:0c76b15cabaf | 166 | notch6_indicator = notch6_start_pt; |
roryhand | 57:0c76b15cabaf | 167 | notch7_indicator = notch7_start_pt; |
roryhand | 57:0c76b15cabaf | 168 | notch8_indicator = notch8_start_pt; |
roryhand | 57:0c76b15cabaf | 169 | |
roryhand | 57:0c76b15cabaf | 170 | } |
roryhand | 57:0c76b15cabaf | 171 | }; |
roryhand | 57:0c76b15cabaf | 172 | |
roryhand | 57:0c76b15cabaf | 173 | |
roryhand | 57:0c76b15cabaf | 174 | |
roryhand | 57:0c76b15cabaf | 175 | |
roryhand | 0:e89d7a0bfa3b | 176 | class classSoundFile |
roryhand | 0:e89d7a0bfa3b | 177 | { |
roryhand | 1:aac37edee302 | 178 | public: |
roryhand | 1:aac37edee302 | 179 | |
roryhand | 44:a9e84d333a6a | 180 | //add a class constructor at some point in the future (perform tests in visual studio) |
roryhand | 1:aac37edee302 | 181 | WAV_FILE_STRUCT FileInfo; |
roryhand | 2:957d3b2afff4 | 182 | short * data_sptr; |
roryhand | 36:569ec4335f92 | 183 | string file_location; |
roryhand | 1:aac37edee302 | 184 | //classSoundFile(string filename);//this is the constructor |
roryhand | 1:aac37edee302 | 185 | //string filename; |
roryhand | 0:e89d7a0bfa3b | 186 | }; |
roryhand | 0:e89d7a0bfa3b | 187 | |
roryhand | 1:aac37edee302 | 188 | //class constructor; |
roryhand | 1:aac37edee302 | 189 | /*classSoundFile::classSoundFile(string filename) |
roryhand | 1:aac37edee302 | 190 | { |
roryhand | 1:aac37edee302 | 191 | //Declare RootFolder and the directory for the appropriate file. |
roryhand | 1:aac37edee302 | 192 | //How we index into filename[] from the outside of this class is another |
roryhand | 1:aac37edee302 | 193 | //issue... |
roryhand | 1:aac37edee302 | 194 | FileInfo.WavFile = fopen("/sd/mydir/645Engine/Startup.wav","rb"); |
roryhand | 1:aac37edee302 | 195 | fseek(FileInfo.WavFile,20,SEEK_SET); |
roryhand | 1:aac37edee302 | 196 | fread(&FileInfo.FileFormat,sizeof(FileInfo.FileFormat),1,FileInfo.WavFile); |
roryhand | 1:aac37edee302 | 197 | printf("wav_format.sample_rate: %d\n\r",FileInfo.FileFormat.sample_rate); |
roryhand | 1:aac37edee302 | 198 | fread(&FileInfo.FileData,sizeof(FileInfo.FileData),1,FileInfo.WavFile); |
roryhand | 1:aac37edee302 | 199 | printf("wav_data.subchunk2_size: %d\n\r",FileInfo.FileData.subchunk2_size); |
roryhand | 1:aac37edee302 | 200 | FileInfo.slice_buf = ( char *)malloc(FileInfo.FileFormat.block_align); |
roryhand | 1:aac37edee302 | 201 | fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,FileInfo.WavFile); //This isnt actually required, its just a test |
roryhand | 1:aac37edee302 | 202 | FileInfo.num_slices = FileInfo.FileData.subchunk2_size/FileInfo.FileFormat.block_align; |
roryhand | 1:aac37edee302 | 203 | }*/ |
roryhand | 54:606a83fff291 | 204 | int OneOff = 0; |
roryhand | 38:3b4c05af5f36 | 205 | int notch_flag = 0; |
roryhand | 0:e89d7a0bfa3b | 206 | int i = 0; |
roryhand | 0:e89d7a0bfa3b | 207 | int h = 0; |
roryhand | 0:e89d7a0bfa3b | 208 | short bufflen = 1; |
roryhand | 0:e89d7a0bfa3b | 209 | int buffer[1]; |
roryhand | 1:aac37edee302 | 210 | int AudioFormat, NumChannels, SampleRate, BitsPerSample ; |
roryhand | 0:e89d7a0bfa3b | 211 | char *slice_buf; |
roryhand | 0:e89d7a0bfa3b | 212 | short *data_sptr; |
roryhand | 0:e89d7a0bfa3b | 213 | short *data_sptr_horn; |
roryhand | 0:e89d7a0bfa3b | 214 | short *data_sptr_IdleN2; |
roryhand | 0:e89d7a0bfa3b | 215 | short * data_sptr_bell; |
roryhand | 0:e89d7a0bfa3b | 216 | short * data_sptr_N2; |
roryhand | 0:e89d7a0bfa3b | 217 | short * data_sptr_Flange; |
roryhand | 0:e89d7a0bfa3b | 218 | unsigned char *data_bptr; |
roryhand | 0:e89d7a0bfa3b | 219 | int *data_wptr; |
roryhand | 0:e89d7a0bfa3b | 220 | unsigned channel; |
roryhand | 45:0e8e1f2ec5d2 | 221 | long slice, slice1, slice2, slice3, num_slices; |
roryhand | 0:e89d7a0bfa3b | 222 | int verbosity = 0; |
roryhand | 0:e89d7a0bfa3b | 223 | int verbosity2 = 0; |
roryhand | 0:e89d7a0bfa3b | 224 | int verbosity3 = 0; |
roryhand | 0:e89d7a0bfa3b | 225 | int verbosity4 = 0; |
roryhand | 0:e89d7a0bfa3b | 226 | int verbosity5 = 0; |
roryhand | 0:e89d7a0bfa3b | 227 | int interrupt_condition = 1; |
roryhand | 0:e89d7a0bfa3b | 228 | int sampling_freq = 11025; |
roryhand | 0:e89d7a0bfa3b | 229 | const int BufferLen = 2000; |
roryhand | 0:e89d7a0bfa3b | 230 | short Buffer1[BufferLen]; |
roryhand | 0:e89d7a0bfa3b | 231 | short Buffer2[BufferLen]; |
roryhand | 0:e89d7a0bfa3b | 232 | short place_hold1 = 0; |
roryhand | 0:e89d7a0bfa3b | 233 | short place_hold2 = 0; |
roryhand | 0:e89d7a0bfa3b | 234 | |
roryhand | 3:6169aeeaeeb4 | 235 | |
roryhand | 3:6169aeeaeeb4 | 236 | string FOLDER; |
roryhand | 3:6169aeeaeeb4 | 237 | string RootFolder = "/sd/mydir/SoundDecoder/"; |
roryhand | 3:6169aeeaeeb4 | 238 | string filename[25]; |
roryhand | 3:6169aeeaeeb4 | 239 | classSoundFile Sound[22]; |
roryhand | 3:6169aeeaeeb4 | 240 | |
roryhand | 0:e89d7a0bfa3b | 241 | volatile int flag1 = 1; |
roryhand | 0:e89d7a0bfa3b | 242 | volatile int flag2 = 0; |
roryhand | 0:e89d7a0bfa3b | 243 | volatile int flag3 = 1; |
roryhand | 0:e89d7a0bfa3b | 244 | volatile int flag4 = 0; |
roryhand | 0:e89d7a0bfa3b | 245 | int FLAGBUFF1 = 0; |
roryhand | 0:e89d7a0bfa3b | 246 | int FLAGBUFF2 = 0; |
roryhand | 0:e89d7a0bfa3b | 247 | int BellFlag = 0; |
roryhand | 0:e89d7a0bfa3b | 248 | int BellFlag2 = 0; |
roryhand | 0:e89d7a0bfa3b | 249 | int FadeFlag = 0; |
roryhand | 54:606a83fff291 | 250 | int BlockFlag = 0; |
roryhand | 32:6ee488c97dcc | 251 | int FileSwitchFlag = 0; |
roryhand | 0:e89d7a0bfa3b | 252 | |
roryhand | 0:e89d7a0bfa3b | 253 | |
roryhand | 0:e89d7a0bfa3b | 254 | short value[1]; |
roryhand | 0:e89d7a0bfa3b | 255 | FILE *HornWav; |
roryhand | 0:e89d7a0bfa3b | 256 | FILE *edsheeran_wav; |
roryhand | 0:e89d7a0bfa3b | 257 | FILE *Startup_wav; |
roryhand | 0:e89d7a0bfa3b | 258 | FILE *IdleN2Wav; |
roryhand | 0:e89d7a0bfa3b | 259 | FILE *N2Wav; |
roryhand | 0:e89d7a0bfa3b | 260 | FILE *BellWav; |
roryhand | 0:e89d7a0bfa3b | 261 | FILE *FlangeWav; |
roryhand | 16:5e3420d0509b | 262 | FILE *HeyWav; |
roryhand | 0:e89d7a0bfa3b | 263 | //long long slice_value; |
roryhand | 0:e89d7a0bfa3b | 264 | int slice_value[1]; |
roryhand | 0:e89d7a0bfa3b | 265 | |
roryhand | 0:e89d7a0bfa3b | 266 | |
roryhand | 45:0e8e1f2ec5d2 | 267 | FILE *wavfile1; |
roryhand | 45:0e8e1f2ec5d2 | 268 | FILE *wavfile2; |
roryhand | 45:0e8e1f2ec5d2 | 269 | FILE *wavfile3; |
roryhand | 45:0e8e1f2ec5d2 | 270 | |
roryhand | 45:0e8e1f2ec5d2 | 271 | classSoundFile Sound1; |
roryhand | 45:0e8e1f2ec5d2 | 272 | classSoundFile Sound2; |
roryhand | 45:0e8e1f2ec5d2 | 273 | classSoundFile Sound3; |
roryhand | 45:0e8e1f2ec5d2 | 274 | |
roryhand | 0:e89d7a0bfa3b | 275 | WAV_FILE_STRUCT WavInfo_Horn; |
roryhand | 0:e89d7a0bfa3b | 276 | WAV_FILE_STRUCT WavInfo_IdleN2; |
roryhand | 0:e89d7a0bfa3b | 277 | WAV_FILE_STRUCT WavInfo_N2; |
roryhand | 0:e89d7a0bfa3b | 278 | WAV_FILE_STRUCT WavInfo_Bell; |
roryhand | 0:e89d7a0bfa3b | 279 | WAV_FILE_STRUCT WavInfo_Flange; |
roryhand | 20:9cc7d825c07b | 280 | WAV_FILE_STRUCT WavInfo_Hey; |
roryhand | 32:6ee488c97dcc | 281 | WAV_FILE_STRUCT WavInfo_N3; |
roryhand | 16:5e3420d0509b | 282 | WAV_FILE_STRUCT WavInfo_Frustration; |
roryhand | 0:e89d7a0bfa3b | 283 | Ticker flipper; |
roryhand | 0:e89d7a0bfa3b | 284 | char * slice_buf_bell; |
roryhand | 0:e89d7a0bfa3b | 285 | char * slice_buf_ed; |
roryhand | 0:e89d7a0bfa3b | 286 | char * slice_buf_startup; |
roryhand | 0:e89d7a0bfa3b | 287 | char * slice_buf_N2; |
roryhand | 1:aac37edee302 | 288 | Notch_STRUCT NotchingSet; |
roryhand | 0:e89d7a0bfa3b | 289 | //test |
roryhand | 0:e89d7a0bfa3b | 290 | //short *data_sptr_bell = 0; |
roryhand | 0:e89d7a0bfa3b | 291 | short *data_sptr_ed = 0; |
roryhand | 0:e89d7a0bfa3b | 292 | short *data_sptr_startup = 0; |
roryhand | 32:6ee488c97dcc | 293 | FILE *StartupWav; |
roryhand | 32:6ee488c97dcc | 294 | FILE *N3Wav; |
roryhand | 33:a75f0a30fbdc | 295 | int temp = 0; |
roryhand | 1:aac37edee302 | 296 | void flip() |
roryhand | 1:aac37edee302 | 297 | { |
roryhand | 0:e89d7a0bfa3b | 298 | led2 = !led2; |
roryhand | 0:e89d7a0bfa3b | 299 | } |
roryhand | 0:e89d7a0bfa3b | 300 | |
roryhand | 0:e89d7a0bfa3b | 301 | |
roryhand | 0:e89d7a0bfa3b | 302 | void isr() |
roryhand | 0:e89d7a0bfa3b | 303 | { |
roryhand | 54:606a83fff291 | 304 | //timer_interrupt.start(); |
roryhand | 1:aac37edee302 | 305 | if(flag1 == 0) { |
roryhand | 0:e89d7a0bfa3b | 306 | value[0] = Buffer1[place_hold1]>>4; |
roryhand | 0:e89d7a0bfa3b | 307 | i2s.write(value,1);//Send next PWM value to amp |
roryhand | 0:e89d7a0bfa3b | 308 | place_hold1 = place_hold1 + 1; |
roryhand | 1:aac37edee302 | 309 | if( (place_hold1 >= BufferLen)) { |
roryhand | 0:e89d7a0bfa3b | 310 | led2 = !led2; |
roryhand | 0:e89d7a0bfa3b | 311 | place_hold1 = 0; |
roryhand | 0:e89d7a0bfa3b | 312 | place_hold2 = 0; |
roryhand | 0:e89d7a0bfa3b | 313 | flag1 = 1; |
roryhand | 0:e89d7a0bfa3b | 314 | flag2 = 0; |
roryhand | 1:aac37edee302 | 315 | } |
roryhand | 1:aac37edee302 | 316 | } else if(flag2 == 0) { |
roryhand | 0:e89d7a0bfa3b | 317 | value[0] = Buffer2[place_hold2]>>4; |
roryhand | 0:e89d7a0bfa3b | 318 | i2s.write(value,1);//Send next PWM value to amp |
roryhand | 0:e89d7a0bfa3b | 319 | place_hold2 = place_hold2 + 1; |
roryhand | 1:aac37edee302 | 320 | if( (place_hold2 >= BufferLen) ) { |
roryhand | 0:e89d7a0bfa3b | 321 | led2 = !led2; |
roryhand | 0:e89d7a0bfa3b | 322 | place_hold1 = 0; |
roryhand | 0:e89d7a0bfa3b | 323 | place_hold2 = 0; |
roryhand | 0:e89d7a0bfa3b | 324 | flag1 = 0; |
roryhand | 1:aac37edee302 | 325 | flag2 = 1; |
roryhand | 0:e89d7a0bfa3b | 326 | FLAGBUFF2 = 0; |
roryhand | 1:aac37edee302 | 327 | } |
roryhand | 0:e89d7a0bfa3b | 328 | } |
roryhand | 54:606a83fff291 | 329 | |
roryhand | 54:606a83fff291 | 330 | //timer_interrupt.stop(); |
roryhand | 54:606a83fff291 | 331 | |
roryhand | 0:e89d7a0bfa3b | 332 | } |
roryhand | 1:aac37edee302 | 333 | |
roryhand | 0:e89d7a0bfa3b | 334 | void horn_sound() |
roryhand | 0:e89d7a0bfa3b | 335 | { |
roryhand | 0:e89d7a0bfa3b | 336 | BellFlag = 1; |
roryhand | 0:e89d7a0bfa3b | 337 | fseek(HornWav,44,SEEK_SET); |
roryhand | 0:e89d7a0bfa3b | 338 | fseek(BellWav,44,SEEK_SET); |
roryhand | 0:e89d7a0bfa3b | 339 | fseek(FlangeWav,44,SEEK_SET); |
roryhand | 0:e89d7a0bfa3b | 340 | fseek(N2Wav,44,SEEK_SET); |
roryhand | 0:e89d7a0bfa3b | 341 | } |
roryhand | 0:e89d7a0bfa3b | 342 | |
roryhand | 0:e89d7a0bfa3b | 343 | |
roryhand | 32:6ee488c97dcc | 344 | void FileSwitch_isr() |
roryhand | 0:e89d7a0bfa3b | 345 | { |
roryhand | 32:6ee488c97dcc | 346 | FileSwitchFlag = 1; |
roryhand | 33:a75f0a30fbdc | 347 | temp = 1; |
roryhand | 33:a75f0a30fbdc | 348 | /*FILE* testwav = fopen("/sd/mydir/SoundDecoder_second/05.wav","rb"); |
roryhand | 33:a75f0a30fbdc | 349 | if(N3Wav == NULL) { |
roryhand | 33:a75f0a30fbdc | 350 | printf("Cannot Open testwav\n\r"); |
roryhand | 33:a75f0a30fbdc | 351 | } |
roryhand | 33:a75f0a30fbdc | 352 | */ |
roryhand | 32:6ee488c97dcc | 353 | fseek(N3Wav,44,SEEK_SET); |
roryhand | 32:6ee488c97dcc | 354 | // fclose(StartupWav); |
roryhand | 0:e89d7a0bfa3b | 355 | } |
roryhand | 0:e89d7a0bfa3b | 356 | |
roryhand | 0:e89d7a0bfa3b | 357 | |
roryhand | 0:e89d7a0bfa3b | 358 | void FadeOutIsr() |
roryhand | 0:e89d7a0bfa3b | 359 | { |
roryhand | 1:aac37edee302 | 360 | FadeFlag = 1; |
roryhand | 54:606a83fff291 | 361 | OneOff = 1; |
roryhand | 54:606a83fff291 | 362 | /* |
roryhand | 54:606a83fff291 | 363 | wavfile2 = fopen("/sd/mydir/SoundDecoder_second/09.wav","rb"); |
roryhand | 54:606a83fff291 | 364 | if(wavfile2 == NULL) { |
roryhand | 54:606a83fff291 | 365 | printf("Cannot Open wavfile2\n\r"); |
roryhand | 54:606a83fff291 | 366 | } |
roryhand | 54:606a83fff291 | 367 | */ |
roryhand | 54:606a83fff291 | 368 | |
roryhand | 54:606a83fff291 | 369 | |
roryhand | 54:606a83fff291 | 370 | |
roryhand | 54:606a83fff291 | 371 | /* |
roryhand | 54:606a83fff291 | 372 | wavfile3 = fopen("/sd/mydir/SoundDecoder_second/02.wav","rb"); |
roryhand | 54:606a83fff291 | 373 | if(wavfile3 == NULL) { |
roryhand | 54:606a83fff291 | 374 | printf("Cannot Open wavfile3\n\r"); |
roryhand | 54:606a83fff291 | 375 | } |
roryhand | 54:606a83fff291 | 376 | */ |
roryhand | 54:606a83fff291 | 377 | /* |
roryhand | 54:606a83fff291 | 378 | FILE* wavfile4 = fopen("/sd/mydir/SoundDecoder_second/04.wav","rb"); |
roryhand | 54:606a83fff291 | 379 | if(wavfile4 == NULL) { |
roryhand | 54:606a83fff291 | 380 | printf("Cannot Open wavfile3\n\r"); |
roryhand | 54:606a83fff291 | 381 | } |
roryhand | 54:606a83fff291 | 382 | */ |
roryhand | 54:606a83fff291 | 383 | //fseek(wavfile2,44,SEEK_SET); |
roryhand | 54:606a83fff291 | 384 | //fseek(wavfile3,44,SEEK_SET); |
roryhand | 54:606a83fff291 | 385 | slice2 = 0; |
roryhand | 54:606a83fff291 | 386 | slice3 = 0; |
roryhand | 54:606a83fff291 | 387 | BlockFlag = 1; |
roryhand | 47:9334a8f54997 | 388 | //printf("We are inside the FadeOut interrupt routine\n\r"); |
roryhand | 1:aac37edee302 | 389 | |
roryhand | 0:e89d7a0bfa3b | 390 | } |
roryhand | 38:3b4c05af5f36 | 391 | |
roryhand | 38:3b4c05af5f36 | 392 | |
roryhand | 38:3b4c05af5f36 | 393 | |
roryhand | 38:3b4c05af5f36 | 394 | |
roryhand | 0:e89d7a0bfa3b | 395 | |
roryhand | 3:6169aeeaeeb4 | 396 | classFade FadeDataInitialise(classFade FadeData); |
roryhand | 3:6169aeeaeeb4 | 397 | |
roryhand | 3:6169aeeaeeb4 | 398 | |
roryhand | 3:6169aeeaeeb4 | 399 | |
roryhand | 3:6169aeeaeeb4 | 400 | |
roryhand | 3:6169aeeaeeb4 | 401 | |
roryhand | 3:6169aeeaeeb4 | 402 | //function prototypes |
roryhand | 45:0e8e1f2ec5d2 | 403 | classSoundFile ReadFileInfo(classSoundFile Sound, FILE * wav_file); |
roryhand | 3:6169aeeaeeb4 | 404 | classSoundFile LoadFileStream(classSoundFile FileInfo, string filename); |
roryhand | 3:6169aeeaeeb4 | 405 | |
roryhand | 3:6169aeeaeeb4 | 406 | float FadeOut(void); |
roryhand | 3:6169aeeaeeb4 | 407 | void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo); |
roryhand | 32:6ee488c97dcc | 408 | void Play_WaveFileDual(FILE * my_wav, WAV_FILE_STRUCT FileInfo); |
roryhand | 3:6169aeeaeeb4 | 409 | //void Play_WaveFileLoop(FILE * my_wav, WAV_FILE_STRUCT FileInfo); |
roryhand | 3:6169aeeaeeb4 | 410 | //*********************INTERRUPT ROUTINE FOR NOTCHING*************************** |
roryhand | 0:e89d7a0bfa3b | 411 | |
roryhand | 1:aac37edee302 | 412 | void NotchUpIsr() |
roryhand | 0:e89d7a0bfa3b | 413 | { |
roryhand | 1:aac37edee302 | 414 | if(1 <= NotchingSet.Notch < 8) { |
roryhand | 1:aac37edee302 | 415 | |
roryhand | 1:aac37edee302 | 416 | NotchingSet.Notch = NotchingSet.Notch + 1; |
roryhand | 1:aac37edee302 | 417 | NotchingSet.NotchTransUp = NotchingSet.Notch + 7; |
roryhand | 1:aac37edee302 | 418 | NotchingSet.NotchDirection = 1; |
roryhand | 3:6169aeeaeeb4 | 419 | FadeDataInitialise(NotchFadeIn); |
roryhand | 3:6169aeeaeeb4 | 420 | FadeDataInitialise(NotchFadeOut); |
roryhand | 1:aac37edee302 | 421 | } |
roryhand | 0:e89d7a0bfa3b | 422 | } |
roryhand | 0:e89d7a0bfa3b | 423 | |
roryhand | 0:e89d7a0bfa3b | 424 | void NotchDownIsr() |
roryhand | 0:e89d7a0bfa3b | 425 | { |
roryhand | 1:aac37edee302 | 426 | if(1 < NotchingSet.Notch <= 8) { |
roryhand | 1:aac37edee302 | 427 | NotchingSet.Notch = NotchingSet.Notch - 1; |
roryhand | 1:aac37edee302 | 428 | NotchingSet.NotchTransDown = NotchingSet.Notch + 15;; |
roryhand | 1:aac37edee302 | 429 | NotchingSet.NotchDirection = 0; |
roryhand | 3:6169aeeaeeb4 | 430 | FadeDataInitialise(NotchFadeIn); |
roryhand | 3:6169aeeaeeb4 | 431 | FadeDataInitialise(NotchFadeOut); |
roryhand | 1:aac37edee302 | 432 | } |
roryhand | 1:aac37edee302 | 433 | } |
roryhand | 0:e89d7a0bfa3b | 434 | |
roryhand | 0:e89d7a0bfa3b | 435 | |
roryhand | 3:6169aeeaeeb4 | 436 | /**********************END OF INTERRUPT ROUTINE FOR NOTCHING*******************/ |
roryhand | 3:6169aeeaeeb4 | 437 | |
roryhand | 3:6169aeeaeeb4 | 438 | |
roryhand | 1:aac37edee302 | 439 | |
roryhand | 0:e89d7a0bfa3b | 440 | |
roryhand | 3:6169aeeaeeb4 | 441 | |
roryhand | 3:6169aeeaeeb4 | 442 | |
roryhand | 58:a174e7a8f5f2 | 443 | void Play_WaveFileLoop(classSoundFile Sound1, FILE* wavfile1,classPositionIndicators Positions); |
roryhand | 1:aac37edee302 | 444 | int main() |
roryhand | 1:aac37edee302 | 445 | { |
roryhand | 44:a9e84d333a6a | 446 | |
roryhand | 0:e89d7a0bfa3b | 447 | NotchUp.mode(PullUp); |
roryhand | 38:3b4c05af5f36 | 448 | NotchDown.mode(PullUp); |
roryhand | 0:e89d7a0bfa3b | 449 | |
roryhand | 0:e89d7a0bfa3b | 450 | pc.printf("Beginning of program\n"); |
roryhand | 32:6ee488c97dcc | 451 | |
roryhand | 13:8e93396a27c5 | 452 | |
roryhand | 13:8e93396a27c5 | 453 | |
roryhand | 4:55fbbb049bae | 454 | |
roryhand | 25:5336e1cf38d6 | 455 | printf("Do we even get to this stupid bloody point\n\r"); |
roryhand | 0:e89d7a0bfa3b | 456 | //Populate our class instances with some data (is there an implicit way to do this?) |
roryhand | 28:6b2353fad12d | 457 | |
roryhand | 1:aac37edee302 | 458 | |
roryhand | 3:6169aeeaeeb4 | 459 | printf("hello\n\r"); |
roryhand | 0:e89d7a0bfa3b | 460 | //Set up the wolfson Audio Codec board |
roryhand | 0:e89d7a0bfa3b | 461 | wm8731_Config_setup(); |
roryhand | 0:e89d7a0bfa3b | 462 | //i2s audio data transfer code?? |
roryhand | 0:e89d7a0bfa3b | 463 | i2s.stereomono(I2S_STEREO); |
roryhand | 0:e89d7a0bfa3b | 464 | i2s.masterslave(I2S_MASTER); |
roryhand | 0:e89d7a0bfa3b | 465 | led3 = 1; |
roryhand | 0:e89d7a0bfa3b | 466 | led2 = 1; |
roryhand | 45:0e8e1f2ec5d2 | 467 | printf("Hello i2s has started!"); |
roryhand | 30:4a8e80b243c4 | 468 | i2s.start(); |
roryhand | 0:e89d7a0bfa3b | 469 | sampletick.attach(&isr,1.0/sampling_freq); //1/16000 |
roryhand | 45:0e8e1f2ec5d2 | 470 | //fileswitch_tick.attach(&FileSwitch_isr,6.0);//So we can switch between playing file 1 and file 2, including opening and closing |
roryhand | 45:0e8e1f2ec5d2 | 471 | //not convinced we need this above line at the moment!! |
roryhand | 54:606a83fff291 | 472 | |
roryhand | 54:606a83fff291 | 473 | |
roryhand | 54:606a83fff291 | 474 | |
roryhand | 54:606a83fff291 | 475 | |
roryhand | 57:0c76b15cabaf | 476 | |
roryhand | 13:8e93396a27c5 | 477 | |
roryhand | 57:0c76b15cabaf | 478 | |
roryhand | 45:0e8e1f2ec5d2 | 479 | |
roryhand | 45:0e8e1f2ec5d2 | 480 | |
roryhand | 45:0e8e1f2ec5d2 | 481 | |
roryhand | 45:0e8e1f2ec5d2 | 482 | TickFadeOut.attach(&FadeOutIsr,10.0); |
roryhand | 45:0e8e1f2ec5d2 | 483 | |
roryhand | 58:a174e7a8f5f2 | 484 | classPositionIndicators Positions; |
roryhand | 58:a174e7a8f5f2 | 485 | slice1 = 0; |
roryhand | 58:a174e7a8f5f2 | 486 | FILE* wavfile1 = fopen("/sd/mydir/SoundDecoder_second/All_eight_notches.wav","rb"); |
roryhand | 58:a174e7a8f5f2 | 487 | classSoundFile Sound1; |
roryhand | 58:a174e7a8f5f2 | 488 | Sound1 = ReadFileInfo(Sound1, wavfile1); |
roryhand | 20:9cc7d825c07b | 489 | printf("about to play wav file\n\r"); |
roryhand | 58:a174e7a8f5f2 | 490 | //Play_WaveFileLoop(Sound1,wavfile1,Positions); |
roryhand | 20:9cc7d825c07b | 491 | printf("finished playing Wav file\n\r"); |
roryhand | 54:606a83fff291 | 492 | |
roryhand | 54:606a83fff291 | 493 | |
roryhand | 31:0f8c3adf09c3 | 494 | timer_open.reset(); |
roryhand | 31:0f8c3adf09c3 | 495 | timer_open.start(); |
roryhand | 45:0e8e1f2ec5d2 | 496 | fclose(wavfile1); |
roryhand | 31:0f8c3adf09c3 | 497 | timer_open.stop(); |
roryhand | 31:0f8c3adf09c3 | 498 | printf("It took %d useconds to close file\n\r",timer_open.read_us()); |
roryhand | 54:606a83fff291 | 499 | |
roryhand | 54:606a83fff291 | 500 | |
roryhand | 54:606a83fff291 | 501 | |
roryhand | 54:606a83fff291 | 502 | |
roryhand | 9:dd9cae06b202 | 503 | /************************************PLAY WAV FILE LOOP*******************/ |
roryhand | 9:dd9cae06b202 | 504 | /************************************END OF PLAY WAV FILE LOOP*************/ |
roryhand | 13:8e93396a27c5 | 505 | |
roryhand | 13:8e93396a27c5 | 506 | |
roryhand | 1:aac37edee302 | 507 | i2s.stop(); |
roryhand | 0:e89d7a0bfa3b | 508 | |
roryhand | 0:e89d7a0bfa3b | 509 | } |
roryhand | 0:e89d7a0bfa3b | 510 | |
roryhand | 0:e89d7a0bfa3b | 511 | |
roryhand | 3:6169aeeaeeb4 | 512 | |
roryhand | 3:6169aeeaeeb4 | 513 | |
roryhand | 3:6169aeeaeeb4 | 514 | |
roryhand | 3:6169aeeaeeb4 | 515 | |
roryhand | 45:0e8e1f2ec5d2 | 516 | classSoundFile ReadFileInfo(classSoundFile Sound, FILE * wav_file) |
roryhand | 0:e89d7a0bfa3b | 517 | { |
roryhand | 0:e89d7a0bfa3b | 518 | fseek(wav_file,20,SEEK_SET); |
roryhand | 22:706e86dc0d45 | 519 | printf("We have just seeked through this file\n\r"); |
roryhand | 45:0e8e1f2ec5d2 | 520 | fread(&Sound.FileInfo.FileFormat,sizeof(Sound.FileInfo.FileFormat),1,wav_file); |
roryhand | 1:aac37edee302 | 521 | //printf("wav_format.sample_rate: %d\n\r",FileInfo.FileFormat.sample_rate); |
roryhand | 1:aac37edee302 | 522 | |
roryhand | 45:0e8e1f2ec5d2 | 523 | fread(&Sound.FileInfo.FileData,sizeof(Sound.FileInfo.FileData),1,wav_file); |
roryhand | 55:5a441d3b0d57 | 524 | printf("wav_data.subchunk2_size: %d\n\r",Sound.FileInfo.FileData.subchunk2_size); |
roryhand | 45:0e8e1f2ec5d2 | 525 | Sound.FileInfo.slice_buf = ( char *)malloc(Sound.FileInfo.FileFormat.block_align); |
roryhand | 45:0e8e1f2ec5d2 | 526 | fread(Sound.FileInfo.slice_buf,Sound.FileInfo.FileFormat.block_align,1,wav_file); //This isnt actually required, its just a test |
roryhand | 45:0e8e1f2ec5d2 | 527 | Sound.FileInfo.num_slices = Sound.FileInfo.FileData.subchunk2_size/Sound.FileInfo.FileFormat.block_align; |
roryhand | 1:aac37edee302 | 528 | //printf("Number of Slices: %d\n\r",FileInfo.num_slices); |
roryhand | 45:0e8e1f2ec5d2 | 529 | return Sound; |
roryhand | 0:e89d7a0bfa3b | 530 | } |
roryhand | 1:aac37edee302 | 531 | |
roryhand | 1:aac37edee302 | 532 | |
roryhand | 1:aac37edee302 | 533 | |
roryhand | 1:aac37edee302 | 534 | |
roryhand | 1:aac37edee302 | 535 | |
roryhand | 0:e89d7a0bfa3b | 536 | |
roryhand | 0:e89d7a0bfa3b | 537 | void Play_WaveFile(FILE * my_wav, WAV_FILE_STRUCT FileInfo) |
roryhand | 0:e89d7a0bfa3b | 538 | { |
roryhand | 1:aac37edee302 | 539 | while(slice<FileInfo.num_slices) { |
roryhand | 1:aac37edee302 | 540 | fread(FileInfo.slice_buf,FileInfo.FileFormat.block_align,1,my_wav); |
roryhand | 1:aac37edee302 | 541 | data_sptr=(short *)FileInfo.slice_buf; // 16 bit samples |
roryhand | 1:aac37edee302 | 542 | for (channel=0; channel<FileInfo.FileFormat.num_channels; channel++) { |
roryhand | 1:aac37edee302 | 543 | if(flag1 == 1) { |
roryhand | 1:aac37edee302 | 544 | Buffer1[place_hold1] = data_sptr[channel]; |
roryhand | 1:aac37edee302 | 545 | place_hold1 = place_hold1 + 1; |
roryhand | 1:aac37edee302 | 546 | if(place_hold1 >= BufferLen) { |
roryhand | 1:aac37edee302 | 547 | while(1) { |
roryhand | 1:aac37edee302 | 548 | if(flag1 == 0) { |
roryhand | 0:e89d7a0bfa3b | 549 | |
roryhand | 1:aac37edee302 | 550 | break; |
roryhand | 0:e89d7a0bfa3b | 551 | } |
roryhand | 1:aac37edee302 | 552 | |
roryhand | 0:e89d7a0bfa3b | 553 | } |
roryhand | 1:aac37edee302 | 554 | } |
roryhand | 1:aac37edee302 | 555 | |
roryhand | 1:aac37edee302 | 556 | } else if(flag2 == 1) { |
roryhand | 1:aac37edee302 | 557 | Buffer2[place_hold2] = data_sptr[channel]; |
roryhand | 1:aac37edee302 | 558 | place_hold2 = place_hold2 + 1; |
roryhand | 1:aac37edee302 | 559 | if(place_hold2 >= BufferLen) { |
roryhand | 1:aac37edee302 | 560 | |
roryhand | 1:aac37edee302 | 561 | while(1) { |
roryhand | 1:aac37edee302 | 562 | if(flag2 == 0) { |
roryhand | 1:aac37edee302 | 563 | |
roryhand | 1:aac37edee302 | 564 | break; |
roryhand | 1:aac37edee302 | 565 | } |
roryhand | 0:e89d7a0bfa3b | 566 | } |
roryhand | 1:aac37edee302 | 567 | } |
roryhand | 0:e89d7a0bfa3b | 568 | } |
roryhand | 1:aac37edee302 | 569 | |
roryhand | 1:aac37edee302 | 570 | } |
roryhand | 1:aac37edee302 | 571 | slice = slice + 1; |
roryhand | 0:e89d7a0bfa3b | 572 | } |
roryhand | 0:e89d7a0bfa3b | 573 | } |
roryhand | 0:e89d7a0bfa3b | 574 | |
roryhand | 0:e89d7a0bfa3b | 575 | |
roryhand | 0:e89d7a0bfa3b | 576 | |
roryhand | 0:e89d7a0bfa3b | 577 | |
roryhand | 38:3b4c05af5f36 | 578 | //***************************************************************************// |
roryhand | 38:3b4c05af5f36 | 579 | |
roryhand | 38:3b4c05af5f36 | 580 | //**************************************************************************// |
roryhand | 38:3b4c05af5f36 | 581 | |
roryhand | 38:3b4c05af5f36 | 582 | |
roryhand | 38:3b4c05af5f36 | 583 | |
roryhand | 38:3b4c05af5f36 | 584 | |
roryhand | 38:3b4c05af5f36 | 585 | |
roryhand | 58:a174e7a8f5f2 | 586 | /* |
roryhand | 44:a9e84d333a6a | 587 | |
roryhand | 57:0c76b15cabaf | 588 | void Play_WaveFileLoop(classSoundFile Sound1, FILE *wavfile1, classPositionIndicators Positions) |
roryhand | 45:0e8e1f2ec5d2 | 589 | { |
roryhand | 45:0e8e1f2ec5d2 | 590 | while(1) { //might have to change this to a while(1) loop? |
roryhand | 44:a9e84d333a6a | 591 | |
roryhand | 2:957d3b2afff4 | 592 | |
roryhand | 44:a9e84d333a6a | 593 | |
roryhand | 44:a9e84d333a6a | 594 | |
roryhand | 54:606a83fff291 | 595 | |
roryhand | 44:a9e84d333a6a | 596 | //Sound1======================================================================================= |
roryhand | 58:a174e7a8f5f2 | 597 | if( slice1 == (Positions.notch2_start_pt) ) { |
roryhand | 44:a9e84d333a6a | 598 | slice1 = 0; |
roryhand | 58:a174e7a8f5f2 | 599 | fseek(wavfile1,Positions.notch1_start_pt,SEEK_SET); |
roryhand | 2:957d3b2afff4 | 600 | } |
roryhand | 57:0c76b15cabaf | 601 | |
roryhand | 44:a9e84d333a6a | 602 | fread(Sound1.FileInfo.slice_buf,Sound1.FileInfo.FileFormat.block_align,1,wavfile1); |
roryhand | 44:a9e84d333a6a | 603 | Sound1.data_sptr=(short *)Sound1.FileInfo.slice_buf; // 16 bit samples |
roryhand | 44:a9e84d333a6a | 604 | //============================================================================================= |
roryhand | 44:a9e84d333a6a | 605 | |
roryhand | 58:a174e7a8f5f2 | 606 | |
roryhand | 1:aac37edee302 | 607 | |
roryhand | 1:aac37edee302 | 608 | |
roryhand | 44:a9e84d333a6a | 609 | |
roryhand | 45:0e8e1f2ec5d2 | 610 | for (channel=0; channel<Sound1.FileInfo.FileFormat.num_channels; channel++) { |
roryhand | 45:0e8e1f2ec5d2 | 611 | switch (Sound1.FileInfo.FileFormat.sig_bps) { |
roryhand | 0:e89d7a0bfa3b | 612 | case 16: |
roryhand | 1:aac37edee302 | 613 | if(flag1 == 1) { |
roryhand | 45:0e8e1f2ec5d2 | 614 | Buffer1[place_hold1] = Sound1.data_sptr[channel]; |
roryhand | 1:aac37edee302 | 615 | place_hold1 = place_hold1 + 1; |
roryhand | 1:aac37edee302 | 616 | if(place_hold1 >= BufferLen) { |
roryhand | 1:aac37edee302 | 617 | while(1) { |
roryhand | 1:aac37edee302 | 618 | if(flag1 == 0) { |
roryhand | 1:aac37edee302 | 619 | break; |
roryhand | 1:aac37edee302 | 620 | }//if(flag1 == 0) |
roryhand | 1:aac37edee302 | 621 | |
roryhand | 1:aac37edee302 | 622 | |
roryhand | 1:aac37edee302 | 623 | }//while(1) |
roryhand | 1:aac37edee302 | 624 | }//if(place_hold1 > = BufferLen) |
roryhand | 0:e89d7a0bfa3b | 625 | |
roryhand | 1:aac37edee302 | 626 | } else if(flag2 == 1) { |
roryhand | 45:0e8e1f2ec5d2 | 627 | Buffer2[place_hold2] = Sound1.data_sptr[channel]; |
roryhand | 1:aac37edee302 | 628 | place_hold2 = place_hold2 + 1; |
roryhand | 1:aac37edee302 | 629 | if(place_hold2 >= BufferLen) { |
roryhand | 1:aac37edee302 | 630 | while(1) { |
roryhand | 1:aac37edee302 | 631 | |
roryhand | 1:aac37edee302 | 632 | if(flag2 == 0) { |
roryhand | 1:aac37edee302 | 633 | break; |
roryhand | 1:aac37edee302 | 634 | } |
roryhand | 1:aac37edee302 | 635 | } |
roryhand | 0:e89d7a0bfa3b | 636 | } |
roryhand | 1:aac37edee302 | 637 | |
roryhand | 1:aac37edee302 | 638 | } |
roryhand | 0:e89d7a0bfa3b | 639 | } |
roryhand | 0:e89d7a0bfa3b | 640 | } |
roryhand | 45:0e8e1f2ec5d2 | 641 | slice1 = slice1 + 1; |
roryhand | 45:0e8e1f2ec5d2 | 642 | slice2 = slice2 + 1; |
roryhand | 45:0e8e1f2ec5d2 | 643 | slice3 = slice3 + 1; |
roryhand | 0:e89d7a0bfa3b | 644 | } |
roryhand | 0:e89d7a0bfa3b | 645 | } |
roryhand | 0:e89d7a0bfa3b | 646 | |
roryhand | 58:a174e7a8f5f2 | 647 | */ |
roryhand | 0:e89d7a0bfa3b | 648 | |
roryhand | 0:e89d7a0bfa3b | 649 | |
roryhand | 0:e89d7a0bfa3b | 650 | |
roryhand | 0:e89d7a0bfa3b | 651 | |
roryhand | 0:e89d7a0bfa3b | 652 | |
roryhand | 0:e89d7a0bfa3b | 653 |