Arduino Music Player and Memory Issues

I'm making a music player designed to play from a set of songs I hand-arranged to be played through the Piezo.

Problem is, even just three full-length songs caused me to run up on memory problems. Initially, the sketch itself was using too much memory due to calling playNote() and rest() hundreds of times for each song. I thought I could solve the problem by converting the songs into arrays, but that just went far over the allotted memory for global variables.

Is there any way for me to make the current model feasible without removing songs or reducing their length? Like, say, putting the songs in an external file, then loading them into the main sketch?

Here's the code:

#include <LiquidCrystal.h>
const int upPin = 10;
const int downPin = 9;
const int playPin = 8;
const int piezoPin = 7;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int upState;
int downState;
int playState;
int prevUpState = 0;
int prevDownState = 0;
int prevPlayState = 0;

const int NOTE_B0 = 31;
const int NOTE_C1 = 33;
const int NOTE_CS1 = 35;
const int NOTE_D1 = 37;
const int NOTE_DS1 = 39;
const int NOTE_E1 = 41;
const int NOTE_F1 = 44;
const int NOTE_FS1 = 46;
const int NOTE_G1 = 49;
const int NOTE_GS1 = 52;
const int NOTE_A1 = 55;
const int NOTE_AS1 = 58;
const int NOTE_B1 = 62;
const int NOTE_C2 = 65;
const int NOTE_CS2 = 69;
const int NOTE_D2 = 73;
const int NOTE_DS2 = 78;
const int NOTE_E2 = 82;
const int NOTE_F2 = 87;
const int NOTE_FS2 = 93;
const int NOTE_G2 = 98;
const int NOTE_GS2 = 104;
const int NOTE_A2 = 110;
const int NOTE_AS2 = 117;
const int NOTE_B2 = 123;
const int NOTE_C3 = 131;
const int NOTE_CS3 = 139;
const int NOTE_D3 = 147;
const int NOTE_DS3 = 156;
const int NOTE_E3 = 165;
const int NOTE_F3 = 175;
const int NOTE_FS3 = 185;
const int NOTE_G3 = 196;
const int NOTE_GS3 = 208;
const int NOTE_A3 = 220;
const int NOTE_AS3 = 233;
const int NOTE_B3 = 247;
const int NOTE_C4 = 262;
const int NOTE_CS4 = 277;
const int NOTE_D4 = 294;
const int NOTE_DS4 = 311;
const int NOTE_E4 = 330;
const int NOTE_F4 = 349;
const int NOTE_FS4 = 370;
const int NOTE_G4 = 392;
const int NOTE_GS4 = 415;
const int NOTE_A4 = 440;
const int NOTE_AS4 = 466;
const int NOTE_B4 = 494;
const int NOTE_C5 = 523;
const int NOTE_CS5 = 554;
const int NOTE_D5 = 587;
const int NOTE_DS5 = 622;
const int NOTE_E5 = 659;
const int NOTE_F5 = 698;
const int NOTE_FS5 = 740;
const int NOTE_G5 = 784;
const int NOTE_GS5 = 831;
const int NOTE_A5 = 880;
const int NOTE_AS5 = 932;
const int NOTE_B5 = 988;
const int NOTE_C6 = 1047;
const int NOTE_CS6 = 1109;
const int NOTE_D6 = 1175;
const int NOTE_DS6 = 1245;
const int NOTE_E6 = 1319;
const int NOTE_F6 = 1397;
const int NOTE_FS6 = 1480;
const int NOTE_G6 = 1568;
const int NOTE_GS6 = 1661;
const int NOTE_A6 = 1760;
const int NOTE_AS6 = 1865;
const int NOTE_B6 = 1976;
const int NOTE_C7 = 2093;
const int NOTE_CS7 = 2217;
const int NOTE_D7 = 2349;
const int NOTE_DS7 = 2489;
const int NOTE_E7 = 2637;
const int NOTE_F7 = 2794;
const int NOTE_FS7 = 2960;
const int NOTE_G7 = 3136;
const int NOTE_GS7 = 3322;
const int NOTE_A7 = 3520;
const int NOTE_AS7 = 3729;
const int NOTE_B7 = 3951;
const int NOTE_C8 = 4186;
const int NOTE_CS8 = 4435;
const int NOTE_D8 = 4699;
const int NOTE_DS8 = 4978;

// String songs[5] = {"C Scale","Eb Scale","F Scale","G Scale","D Scale"};
String songs[5] = { "Eien no Ashita", "KARMA", "MEGALOVANIA", "Your Best Nightmare", "ASGORE" };
int currSong = 0;

