help :(

Dependencies:   FFT

Committer:
dimitryjl23
Date:
Fri Dec 04 18:01:22 2020 +0000
Revision:
11:951bbb0385aa
Parent:
10:a259a4a70210
Final :)

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