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
|
#include<iostream>
#include<string>
using namespace std;
struct Semitones{string tone_value;};
enum key {gsharp_aflat, tone_A, asharp_bflat, tone_B, tone_C, csharp_dflat,
tone_D, dsharp_eflat, tone_E, tone_F, fsharp_gflat, tone_G};
enum intervals {unison, minor2, major2, minor3, major3, perfect4th,
aug_fourth, perfect5th, minor6, major6, minor7, major7};
int root_finder(Semitones tone[], string input); //function prototype
void print_fretboard(Semitones tone[]);
int set_tuning;
int main()
{
Semitones note[12]; // resource used by "root_finder" during "scale[]'s" formatting
Semitones scale[12]; // will contain users scale
//- i.e all 12 semitones, but in order according to the key entered by user
note[gsharp_aflat].tone_value = "G#/Ab";
note[tone_A].tone_value = "A";
note[asharp_bflat].tone_value = "A#/Bb";
note[tone_B].tone_value = "B";
note[tone_C].tone_value = "C";
note[csharp_dflat].tone_value = "C#/Db";
note[tone_D].tone_value = "D";
note[dsharp_eflat].tone_value = "D#/Eb";
note[tone_E].tone_value = "E";
note[tone_F].tone_value = "F";
note[fsharp_gflat].tone_value = "F#/Gb";
note[tone_G].tone_value = "G";
cout<<"Natural minor (Aeolian) Scale Finder\n" << endl;
cout<<"Enter Key Signature"<<endl;
string user_input;
cin>>user_input;
cout<<endl<<endl;
int root;
root =(root_finder(note, user_input)); //function called will compare the input to the existing "note[]" database and create new scale
// inside of "scale[]" according to user input
int n = 0;
do {// stores the intervals corresponding to the detected key, each pass represents one semitone, in ascending order
scale[n].tone_value = note[(root)].tone_value;
++n; // increase both to store the next intervals value into scale
++root;
if (root >= 12) // since root may be a value close to 12,
{root = 0;} // we need to reset couter to zero so that the values in the array positions
else // less than the original value of root will be properly transferred
continue;
} while (n <= 12);
// scale complete
root = 0; // reset root to zero
cout << " Key Established...\n" << endl; // the following prints values according to the minor scale,
cout << "Natural minor (Aeolian) scale\n" << endl; // which is defined by
cout << " For Root Note "; // {key, major2, minor3, perfect4, perfect5, minor6, minor7, octave(same as root/key)
cout << scale[unison].tone_value <<"\n(";
cout << scale[unison].tone_value <<" ";
cout << scale[major2].tone_value <<" ";
cout << scale[minor3].tone_value <<" ";
cout << scale[perfect4th].tone_value <<" ";
cout << scale[perfect5th].tone_value <<" ";
cout << scale[minor6].tone_value <<" ";
cout << scale[minor7].tone_value <<" ";
cout << scale[unison].tone_value <<")\n";
cout << endl;
}
int root_finder(Semitones tone[], string input){ //compares users input to values inside the template array "note[]"
if (input == tone[0].tone_value) //and returns a corresponding array position based on user input
return(gsharp_aflat);
else if (input == tone[1].tone_value)
return(tone_A);
else if (input == tone[2].tone_value)
return(asharp_bflat);
else if (input == tone[3].tone_value)
return(tone_B);
else if (input == tone[4].tone_value)
return(tone_C);
else if (input == tone[5].tone_value)
return(csharp_dflat);
else if (input == tone[6].tone_value)
return(tone_D);
else if (input == tone[7].tone_value)
return(dsharp_eflat);
else if (input == tone[8].tone_value)
return(tone_E);
else if (input == tone[9].tone_value)
return(tone_F);
else if (input == tone[10].tone_value)
return(fsharp_gflat);
else if (input == tone[11].tone_value)
return(tone_G);
else
cout<<"there was an error";
return 0;
}
|