help :(

Dependencies:   FFT

Committer:
shyamgatech
Date:
Thu Dec 03 15:50:45 2020 +0000
Revision:
6:d311a95f1e9b
Parent:
5:598d94b45bad
Parent:
3:3dbf078989b1
Child:
7:0d62545e6d73
a

Who changed what in which revision?

UserRevisionLine numberNew contents of line
annieluo2 0:d6c9b09b4042 1 #include "mbed.h"
annieluo2 0:d6c9b09b4042 2 #include "SDFileSystem.h"
annieluo2 0:d6c9b09b4042 3 #include "wave_player.h"
annieluo2 0:d6c9b09b4042 4 #include "Adafruit_LEDBackpack.h"
annieluo2 0:d6c9b09b4042 5 #include "Adafruit_GFX.h"
annieluo2 0:d6c9b09b4042 6 #include "rtos.h"
annieluo2 0:d6c9b09b4042 7 #include "FFT.h"
shyamgatech 5:598d94b45bad 8 #include <string>
annieluo2 0:d6c9b09b4042 9
annieluo2 0:d6c9b09b4042 10 SDFileSystem sd(p5, p6, p7, p8, "sd"); // SD card
annieluo2 0:d6c9b09b4042 11
shyamgatech 5:598d94b45bad 12 I2C i2c(p28, p27); // LED display
annieluo2 0:d6c9b09b4042 13 Adafruit_8x8matrix matrix = Adafruit_8x8matrix(&i2c);
annieluo2 0:d6c9b09b4042 14
annieluo2 0:d6c9b09b4042 15 AnalogOut DACout(p18); // speaker
annieluo2 0:d6c9b09b4042 16 wave_player waver(&DACout);
annieluo2 0:d6c9b09b4042 17 Mutex speaker_lock;
dimitryjl23 2:a6e81c45ef48 18 DigitalOut myled(LED1); // mbed LED
dimitryjl23 2:a6e81c45ef48 19 Serial pc (USBTX,USBRX);
shyamgatech 5:598d94b45bad 20 string dir; // "/sd/" + song + ".wav"
shyamgatech 5:598d94b45bad 21 string song;
shyamgatech 5:598d94b45bad 22 bool play;
annieluo2 0:d6c9b09b4042 23
shyamgatech 6:d311a95f1e9b 24 <<<<<<< working copy
dimitryjl23 2:a6e81c45ef48 25 #define BUFFER_SIZE 50
annieluo2 0:d6c9b09b4042 26
annieluo2 1:5dd6801bb0d6 27 // delete later
dimitryjl23 2:a6e81c45ef48 28 /*int sample[12][8] = {
shyamgatech 5:598d94b45bad 29 34085,32666,29810,29823,27514,24175,24468,32559,
shyamgatech 5:598d94b45bad 30 36401,33075,29037,21933,20189,21751,20975,20087,
shyamgatech 5:598d94b45bad 31 17530,27723,30891,21128,19982,15446,12413,13597,
shyamgatech 5:598d94b45bad 32 15776,14233,15622,16334,15485,17136,16389,17954,
shyamgatech 5:598d94b45bad 33 20349,18486,23377,34447,34400,34681,33107,31171,
shyamgatech 5:598d94b45bad 34 30007,33640,37007,38136,39187,38169,51831,52041,
shyamgatech 5:598d94b45bad 35 47831,48634,44189,43878,44743,46468,43170,47172,
shyamgatech 5:598d94b45bad 36 53518,52294,54825,51992,49619,48147,47901,48413,
shyamgatech 5:598d94b45bad 37 46049,49090,47590,46154,45423,41223,41782,54695,
shyamgatech 5:598d94b45bad 38 57452,51210,52462,59096,56711,52268,49364,42865,
shyamgatech 5:598d94b45bad 39 41483,37964,39215,35908,31570,28332,24492,23121,
annieluo2 1:5dd6801bb0d6 40 22874,18154,15541,15263,12463,12198,13301,9951
dimitryjl23 2:a6e81c45ef48 41 };*/
shyamgatech 6:d311a95f1e9b 42 =======
annieluo2 3:3dbf078989b1 43 #define BUFFER_SIZE 64
shyamgatech 6:d311a95f1e9b 44 >>>>>>> merge rev
annieluo2 1:5dd6801bb0d6 45
annieluo2 1:5dd6801bb0d6 46 // states for display output
shyamgatech 5:598d94b45bad 47 const int on[8][8] = {
shyamgatech 5:598d94b45bad 48 1, 1, 1, 1, 1, 1, 1, 1,
shyamgatech 5:598d94b45bad 49 1, 1, 1, 1, 1, 1, 1, 1,
shyamgatech 5:598d94b45bad 50 1, 1, 1, 1, 1, 1, 1, 1,
shyamgatech 5:598d94b45bad 51 1, 1, 1, 1, 1, 1, 1, 1,
shyamgatech 5:598d94b45bad 52 1, 1, 1, 1, 1, 1, 1, 1,
shyamgatech 5:598d94b45bad 53 1, 1, 1, 1, 1, 1, 1, 1,
shyamgatech 5:598d94b45bad 54 1, 1, 1, 1, 1, 1, 1, 1,
shyamgatech 5:598d94b45bad 55 1, 1, 1, 1, 1, 1, 1, 1
shyamgatech 5:598d94b45bad 56 };
annieluo2 1:5dd6801bb0d6 57
shyamgatech 5:598d94b45bad 58 const int high[8][8] = {
shyamgatech 5:598d94b45bad 59 0, 0, 0, 1, 1, 0, 0, 0,
shyamgatech 5:598d94b45bad 60 0, 0, 0, 1, 1, 0, 0, 0,
shyamgatech 5:598d94b45bad 61 0, 0, 1, 1, 1, 1, 0, 0,
shyamgatech 5:598d94b45bad 62 0, 1, 1, 1, 1, 1, 1, 0,
shyamgatech 5:598d94b45bad 63 0, 1, 1, 1, 1, 1, 1, 0,
shyamgatech 5:598d94b45bad 64 1, 1, 1, 1, 1, 1, 1, 1,
shyamgatech 5:598d94b45bad 65 1, 1, 1, 1, 1, 1, 1, 1,
shyamgatech 5:598d94b45bad 66 1, 1, 1, 1, 1, 1, 1, 1
shyamgatech 5:598d94b45bad 67 };
annieluo2 1:5dd6801bb0d6 68
shyamgatech 5:598d94b45bad 69 const int med[8][8] = {
shyamgatech 5:598d94b45bad 70 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 71 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 72 0, 0, 0, 1, 1, 0, 0, 0,
shyamgatech 5:598d94b45bad 73 0, 0, 1, 1, 1, 1, 0, 0,
shyamgatech 5:598d94b45bad 74 0, 0, 1, 1, 1, 1, 0, 0,
shyamgatech 5:598d94b45bad 75 0, 1, 1, 1, 1, 1, 1, 0,
shyamgatech 5:598d94b45bad 76 1, 1, 1, 1, 1, 1, 1, 1,
shyamgatech 5:598d94b45bad 77 1, 1, 1, 1, 1, 1, 1, 1
shyamgatech 5:598d94b45bad 78 };
annieluo2 1:5dd6801bb0d6 79
shyamgatech 5:598d94b45bad 80 const int low[8][8] = {
shyamgatech 5:598d94b45bad 81 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 82 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 83 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 84 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 85 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 86 0, 0, 1, 1, 1, 1, 0, 0,
shyamgatech 5:598d94b45bad 87 0, 1, 1, 1, 1, 1, 1, 0,
shyamgatech 5:598d94b45bad 88 1, 1, 1, 1, 1, 1, 1, 1
shyamgatech 5:598d94b45bad 89 };
annieluo2 1:5dd6801bb0d6 90
shyamgatech 5:598d94b45bad 91 const int off[8][8] = {
shyamgatech 5:598d94b45bad 92 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 93 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 94 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 95 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 96 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 97 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 98 0, 0, 0, 0, 0, 0, 0, 0,
shyamgatech 5:598d94b45bad 99 0, 0, 0, 0, 0, 0, 0, 0
shyamgatech 5:598d94b45bad 100 };
annieluo2 1:5dd6801bb0d6 101
dimitryjl23 2:a6e81c45ef48 102
dimitryjl23 2:a6e81c45ef48 103
shyamgatech 6:d311a95f1e9b 104 <<<<<<< working copy
shyamgatech 5:598d94b45bad 105 void display_fft(int sample[])
shyamgatech 5:598d94b45bad 106 {
shyamgatech 5:598d94b45bad 107
shyamgatech 6:d311a95f1e9b 108 =======
annieluo2 3:3dbf078989b1 109 void display_fft(float sample[]) {
annieluo2 1:5dd6801bb0d6 110
shyamgatech 6:d311a95f1e9b 111 >>>>>>> merge rev
annieluo2 1:5dd6801bb0d6 112 int state = 0;
annieluo2 3:3dbf078989b1 113 float freq = 0;
annieluo2 1:5dd6801bb0d6 114 matrix.begin(0x70);
shyamgatech 6:d311a95f1e9b 115 <<<<<<< working copy
shyamgatech 5:598d94b45bad 116
shyamgatech 5:598d94b45bad 117 for (int a = 0; a < 50; a++) {
shyamgatech 5:598d94b45bad 118
shyamgatech 5:598d94b45bad 119 freq = sample[a];
shyamgatech 5:598d94b45bad 120
shyamgatech 6:d311a95f1e9b 121 =======
annieluo2 1:5dd6801bb0d6 122
annieluo2 3:3dbf078989b1 123 int s = sizeof(sample);
annieluo2 3:3dbf078989b1 124
annieluo2 3:3dbf078989b1 125 pc.printf("%d\n", s);
annieluo2 3:3dbf078989b1 126
annieluo2 3:3dbf078989b1 127 for (int a = 0; a < 64; a++) {
dimitryjl23 2:a6e81c45ef48 128
annieluo2 3:3dbf078989b1 129 freq = sample[a];
annieluo2 3:3dbf078989b1 130
annieluo2 3:3dbf078989b1 131 pc.printf("%d\n",freq);
annieluo2 1:5dd6801bb0d6 132
shyamgatech 6:d311a95f1e9b 133 >>>>>>> merge rev
annieluo2 1:5dd6801bb0d6 134 // determine state based on the FFT output range
annieluo2 3:3dbf078989b1 135 if (freq < 10000) {
annieluo2 1:5dd6801bb0d6 136 state = 5; // OFF
annieluo2 1:5dd6801bb0d6 137 } else if (freq >= 10000 && freq < 25000) {
annieluo2 1:5dd6801bb0d6 138 state = 4; // LOW
annieluo2 1:5dd6801bb0d6 139 } else if (freq >= 25000 && freq < 40000) {
annieluo2 1:5dd6801bb0d6 140 state = 3; // MED
annieluo2 1:5dd6801bb0d6 141 } else if (freq >= 40000 && freq < 55000) {
annieluo2 1:5dd6801bb0d6 142 state = 2; // HIGH
annieluo2 1:5dd6801bb0d6 143 } else if (freq >= 55000) {
shyamgatech 6:d311a95f1e9b 144 <<<<<<< working copy
annieluo2 1:5dd6801bb0d6 145 state = 1; // ON
shyamgatech 5:598d94b45bad 146 }
shyamgatech 5:598d94b45bad 147
shyamgatech 6:d311a95f1e9b 148 =======
annieluo2 3:3dbf078989b1 149 state = 1; // HIGHEST
annieluo2 1:5dd6801bb0d6 150 }
annieluo2 1:5dd6801bb0d6 151
shyamgatech 6:d311a95f1e9b 152 >>>>>>> merge rev
annieluo2 1:5dd6801bb0d6 153 // switch statement based on the state
annieluo2 1:5dd6801bb0d6 154 switch (state) {
annieluo2 1:5dd6801bb0d6 155 case(1): // CASE HIGHEST
annieluo2 1:5dd6801bb0d6 156 matrix.clear();
annieluo2 1:5dd6801bb0d6 157 for (int i = 0; i < 8; i++) {
annieluo2 1:5dd6801bb0d6 158 for (int j = 0; j < 8; j++) {
annieluo2 1:5dd6801bb0d6 159 if (on[i][j] == 1) {
annieluo2 1:5dd6801bb0d6 160 matrix.drawPixel(i, j, LED_ON);
annieluo2 1:5dd6801bb0d6 161 }
annieluo2 1:5dd6801bb0d6 162 }
annieluo2 1:5dd6801bb0d6 163 }
annieluo2 1:5dd6801bb0d6 164 matrix.writeDisplay();
annieluo2 1:5dd6801bb0d6 165 wait(1);
annieluo2 1:5dd6801bb0d6 166 break;
shyamgatech 5:598d94b45bad 167
annieluo2 1:5dd6801bb0d6 168 case(2): // CASE HIGH
annieluo2 1:5dd6801bb0d6 169 matrix.clear();
annieluo2 1:5dd6801bb0d6 170 for (int i = 0; i < 8; i++) {
annieluo2 1:5dd6801bb0d6 171 for (int j = 0; j < 8; j++) {
annieluo2 1:5dd6801bb0d6 172 if (high[i][j] == 1) {
annieluo2 1:5dd6801bb0d6 173 matrix.drawPixel(i, j, LED_ON);
annieluo2 1:5dd6801bb0d6 174 }
annieluo2 1:5dd6801bb0d6 175 }
annieluo2 1:5dd6801bb0d6 176 }
annieluo2 1:5dd6801bb0d6 177 matrix.writeDisplay();
annieluo2 1:5dd6801bb0d6 178 wait(1);
shyamgatech 5:598d94b45bad 179
annieluo2 1:5dd6801bb0d6 180 case(3): // CASE MEDIUM
annieluo2 1:5dd6801bb0d6 181 matrix.clear();
annieluo2 1:5dd6801bb0d6 182 for (int i = 0; i < 8; i++) {
annieluo2 1:5dd6801bb0d6 183 for (int j = 0; j < 8; j++) {
annieluo2 1:5dd6801bb0d6 184 if (med[i][j] == 1) {
shyamgatech 5:598d94b45bad 185 matrix.drawPixel(i, j, LED_ON);
annieluo2 1:5dd6801bb0d6 186 }
annieluo2 1:5dd6801bb0d6 187 }
annieluo2 1:5dd6801bb0d6 188 }
annieluo2 1:5dd6801bb0d6 189 matrix.writeDisplay();
annieluo2 1:5dd6801bb0d6 190 wait(1);
annieluo2 1:5dd6801bb0d6 191 break;
shyamgatech 5:598d94b45bad 192
annieluo2 1:5dd6801bb0d6 193 case(4): // CASE LOW
annieluo2 1:5dd6801bb0d6 194 matrix.clear();
annieluo2 1:5dd6801bb0d6 195 for (int i = 0; i < 8; i++) {
annieluo2 1:5dd6801bb0d6 196 for (int j = 0; j < 8; j++) {
annieluo2 1:5dd6801bb0d6 197 if (low[i][j] == 1) {
annieluo2 1:5dd6801bb0d6 198 matrix.drawPixel(i, j, LED_ON);
annieluo2 1:5dd6801bb0d6 199 }
annieluo2 1:5dd6801bb0d6 200 }
annieluo2 1:5dd6801bb0d6 201 }
annieluo2 1:5dd6801bb0d6 202 matrix.writeDisplay();
annieluo2 1:5dd6801bb0d6 203 wait(1);
annieluo2 1:5dd6801bb0d6 204 break;
shyamgatech 5:598d94b45bad 205
annieluo2 1:5dd6801bb0d6 206 case(5): // CASE OFF
annieluo2 1:5dd6801bb0d6 207 matrix.clear();
annieluo2 1:5dd6801bb0d6 208 for (int i = 0; i < 8; i++) {
annieluo2 1:5dd6801bb0d6 209 for (int j = 0; j < 8; j++) {
annieluo2 1:5dd6801bb0d6 210 if (off[i][j] == 1) {
annieluo2 1:5dd6801bb0d6 211 matrix.drawPixel(i, j, LED_ON);
annieluo2 1:5dd6801bb0d6 212 }
annieluo2 1:5dd6801bb0d6 213 }
annieluo2 1:5dd6801bb0d6 214 }
annieluo2 1:5dd6801bb0d6 215 matrix.writeDisplay();
annieluo2 1:5dd6801bb0d6 216 wait(1);
annieluo2 1:5dd6801bb0d6 217 break;
shyamgatech 5:598d94b45bad 218
annieluo2 1:5dd6801bb0d6 219 default:
annieluo2 1:5dd6801bb0d6 220 break;
annieluo2 1:5dd6801bb0d6 221 }
shyamgatech 6:d311a95f1e9b 222 <<<<<<< working copy
shyamgatech 5:598d94b45bad 223
shyamgatech 5:598d94b45bad 224
shyamgatech 5:598d94b45bad 225 }
shyamgatech 5:598d94b45bad 226
shyamgatech 6:d311a95f1e9b 227 =======
annieluo2 3:3dbf078989b1 228
annieluo2 3:3dbf078989b1 229 pc.printf("done");
dimitryjl23 2:a6e81c45ef48 230
shyamgatech 6:d311a95f1e9b 231 >>>>>>> merge rev
dimitryjl23 2:a6e81c45ef48 232 }
dimitryjl23 2:a6e81c45ef48 233
dimitryjl23 2:a6e81c45ef48 234 //Reads SD card and passes value to frequency display
dimitryjl23 2:a6e81c45ef48 235 void display_thread(void const* args)
dimitryjl23 2:a6e81c45ef48 236 {
dimitryjl23 2:a6e81c45ef48 237 FILE *fp = fopen("/sd/africa-toto-array.txt","r");
dimitryjl23 2:a6e81c45ef48 238 if(fp == NULL) {
dimitryjl23 2:a6e81c45ef48 239 pc.printf("Error opening file\n");
dimitryjl23 2:a6e81c45ef48 240 return;
annieluo2 0:d6c9b09b4042 241 }
shyamgatech 6:d311a95f1e9b 242 <<<<<<< working copy
shyamgatech 5:598d94b45bad 243
dimitryjl23 2:a6e81c45ef48 244 int buffer[BUFFER_SIZE];
shyamgatech 6:d311a95f1e9b 245 =======
dimitryjl23 2:a6e81c45ef48 246
annieluo2 3:3dbf078989b1 247 float buffer[BUFFER_SIZE];
shyamgatech 6:d311a95f1e9b 248 >>>>>>> merge rev
dimitryjl23 2:a6e81c45ef48 249 int buffer_index = 0;
dimitryjl23 2:a6e81c45ef48 250 int value;
shyamgatech 6:d311a95f1e9b 251 <<<<<<< working copy
dimitryjl23 2:a6e81c45ef48 252 pc.printf("Thread start\n");
shyamgatech 5:598d94b45bad 253 while(fscanf(fp,"%d,",&value) == 1) {
shyamgatech 5:598d94b45bad 254 buffer[buffer_index] = value;
shyamgatech 5:598d94b45bad 255 buffer_index++;
shyamgatech 5:598d94b45bad 256 pc.printf("%d\n",value);
shyamgatech 5:598d94b45bad 257 buffer_index++;
shyamgatech 5:598d94b45bad 258 if(buffer_index == BUFFER_SIZE) {
shyamgatech 5:598d94b45bad 259 //fast fourier tranform function here
shyamgatech 5:598d94b45bad 260 display_fft(buffer);
shyamgatech 5:598d94b45bad 261 buffer_index = 0;
shyamgatech 5:598d94b45bad 262 memset(buffer,0,sizeof(buffer));
shyamgatech 5:598d94b45bad 263
shyamgatech 5:598d94b45bad 264 }
shyamgatech 6:d311a95f1e9b 265 =======
annieluo2 3:3dbf078989b1 266
dimitryjl23 2:a6e81c45ef48 267 while(fscanf(fp,"%d,",&value) == 1){
annieluo2 3:3dbf078989b1 268 buffer[buffer_index] = (float)value;
dimitryjl23 2:a6e81c45ef48 269 buffer_index++;
annieluo2 3:3dbf078989b1 270 //pc.printf("%d\n",value);
annieluo2 3:3dbf078989b1 271 //buffer_index++;
dimitryjl23 2:a6e81c45ef48 272 if(buffer_index == BUFFER_SIZE)
dimitryjl23 2:a6e81c45ef48 273 {
dimitryjl23 2:a6e81c45ef48 274 //fast fourier tranform function here
annieluo2 3:3dbf078989b1 275 vRealFFT(buffer, 64);
dimitryjl23 2:a6e81c45ef48 276 display_fft(buffer);
dimitryjl23 2:a6e81c45ef48 277 buffer_index = 0;
dimitryjl23 2:a6e81c45ef48 278 memset(buffer,0,sizeof(buffer));
dimitryjl23 2:a6e81c45ef48 279
dimitryjl23 2:a6e81c45ef48 280 }
shyamgatech 6:d311a95f1e9b 281 >>>>>>> merge rev
dimitryjl23 2:a6e81c45ef48 282 }
shyamgatech 5:598d94b45bad 283
dimitryjl23 2:a6e81c45ef48 284 fclose(fp);
annieluo2 0:d6c9b09b4042 285 }
annieluo2 0:d6c9b09b4042 286
annieluo2 0:d6c9b09b4042 287 void speaker_thread(void const* args)
annieluo2 0:d6c9b09b4042 288 {
shyamgatech 5:598d94b45bad 289 while(1) {
annieluo2 1:5dd6801bb0d6 290 // check helper function for new song in GUI
annieluo2 0:d6c9b09b4042 291 // grab file here and put together string
annieluo2 0:d6c9b09b4042 292 // string song_title = "/sd/" + "" + ".wav";
shyamgatech 5:598d94b45bad 293
shyamgatech 5:598d94b45bad 294
dimitryjl23 2:a6e81c45ef48 295 /*
annieluo2 0:d6c9b09b4042 296 FILE *wave_file;
shyamgatech 5:598d94b45bad 297 dir = "/sd/" + song + ".wav";
shyamgatech 5:598d94b45bad 298 wave_file=fopen(dir.c_str(),"r");
shyamgatech 5:598d94b45bad 299
annieluo2 0:d6c9b09b4042 300 speaker_lock.lock();
shyamgatech 5:598d94b45bad 301 if (play)
shyamgatech 5:598d94b45bad 302 {
shyamgatech 5:598d94b45bad 303 waver.play(wave_file);
shyamgatech 5:598d94b45bad 304 }
annieluo2 0:d6c9b09b4042 305 speaker_lock.unlock();
annieluo2 0:d6c9b09b4042 306 fclose(wave_file);
annieluo2 0:d6c9b09b4042 307 Thread::wait(100);
dimitryjl23 2:a6e81c45ef48 308 */
annieluo2 0:d6c9b09b4042 309 }
annieluo2 0:d6c9b09b4042 310 }
shyamgatech 5:598d94b45bad 311
annieluo2 0:d6c9b09b4042 312
annieluo2 0:d6c9b09b4042 313 int main()
annieluo2 0:d6c9b09b4042 314 {
shyamgatech 5:598d94b45bad 315
annieluo2 0:d6c9b09b4042 316 Thread th1(speaker_thread);
annieluo2 1:5dd6801bb0d6 317 Thread th2(display_thread);
shyamgatech 5:598d94b45bad 318 char c;
annieluo2 0:d6c9b09b4042 319 while(1) {
annieluo2 1:5dd6801bb0d6 320 myled = 1;
annieluo2 1:5dd6801bb0d6 321 wait(0.2);
annieluo2 1:5dd6801bb0d6 322 myled = 0;
annieluo2 1:5dd6801bb0d6 323 wait(0.2);
shyamgatech 5:598d94b45bad 324 while(!pc.readable()) {
shyamgatech 5:598d94b45bad 325 Thread::wait(1);
shyamgatech 5:598d94b45bad 326 }
shyamgatech 5:598d94b45bad 327 if (pc.getc() == '!') {
shyamgatech 5:598d94b45bad 328 c = pc.getc();
shyamgatech 5:598d94b45bad 329 switch(c) {
shyamgatech 5:598d94b45bad 330 case '1':
shyamgatech 5:598d94b45bad 331 song = "africa-toto";
shyamgatech 5:598d94b45bad 332 break;
shyamgatech 5:598d94b45bad 333 case '2':
shyamgatech 5:598d94b45bad 334 song = "around_the_world-atc";
shyamgatech 5:598d94b45bad 335 break;
shyamgatech 5:598d94b45bad 336 case '3':
shyamgatech 5:598d94b45bad 337 song = "beautiful_life-ace_of_base";
shyamgatech 5:598d94b45bad 338 break;
shyamgatech 5:598d94b45bad 339 case '4':
shyamgatech 5:598d94b45bad 340 song = "dont_speak-no_doubt";
shyamgatech 5:598d94b45bad 341 break;
shyamgatech 5:598d94b45bad 342 case '5':
shyamgatech 5:598d94b45bad 343 song = "my-love";
shyamgatech 5:598d94b45bad 344 break;
shyamgatech 5:598d94b45bad 345 case '6':
shyamgatech 5:598d94b45bad 346 song = "Song1_test";
shyamgatech 5:598d94b45bad 347 break;
shyamgatech 5:598d94b45bad 348 case 'P':
shyamgatech 5:598d94b45bad 349 // wave_player plays
shyamgatech 5:598d94b45bad 350 play = true;
shyamgatech 5:598d94b45bad 351 break;
shyamgatech 5:598d94b45bad 352 case 'S':
shyamgatech 5:598d94b45bad 353 // wave_player stops
shyamgatech 5:598d94b45bad 354 play = false;
shyamgatech 5:598d94b45bad 355 break;
shyamgatech 5:598d94b45bad 356 default:
shyamgatech 5:598d94b45bad 357 break;
shyamgatech 5:598d94b45bad 358 }
shyamgatech 5:598d94b45bad 359 }
annieluo2 0:d6c9b09b4042 360 Thread::wait(100);
annieluo2 0:d6c9b09b4042 361 }
shyamgatech 5:598d94b45bad 362
annieluo2 0:d6c9b09b4042 363 }