Add 3 row chromatic layout

This patch adds a 3 row chromatic keyboard layout, for experimentation.
master
Raph Levien 11 years ago
parent c9fd115563
commit c1604c3662
  1. 16
      android/res/values/strings.xml
  2. 8
      android/src/com/levien/synthesizer/android/ui/PianoActivity2.java
  3. 35
      android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardSpec.java
  4. 2
      android/src/com/levien/synthesizer/android/widgets/keyboard/KeyboardView.java

@ -86,13 +86,15 @@
<!-- Preferences -->
<string name="pref_keyboardType">Keyboard Type</string>
<string-array name="pref_keyboardType_entries">
<item>2 Level (Piano)</item>
<item>3 Level</item>
</string-array>
<item>2 Row (Piano)</item>
<item>3 Row</item>
<item>3 Row Chromatic</item>
</string-array>
<string-array name="pref_keyboardType_values">
<item>2level</item>
<item>3level</item>
</string-array>
<string name="pref_keyboardType_default">2level</string>
<item>2row</item>
<item>3row</item>
<item>3chrome</item>
</string-array>
<string name="pref_keyboardType_default">2row</string>
</resources>

@ -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));
}
}

@ -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;

@ -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;
}

Loading…
Cancel
Save