const int NOTES_A[] = {
  NOTE_C5,
  NOTE_B4,
  NOTE_A4,
  NOTE_G4,
  NOTE_D5,
  NOTE_D5,
  NOTE_A4,
  NOTE_A4,
  NOTE_C5,
  NOTE_B4,
  NOTE_A4,
  NOTE_G4,
  NOTE_D5,
  NOTE_D5,
  NOTE_A4,
  NOTE_A4,
  NOTE_G4,
  NOTE_FS4,
  NOTE_G4,
  NOTE_A4,
  NOTE_FS4,
  NOTE_G4,
  NOTE_G4,
  NOTE_A4,
  NOTE_A4,
  NOTE_G4,
  NOTE_FS4,
  NOTE_G4,
  NOTE_B3,
  NOTE_E3,
  NOTE_E3,
  0,
  NOTE_D4,
  NOTE_C4,
  NOTE_B3,
  NOTE_A3,
  NOTE_G3,
  NOTE_G3,
  NOTE_G3,
  NOTE_A3,
  0,
  NOTE_G3,
  NOTE_A3,
  NOTE_G3,
  NOTE_G3,
  NOTE_FS3,
  NOTE_G3,
  NOTE_G3,
  0,
  NOTE_A3,
  NOTE_B3,
  NOTE_E3,
  NOTE_E3,
  0,
  NOTE_D4,
  NOTE_C4,
  NOTE_B3,
  NOTE_A3,
  NOTE_G3,
  NOTE_G3,
  NOTE_A3,
  0,
  NOTE_B3,
  NOTE_A3,
  NOTE_D4,
  NOTE_C4,
  NOTE_B3,
  NOTE_B3,
  0,
  NOTE_A3,
  NOTE_G3,
  NOTE_FS3,
  NOTE_G3,
  NOTE_FS3,
  NOTE_G3,
  0,
  NOTE_G3,
  NOTE_A3,
  NOTE_G3,
  NOTE_G3,
  NOTE_FS3,
  NOTE_G3,
  0,
  NOTE_D3,
  NOTE_E3,
  NOTE_FS3,
  NOTE_G3,
  NOTE_E3,
  NOTE_B3,
  NOTE_C4,
  NOTE_B3,
  NOTE_C4,
  NOTE_B3,
  NOTE_A3,
  NOTE_C4,
  NOTE_D4,
  NOTE_C4,
  NOTE_B3,
  NOTE_B3,
  NOTE_G3,
  NOTE_A3,
  NOTE_D4,
  NOTE_D4,
  05,
  NOTE_E4,
  NOTE_FS4,
  NOTE_FS4,
  NOTE_G4,
  NOTE_FS4,
  NOTE_D4,
  0,
  NOTE_B3,
  NOTE_E4,
  NOTE_E4,
  NOTE_D4,
  NOTE_C4,
  NOTE_B3,
  NOTE_B3,
  NOTE_A3,
  NOTE_A3,
  NOTE_A3,
  NOTE_A3,
  NOTE_D4,
  NOTE_A3,
  NOTE_G3,
  0,
  NOTE_E3,
  NOTE_FS3,
  NOTE_G3,
  NOTE_B3,
  NOTE_C4,
  NOTE_B3,
  NOTE_B3,
  NOTE_A3,
  NOTE_A3,
  0,
  NOTE_C4,
  NOTE_D4,
  NOTE_C4,
  NOTE_B3,
  NOTE_B3,
  NOTE_G3,
  NOTE_A3,
  NOTE_D4,
  NOTE_D4,
  0,
  NOTE_E4,
  NOTE_FS4,
  NOTE_FS4,
  NOTE_G4,
  NOTE_FS4,
  NOTE_D4,
  0,
  NOTE_B3,
  NOTE_E4,
  NOTE_E4,
  NOTE_FS4,
  NOTE_D4,
  0,
  NOTE_E4,
  NOTE_E4,
  NOTE_E4,
  NOTE_E4,
  NOTE_D4,
  NOTE_E4,
  NOTE_FS4,
  NOTE_E4,
  NOTE_FS4,
  NOTE_FS4,
  NOTE_G4,
  0,
  NOTE_G3,
  NOTE_G3,
  NOTE_G3,
  NOTE_A3,
  NOTE_A3,
  0,
  NOTE_A3,
  NOTE_A3,
  NOTE_A3,
  NOTE_D4,
  NOTE_C4,
  NOTE_C4,
  NOTE_C4,
  NOTE_B3,
  NOTE_B3,
  0,
  NOTE_C4,
  NOTE_D4,
  NOTE_D4,
  NOTE_E4,
  NOTE_E4,
  NOTE_FS4,
  NOTE_G4,
  NOTE_G3,
  0,
  NOTE_G3,
  NOTE_A3,
  NOTE_G3,
  NOTE_G3,
  NOTE_E4,
  NOTE_FS4,
  NOTE_G4,
  NOTE_G4,
  NOTE_C4,
  NOTE_D4,
  NOTE_D4,
  NOTE_E4,
  NOTE_E4,
  NOTE_FS4,
  NOTE_G4,
  NOTE_G3,
  0,
  NOTE_A3,
  NOTE_G3,
  NOTE_A3,
  NOTE_G3,
  NOTE_D6,
  NOTE_A5,
  NOTE_A5,
  NOTE_C6,
  NOTE_B5,
  NOTE_A5,
  NOTE_G5,
  NOTE_D6,
  NOTE_D6,
  NOTE_A5,
  NOTE_A5,
  NOTE_G5,
  NOTE_FS5,
  NOTE_G5,
  NOTE_G5,
  NOTE_A5,
  NOTE_B5,
  NOTE_G5,
  NOTE_D5,
  NOTE_D5,
  NOTE_E5,
  NOTE_G5,
  NOTE_C6,
  NOTE_B5,
  NOTE_A5,
  NOTE_G5,
  NOTE_G5,
  NOTE_E5,
  NOTE_FS5,
  NOTE_G5,
  NOTE_G5,
  NOTE_A5,
  NOTE_B5
};
const float BEATS_A[] = { 1, 0.5,
                          1,
                          1,
                          0.5,
                          1.5,
                          0.5,
                          2,
                          1,
                          0.5,
                          1,
                          1,
                          0.5,
                          1.5,
                          0.5,
                          1.5,
                          0.25,
                          0.25,
                          1.5,
                          2.5,
                          1.5,
                          2.5,
                          1.5,
                          2.5,
                          0.5,
                          0.5,
                          0.5,
                          2.5,
                          1,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          1.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1.5,
                          0.5,
                          1,
                          1,
                          0.5,
                          1,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          1.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          1,
                          1,
                          0.5,
                          1.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          1.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          1,
                          1.5,
                          0.5,
                          1,
                          0.5,
                          1,
                          3.5,
                          0.75,
                          0.75,
                          0.5,
                          0.75,
                          0.75,
                          0.5,
                          1,
                          0.75,
                          0.5,
                          0.75,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          1.5,
                          2.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.25,
                          0.25,
                          1,
                          0.75,
                          0.75,
                          1.5,
                          0.75,
                          0.75,
                          0.5,
                          0.75,
                          0.75,
                          0.5,
                          1,
                          0.5,
                          1.5,
                          1,
                          0.75,
                          0.75,
                          0.5,
                          0.75,
                          0.75,
                          0.5,
                          1,
                          0.75,
                          0.5,
                          0.75,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          1,
                          0.5,
                          1.5,
                          1,
                          0.75,
                          0.75,
                          0.5,
                          0.75,
                          0.75,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          3,
                          0.5,
                          1,
                          1,
                          0.5,
                          0.5,
                          1.5,
                          0.5,
                          1,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          1,
                          1,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          1.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          1.5,
                          0.5,
                          4,
                          0.75,
                          0.75,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          1.5,
                          0.5,
                          0.5,
                          0.5,
                          1.5,
                          1.5,
                          0.5,
                          0.5,
                          3.5,
                          1.5,
                          0.5,
                          2,
                          1,
                          0.5,
                          1,
                          1,
                          0.5,
                          1.5,
                          0.5,
                          2,
                          0.25,
                          0.25,
                          2,
                          0.5,
                          0.5,
                          0.5,
                          2,
                          0.5,
                          2,
                          1,
                          1,
                          1,
                          1,
                          2,
                          2,
                          4,
                          0.75,
                          0.75,
                          0.5,
                          2,
                          2,
                          8 };
