commit b82e8e76e4a7dad553cd5be58b4dd52f0b96242d
parent 2237b4fc97fd78958ca9b85339963ef4a6da5760
Author: gstraube <gstraube@mailbox.org>
Date: Sun, 29 Oct 2017 16:45:23 +0100
Add further tunings
Diffstat:
7 files changed, 212 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/com/github/cythara/BassTuning.java b/app/src/main/java/com/github/cythara/BassTuning.java
@@ -0,0 +1,36 @@
+package com.github.cythara;
+
+public class BassTuning implements Tuning {
+
+ enum Pitch implements com.github.cythara.Note {
+
+ E1(41.204f),
+ A1(55f),
+ D2(73.416f),
+ G2(97.999f);
+
+ private final float frequency;
+
+ Pitch(float frequency) {
+ this.frequency = frequency;
+ }
+
+ public String getName() {
+ return this.name();
+ }
+
+ public float getFrequency() {
+ return frequency;
+ }
+ }
+
+ @Override
+ public com.github.cythara.Note[] getNotes() {
+ return Pitch.values();
+ }
+
+ @Override
+ public com.github.cythara.Note findNote(String name) {
+ return Pitch.valueOf(name);
+ }
+}
diff --git a/app/src/main/java/com/github/cythara/DropCGuitarTuning.java b/app/src/main/java/com/github/cythara/DropCGuitarTuning.java
@@ -0,0 +1,38 @@
+package com.github.cythara;
+
+public class DropCGuitarTuning implements Tuning {
+
+ private enum Pitch implements com.github.cythara.Note {
+
+ C2(65.406f),
+ G2(97.999f),
+ C3(130.813f),
+ F3(174.614f),
+ A3(220f),
+ D4(293.665f);
+
+ private final float frequency;
+
+ Pitch(float frequency) {
+ this.frequency = frequency;
+ }
+
+ public String getName() {
+ return this.name();
+ }
+
+ public float getFrequency() {
+ return frequency;
+ }
+ }
+
+ @Override
+ public com.github.cythara.Note[] getNotes() {
+ return Pitch.values();
+ }
+
+ @Override
+ public com.github.cythara.Note findNote(String name) {
+ return Pitch.valueOf(name);
+ }
+}
diff --git a/app/src/main/java/com/github/cythara/DropCSharpGuitarTuning.java b/app/src/main/java/com/github/cythara/DropCSharpGuitarTuning.java
@@ -0,0 +1,40 @@
+package com.github.cythara;
+
+public class DropCSharpGuitarTuning implements Tuning {
+
+ private enum Pitch implements com.github.cythara.Note {
+
+ C2_SHARP("C2#", 69.30f),
+ A2("A2", 110f),
+ D3("D3", 146.832f),
+ G3("G3", 195.998f),
+ B3("B3", 246.942f),
+ E4("E4", 329.628f);
+
+ private String name;
+ private final float frequency;
+
+ Pitch(String name, float frequency) {
+ this.name = name;
+ this.frequency = frequency;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public float getFrequency() {
+ return frequency;
+ }
+ }
+
+ @Override
+ public com.github.cythara.Note[] getNotes() {
+ return Pitch.values();
+ }
+
+ @Override
+ public com.github.cythara.Note findNote(String name) {
+ return Pitch.valueOf(name);
+ }
+}
diff --git a/app/src/main/java/com/github/cythara/OpenGGuitarTuning.java b/app/src/main/java/com/github/cythara/OpenGGuitarTuning.java
@@ -0,0 +1,38 @@
+package com.github.cythara;
+
+public class OpenGGuitarTuning implements Tuning {
+
+ enum Pitch implements com.github.cythara.Note {
+
+ D2(73.416f),
+ G2(97.999f),
+ D3(146.832f),
+ G3(195.998f),
+ B3(246.942f),
+ D4(293.665f);
+
+ private final float frequency;
+
+ Pitch(float frequency) {
+ this.frequency = frequency;
+ }
+
+ public String getName() {
+ return this.name();
+ }
+
+ public float getFrequency() {
+ return frequency;
+ }
+ }
+
+ @Override
+ public com.github.cythara.Note[] getNotes() {
+ return Pitch.values();
+ }
+
+ @Override
+ public com.github.cythara.Note findNote(String name) {
+ return Pitch.valueOf(name);
+ }
+}
diff --git a/app/src/main/java/com/github/cythara/TuningMapper.java b/app/src/main/java/com/github/cythara/TuningMapper.java
@@ -6,7 +6,12 @@ class TuningMapper {
private static final int GUITAR_TUNING_POSITION = 0;
private static final int DROP_D_TUNING_POSITION = 1;
- private static final int UKULELE_TUNING_POSITION = 2;
+ private static final int DROP_C_TUNING_POSITION = 2;
+ private static final int DROP_C_SHARP_TUNING_POSITION = 3;
+ private static final int OPEN_G_TUNING = 4;
+ private static final int BASS_TUNING_POSITION = 5;
+ private static final int UKULELE_TUNING_POSITION = 6;
+ private static final int D_TUNING_POSITION = 7;
static Tuning getTuningFromPosition(int position) {
switch (position) {
@@ -14,8 +19,18 @@ class TuningMapper {
return new GuitarTuning();
case DROP_D_TUNING_POSITION:
return new DropDGuitarTuning();
+ case DROP_C_TUNING_POSITION:
+ return new DropCGuitarTuning();
+ case DROP_C_SHARP_TUNING_POSITION:
+ return new DropCSharpGuitarTuning();
+ case OPEN_G_TUNING:
+ return new OpenGGuitarTuning();
+ case BASS_TUNING_POSITION:
+ return new BassTuning();
case UKULELE_TUNING_POSITION:
return new UkuleleTuning();
+ case D_TUNING_POSITION:
+ return new UkuleleDTuning();
default:
Log.w("com.github.cythara", "Unknown position for tuning dropdown list");
return new GuitarTuning();
diff --git a/app/src/main/java/com/github/cythara/UkuleleDTuning.java b/app/src/main/java/com/github/cythara/UkuleleDTuning.java
@@ -0,0 +1,38 @@
+package com.github.cythara;
+
+public class UkuleleDTuning implements Tuning {
+
+ private enum Pitch implements com.github.cythara.Note {
+
+ A4("A4", 440f),
+ D4("D4", 293.665f),
+ F3_SHARP("F3#", 369.99f),
+ B4("B4", 493.88f);
+
+ private String name;
+ private final float frequency;
+
+ Pitch(String name, float frequency) {
+ this.name = name;
+ this.frequency = frequency;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public float getFrequency() {
+ return frequency;
+ }
+ }
+
+ @Override
+ public Note[] getNotes() {
+ return Pitch.values();
+ }
+
+ @Override
+ public Note findNote(String name) {
+ return Pitch.valueOf(name);
+ }
+}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
@@ -3,7 +3,12 @@
<string-array name="tunings">
<item>Guitar (standard)</item>
<item>Guitar (Drop D)</item>
- <item>Ukulele</item>
+ <item>Guitar (Drop C)</item>
+ <item>Guitar (Drop C#)</item>
+ <item>Guitar (Open G)</item>
+ <item>Bass (standard)</item>
+ <item>Ukulele (standard)</item>
+ <item>Ukulele (D tuning)</item>
</string-array>
</resources>