118 lines
2.2 KiB
C++
118 lines
2.2 KiB
C++
#ifndef _MUSIC_SCALE_HPP_
|
|
#define _MUSIC_SCALE_HPP_
|
|
#ifndef _MUSIC_NOTES_HPP_
|
|
#include <music/notes.hpp>
|
|
#endif
|
|
#ifndef _MUSIC_DEGREE_HPP_
|
|
#include <music/degree.hpp>
|
|
#endif
|
|
#ifndef _MUSIC_CHORD_HPP_
|
|
#include <music/chord.hpp>
|
|
#endif
|
|
|
|
class Scale : public Notes
|
|
{
|
|
public:
|
|
enum{CNotes=8};
|
|
enum{Delay=200};
|
|
Scale(Note root=Note::G,const String &description=String());
|
|
Scale(Note root=Note::G,int octave=Note::Octave,const String &description=String());
|
|
virtual ~Scale();
|
|
const String &getDescription(void)const;
|
|
void setDescription(const String &description);
|
|
const Note &getRoot(void)const;
|
|
void setRoot(const Note &root);
|
|
Music::Chord getIChord(void)const;
|
|
Music::Chord getI7Chord(void)const;
|
|
Music::Chord getIVChord(void)const;
|
|
Music::Chord getV7Chord(void)const;
|
|
const Note &getDegree(Degree degree)const;
|
|
Degree getDegree(const Note ¬e);
|
|
bool has(Degree degree)const;
|
|
void setDegree(Degree degree,const Note ¬e);
|
|
void setDelay(int Delay);
|
|
bool contains(const Notes ¬es)const;
|
|
protected:
|
|
virtual void createScale()=0;
|
|
virtual int getDelay(void)const;
|
|
private:
|
|
Note mRoot;
|
|
String mDescription;
|
|
int mDelay;
|
|
};
|
|
|
|
inline
|
|
Scale::Scale(Note root,const String &description)
|
|
: mRoot(root), mDescription(description), mDelay(Delay)
|
|
{
|
|
size(CNotes);
|
|
}
|
|
|
|
inline
|
|
Scale::Scale(Note root,int octave,const String &description)
|
|
: mRoot(root.getNote(),octave), mDescription(description), mDelay(Delay)
|
|
{
|
|
}
|
|
|
|
inline
|
|
Scale::~Scale()
|
|
{
|
|
}
|
|
|
|
inline
|
|
const String &Scale::getDescription(void)const
|
|
{
|
|
return mDescription;
|
|
}
|
|
|
|
inline
|
|
void Scale::setDescription(const String &description)
|
|
{
|
|
mDescription=description;
|
|
}
|
|
|
|
inline
|
|
const Note &Scale::getRoot(void)const
|
|
{
|
|
return mRoot;
|
|
}
|
|
|
|
inline
|
|
void Scale::setRoot(const Note &root)
|
|
{
|
|
mRoot=root;
|
|
createScale();
|
|
}
|
|
|
|
inline
|
|
int Scale::getDelay(void)const
|
|
{
|
|
return mDelay;
|
|
}
|
|
|
|
inline
|
|
void Scale::setDelay(int delay)
|
|
{
|
|
mDelay=delay;
|
|
}
|
|
|
|
inline
|
|
const Note &Scale::getDegree(Degree degree)const
|
|
{
|
|
return ((Notes&)*this).operator[](degree.getInterval());
|
|
}
|
|
|
|
inline
|
|
bool Scale::has(Degree degree)const
|
|
{
|
|
if((int)size()>=degree.getInterval())return true;
|
|
return false;
|
|
}
|
|
|
|
inline
|
|
void Scale::setDegree(Degree degree,const Note ¬e)
|
|
{
|
|
operator[](degree.getInterval())=note;
|
|
}
|
|
#endif
|