const int NOTES_B[] = { NOTE_FS5, NOTE_FS5, NOTE_FS5, NOTE_FS5, NOTE_F5, NOTE_F5, NOTE_F5, NOTE_F5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_GS4, NOTE_GS4, NOTE_GS4, NOTE_GS4, NOTE_FS5, NOTE_FS5, NOTE_FS5, NOTE_FS5, NOTE_F5, NOTE_F5, NOTE_F5, NOTE_F5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_FS4, NOTE_FS4, NOTE_FS4, NOTE_FS4, NOTE_FS5, NOTE_FS5, NOTE_FS5, NOTE_FS5, NOTE_F5, NOTE_F5, NOTE_F5, NOTE_F5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_GS4, NOTE_GS4, NOTE_GS4, NOTE_GS4, NOTE_FS5, NOTE_FS5, NOTE_FS5, NOTE_FS5, NOTE_F5, NOTE_F5, NOTE_F5, NOTE_F5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, 0, NOTE_DS4, NOTE_AS4, NOTE_F4, NOTE_FS4, 0, NOTE_CS5, NOTE_AS4, NOTE_F5, NOTE_CS5, NOTE_B4, NOTE_B4, NOTE_B4, NOTE_B4, NOTE_B4, NOTE_B4, 0, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, 0, NOTE_DS4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_FS4, 0, NOTE_CS5, NOTE_AS4, NOTE_F5, NOTE_CS5, NOTE_B4, NOTE_B4, NOTE_B4, NOTE_B4, NOTE_B4, NOTE_B4, 0, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, 0, NOTE_GS4, NOTE_AS4, NOTE_AS4, NOTE_AS4, NOTE_AS4, NOTE_FS4, NOTE_GS4, NOTE_AS4, NOTE_AS4, NOTE_AS4, NOTE_GS4, NOTE_AS4, 0, NOTE_FS4, NOTE_AS4, NOTE_GS4, NOTE_GS4, NOTE_FS4, NOTE_FS4, NOTE_DS4, NOTE_DS4, NOTE_CS4, NOTE_CS4, NOTE_GS4, NOTE_FS4, 0, NOTE_CS4, NOTE_CS4, NOTE_GS4, NOTE_FS4, NOTE_CS5, NOTE_CS5, NOTE_AS4, NOTE_GS4, NOTE_FS4, 0, NOTE_FS4, NOTE_AS4, NOTE_B4, NOTE_GS4, NOTE_DS4, NOTE_F4, NOTE_FS4, NOTE_F4, NOTE_GS4, NOTE_AS4, NOTE_AS4, NOTE_AS4, NOTE_FS4, NOTE_GS4, NOTE_AS4, NOTE_AS4, NOTE_GS4, NOTE_AS4, 0, NOTE_FS4, NOTE_AS4, NOTE_GS4, NOTE_GS4, NOTE_FS4, NOTE_FS4, NOTE_DS4, NOTE_DS4, NOTE_CS4, NOTE_CS4, NOTE_GS4, NOTE_FS4, 0, NOTE_CS4, NOTE_CS4, NOTE_GS4, NOTE_FS4, NOTE_CS5, NOTE_DS5, NOTE_AS4, NOTE_FS4, NOTE_FS4, NOTE_CS5, NOTE_B4, NOTE_AS4, NOTE_FS4, NOTE_F4, NOTE_FS4, NOTE_CS4, NOTE_CS4, NOTE_FS4, NOTE_GS4, NOTE_FS4, NOTE_AS4, 0, NOTE_CS5, NOTE_CS5, 0, NOTE_FS4, NOTE_DS5, NOTE_CS5, NOTE_CS5, NOTE_B4, NOTE_AS4, NOTE_B4, NOTE_AS4, 0, NOTE_CS5, NOTE_FS5, NOTE_FS5, NOTE_DS5, NOTE_CS5, 0, NOTE_DS5, NOTE_CS5, NOTE_CS5, NOTE_B4, NOTE_AS4, NOTE_B4, NOTE_AS4, 0, NOTE_CS5, NOTE_FS5, NOTE_FS5, NOTE_DS5, NOTE_CS5, 0, NOTE_CS4, NOTE_FS4, NOTE_GS4, NOTE_FS4, NOTE_AS4, 0, NOTE_CS5, NOTE_CS5, 0, NOTE_FS4, NOTE_DS5, NOTE_CS5, NOTE_CS5, NOTE_B4, NOTE_AS4, NOTE_GS4, NOTE_FS4, NOTE_FS4, NOTE_DS5, NOTE_AS4, NOTE_D5, NOTE_DS5, NOTE_F5, 0, NOTE_CS5, NOTE_FS5, NOTE_F5, NOTE_CS5, 0, NOTE_AS4, NOTE_B4, NOTE_CS5, NOTE_FS4, NOTE_CS5, NOTE_DS5, NOTE_CS5, NOTE_B4, NOTE_AS4, NOTE_AS4, NOTE_AS4, NOTE_GS4, NOTE_AS4, NOTE_B4, NOTE_AS4, NOTE_GS4, NOTE_F4, NOTE_GS4, NOTE_AS4, 0, NOTE_DS5, NOTE_F5, NOTE_DS5, NOTE_FS5, NOTE_F5, NOTE_DS5, NOTE_FS4, NOTE_AS4, NOTE_CS5, NOTE_FS5, NOTE_F5, NOTE_CS5, 0, NOTE_AS4, NOTE_B4, NOTE_CS5, NOTE_FS4, NOTE_CS5, NOTE_DS5, NOTE_CS5, NOTE_B4, NOTE_AS4, NOTE_AS4, NOTE_AS4, NOTE_GS4, NOTE_AS4, NOTE_B4, NOTE_AS4, NOTE_GS4, NOTE_F4, NOTE_GS4, NOTE_AS4, 0, NOTE_DS5, NOTE_F5, NOTE_DS5, NOTE_FS5, NOTE_F5, NOTE_DS5, NOTE_AS4, NOTE_B4, NOTE_CS4, NOTE_B4, 0, NOTE_CS5, NOTE_DS5, NOTE_FS5, NOTE_F5, NOTE_FS5, 0, NOTE_DS4, NOTE_F4, NOTE_FS4, NOTE_AS4, NOTE_CS5, 0, NOTE_CS5, NOTE_B4, NOTE_AS4, NOTE_B4, NOTE_AS4, NOTE_FS4, NOTE_GS4, 0, NOTE_DS4, NOTE_F4, NOTE_FS4, NOTE_AS4, NOTE_CS5, NOTE_CS5, NOTE_B4, NOTE_B4, NOTE_AS4, NOTE_AS4, NOTE_GS4, NOTE_GS4, NOTE_FS4, 0, NOTE_FS4, NOTE_GS4, NOTE_AS4, NOTE_B4, NOTE_DS5, NOTE_F5, NOTE_FS5, NOTE_CS5, NOTE_B4, NOTE_B4, NOTE_AS4, NOTE_GS4, NOTE_FS4, NOTE_FS4, 0, NOTE_FS4, NOTE_AS4, NOTE_GS4, NOTE_FS4, NOTE_GS4, NOTE_AS4, NOTE_FS5, 0, NOTE_FS4, NOTE_AS4, NOTE_CS5, NOTE_FS5, NOTE_F5, NOTE_CS5, 0, NOTE_AS4, NOTE_B4, NOTE_CS5, NOTE_FS4, NOTE_CS5, NOTE_DS5, NOTE_CS5, NOTE_B4, NOTE_AS4, NOTE_AS4, NOTE_AS4, NOTE_GS4, NOTE_AS4, NOTE_B4, NOTE_AS4, NOTE_GS4, NOTE_F4, NOTE_GS4, NOTE_AS4, 0, NOTE_DS5, NOTE_F5, NOTE_DS5, NOTE_FS5, 0, NOTE_FS4, NOTE_AS4, NOTE_CS5, NOTE_FS5, NOTE_F5, NOTE_CS5, 0, NOTE_AS4, NOTE_B4, NOTE_CS5, NOTE_FS4, NOTE_CS5, NOTE_DS5, NOTE_CS5, NOTE_B4, NOTE_AS4, NOTE_AS4, NOTE_AS4, NOTE_GS4, NOTE_AS4, NOTE_B4, NOTE_AS4, NOTE_GS4, NOTE_F4, NOTE_GS4, NOTE_AS4, 0, NOTE_DS5, NOTE_F5, NOTE_DS5, NOTE_FS5, NOTE_F5, NOTE_DS5, NOTE_FS4, NOTE_AS4, NOTE_CS5, NOTE_FS5, NOTE_F5, NOTE_CS5, 0, NOTE_AS4, NOTE_B4, NOTE_CS5, NOTE_FS4, NOTE_CS5, NOTE_DS5, NOTE_CS5, NOTE_B4, NOTE_AS4, NOTE_AS4, NOTE_AS4, NOTE_GS4, NOTE_AS4, NOTE_B4, NOTE_AS4, NOTE_GS4, NOTE_F4, NOTE_GS4, NOTE_AS4, 0, NOTE_DS5, NOTE_F5, NOTE_DS5, NOTE_FS5, NOTE_F5, NOTE_DS5, NOTE_AS4, NOTE_B4, NOTE_CS5, 0, NOTE_CS5, NOTE_B4, NOTE_CS5, NOTE_DS5, NOTE_FS5, NOTE_F5, 0, NOTE_FS5, 0, NOTE_AS4, NOTE_B4, NOTE_CS5, NOTE_B4, 0, NOTE_CS5, NOTE_DS5, NOTE_FS5, NOTE_F5, NOTE_CS5, NOTE_FS5, NOTE_F5, NOTE_CS5, 0, NOTE_FS4, NOTE_FS5, NOTE_F5, NOTE_CS5, NOTE_DS5, 0, NOTE_AS4, NOTE_F4, NOTE_FS4, 0, NOTE_CS5, NOTE_AS4, NOTE_F5, NOTE_CS5, NOTE_B4, NOTE_B4, NOTE_B4, NOTE_B4, NOTE_B4, NOTE_B4, 0, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, 0, NOTE_DS4, NOTE_F4, NOTE_F4, NOTE_F4, NOTE_FS4, 0, NOTE_CS5, NOTE_AS4, NOTE_F5, NOTE_CS5, NOTE_B4, NOTE_B4, NOTE_B4, NOTE_B4, NOTE_B4, NOTE_B4, 0, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5, NOTE_CS5 };
const float BEATS_B[] = { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1.5, 1, 1, 0.5, 0.5, 0.5, 1, 1, 1, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 1, 1, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 1, 1, 0.5, 0.5, 1, 1, 1, 0.5, 1, 0.5, 1, 1, 0.5, 0.5, 1, 0.5, 1, 1, 0.5, 1.5, 0.5, 2, 1, 1, 1, 0.5, 0.5, 1, 0.5, 0.5, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 1, 1, 0.5, 0.5, 1, 1, 0.5, 1, 1, 1, 0.5, 1, 1, 0.5, 1, 1, 1, 2, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 2, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 1.5, 0.5, 0.5, 2, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 1.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 2, 1, 0.5, 0.5, 0.5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 0.5, 0.5, 1.5, 0.5, 1.5, 0.5, 0.5, 0.5, 2, 1, 1, 1, 0.5, 1, 1.5, 1, 1, 1, 0.5, 0.5, 0.5, 1, 0.5, 1.5, 0.5, 1, 1, 1, 1, 1, 1, 3, 1, 0.5, 0.5, 1.5, 0.5, 1.5, 0.5, 0.5, 0.5, 2, 1, 1, 1, 0.5, 1, 1.5, 1, 1, 1, 0.5, 0.5, 0.5, 1, 0.5, 1.5, 0.5, 1, 0.5, 0.5, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1.5, 0.5, 1.5, 0.5, 1.5, 0.5, 0.5, 1.5, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 2, 1, 1, 1, 1, 1, 3, 1, 0.5, 0.5, 1.5, 0.5, 1.5, 0.5, 0.5, 0.5, 2, 1, 1, 1, 1, 0.5, 1.5, 1, 1, 1, 0.5, 0.5, 0.5, 1, 0.5, 2, 1, 1, 1, 1, 1, 1, 3, 1, 0.5, 0.5, 1.5, 0.5, 1.5, 0.5, 0.5, 0.5, 2, 1, 1, 1, 0.5, 1, 1.5, 1, 1, 1, 0.5, 0.5, 0.5, 1, 0.5, 1.5, 0.5, 1, 1, 1, 1, 1, 1, 3, 1, 0.5, 0.5, 1.5, 0.5, 1.5, 0.5, 0.5, 0.5, 2, 1, 1, 1, 0.5, 1, 1.5, 1, 1, 1, 0.5, 0.5, 0.5, 1, 0.5, 1.5, 0.5, 1, 0.5, 0.5, 0.5, 0.5, 1, 1, 1, 1, 2, 1, 1, 4, 2, 0.5, 0.5, 1, 1, 1, 1, 1, 2, 1, 1, 6, 2, 4, 3, 1, 4, 2, 3, 7, 1, 1, 0.5, 0.5, 0.5, 1, 1, 1, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 1, 1, 1, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1, 0.5, 0.5, 0.5, 1 };
const int NOTES_C[] = { NOTE_D3,
                        NOTE_D3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_C3,
                        NOTE_C3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_AS2,
                        NOTE_AS2,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_D3,
                        NOTE_D3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_C3,
                        NOTE_C3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_AS2,
                        NOTE_AS2,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_D4,
                        NOTE_D4,
                        NOTE_D5,
                        0,
                        NOTE_A4,
                        0,
                        NOTE_GS4,
                        0,
                        NOTE_G4,
                        0,
                        NOTE_F4,
                        NOTE_D4,
                        NOTE_F4,
                        NOTE_G4,
                        NOTE_C4,
                        NOTE_C4,
                        NOTE_D5,
                        0,
                        NOTE_A4,
                        0,
                        NOTE_GS4,
                        0,
                        NOTE_G4,
                        0,
                        NOTE_F4,
                        NOTE_D4,
                        NOTE_F4,
                        NOTE_G4,
                        NOTE_B3,
                        NOTE_B3,
                        NOTE_D5,
                        0,
                        NOTE_A4,
                        0,
                        NOTE_GS4,
                        0,
                        NOTE_G4,
                        0,
                        NOTE_F4,
                        NOTE_D4,
                        NOTE_F4,
                        NOTE_G4,
                        NOTE_AS3,
                        NOTE_AS3,
                        NOTE_D5,
                        0,
                        NOTE_A4,
                        0,
                        NOTE_GS4,
                        0,
                        NOTE_G4,
                        0,
                        NOTE_F4,
                        NOTE_D4,
                        NOTE_F4,
                        NOTE_G4,
                        NOTE_D4,
                        NOTE_D4,
                        NOTE_D5,
                        0,
                        NOTE_A4,
                        0,
                        NOTE_GS4,
                        0,
                        NOTE_G4,
                        0,
                        NOTE_F4,
                        NOTE_D4,
                        NOTE_F4,
                        NOTE_G4,
                        NOTE_C4,
                        NOTE_C4,
                        NOTE_D5,
                        0,
                        NOTE_A4,
                        0,
                        NOTE_GS4,
                        0,
                        NOTE_G4,
                        0,
                        NOTE_F4,
                        NOTE_D4,
                        NOTE_F4,
                        NOTE_G4,
                        NOTE_B3,
                        NOTE_B3,
                        NOTE_D5,
                        0,
                        NOTE_A4,
                        0,
                        NOTE_GS4,
                        0,
                        NOTE_G4,
                        0,
                        NOTE_F4,
                        NOTE_D4,
                        NOTE_F4,
                        NOTE_G4,
                        NOTE_AS3,
                        NOTE_AS3,
                        NOTE_D5,
                        0,
                        NOTE_A4,
                        0,
                        NOTE_GS4,
                        0,
                        NOTE_G4,
                        0,
                        NOTE_F4,
                        NOTE_D4,
                        NOTE_F4,
                        NOTE_G4,
                        NOTE_F5,
                        NOTE_F5,
                        NOTE_F5,
                        NOTE_F5,
                        NOTE_F5,
                        NOTE_D5,
                        NOTE_D5,
                        NOTE_F5,
                        NOTE_F5,
                        NOTE_F5,
                        NOTE_G5,
                        NOTE_GS5,
                        NOTE_GS5,
                        NOTE_G5,
                        NOTE_F5,
                        NOTE_D5,
                        NOTE_F5,
                        NOTE_G5,
                        0,
                        NOTE_F5,
                        NOTE_F5,
                        NOTE_F5,
                        0,
                        NOTE_G5,
                        0,
                        NOTE_GS5,
                        0,
                        NOTE_A5,
                        0,
                        NOTE_C6,
                        0,
                        NOTE_A5,
                        NOTE_D6,
                        0,
                        NOTE_D6,
                        0,
                        NOTE_D6,
                        NOTE_A5,
                        NOTE_D6,
                        NOTE_D6,
                        NOTE_A5,
                        NOTE_A5,
                        NOTE_A5,
                        NOTE_A5,
                        NOTE_A5,
                        NOTE_G5,
                        NOTE_G5,
                        NOTE_A5,
                        NOTE_A5,
                        NOTE_A5,
                        NOTE_A5,
                        NOTE_G5,
                        NOTE_A5,
                        NOTE_D6,
                        0,
                        NOTE_A5,
                        NOTE_G5,
                        NOTE_D6,
                        NOTE_A5,
                        NOTE_G5,
                        NOTE_F5,
                        NOTE_C6,
                        NOTE_G5,
                        NOTE_F5,
                        NOTE_E5,
                        NOTE_AS4,
                        0,
                        NOTE_D5,
                        NOTE_E5,
                        0,
                        NOTE_F5,
                        0,
                        NOTE_C6,
                        0,
                        NOTE_F5,
                        NOTE_D5,
                        NOTE_F5,
                        NOTE_G5,
                        NOTE_GS5,
                        NOTE_G5,
                        NOTE_F5,
                        NOTE_D5,
                        NOTE_F5,
                        NOTE_E5,
                        NOTE_D5,
                        NOTE_F5,
                        NOTE_G5,
                        NOTE_GS5,
                        NOTE_A5,
                        NOTE_C6,
                        0,
                        NOTE_A5,
                        NOTE_GS5,
                        NOTE_G5,
                        NOTE_F5,
                        NOTE_D5,
                        NOTE_E5,
                        NOTE_F5,
                        NOTE_G5,
                        NOTE_A5,
                        NOTE_C6,
                        NOTE_CS6,
                        NOTE_GS5,
                        0,
                        NOTE_GS5,
                        NOTE_G5,
                        NOTE_F5,
                        NOTE_G5,
                        NOTE_F4,
                        NOTE_G4,
                        NOTE_A4,
                        NOTE_F5,
                        NOTE_E5,
                        NOTE_D5,
                        NOTE_E5,
                        NOTE_F5,
                        NOTE_G5,
                        NOTE_E5,
                        NOTE_A5,
                        0,
                        NOTE_A5,
                        NOTE_GS5,
                        NOTE_G5,
                        NOTE_FS5,
                        NOTE_F5,
                        NOTE_E5,
                        NOTE_DS5,
                        NOTE_D5,
                        NOTE_CS5,
                        NOTE_D5,
                        NOTE_DS5,
                        0,
                        NOTE_F5,
                        NOTE_D5,
                        NOTE_F5,
                        NOTE_G5,
                        NOTE_GS5,
                        NOTE_G5,
                        NOTE_F5,
                        NOTE_D5,
                        NOTE_F5,
                        NOTE_E5,
                        NOTE_D5,
                        NOTE_F5,
                        NOTE_G5,
                        NOTE_GS5,
                        NOTE_A5,
                        NOTE_C6,
                        0,
                        NOTE_A5,
                        NOTE_GS5,
                        NOTE_G5,
                        NOTE_F5,
                        NOTE_D5,
                        NOTE_E5,
                        NOTE_F5,
                        NOTE_G5,
                        NOTE_A5,
                        NOTE_C6,
                        NOTE_CS6,
                        NOTE_GS5,
                        0,
                        NOTE_GS5,
                        NOTE_G5,
                        NOTE_F5,
                        NOTE_G5,
                        NOTE_F4,
                        NOTE_G4,
                        NOTE_A4,
                        NOTE_F5,
                        NOTE_E5,
                        NOTE_D5,
                        NOTE_E5,
                        NOTE_F5,
                        NOTE_G5,
                        NOTE_E5,
                        NOTE_A5,
                        0,
                        NOTE_A5,
                        NOTE_GS5,
                        NOTE_G5,
                        NOTE_FS5,
                        NOTE_F5,
                        NOTE_E5,
                        NOTE_DS5,
                        NOTE_D5,
                        NOTE_CS5,
                        NOTE_D5,
                        NOTE_DS5,
                        NOTE_AS2,
                        NOTE_F3,
                        NOTE_E3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_AS2,
                        NOTE_F3,
                        NOTE_E3,
                        NOTE_D3,
                        NOTE_D3,
                        NOTE_AS2,
                        NOTE_AS2,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_C3,
                        NOTE_C3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_AS2,
                        NOTE_AS2,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_C3,
                        NOTE_C3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        0,
                        NOTE_F5,
                        0,
                        NOTE_E5,
                        0,
                        NOTE_C5,
                        0,
                        NOTE_E5,
                        0,
                        NOTE_D5,
                        NOTE_G4,
                        NOTE_A4,
                        NOTE_C5,
                        0,
                        NOTE_F5,
                        0,
                        NOTE_E5,
                        0,
                        NOTE_C5,
                        0,
                        NOTE_E5,
                        0,
                        NOTE_D5,
                        NOTE_G4,
                        NOTE_A4,
                        NOTE_C5,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_CS2,
                        NOTE_CS2,
                        NOTE_CS2,
                        NOTE_CS2,
                        NOTE_CS2,
                        NOTE_CS2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_D2,
                        NOTE_CS2,
                        NOTE_CS2,
                        NOTE_CS2,
                        NOTE_CS2,
                        NOTE_CS2,
                        NOTE_CS2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_B2,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_AS1,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_C2,
                        NOTE_D3,
                        NOTE_D3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_D3,
                        NOTE_D3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_AS2,
                        NOTE_AS2,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_C3,
                        NOTE_C3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_D3,
                        NOTE_D3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_D3,
                        NOTE_D3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_AS2,
                        NOTE_AS2,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_C3,
                        NOTE_C3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_D3,
                        NOTE_D3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3,
                        NOTE_D3,
                        NOTE_D3,
                        NOTE_D4,
                        0,
                        NOTE_A3,
                        0,
                        NOTE_GS3,
                        0,
                        NOTE_G3,
                        0,
                        NOTE_F3,
                        NOTE_D3,
                        NOTE_F3,
                        NOTE_G3 };
