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)
"Playing the keyboard:"
"<ul>"
-"<li>You can change the octave using the "Octave" box above. Middle C is the third octave</li>"
+"<li>You can change the octave using the "Base Octave" 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>"
"<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>"
return;
}
e->accept();
- emitSounds();
+ QTimer::singleShot(50, this, SLOT(emitSounds()));
}
void StringInstrument::keyReleaseEvent(QKeyEvent *e)
return;
}
e->accept();
- emitSounds();
+ QTimer::singleShot(50, this, SLOT(emitSounds()));
}
void StringInstrument::zeroArray(bool array[4][4])
#include <qwidget.h>
#include <qpixmap.h>
#include <qpainter.h>
+#include <qtimer.h>
#include "instrument.h"
public:
StringInstrument(QWidget *parent);
~StringInstrument();
+
+ private slots:
+ void emitSounds();
protected:
QString generateHelp();
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];