1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
#include<Windows.h>
#include<iostream>
#include <string>
using namespace std;
int A = 880;
int As = 932;
int B = 988;
int C = 1030;
int Cs = 1045;
int D = 294;
int Ds = 311;
int E = 330;
int F = 698;
int Fs = 740;
int G = 784 ;
int Gs = 830 ;
int frth = 400;
int one = 800;
int half = 1600;
int whole = 3200;
void Pause()
{
char Ref;
cin >> Ref;
}
int play(int note, int length)
{
Beep(note,length);
return 0;
}
//mary had a little lamb function
void Mary()
{
play(A,frth);
play(G,frth);
play(F,frth);
play(G,frth);
play(A,frth);
play(A,frth);
play(A,one);
play(G,frth);
play(G,frth);
play(G,one);
play(A,frth);
play(C,frth);
play(C,one);
play(A,frth);
play(G,frth);
play(F,frth);
play(G,frth);
play(A,frth);
play(A,frth);
play(A,frth);
play(A,frth);
play(G,frth);
play(G,frth);
play(A,frth);
play(G,frth);
play(F,one);
}
void playC(int n1,int n2,int n3,int n4,int n5,int n6,int n7,int n8,int n9,int n10,int n11,int n12,int n13,int n14,int n15)
{
play(n1,frth);
play(n2,frth);
play(n3,frth);
play(n4,frth);
play(n5,frth);
play(n6,frth);
play(n7,frth);
play(n8,frth);
play(n9,frth);
play(n10,frth);
play(n11,frth);
play(n12,frth);
play(n13,frth);
play(n14,frth);
play(n15,frth);
}
int main()
{
string note; // input for notes
int choice; // choice for main action
int N[15]; //Array to store user custom notes
int Nn = 1 ;
cout << "Do you want to play mary had a little lamb or write your own music?\n" << endl;
cout << "(1)Mary Had a Little Lamb" << endl;
cout << "(2)Make Own Music(up to 15 notes)" << endl;
cin >> choice;
while(choice != -1)
{
if(choice == 1)
{
Mary();
}
if (choice == 2)
{
for (int x = 0; x < 15; x++)
{
if(note == "A")
{
N[x] = 880;
}
if(note == "As")
{
N[x] = 932;
}
if(note == "B")
{
N[x] = 988;
}
if(note == "C")
{
N[x] = 1030;
}
if(note == "Cs")
{
N[x] = 1045;
}
if(note == "D")
{
N[x] = 294;
}
if(note == "Ds")
{
N[x] = 311;
}
if(note == "E")
{
N[x] = 330;
}
if(note == "F")
{
N[x] = 698;
}
if(note == "Fs")
{
N[x] = 740;
}
if(note == "G")
{
N[x] = 784;
}
if(note == "Gs")
{
N[x] = 830;
}
cout << "enter a note: ";
cin >> N[x]; cin.ignore(1,1);
}
playC(N[0],N[1],N[2],N[3],N[4],N[5],N[6],N[7],N[8],N[9],N[10],N[11],N[12],N[13],N[14]);
}
}
Pause();
return 0;
}
|