const float BEATS_C[] = { 0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          1,
                          2.5,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.25,
                          0.25,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          4.5,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          1,
                          2.5,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          1,
                          1,
                          1,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          4.5,
                          4,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.25,
                          0.25,
                          0.5,
                          1,
                          5,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          4.5,
                          1,
                          1,
                          1,
                          1,
                          2,
                          2,
                          2,
                          2,
                          2,
                          2,
                          3,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          3.75,
                          0.25,
                          4,
                          4,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.25,
                          0.25,
                          0.5,
                          1,
                          5,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          4.5,
                          1,
                          1,
                          1,
                          1,
                          2,
                          2,
                          2,
                          2,
                          2,
                          2,
                          3,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          3.75,
                          0.25,
                          4,
                          6,
                          2,
                          4,
                          4,
                          16,
                          6,
                          2,
                          4,
                          4,
                          16,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          1,
                          1,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5,
                          0.5,
                          1,
                          0.5,
                          0.5,
                          0.5 };



void setup() {
  Serial.begin(9600);
  pinMode(upPin, INPUT);
  pinMode(downPin, INPUT);
  pinMode(playPin, INPUT);
  pinMode(piezoPin, OUTPUT);
  lcd.begin(16, 2);
  lcd.setCursor(0, 0);
  lcd.print(songs[currSong]);
}

