This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

80
guitar/NoteType.cpp Normal file
View File

@@ -0,0 +1,80 @@
#include <guitar/NoteType.hpp>
const NoteType &NoteType::operator++(void)
{
if(WholeNote==mNoteType)mNoteType=HalfNote;
else if(HalfNote==mNoteType)mNoteType=QuarterNote;
else if(QuarterNote==mNoteType)mNoteType=EighthNote;
else if(EighthNote==mNoteType)mNoteType=SixteenthNote;
else if(SixteenthNote==mNoteType)mNoteType=ThirtySecondNote;
else if(ThirtySecondNote==mNoteType)mNoteType=SixtyFourthNote;
else mNoteType++;
return *this;
}
const NoteType &NoteType::operator--(void)
{
if(HalfNote==mNoteType)mNoteType=WholeNote;
else if(QuarterNote==mNoteType)mNoteType=HalfNote;
else if(EighthNote==mNoteType)mNoteType=QuarterNote;
else if(SixteenthNote==mNoteType)mNoteType=EighthNote;
else if(ThirtySecondNote==mNoteType)mNoteType=SixteenthNote;
else if(SixtyFourthNote==mNoteType)mNoteType=ThirtySecondNote;
else mNoteType--;
return *this;
}
NoteType &NoteType::fromString(const String &stringRep)
{
if(stringRep.equals(toString(WholeNote)))mNoteType=WholeNote;
else if(stringRep.equals(toString(HalfNote)))mNoteType=HalfNote;
else if(stringRep.equals(toString(QuarterNote)))mNoteType=QuarterNote;
else if(stringRep.equals(toString(EighthNote)))mNoteType=EighthNote;
else if(stringRep.equals(toString(SixteenthNote)))mNoteType=SixteenthNote;
else if(stringRep.equals(toString(ThirtySecondNote)))mNoteType=ThirtySecondNote;
else if(stringRep.equals(toString(SixtyFourthNote)))mNoteType=SixtyFourthNote;
else mNoteType=stringRep.betweenString('/',0).toInt();
return *this;
}
Array<String> NoteType::enumerate(void)
{
Array<String> values;
values.size(7);
values[0]=NoteType::toString(WholeNote);
values[1]=NoteType::toString(HalfNote);
values[2]=NoteType::toString(QuarterNote);
values[3]=NoteType::toString(EighthNote);
values[4]=NoteType::toString(SixteenthNote);
values[5]=NoteType::toString(ThirtySecondNote);
values[6]=NoteType::toString(SixtyFourthNote);
return values;
}
String NoteType::toString(void)const
{
return toString(getNoteType());
}
String NoteType::toString(TypeNote noteType)
{
switch(noteType)
{
case WholeNote :
return "1/1";
case HalfNote :
return "1/2";
case QuarterNote :
return "1/4";
case EighthNote :
return "1/8";
case SixteenthNote :
return "1/16";
case ThirtySecondNote :
return "1/32";
case SixtyFourthNote :
return "1/64";
default :
return "1/"+String().fromInt((int)noteType);
}
}