Files
Work/music/scale.cpp
2024-08-07 09:16:27 -04:00

78 lines
1.6 KiB
C++

#include <music/scale.hpp>
Music::Chord Scale::getIChord(void)const
{
Music::Chord iChord;
iChord.size(3);
iChord[0]=((Notes&)*this).operator[](0);
iChord[1]=((Notes&)*this).operator[](2);
iChord[2]=((Notes&)*this).operator[](4);
return iChord;
}
Music::Chord Scale::getI7Chord(void)const
{
Music::Chord iChord;
iChord.size(4);
iChord[0]=((Notes&)*this).operator[](0);
iChord[1]=((Notes&)*this).operator[](2);
iChord[2]=((Notes&)*this).operator[](4);
iChord[3]=size()<7?iChord[0]:((Notes&)*this).operator[](6);
return iChord;
}
Music::Chord Scale::getIVChord(void)const
{
Music::Chord ivChord;
ivChord.size(3);
ivChord[0]=((Notes&)*this).operator[](0);
ivChord[1]=((Notes&)*this).operator[](3);
ivChord[2]=((Notes&)*this).operator[](5);
return ivChord;
}
Music::Chord Scale::getV7Chord(void)const
{
Music::Chord v7Chord;
v7Chord.size(3);
v7Chord[0]=((Notes&)*this).operator[](3);
v7Chord[1]=((Notes&)*this).operator[](4);
Note note(((Notes&)*this).operator[](0));
note--;
v7Chord[2]=note;
return v7Chord;
}
Degree Scale::getDegree(const Note &note)
{
for(int index=0;index<size();index++)
{
if(operator[](index).getNote()==note.getNote())
{
return Degree((Degree::Interval)index);
}
}
return Degree::None;
}
bool Scale::contains(const Notes &notes)const
{
bool found=false;
for(int noteIndex=0;noteIndex<notes.size();noteIndex++)
{
Note &currNote=((Notes &)notes)[noteIndex];
found=false;
for(int index=0;index<size();index++)
{
if(currNote==((Notes &)(*this))[index])
{
found=true;
break;
}
}
if(!found)return false;
}
return true;
}