void loop() {
  upState = digitalRead(upPin);
  downState = digitalRead(downPin);
  playState = digitalRead(playPin);

  if (upState == 1 && prevUpState == 0) {
    if (currSong == 4) {
      Serial.println("Looping back to the start.");
      currSong = 0;
      Serial.println(currSong);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print(songs[currSong]);
    } else {
      Serial.println("Moving back.");
      currSong++;
      Serial.println(currSong);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print(songs[currSong]);
    }
  }

  if (downState == 1 && prevDownState == 0) {
    if (currSong == 0) {
      Serial.println("Looping back to the end.");
      currSong = 4;
      Serial.println(currSong);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print(songs[currSong]);
    } else {
      Serial.println("Moving forward.");
      currSong--;
      Serial.println(currSong);
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print(songs[currSong]);
    }
  }

  if (playState == 1 && prevPlayState == 0) {
    // switch (currSong){
    //   case 0:
    //   	CScale(120);
    //   break;
    //   case 1:
    //   	EbScale(120);
    //   break;
    //   case 2:
    //   	FScale(120);
    //   break;
    //   case 3:
    //   	GScale(120);
    //   break;
    //   case 4:
    //   	DScale(120);
    //   break;
    // }

    switch (currSong) {
      case 0:
        playSong(NOTES_A, BEATS_A, 120);
        break;
      case 1:
        playSong(NOTES_B, BEATS_B, 155);
        break;
      case 2:
        playSong(NOTES_C, BEATS_C, 200);
        break;
      case 3:
        break;
      case 4:
        break;
    }
  }

  prevUpState = upState;
  prevDownState = downState;
  prevPlayState = playState;
}

