X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=MooKeyboard.java;h=ef4785e67c5081e343983c06d411800dab2e1d1c;hb=17d535e703a8ba178ad816d0a0cf4fa1ac787e5b;hp=5581172e6d10792cbe5d6cbbae30c10b88ce492e;hpb=623c453a916803c781d32f667fca8698d0814c8c;p=moosique.git diff --git a/MooKeyboard.java b/MooKeyboard.java index 5581172..ef4785e 100644 --- a/MooKeyboard.java +++ b/MooKeyboard.java @@ -64,11 +64,24 @@ public class MooKeyboard extends KeyAdapter { * @param n the octave to start at */ public static void setOctave(int n) { - if ((startNote == 0 && n == -1) || (startNote == 108 && n == 1)) return; - startNote += n*12; + 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); + } + } + /** Maps keycodes (array indices) to MIDI note numbers using the following layout: * * 2 3 5 6 7 9 0 => # # # # # # #