X-Git-Url: https://code.delx.au/virtualtones/blobdiff_plain/fea523e103dc13f1f80f71d75fe4f88686566584..cb268b4b10d164509f5c02d4719dfb00dd9d61e9:/instrument.cpp diff --git a/instrument.cpp b/instrument.cpp index f8d7083..546100e 100644 --- a/instrument.cpp +++ b/instrument.cpp @@ -1,10 +1,12 @@ // instrument.cpp - An instrument widget -// Written by James Bunton +// Written by James Bunton // Licensed under the GPL, see COPYING.txt for more details #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 - 2)); // 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; } - -