void playNote(int frequency, float beatCount, int tempo) {
  Serial.print("Playing at: ");
  Serial.println(frequency);
  float duration = (float)(60000 / tempo) * beatCount;
  tone(piezoPin, frequency, duration);
  delay(duration);
}

void rest(float beatCount, int tempo) {
  float duration = (float)(60000 / tempo) * beatCount;
  delay(duration);
}

void playSong(int notes[], float beatCounts[], int tempo) {
  for (int i = 0; i < sizeof(notes); i++) {
    if (notes[i] == 0) {
      rest(beatCounts[i], tempo);
    } else {
      playNote(notes[i], beatCounts[i], tempo);
    }
  }
}

// void CScale(int tempo) {
//   playNote(NOTE_C4, tempo, 1);
//   playNote(NOTE_D4, tempo, 1);
//   playNote(NOTE_E4, tempo, 1);
//   playNote(NOTE_F4, tempo, 1);
//   playNote(NOTE_G4, tempo, 1);
//   playNote(NOTE_A4, tempo, 1);
//   playNote(NOTE_B4, tempo, 1);
//   playNote(NOTE_C5, tempo, 1);
//   playNote(NOTE_B4, tempo, 1);
//   playNote(NOTE_A4, tempo, 1);
//   playNote(NOTE_G4, tempo, 1);
//   playNote(NOTE_F4, tempo, 1);
//   playNote(NOTE_E4, tempo, 1);
//   playNote(NOTE_D4, tempo, 1);
//   playNote(NOTE_C4, tempo, 1);
// }

