public class MooKeyboard extends KeyAdapter {
private boolean[] isOn = new boolean[120];
- private static final int startNote = 48;
+ private static int startNote = 48;
private static final int[] keyToNote = new int[120];
/**
}
}
+ /**
+ * Sets the octave of the lower part of the keyboard (default = 4)
+ * @param n the octave to start at
+ */
+ public void setOctave(int n) {
+ startNote = n * 12;
+ }
+
/** Maps keycodes (array indices) to MIDI note numbers using the following layout:
*
* 2 3 5 6 7 9 0 => # # # # # # #
* z x c v b n m , . => c d e f g a b c d
*/
static {
- keyToNote[90] = startNote;
+ keyToNote[KeyEvent.VK_Q] = startNote;
keyToNote[83] = startNote + 1;
keyToNote[88] = startNote + 2;
keyToNote[68] = startNote + 3;