summaryrefslogtreecommitdiff
authorwaspe <waspe>2003-11-17 20:33:13 (UTC)
committer waspe <waspe>2003-11-17 20:33:13 (UTC)
commit9ea83d1fc66171dbbcf8d1d435eedbb75c346935 (patch) (side-by-side diff)
treedac84f83e68d8a7a02418ec201e576920161155a
parent56f2b27abab0cbae7548b43be4509965b37e3a92 (diff)
downloadopie-9ea83d1fc66171dbbcf8d1d435eedbb75c346935.zip
opie-9ea83d1fc66171dbbcf8d1d435eedbb75c346935.tar.gz
opie-9ea83d1fc66171dbbcf8d1d435eedbb75c346935.tar.bz2
bugfix in getHalfTone(int)
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/tonleiter/tonleiterdatahelper.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp b/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp
index 6b8a5bd..c52e0da 100644
--- a/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp
+++ b/noncore/multimedia/tonleiter/tonleiterdatahelper.cpp
@@ -6,128 +6,126 @@ int Note::getOctaveOfNote(int note)
return (note-remain)/12;
}
//****************************************************************************
QString Note::getNameOfNote(int note)
{
int octave=getOctaveOfNote(note);
return notenames[note-12*octave];
}
//****************************************************************************
int Note::getNoteFromName(QString name,int octave)
{
int notevalue=0;
for(int a=0;a<12;a++)
{
if(name==notenames[a])
{
notevalue=a;
break;
}
}
return notevalue+12*octave;
}
//****************************************************************************
int Note::octaveOfBaseNote(int base,int note)
{
int normnote = (note>=base) ? note-base : (12-base)+note;
int octave=getOctaveOfNote(normnote);
//qDebug("note %d of %d base is norm %d -> ocatve %d",note,base,normnote,octave);
return octave;
}
//****************************************************************************
//****************************************************************************
Instrument::Instrument()
{
name="UNDEFINED";
frets=0;
}
//****************************************************************************
Instrument::Instrument(QString name,int frets,QValueList<int> strings)
:name(name),frets(frets),strings(strings)
{
}
//****************************************************************************
Instrument::~Instrument()
{
}
//****************************************************************************
int Instrument::noOfStrings()
{
return (int)strings.count();
}
//****************************************************************************
int Instrument::noOfFrets()
{
return frets;
}
//****************************************************************************
QString Instrument::instName()
{
return name;
}
//****************************************************************************
int Instrument::string(int id)
{
return strings[id];
}
//****************************************************************************
int Instrument::noOfOctaves()
{
int lowest=strings[0];
int highest=strings[strings.count()-1]+frets;
return (int)((highest-lowest)/12.0);
}
//****************************************************************************
//****************************************************************************
Scale::Scale()
{
name="UNDEFINED";
}
//****************************************************************************
Scale::Scale(QString name,QValueList<int> halftones)
:name(name),halftones(halftones)
{
}
//****************************************************************************
Scale::~Scale()
{
}
//****************************************************************************
int Scale::noOfHaltones()
{
return (int)halftones.count();
}
//****************************************************************************
int Scale::getHalfTone(int id)
{
- if(id>=0 && noOfHaltones()<id)
- {
+ if(id>=0 && id<noOfHaltones())
return halftones[id];
- }
else
return 0;
}
//****************************************************************************
QString Scale::scaleName()
{
return name;
}
//****************************************************************************
bool Scale::noteInScale(int base,int note)
{
int octave=Note::getOctaveOfNote(note);
note-=12*octave;
int normnote = (note>=base) ? note-base : (12-base)+note;
if(halftones.contains(normnote)>0)
{
//qDebug("OK : base : %d, note %d -> norm %d",base,note,normnote);
return true;
}
else
{
//qDebug("BAD : base : %d, note %d -> norm %d",base,note,normnote);
return false;
}
}
//****************************************************************************
//****************************************************************************