#ifndef _MUSICKEY_H
#define _MUSICKEY_H
#include<string>
using namespace std;
class musickey
{
public:
musickey();
musickey(const musickey &);
string GetScale(const string &,const string &);
private:
string chromatic[12];
string formula;
string result;
string mode;
string scale;
int last, next;
};
musickey::musickey()
{
}
musickey::musickey(const musickey &Object)
{
}
string musickey::GetScale(const string &inckey,const string &incmode)
{
//initialize everything
const string chromatic[12]=
{
"A","A#","B","C","C#","D","D#","E","F","F#","G","G#"
};
//initialize everything
//SetKey
int i;
for(i = 0; (chromatic[i] != inckey) && (i < 12) ; i++)
{
last = i+1;
}
if(i == 12)
{
return "\nError\nInvalid Key";
}
//SetKey
//SetMode
if(incmode == "Major")
{
formula = "wwhwwwh";
}
if(incmode == "Minor")
{
formula = "whhhwhh";
}
if(incmode == "Dorian")
{
formula = "whwwwhw";
}
if(incmode == "Phrygian")
{
formula = "hwwwhww";
}
else
{
return "\nError\nInvalid mode.";
}
//SetMode
//GetScale
scale = "";
for(unsigned int i = 0; i < formula.length(); i++)
{
scale.append(chromatic[last]);
scale.append(" ");
if(formula[i] == ('W' || 'w'))
{
next = 2;
}
if(formula[i] == ('H' || 'h'))
{
next = 1;
}
next += last;
if(next > 11)
{
next -= 12;
}
last = next;
}
//GetScale
return scale;
}
#endif
This post has been edited by Ty Meador: 11 September 2011 - 03:10 PM

New Topic/Question
Reply




MultiQuote






|