// void EbScale(int tempo) {
//   playNote(NOTE_DS4, tempo, 1);
//   playNote(NOTE_F4, tempo, 1);
//   playNote(NOTE_G4, tempo, 1);
//   playNote(NOTE_GS4, tempo, 1);
//   playNote(NOTE_AS4, tempo, 1);
//   playNote(NOTE_C5, tempo, 1);
//   playNote(NOTE_D5, tempo, 1);
//   playNote(NOTE_DS5, tempo, 1);
//   playNote(NOTE_D5, tempo, 1);
//   playNote(NOTE_C5, tempo, 1);
//   playNote(NOTE_AS4, tempo, 1);
//   playNote(NOTE_GS4, tempo, 1);
//   playNote(NOTE_G4, tempo, 1);
//   playNote(NOTE_F4, tempo, 1);
//   playNote(NOTE_DS4, tempo, 1);
// }

// void FScale(int tempo) {
//   playNote(NOTE_F4, tempo, 1);
//   playNote(NOTE_G4, tempo, 1);
//   playNote(NOTE_A4, tempo, 1);
//   playNote(NOTE_AS4, tempo, 1);
//   playNote(NOTE_C5, tempo, 1);
//   playNote(NOTE_D5, tempo, 1);
//   playNote(NOTE_E5, tempo, 1);
//   playNote(NOTE_F5, tempo, 1);
//   playNote(NOTE_E5, tempo, 1);
//   playNote(NOTE_D5, tempo, 1);
//   playNote(NOTE_C5, tempo, 1);
//   playNote(NOTE_AS4, tempo, 1);
//   playNote(NOTE_A4, tempo, 1);
//   playNote(NOTE_G4, tempo, 1);
//   playNote(NOTE_F4, tempo, 1);
// }

