]> code.delx.au - virtualtones/blobdiff - instrument.cpp
Updated to modern Qt
[virtualtones] / instrument.cpp
index f8d7083197b006457521345e8fa909d92e34e5fa..0ebf341f3893319096f2ac4f25d4d7042d2121d3 100644 (file)
@@ -5,6 +5,8 @@
 
 #include "instrument.h"
 
+using namespace Qt;
+
 
 Instrument::Instrument(QWidget *parent)
 : QWidget(parent, 0)
@@ -92,16 +94,17 @@ bool Instrument::event(QEvent *e)
 
 QString Instrument::midi2string(int num)
 {
-       int i;
-       for(i = 9; num > 11; i--) {
+       int octave;
+       for(octave = 0; num >= 12; octave++) {
                num -= 12;
        }
-
-       return QString(midnotes[num] + " - Octave:" + QString::number(i - 6)); // Middle C is then "C - Octave: 3"
+       return QString(midnotes[num] + " - Octave: " + QString::number(octave - 6)); // Middle C is then "C - Octave: 3"
 }
 
 bool Instrument::checkSharp(int note)
 {
+       // This misnamed function checks to see if we are of the the following notes. Useful for string instruments
+       // These are the notes with only a half-tone gap between them
 //1    13      25      37      49      61      73      85      97      109     121
 //6    18      30      42      54      66      78      90      102     114     126
        if((note - 1) % 12 == 0 || note - 1 == 0)
@@ -111,5 +114,3 @@ bool Instrument::checkSharp(int note)
 
        return false;
 }
-
-