help :(

Dependencies:   FFT

Committer:
dimitryjl23
Date:
Fri Dec 04 17:17:17 2020 +0000
Revision:
10:a259a4a70210
Parent:
9:97abd5e954f1
Child:
11:951bbb0385aa
First Draft;

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