summaryrefslogtreecommitdiff
authorwaspe <waspe>2003-11-17 20:33:13 (UTC)
committer waspe <waspe>2003-11-17 20:33:13 (UTC)
commit9ea83d1fc66171dbbcf8d1d435eedbb75c346935 (patch) (unidiff)
treedac84f83e68d8a7a02418ec201e576920161155a
parent56f2b27abab0cbae7548b43be4509965b37e3a92 (diff)
downloadopie-9ea83d1fc66171dbbcf8d1d435eedbb75c346935.zip
opie-9ea83d1fc66171dbbcf8d1d435eedbb75c346935.tar.gz
opie-9ea83d1fc66171dbbcf8d1d435eedbb75c346935.tar.bz2
bugfix in getHalfTone(int)
Diffstat (more/less context) (ignore 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
@@ -1,133 +1,131 @@
1#include "tonleiterdatahelper.h" 1#include "tonleiterdatahelper.h"
2 2
3int Note::getOctaveOfNote(int note) 3int Note::getOctaveOfNote(int note)
4{ 4{
5 int remain=note%12; 5 int remain=note%12;
6 return (note-remain)/12; 6 return (note-remain)/12;
7} 7}
8//**************************************************************************** 8//****************************************************************************
9QString Note::getNameOfNote(int note) 9QString Note::getNameOfNote(int note)
10{ 10{
11 int octave=getOctaveOfNote(note); 11 int octave=getOctaveOfNote(note);
12 return notenames[note-12*octave]; 12 return notenames[note-12*octave];
13} 13}
14//**************************************************************************** 14//****************************************************************************
15int Note::getNoteFromName(QString name,int octave) 15int Note::getNoteFromName(QString name,int octave)
16{ 16{
17 int notevalue=0; 17 int notevalue=0;
18 for(int a=0;a<12;a++) 18 for(int a=0;a<12;a++)
19 { 19 {
20 if(name==notenames[a]) 20 if(name==notenames[a])
21 { 21 {
22 notevalue=a; 22 notevalue=a;
23 break; 23 break;
24 } 24 }
25 } 25 }
26 return notevalue+12*octave; 26 return notevalue+12*octave;
27} 27}
28//**************************************************************************** 28//****************************************************************************
29int Note::octaveOfBaseNote(int base,int note) 29int Note::octaveOfBaseNote(int base,int note)
30{ 30{
31 int normnote = (note>=base) ? note-base : (12-base)+note; 31 int normnote = (note>=base) ? note-base : (12-base)+note;
32 int octave=getOctaveOfNote(normnote); 32 int octave=getOctaveOfNote(normnote);
33 //qDebug("note %d of %d base is norm %d -> ocatve %d",note,base,normnote,octave); 33 //qDebug("note %d of %d base is norm %d -> ocatve %d",note,base,normnote,octave);
34 return octave; 34 return octave;
35} 35}
36//**************************************************************************** 36//****************************************************************************
37//**************************************************************************** 37//****************************************************************************
38Instrument::Instrument() 38Instrument::Instrument()
39{ 39{
40 name="UNDEFINED"; 40 name="UNDEFINED";
41 frets=0; 41 frets=0;
42} 42}
43//**************************************************************************** 43//****************************************************************************
44Instrument::Instrument(QString name,int frets,QValueList<int> strings) 44Instrument::Instrument(QString name,int frets,QValueList<int> strings)
45:name(name),frets(frets),strings(strings) 45:name(name),frets(frets),strings(strings)
46{ 46{
47} 47}
48//**************************************************************************** 48//****************************************************************************
49Instrument::~Instrument() 49Instrument::~Instrument()
50{ 50{
51} 51}
52//**************************************************************************** 52//****************************************************************************
53int Instrument::noOfStrings() 53int Instrument::noOfStrings()
54{ 54{
55 return (int)strings.count(); 55 return (int)strings.count();
56} 56}
57//**************************************************************************** 57//****************************************************************************
58int Instrument::noOfFrets() 58int Instrument::noOfFrets()
59{ 59{
60 return frets; 60 return frets;
61} 61}
62//**************************************************************************** 62//****************************************************************************
63QString Instrument::instName() 63QString Instrument::instName()
64{ 64{
65 return name; 65 return name;
66} 66}
67//**************************************************************************** 67//****************************************************************************
68int Instrument::string(int id) 68int Instrument::string(int id)
69{ 69{
70 return strings[id]; 70 return strings[id];
71} 71}
72//**************************************************************************** 72//****************************************************************************
73int Instrument::noOfOctaves() 73int Instrument::noOfOctaves()
74{ 74{
75 int lowest=strings[0]; 75 int lowest=strings[0];
76 int highest=strings[strings.count()-1]+frets; 76 int highest=strings[strings.count()-1]+frets;
77 return (int)((highest-lowest)/12.0); 77 return (int)((highest-lowest)/12.0);
78} 78}
79//**************************************************************************** 79//****************************************************************************
80//**************************************************************************** 80//****************************************************************************
81Scale::Scale() 81Scale::Scale()
82{ 82{
83 name="UNDEFINED"; 83 name="UNDEFINED";
84} 84}
85//**************************************************************************** 85//****************************************************************************
86Scale::Scale(QString name,QValueList<int> halftones) 86Scale::Scale(QString name,QValueList<int> halftones)
87:name(name),halftones(halftones) 87:name(name),halftones(halftones)
88{ 88{
89} 89}
90//**************************************************************************** 90//****************************************************************************
91Scale::~Scale() 91Scale::~Scale()
92{ 92{
93} 93}
94//**************************************************************************** 94//****************************************************************************
95int Scale::noOfHaltones() 95int Scale::noOfHaltones()
96{ 96{
97 return (int)halftones.count(); 97 return (int)halftones.count();
98} 98}
99//**************************************************************************** 99//****************************************************************************
100int Scale::getHalfTone(int id) 100int Scale::getHalfTone(int id)
101{ 101{
102 if(id>=0 && noOfHaltones()<id) 102 if(id>=0 && id<noOfHaltones())
103 {
104 return halftones[id]; 103 return halftones[id];
105 }
106 else 104 else
107 return 0; 105 return 0;
108} 106}
109//**************************************************************************** 107//****************************************************************************
110QString Scale::scaleName() 108QString Scale::scaleName()
111{ 109{
112 return name; 110 return name;
113} 111}
114//**************************************************************************** 112//****************************************************************************
115bool Scale::noteInScale(int base,int note) 113bool Scale::noteInScale(int base,int note)
116{ 114{
117 int octave=Note::getOctaveOfNote(note); 115 int octave=Note::getOctaveOfNote(note);
118 note-=12*octave; 116 note-=12*octave;
119 int normnote = (note>=base) ? note-base : (12-base)+note; 117 int normnote = (note>=base) ? note-base : (12-base)+note;
120 118
121 if(halftones.contains(normnote)>0) 119 if(halftones.contains(normnote)>0)
122 { 120 {
123 //qDebug("OK : base : %d, note %d -> norm %d",base,note,normnote); 121 //qDebug("OK : base : %d, note %d -> norm %d",base,note,normnote);
124 return true; 122 return true;
125 } 123 }
126 else 124 else
127 { 125 {
128 //qDebug("BAD : base : %d, note %d -> norm %d",base,note,normnote); 126 //qDebug("BAD : base : %d, note %d -> norm %d",base,note,normnote);
129 return false; 127 return false;
130 } 128 }
131} 129}
132//**************************************************************************** 130//****************************************************************************
133//**************************************************************************** 131//****************************************************************************