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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
bool find (char letter, string &input, string chord[10])
{
bool isFind = false;
for (int i=0; i<10 ; i++)
{
if (chord[i][0] == letter)
{
isFind = true;
input = chord [i];
}
}
}
bool blank = true;
bool checkRange (string chords)
{
string Range="ABCDEFG";
bool found = false;
int count = 0;
string word;
string ChordsWrd = "";
return found;
}
bool checkSpace (string chords)
{
string Range="ABCDEFG";
bool found = true;
string temp = "";
int count = 0;
for (int i=0;i<chords.length();i++)
{
if (chords[i]!=' '&&i!=chords.size()-1)
temp = temp+chords[i];
else
{
for (int j=0;j<7;j++)
{
if (temp[1]==Range[j])
{
found = false;
}
}
if (!found)
{
i = chords.length()+1;
}
temp = "";
}
}
return found;
}
bool validate(string chords)
{
bool firstChar = true;
bool chordRange = true;
bool inputSize = true;
bool space = true;
chordRange = checkRange(chords);
space = checkSpace(chords);
int count = 1;
for (int i=0;i<chords.length();i++)
if (chords[i]== ' ')
count = count+1;
if (count<1 ||count>10)
inputSize = false;
if (!firstChar)
cout<<"You Should Start with Capital Letter\n";
else if (!chordRange)
cout<<"The Chords must be in range from A to G\n";
else if (!inputSize)
cout<<"Maximum Input is 10 Chords \n";
else if (!space)
cout<<"Chords Must be seperated with blank space\n";
if (firstChar && chordRange && inputSize && space)
return true;
else
return false;
}
void Lower(string chords,int trans)
{
string tablArray [1][12] = {"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
string tablArray2 [1][12] = {"C","B","Bb","A","Ab","G","Gb","F","E","Eb","D","Db"};
string temp = "";
int newIndex;
string result = "";
string str = chords;
string str2,rest;
}
void Higher(string chords,int trans)
{
string tablArray [1][12] = {"C","C#","D","D#","E","F","F#","G","G#","A","A#","B"};
string tablArray2 [1][12] = {"C","B","Bb","A","Ab","G","Gb","F","E","Eb","D","Db"};
string temp = "";
string result = "";
string str = chords;
string str2,rest;
}
int main()
{
string input,chord[10];
int i, counter;
int chords,validate;
cout << "\t" << "\t" << "Music Chord Converter" << endl;
cout << endl;
cout << "Welcome to Music Chord Converter." << endl;
cout << "Please input the original chords (Maximum is 10 chords)." << endl;
cout << "Separate the chords with blank space: ";
getline (cin,input);
cout << "\n";
cout<<"-------Hint to Use This Program------------\n";
cout<<"- Use capital Letters for Chords \n";
cout<<"- Use '#' character for sharp chords \n";
cout<<"- Use 'b' character for flat chords \n";
cout<<"- Add 'm' character for minor chords \n";
cout<<"- Add 'M' character for major chords \n";
cout<<"-------------------------------------------\n";
cout<<"\n";
cout<<"Menu:\n";
if (validate(chords))
{
cout<<"1.Transpose to Higher Key\n";
cout<<"2.Transpose to Lower Key\n";
cout<<"Select:";
string choice;
cin>>choice;
cout<<"Input Key Number:";
int keyNo;
cin>>keyNo;
cout<<endl;
cout<<endl;
if (choice == "1")
{
Higher(chords,keyNo);
}
else if (choice == "2")
{
Lower(chords,keyNo);
}
else
cout<<"Invalid Choice\n";
}
cout<<endl;
for (i=0, counter=0; i<10 && input.find (" ") !=-1; i++, counter++)
{
chord[10] = input.substr (0, input.find (" "));
input = input.substr (input.find (" ")+1);
cout << i << "." << chord [i] << " " << input << endl;
}
cout << endl;
chord [i] = input;
for (i=0; i<=counter; i++)
{
cout << chord [i] << endl;
}
return 0;
|