diff --git a/android/res/values/strings.xml b/android/res/values/strings.xml index 723dcdc..5cafd8f 100644 --- a/android/res/values/strings.xml +++ b/android/res/values/strings.xml @@ -86,13 +86,15 @@ Keyboard Type - 2 Level (Piano) - 3 Level - + 2 Row (Piano) + 3 Row + 3 Row Chromatic + - 2level - 3level - - 2level + 2row + 3row + 3chrome + + 2row diff --git a/android/src/com/levien/synthesizer/android/ui/PianoActivity2.java b/android/src/com/levien/synthesizer/android/ui/PianoActivity2.java index 401acce..5e9826a 100644 --- a/android/src/com/levien/synthesizer/android/ui/PianoActivity2.java +++ b/android/src/com/levien/synthesizer/android/ui/PianoActivity2.java @@ -120,12 +120,8 @@ public class PianoActivity2 extends SynthActivity implements OnSharedPreferenceC public void onSharedPreferenceChanged(SharedPreferences prefs, String key) { if (key.equals("keyboard_type")) { - String keyboardType = prefs.getString(key, "2level"); - if (keyboardType.equals("2level")) { - keyboard_.setKeyboardSpec(KeyboardSpec.make2Layer()); - } else if (keyboardType.equals("3level")) { - keyboard_.setKeyboardSpec(KeyboardSpec.make3Layer()); - } + String keyboardType = prefs.getString(key, "2row"); + keyboard_.setKeyboardSpec(KeyboardSpec.make(keyboardType)); } } diff --git a/android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardSpec.java b/android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardSpec.java index 31747e2..f175800 100644 --- a/android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardSpec.java +++ b/android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardSpec.java @@ -38,7 +38,7 @@ public class KeyboardSpec { addKey(ks); } - public static KeyboardSpec make2Layer() { + public static KeyboardSpec make2Row() { KeyboardSpec ks = new KeyboardSpec(12, 84, 24); final int w = Color.WHITE; final int b = Color.BLACK; @@ -57,7 +57,7 @@ public class KeyboardSpec { return ks; } - public static KeyboardSpec make3Layer() { + public static KeyboardSpec make3Row() { KeyboardSpec ks = new KeyboardSpec(24, 84, 32); final int w = Color.WHITE; final int b = Color.BLACK; @@ -81,6 +81,37 @@ public class KeyboardSpec { return ks; } + public static KeyboardSpec make3RowChromatic() { + KeyboardSpec ks = new KeyboardSpec(12, 12, 9); + final int w = Color.WHITE; + final int b = Color.BLACK; + ks.addKey(0, 6, 3, 3, w); // C + ks.addKey(1, 3, 3, 3, b); // C# + ks.addKey(2, 0, 3, 3, w); // D + ks.addKey(3, 6, 3, 3, b); // D# + ks.addKey(4, 3, 3, 3, w); // E + ks.addKey(5, 0, 3, 3, w); // F + ks.addKey(6, 6, 3, 3, b); // F# + ks.addKey(7, 3, 3, 3, w); // G + ks.addKey(8, 0, 3, 3, b); // G# + ks.addKey(9, 6, 3, 3, w); // A + ks.addKey(10, 3, 3, 3, b); // A# + ks.addKey(11, 0, 3, 3, w); // B + return ks; + } + + public static KeyboardSpec make(String name) { + if ("2row".equals(name)) { + return make2Row(); + } else if ("3row".equals(name)) { + return make3Row(); + } else if ("3chrome".equals(name)) { + return make3RowChromatic(); + } else { + return null; + } + } + public KeySpec keys[]; public float repeatWidth; public float height; diff --git a/android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardView.java b/android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardView.java index 97ec3d7..6f6c45d 100644 --- a/android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardView.java +++ b/android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardView.java @@ -48,7 +48,7 @@ public class KeyboardView extends View { paint_.setTextAlign(Paint.Align.CENTER); strokeWidth_ = 1.0f * density; paint_.setStrokeWidth(strokeWidth_); - keyboardSpec_ = KeyboardSpec.make2Layer(); + keyboardSpec_ = KeyboardSpec.make2Row(); offset_ = 0.0f; zoom_ = 1.0f; }