// void GScale(int tempo) {
//   playNote(NOTE_G4, tempo, 1);
//   playNote(NOTE_A4, tempo, 1);
//   playNote(NOTE_B4, tempo, 1);
//   playNote(NOTE_C5, tempo, 1);
//   playNote(NOTE_D5, tempo, 1);
//   playNote(NOTE_E5, tempo, 1);
//   playNote(NOTE_FS5, tempo, 1);
//   playNote(NOTE_G5, tempo, 1);
//   playNote(NOTE_FS5, tempo, 1);
//   playNote(NOTE_E5, tempo, 1);
//   playNote(NOTE_D5, tempo, 1);
//   playNote(NOTE_C5, tempo, 1);
//   playNote(NOTE_B4, tempo, 1);
//   playNote(NOTE_A4, tempo, 1);
//   playNote(NOTE_G4, tempo, 1);
// }

// void DScale(int tempo) {
//   playNote(NOTE_D4, tempo, 1);
//   playNote(NOTE_E4, tempo, 1);
//   playNote(NOTE_FS4, tempo, 1);
//   playNote(NOTE_G4, tempo, 1);
//   playNote(NOTE_A4, tempo, 1);
//   playNote(NOTE_B4, tempo, 1);
//   playNote(NOTE_CS5, tempo, 1);
//   playNote(NOTE_D5, tempo, 1);
//   playNote(NOTE_CS5, tempo, 1);
//   playNote(NOTE_B4, tempo, 1);
//   playNote(NOTE_A4, tempo, 1);
//   playNote(NOTE_G4, tempo, 1);
//   playNote(NOTE_FS4, tempo, 1);
//   playNote(NOTE_E4, tempo, 1);
//   playNote(NOTE_D4, tempo, 1);
// }

You could store the note data on an SD card and read it in as needed. The internet has hundreds of examples of how.

Perhaps.

You neglected to say what board you're compiling for. That matters a great deal. If it's an Uno R3, or some other board using a 328P, you might look into using PROGMEM to reduce your RAM usage.

But ignoring that for moment, your sketch wouldn't work even if you had unlimited memory. You are passing array addresses to playSong without passing the length of the arrays. sizeof in playSong doesn't do what you seem to think it will. It'll just give you the size of the pointer that's passed, not the number of elements in the original array. You need to brush up on your basic C programming.

1 Like
  • I'm using an Arduino Uno.
  • Arrays in Arduino language don't seem to have any length property, and I couldn't find any information on how to pull the length of an array from said array. Is there such a property? Or do I just need to hard-code it?

You can use

sizeof(array) / sizeof(array[0])

To get the number of elementsnin an array but you can't do that in your function because it on nly has a pointer to the array and sizeof will just give you the size of the pointer. You have to figure the size of that array someplace where it is in scope.

1 Like

Here's a good explanation of how to determine the number of elements in an array in C:

And here's an important "why it doesn't work when an array is passed to a function" provisio and why you have to pass the length as a parameter as well:

Thank you.

Any special reason, academic curiosity apart, why you want to play music through a piezo transducer? Seems an obvious project for the DFRobot DFR MP3 Player?

I just felt like it. Plus, your comment is the first I'm hearing about the DFRobot DFR MP3 Player.

As you're posting in Project Guidance I assumed you might be looking for suggestions about your 'Arduino Music Player' project.

If that's so I recommend a search using 'arduino music player' either here in the forum or within the 23 pages of hits delivered by Google Search.

If not, and your interest is solely about your coding/memory problem, I suggest you ask a moderator to move the thread to Programming Questions.

I'm going to start a new thread there momentarily; I actually got a major lead for the memory problem yesterday, but I ran up on some new issues.