]> code.delx.au - virtualtones/commitdiff
Few polish fixes
authorJames Bunton <jamesbunton@delx.net.au>
Thu, 1 Jan 2004 21:46:33 +0000 (21:46 +0000)
committerJames Bunton <jamesbunton@delx.net.au>
Thu, 1 Jan 2004 21:46:33 +0000 (21:46 +0000)
It's now easier to play stringed instruments (less accidental notes)

instrument.cpp
pianoinstrument.cpp
stringinstrument.cpp
stringinstrument.h

index f8d7083197b006457521345e8fa909d92e34e5fa..b4e729602f341f334b915bfd8d7cbbedb0f9a757 100644 (file)
@@ -92,16 +92,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)
index 67ebc13a9f211d9de5d89bed50dcdfdbd0b88c4d..127d9e14ded50daf9eca339d68316ee9c96809c1 100644 (file)
@@ -40,11 +40,12 @@ QString PianoInstrument::generateHelp()
 
 "Playing the keyboard:"
 "<ul>"
-"<li>You can change the octave using the &quot;Octave&quot; box above. Middle C is the third octave</li>"
+"<li>You can change the octave using the &quot;Base Octave&quot; box above. Middle C is the third octave</li>"
 "<li>The keys - qwertyui are the top row white keys</li>"
 "<li>The keys - 23 567 9 are the top row black keys</li>"
 "<li>The keys - zxcvbnm, are the bottom row white keys</li>"
 "<li>The keys - sd ghj l are the bottom row black keys</li>"
+"<li>When you push a key, the note it corresponds to is highlighted</li>"
 "</ul>"
 
 "</html>"
index b9ba3920115bb287349cd48b5e3ce6f66d967bc6..8d369a1b1d9f106a3fe0083d81ef635d642b154d 100644 (file)
@@ -156,7 +156,7 @@ QString StringInstrument::generateHelp()
 "<li>The row 'q' 'w' 'e' 'r' is the A string</li>"
 "<li>The row 'a' 's' 'd' 'f' is the D string</li>"
 "<li>The row 'z' 'x' 'c' 'v' is the G string</li>"
-"<li>The further right the key is, the higher the note</li>"
+"<li>The further to the right the key is, the higher the note</li>"
 "<li>Try pressing multiple keys on the same string to get sharp notes. On the A,D,G strings try the Tab, Caps and Shift keys for sharp notes</li>"
 "</ul>"
 
@@ -332,7 +332,7 @@ void StringInstrument::keyPressEvent(QKeyEvent *e)
                return;
        }
        e->accept();
-       emitSounds();
+       QTimer::singleShot(50, this, SLOT(emitSounds()));
 }
 
 void StringInstrument::keyReleaseEvent(QKeyEvent *e)
@@ -480,7 +480,7 @@ void StringInstrument::keyReleaseEvent(QKeyEvent *e)
                return;
        }
        e->accept();
-       emitSounds();
+       QTimer::singleShot(50, this, SLOT(emitSounds()));
 }
 
 void StringInstrument::zeroArray(bool array[4][4])
index e88d29f332276799e769c3683a53cebf287cb501..8e5b485441587a1dafc3401eedd3780b734e2a22 100644 (file)
@@ -9,6 +9,7 @@
 #include <qwidget.h>
 #include <qpixmap.h>
 #include <qpainter.h>
+#include <qtimer.h>
 
 #include "instrument.h"
 
@@ -20,6 +21,9 @@ Q_OBJECT
        public:
                StringInstrument(QWidget *parent);
                ~StringInstrument();
+       
+       private slots:
+               void emitSounds();
 
        protected:
                QString generateHelp();
@@ -33,7 +37,6 @@ Q_OBJECT
                void zeroArray(int array[4]);
                virtual void setNotes(int array[4])=0; // Set the base string notes
                void copyArray(int source[4], int dest[4]);
-               void emitSounds();
 
                // Keys
                bool down[4][4];