- try {
- // Retrieves the notenumber from the conversion array.
- int noteNumber = keyToNote[e.getKeyCode()];
- // Sends the NoteOff event.
- Moosique.getActiveChannel().noteOff(noteNumber);
- isOn[noteNumber] = false;
- } catch (ArrayIndexOutOfBoundsException x) {
- return;
+ if (!e.isControlDown()) {
+ try {
+ // Retrieves the notenumber from the conversion array.
+ int noteNumber = keyToNote[e.getKeyCode()];
+ // Sends the NoteOff event.
+ if (recording) {
+ ShortMessage msg = new ShortMessage();
+ msg.setMessage(ShortMessage.NOTE_OFF, title.getChannel(), noteNumber, 0);
+ Moosique.getSequencer().getReceiver().send(msg, -1);
+ } else {
+ Moosique.getActiveChannel().noteOff(noteNumber);
+ }
+ isOn[noteNumber] = false;
+ } catch (Exception x) {
+ return;
+ }
+ }
+ }
+
+ /**
+ * Prepares the keyboard for recording on the current channel.
+ */
+ public void recordEnable() {
+ recording = true;
+ }
+
+ /**
+ * Disables recording and returns to keyjazz mode.
+ */
+ public void recordDisable() {
+ recording = false;
+ }
+
+ /**
+ * Sets the octave of the lower part of the keyboard (default = 4).
+ * @param n the octave to start at
+ */
+ public static void setOctave(int n) {
+ startNote = n * 12;
+ makeKeyboardMapping();
+ }
+
+ /**
+ * Increases or decreases the octave of the lower part of the keyboard (default = 4).
+ * @param increase true for increase, false for decrease
+ */
+ public static void setRelativeOctave(boolean increase) {
+ if (increase) {
+ if (startNote == 108) return;
+ setOctave((startNote/12) + 1);
+ } else {
+ if (startNote == 0) return;
+ setOctave((startNote/12) - 1);