Files
Work/guitar/backup/20040302/FrettedNote.hpp
2024-08-07 09:16:27 -04:00

159 lines
3.2 KiB
C++

#ifndef _GUITAR_FRETTEDNOTE_HPP_
#define _GUITAR_FRETTEDNOTE_HPP_
#ifndef _COMMON_STDIO_HPP_
#include <common/stdio.hpp>
#endif
#ifndef _COMMON_ARRAY_HPP_
#include <common/array.hpp>
#endif
#ifndef _MUSIC_NOTE_HPP_
#include <music/note.hpp>
#endif
#ifndef _GUITAR_ACTION_HPP_
#include <guitar/Action.hpp>
#endif
class FrettedNote;
typedef Array<FrettedNote> FrettedNotes;
class FrettedNote : public Note
{
public:
FrettedNote();
FrettedNote(const FrettedNote &frettedNote);
FrettedNote(const Note &note,int string,int fret,const Action &action=Action(Action::Pick));
virtual ~FrettedNote();
FrettedNote &operator=(const FrettedNote &frettedNote);
bool operator==(const FrettedNote &frettedNote)const;
bool operator>(const FrettedNote &frettedNote)const;
bool operator<(const FrettedNote &frettedNote)const;
int getString(void)const;
void setString(int string);
int getFret(void)const;
void setFret(int fret);
void setNote(const Note &note);
const Note &getNote(void)const;
const Action &getAction(void)const;
void setAction(const Action &action);
String toString(void)const;
private:
int mString;
int mFret;
Action mAction;
};
inline
FrettedNote::FrettedNote(const FrettedNote &frettedNote)
{
*this=frettedNote;
}
inline
FrettedNote::FrettedNote()
: Note(Note::E,4), mString(0), mFret(0)
{
}
inline
FrettedNote::FrettedNote(const Note &note,int string,int fret,const Action &action)
: Note(note), mString(string), mFret(fret), mAction(action)
{
}
inline
FrettedNote::~FrettedNote()
{
}
inline
FrettedNote &FrettedNote::operator=(const FrettedNote &frettedNote)
{
setString(frettedNote.getString());
setFret(frettedNote.getFret());
(Note&)*this=(Note&)frettedNote;
setAction(frettedNote.getAction());
return *this;
}
inline
bool FrettedNote::operator==(const FrettedNote &frettedNote)const
{
if(getString()==frettedNote.getString()&&getFret()==frettedNote.getFret())
return (Note&)*this==(Note&)frettedNote;
return false;
}
inline
bool FrettedNote::operator>(const FrettedNote &frettedNote)const
{
if(getString()>frettedNote.getString())return true;
if(getFret()>frettedNote.getFret())return true;
return (Note&)*this>(Note&)frettedNote;
}
inline
bool FrettedNote::operator<(const FrettedNote &frettedNote)const
{
if(getString()<frettedNote.getString())return true;
if(getFret()<frettedNote.getFret())return true;
return (Note&)*this<(Note&)frettedNote;
}
inline
int FrettedNote::getString(void)const
{
return mString;
}
inline
void FrettedNote::setString(int string)
{
mString=string;
}
inline
int FrettedNote::getFret(void)const
{
return mFret;
}
inline
void FrettedNote::setFret(int fret)
{
mFret=fret;
}
inline
void FrettedNote::setNote(const Note &note)
{
(Note&)*this=note;
}
inline
const Note &FrettedNote::getNote(void)const
{
return (Note&)*this;
}
inline
const Action &FrettedNote::getAction(void)const
{
return mAction;
}
inline
void FrettedNote::setAction(const Action &action)
{
mAction=action;
}
inline
String FrettedNote::toString(void)const
{
String str;
::sprintf(str.str(),"[String=%d Fret=%d ",mString,mFret);
return str+String("Note=")+Note::toStringWithOctave()+String(" Action=")+mAction.toString()+String("]");
}
#endif