rectTop = 100000;
rectRight = oldX;
rectBot = 0;
while (enum3.hasMoreElements()) {
Note aNote = (Note) enum3.nextElement();
int currNote = -1;
if (aNote.getPitchType() == Note.MIDI_PITCH) currNote = aNote.getPitch();
else currNote = Note.freqToMidiPitch(aNote.getFrequency());
if ((currNote <= 127) && (currNote >= 0)) {
// 10 - numb of octaves, 12 notes in an octave, 21
// (octavePixelheight) is the height of
// an octave, 156 is offset to put in position
int octavePixelheight = noteHeight * 7;
int y = (int) (((10 - currNote / 12) * octavePixelheight +
(ePos)) - noteOffset[currNote % 12]);
int x = (int) (Math.round(aNote.getDuration() * beatWidth)); //480 ppq note
int xRV = (int) (Math.round(aNote.getRhythmValue() * beatWidth)); //480 ppq note
// check if the width of the note is less than 1 so
// that it will be displayed
if (x < 1) x = 1;
if (y < rectTop) rectTop = y;
if (y > rectBot) rectBot = y;//update values to phrase rectangle
//set the colour change brightness for dynamic
offScreenGraphics.setColor(Color.getHSBColor(theColours[i % maxColours][0],
theColours[i % maxColours][1],
(float) (0.7 - (aNote.getDynamic() * 0.004))));
// draw note inside
if (aNote.getPitchType() == Note.MIDI_PITCH) {
offScreenGraphics.fillRect(oldX, y - noteHeight + thinNote, x,
noteHeight * 2 - 2 * thinNote);
} else { // draw frequency derrived note
int heightOffset = 7;
for (int j = oldX; j < oldX + x - 4; j += 4) {
offScreenGraphics.drawLine(j, y - noteHeight + heightOffset,
j + 2, y - noteHeight + heightOffset - 3);
offScreenGraphics.drawLine(j + 2, y - noteHeight + heightOffset - 3,
j + 4, y - noteHeight + heightOffset);
}
}
// draw note ouside
offScreenGraphics.setColor(Color.getHSBColor(theColours[i % maxColours][0],
theColours[i % maxColours][1], (float) (0.4)));
offScreenGraphics.drawRect(oldX, y - noteHeight + thinNote, xRV,
noteHeight * 2 - 2 * thinNote);
//add a sharp if required
if ((currNote % 12) == 1 || (currNote % 12) == 3 ||
(currNote % 12) == 6 || (currNote % 12) == 8 ||
(currNote % 12) == 10) {
offScreenGraphics.setColor(Color.getHSBColor(
theColours[i % maxColours][0],
theColours[i % maxColours][1], (float) (0.3)));
offScreenGraphics.drawString("#", oldX - 7, y + 5);
}
}
oldXBeat += aNote.getRhythmValue();
oldX = (int) (Math.round(oldXBeat * beatWidth));
rectRight = oldX - rectLeft; //update value for phrase rectangle
}
// draw the phrase rectangle
//offScreenGraphics.setColor(Color.lightGray);