Sound update

Dependencies:   4DGL-uLCD-SE Physac-MBED PinDetect SDFileSystem mbed-rtos mbed

Revision:
28:bccd14334bb9
Parent:
27:a09981ebd532
Child:
29:431e5788a313
diff -r a09981ebd532 -r bccd14334bb9 main.cpp
--- a/main.cpp	Thu Dec 08 18:42:16 2022 +0000
+++ b/main.cpp	Fri Dec 09 20:29:08 2022 +0000
@@ -10,6 +10,10 @@
 #include "uLCD_4DGL.h"
 
 
+#include "cylonbyc.h"
+
+#define sample_freq 11025.0
+
 
 ///////////////////////////
 // GLOBALS.H DEFINITIONS //
@@ -35,7 +39,10 @@
 PwmOut Rgb(p23);
 PwmOut rGb(p24);
 PwmOut rgB(p25);
-Speaker DACout(p18);
+
+Ticker sampletick;
+AnalogOut speaker(p18);
+//Speaker DACout(p18);
 //wave_player waver(&DACout);
 
 
@@ -54,82 +61,109 @@
 //////////////////////
 // MAIN.CPP THREADS //
 //////////////////////
+int i = 0;
+int j = 0;
+int k = 0;
+void audio_sample ()
+{
+    if (game1) {
+        speaker.write_u16(tetris[i]);
+        i++;
+    }
+    if (game2) {
+        speaker.write_u16(air_hockey[j]);
+        j++;
+    }
+    if (!game1 && !game2) {
+        speaker.write_u16(mii_menu[k]);
+        k++;
+    }
+    if (k>= NUM_ELEMENTS) {
+        k = 0;
+    }
+    if (i>= 72584) {
+        i = 0;
+    }
+    if (j>= 72488) {
+        j = 0;
+    }
+}
 
 void audioThread()
 {
     while (true) {
         //FILE *wave_file;
         while (game1 == false && game2 == false) {
-            DACout.PlayNote(369.99, 0.4, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(466.16, 0.2, 1);
-            DACout.PlayNote(554.37, 0.2, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(466.16, 0.4, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(369.99, 0.4, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(293.66, 0.2, 1);
-            DACout.PlayNote(293.66, 0.2, 1);
-            DACout.PlayNote(293.66, 0.2, 1);
-            DACout.PlayNote(0, 0.8, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(277.18, 0.4, 1);
-            DACout.PlayNote(293.66, 0.2, 1);
-            DACout.PlayNote(369.99, 0.2, 1);
-            DACout.PlayNote(466.16, 0.2, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(554.37, 0.2, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(466.16, 0.4, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(369.99, 0.4, 1);
-            DACout.PlayNote(659.25, 0.4, 1);
-            DACout.PlayNote(622.25, 0.4, 1);
-            DACout.PlayNote(587.33, 0.4, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(0, 0.4, 1);
-            
-            
-            
-            DACout.PlayNote(392.00, 0.4, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(554.37, 0.2, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(369.99, 0.2, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(554.37, 0.4, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(329.00, 0.4, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(523.25, 0.4, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(329.00, 0.4, 1);
-            DACout.PlayNote(369.99, 0.4, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(329.63, 0.4, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(277.18, 0.2, 1);
-            DACout.PlayNote(277.18, 0.2, 1);
-            DACout.PlayNote(277.18, 0.2, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(277.18, 0.2, 1);
-            DACout.PlayNote(277.18, 0.2, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(277.18, 0.4, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(0, 0.4, 1);
-            DACout.PlayNote(311.13, 0.4, 1);
-            if(game1 == true || game2 == true) break;
-            DACout.PlayNote(293.66, 0.4, 1);
-            //DACout.PlayNote(440.00, 0.3, 1);
+            sampletick.attach(&audio_sample, 1.0 / sample_freq);
+            //DACout.PlayNote(369.99, 0.4, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(466.16, 0.2, 1);
+//            DACout.PlayNote(554.37, 0.2, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(466.16, 0.4, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(369.99, 0.4, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(293.66, 0.2, 1);
+//            DACout.PlayNote(293.66, 0.2, 1);
+//            DACout.PlayNote(293.66, 0.2, 1);
+//            DACout.PlayNote(0, 0.8, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(277.18, 0.4, 1);
+//            DACout.PlayNote(293.66, 0.2, 1);
+//            DACout.PlayNote(369.99, 0.2, 1);
+//            DACout.PlayNote(466.16, 0.2, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(554.37, 0.2, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(466.16, 0.4, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(369.99, 0.4, 1);
+//            DACout.PlayNote(659.25, 0.4, 1);
+//            DACout.PlayNote(622.25, 0.4, 1);
+//            DACout.PlayNote(587.33, 0.4, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(0, 0.4, 1);
+//            
+//            
+//            
+//            DACout.PlayNote(392.00, 0.4, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(554.37, 0.2, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(369.99, 0.2, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(554.37, 0.4, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(329.00, 0.4, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(523.25, 0.4, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(329.00, 0.4, 1);
+//            DACout.PlayNote(369.99, 0.4, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(329.63, 0.4, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(277.18, 0.2, 1);
+//            DACout.PlayNote(277.18, 0.2, 1);
+//            DACout.PlayNote(277.18, 0.2, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(277.18, 0.2, 1);
+//            DACout.PlayNote(277.18, 0.2, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(277.18, 0.4, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(0, 0.4, 1);
+//            DACout.PlayNote(311.13, 0.4, 1);
+//            if(game1 == true || game2 == true) break;
+//            DACout.PlayNote(293.66, 0.4, 1);
             
             /*led2 = true;
             wave_file=fopen("/sd/MiiMenu.wav","r");
@@ -139,53 +173,53 @@
             led2 = false;*/
         }
         while (game1 == true && game2 == false) {
-            DACout.PlayNote(659.25, 0.3, 1);
-            DACout.PlayNote(493.88, 0.3, 1);
-            DACout.PlayNote(523.25, 0.3, 1);
-           if(game1 != true && game2 == false) break;
-            DACout.PlayNote(587.33, 0.3, 1);
-            DACout.PlayNote(523.25, 0.3, 1);
-            DACout.PlayNote(493.88, 0.3, 1);
-            DACout.PlayNote(440.00, 0.3, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(440.00, 0.3, 1);
-            DACout.PlayNote(523.25, 0.3, 1);
-            DACout.PlayNote(659.25, 0.3, 1);
-            DACout.PlayNote(587.33, 0.3, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(523.25, 0.3, 1);
-            DACout.PlayNote(493.88, 0.3, 1);
-            DACout.PlayNote(523.25, 0.3, 1);
-            DACout.PlayNote(587.33, 0.3, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(659.25, 0.3, 1);
-            DACout.PlayNote(523.25, 0.3, 1);
-            DACout.PlayNote(440.00, 0.3, 1);
-            DACout.PlayNote(440.00, 0.3, 1);
-            if(game1 != true && game2 == false) break;
-            
-            DACout.PlayNote(583.33, 0.3, 1);
-            DACout.PlayNote(698.46, 0.3, 1);
-            DACout.PlayNote(880.00, 0.3, 1);
-            DACout.PlayNote(783.99, 0.3, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(698.46, 0.3, 1);
-            DACout.PlayNote(659.25, 0.3, 1);
-            DACout.PlayNote(523.25, 0.3, 1);
-            DACout.PlayNote(659.25, 0.3, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(587.33, 0.3, 1);
-            DACout.PlayNote(523.25, 0.3, 1);
-            DACout.PlayNote(493.88, 0.3, 1);
-            DACout.PlayNote(493.88, 0.3, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(523.25, 0.3, 1);
-            DACout.PlayNote(587.33, 0.3, 1);
-            DACout.PlayNote(659.25, 0.3, 1);
-            DACout.PlayNote(523.35, 0.3, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(440.00, 0.3, 1);
-            DACout.PlayNote(440.00, 0.3, 1);
+            //DACout.PlayNote(659.25, 0.3, 1);
+//            DACout.PlayNote(493.88, 0.3, 1);
+//            DACout.PlayNote(523.25, 0.3, 1);
+//           if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(587.33, 0.3, 1);
+//            DACout.PlayNote(523.25, 0.3, 1);
+//            DACout.PlayNote(493.88, 0.3, 1);
+//            DACout.PlayNote(440.00, 0.3, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(440.00, 0.3, 1);
+//            DACout.PlayNote(523.25, 0.3, 1);
+//            DACout.PlayNote(659.25, 0.3, 1);
+//            DACout.PlayNote(587.33, 0.3, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(523.25, 0.3, 1);
+//            DACout.PlayNote(493.88, 0.3, 1);
+//            DACout.PlayNote(523.25, 0.3, 1);
+//            DACout.PlayNote(587.33, 0.3, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(659.25, 0.3, 1);
+//            DACout.PlayNote(523.25, 0.3, 1);
+//            DACout.PlayNote(440.00, 0.3, 1);
+//            DACout.PlayNote(440.00, 0.3, 1);
+//            if(game1 != true && game2 == false) break;
+//            
+//            DACout.PlayNote(583.33, 0.3, 1);
+//            DACout.PlayNote(698.46, 0.3, 1);
+//            DACout.PlayNote(880.00, 0.3, 1);
+//            DACout.PlayNote(783.99, 0.3, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(698.46, 0.3, 1);
+//            DACout.PlayNote(659.25, 0.3, 1);
+//            DACout.PlayNote(523.25, 0.3, 1);
+//            DACout.PlayNote(659.25, 0.3, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(587.33, 0.3, 1);
+//            DACout.PlayNote(523.25, 0.3, 1);
+//            DACout.PlayNote(493.88, 0.3, 1);
+//            DACout.PlayNote(493.88, 0.3, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(523.25, 0.3, 1);
+//            DACout.PlayNote(587.33, 0.3, 1);
+//            DACout.PlayNote(659.25, 0.3, 1);
+//            DACout.PlayNote(523.35, 0.3, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(440.00, 0.3, 1);
+//            DACout.PlayNote(440.00, 0.3, 1);
            /* led2 = true;
             wave_file=fopen("/sd/tetris.wav","r");
             waver.play(wave_file);
@@ -193,106 +227,106 @@
             led2 = false;*/
         }
         while (game2 == true && game1 == false) {
-            DACout.PlayNote(329.63, 0.6, 1);
-            DACout.PlayNote(349.23, 0.6, 1);
-            DACout.PlayNote(392.00, 0.15, 1);
-            DACout.PlayNote(523.25, 0.15, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(493.88, 0.15, 1);
-            DACout.PlayNote(523.25, 0.15, 1);
-            DACout.PlayNote(392.00, 0.15, 1);
-            DACout.PlayNote(329.63, 0.15, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(261.63, 0.15, 1);
-            DACout.PlayNote(293.66, 0.15, 1);
-            DACout.PlayNote(329.33, 0.15, 1);
-            DACout.PlayNote(293.66, 0.6, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(293.66, 1.2, 1);
-            DACout.PlayNote(329.63, 0.6, 1);
-            DACout.PlayNote(349.23, 0.3, 1);
-            DACout.PlayNote(329.63, 0.15, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(349.23, 0.15, 1);
-            
-            
-            DACout.PlayNote(392.00, 0.15, 1);
-            DACout.PlayNote(523.25, 0.15, 1);           
-            DACout.PlayNote(587.33, 0.15, 1);
-            DACout.PlayNote(523.25, 0.3, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(587.33, 0.1, 1);
-            DACout.PlayNote(659.25, 0.1, 1);
-            DACout.PlayNote(698.46, 0.15, 1);
-            DACout.PlayNote(659.25, 0.15, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(587.33, 0.15, 1);
-            DACout.PlayNote(523.25, 0.3, 1);
-            DACout.PlayNote(392.00, 0.15, 1);
-            DACout.PlayNote(440.00, 0.15, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(440.00, 0.15, 1);
-            DACout.PlayNote(587.33, 0.15, 1);
-            DACout.PlayNote(587.33, 0.1, 1);
-            DACout.PlayNote(587.33, 0.15, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(587.33, 0.1, 1);
-            DACout.PlayNote(659.25, 0.1, 1);
-            DACout.PlayNote(698.46, 0.15, 1);
-            DACout.PlayNote(659.25, 0.15, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(587.33, 0.15, 1);
-            DACout.PlayNote(523.25, 0.3, 1);
-            DACout.PlayNote(392.00, 0.3, 1);
-            DACout.PlayNote(392.00, 0.6, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(392.00, 0.15, 1);
-            DACout.PlayNote(587.33, 0.1, 1);
-            DACout.PlayNote(659.25, 0.1, 1);
-            DACout.PlayNote(698.46, 0.15, 1);
-            DACout.PlayNote(659.25, 0.15, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(587.33, 0.15, 1);
-            DACout.PlayNote(523.25, 0.3, 1);
-            DACout.PlayNote(783.99, 0.3, 1);
-            DACout.PlayNote(783.99, 0.6, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(783.99, 0.15, 1);
-            DACout.PlayNote(783.99, 0.1, 1);
-            DACout.PlayNote(880.00, 0.1, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(932.33, 0.15, 1);
-            DACout.PlayNote(880.00, 0.15, 1);           
-            DACout.PlayNote(783.99, 0.15, 1);
-            DACout.PlayNote(698.46, 0.6, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(830.61, 0.15, 1);
-            DACout.PlayNote(783.99, 0.15, 1);
-            DACout.PlayNote(698.46, 0.15, 1);
-            DACout.PlayNote(622.25, 0.3, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(739.99, 0.15, 1);
-            DACout.PlayNote(698.46, 0.1, 1);
-            DACout.PlayNote(698.46, 0.15, 1);
-            DACout.PlayNote(622.25, 0.15, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(554.37, 0.15, 1);
-            DACout.PlayNote(415.30, 0.15, 1);
-            DACout.PlayNote(349.23, 0.15, 1);
-            DACout.PlayNote(277.18, 0.15, 1);
-            DACout.PlayNote(311.13, 0.3, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(554.37, 0.3, 1);
-            DACout.PlayNote(587.33, 0.6, 1);
-            DACout.PlayNote(587.33, 0.6, 1);
-            DACout.PlayNote(587.33, 0.15, 1);
-            DACout.PlayNote(392.00, 0.15, 1);
-            if(game1 != true && game2 == false) break;
-            DACout.PlayNote(587.33, 0.3, 1);
-            DACout.PlayNote(783.99, 0.3, 1);
-            DACout.PlayNote(783.99, 0.6, 1);
-            DACout.PlayNote(783.99, 1.2, 1);
-            if(game1 != true && game2 == false) break;
+            //DACout.PlayNote(329.63, 0.6, 1);
+//            DACout.PlayNote(349.23, 0.6, 1);
+//            DACout.PlayNote(392.00, 0.15, 1);
+//            DACout.PlayNote(523.25, 0.15, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(493.88, 0.15, 1);
+//            DACout.PlayNote(523.25, 0.15, 1);
+//            DACout.PlayNote(392.00, 0.15, 1);
+//            DACout.PlayNote(329.63, 0.15, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(261.63, 0.15, 1);
+//            DACout.PlayNote(293.66, 0.15, 1);
+//            DACout.PlayNote(329.33, 0.15, 1);
+//            DACout.PlayNote(293.66, 0.6, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(293.66, 1.2, 1);
+//            DACout.PlayNote(329.63, 0.6, 1);
+//            DACout.PlayNote(349.23, 0.3, 1);
+//            DACout.PlayNote(329.63, 0.15, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(349.23, 0.15, 1);
+//            
+//            
+//            DACout.PlayNote(392.00, 0.15, 1);
+//            DACout.PlayNote(523.25, 0.15, 1);           
+//            DACout.PlayNote(587.33, 0.15, 1);
+//            DACout.PlayNote(523.25, 0.3, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(587.33, 0.1, 1);
+//            DACout.PlayNote(659.25, 0.1, 1);
+//            DACout.PlayNote(698.46, 0.15, 1);
+//            DACout.PlayNote(659.25, 0.15, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(587.33, 0.15, 1);
+//            DACout.PlayNote(523.25, 0.3, 1);
+//            DACout.PlayNote(392.00, 0.15, 1);
+//            DACout.PlayNote(440.00, 0.15, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(440.00, 0.15, 1);
+//            DACout.PlayNote(587.33, 0.15, 1);
+//            DACout.PlayNote(587.33, 0.1, 1);
+//            DACout.PlayNote(587.33, 0.15, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(587.33, 0.1, 1);
+//            DACout.PlayNote(659.25, 0.1, 1);
+//            DACout.PlayNote(698.46, 0.15, 1);
+//            DACout.PlayNote(659.25, 0.15, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(587.33, 0.15, 1);
+//            DACout.PlayNote(523.25, 0.3, 1);
+//            DACout.PlayNote(392.00, 0.3, 1);
+//            DACout.PlayNote(392.00, 0.6, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(392.00, 0.15, 1);
+//            DACout.PlayNote(587.33, 0.1, 1);
+//            DACout.PlayNote(659.25, 0.1, 1);
+//            DACout.PlayNote(698.46, 0.15, 1);
+//            DACout.PlayNote(659.25, 0.15, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(587.33, 0.15, 1);
+//            DACout.PlayNote(523.25, 0.3, 1);
+//            DACout.PlayNote(783.99, 0.3, 1);
+//            DACout.PlayNote(783.99, 0.6, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(783.99, 0.15, 1);
+//            DACout.PlayNote(783.99, 0.1, 1);
+//            DACout.PlayNote(880.00, 0.1, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(932.33, 0.15, 1);
+//            DACout.PlayNote(880.00, 0.15, 1);           
+//            DACout.PlayNote(783.99, 0.15, 1);
+//            DACout.PlayNote(698.46, 0.6, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(830.61, 0.15, 1);
+//            DACout.PlayNote(783.99, 0.15, 1);
+//            DACout.PlayNote(698.46, 0.15, 1);
+//            DACout.PlayNote(622.25, 0.3, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(739.99, 0.15, 1);
+//            DACout.PlayNote(698.46, 0.1, 1);
+//            DACout.PlayNote(698.46, 0.15, 1);
+//            DACout.PlayNote(622.25, 0.15, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(554.37, 0.15, 1);
+//            DACout.PlayNote(415.30, 0.15, 1);
+//            DACout.PlayNote(349.23, 0.15, 1);
+//            DACout.PlayNote(277.18, 0.15, 1);
+//            DACout.PlayNote(311.13, 0.3, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(554.37, 0.3, 1);
+//            DACout.PlayNote(587.33, 0.6, 1);
+//            DACout.PlayNote(587.33, 0.6, 1);
+//            DACout.PlayNote(587.33, 0.15, 1);
+//            DACout.PlayNote(392.00, 0.15, 1);
+//            if(game1 != true && game2 == false) break;
+//            DACout.PlayNote(587.33, 0.3, 1);
+//            DACout.PlayNote(783.99, 0.3, 1);
+//            DACout.PlayNote(783.99, 0.6, 1);
+//            DACout.PlayNote(783.99, 1.2, 1);
+//            if(game1 != true && game2 == false) break;
             /*led2 = true;
             wave_file=fopen("/sd/WiiPlayAirHockey.wav","r");
             waver.play(wave_file);
@@ -306,22 +340,27 @@
 {
     float x = 0.0;
     while(1) {
-        //get a new random number for PWM
-        x = rand() / float(RAND_MAX);
-        //add some exponential brightness scaling
-        //for more of a fast flash effect
-        x = x*x*x;
-        Rgb = x;
-        rGb = x;
-        rgB = x;
-        //fast update rate for welding flashes
-        Thread::wait(20);
-        //add a random pause between welds
-        if (rand() / float(RAND_MAX) > 0.95) {
-            Rgb = 0;
-            rGb = 0;
-            rgB = 0;
-            Thread::wait(4000.0 * rand() / float(RAND_MAX));
+        if (!game1 && !game2) { 
+            //get a new random number for PWM
+            x = rand() / float(RAND_MAX);
+            //add some exponential brightness scaling
+            //for more of a fast flash effect
+            x = x*x*x;
+            Rgb = x;
+            rGb = x;
+            rgB = x;
+            //fast update rate for welding flashes
+            Thread::wait(20);
+            //add a random pause between welds
+            if (rand() / float(RAND_MAX) > 0.95) {
+                Rgb = 0;
+                rGb = 0;
+                rgB = 0;
+                Thread::wait(4000.0 * rand() / float(RAND_MAX));
+            }
+        }
+        else if (game1) {
+            
         }
     }
 }