diff --git a/app/src/main/java/com/lukas/music/song/Scale.kt b/app/src/main/java/com/lukas/music/song/Scale.kt
deleted file mode 100644
index 8e08034..0000000
--- a/app/src/main/java/com/lukas/music/song/Scale.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2022 Lukas Eisenhauer
- *
- * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with this program. If not, see .
- */
-
-package com.lukas.music.song
-
-import com.lukas.music.song.chords.ChordType
-
-enum class Scale(val identifier: String, val steps: Array, val chordTypes: Array) {
- MAJOR(
- "major",
- arrayOf(0, 2, 4, 5, 7, 9, 11, 12),
- arrayOf(
- ChordType.MAJOR,
- ChordType.MINOR,
- ChordType.MINOR,
- ChordType.MAJOR,
- ChordType.MAJOR,
- ChordType.MINOR,
- ChordType.DIMINISHED
- )
- )
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/song/Scale.kt b/app/src/main/java/com/lukas/music/song/Scale.kt
deleted file mode 100644
index 8e08034..0000000
--- a/app/src/main/java/com/lukas/music/song/Scale.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2022 Lukas Eisenhauer
- *
- * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with this program. If not, see .
- */
-
-package com.lukas.music.song
-
-import com.lukas.music.song.chords.ChordType
-
-enum class Scale(val identifier: String, val steps: Array, val chordTypes: Array) {
- MAJOR(
- "major",
- arrayOf(0, 2, 4, 5, 7, 9, 11, 12),
- arrayOf(
- ChordType.MAJOR,
- ChordType.MINOR,
- ChordType.MINOR,
- ChordType.MAJOR,
- ChordType.MAJOR,
- ChordType.MINOR,
- ChordType.DIMINISHED
- )
- )
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/song/ScaleType.kt b/app/src/main/java/com/lukas/music/song/ScaleType.kt
new file mode 100644
index 0000000..4c6a0d9
--- /dev/null
+++ b/app/src/main/java/com/lukas/music/song/ScaleType.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2022 Lukas Eisenhauer
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program. If not, see .
+ */
+
+package com.lukas.music.song
+
+import com.lukas.music.song.chords.ChordType
+
+enum class ScaleType(
+ val identifier: String,
+ val steps: Array,
+ val chordTypes: Array
+) {
+ MAJOR(
+ "major",
+ arrayOf(0, 2, 4, 5, 7, 9, 11, 12),
+ arrayOf(
+ ChordType.MAJOR,
+ ChordType.MINOR,
+ ChordType.MINOR,
+ ChordType.MAJOR,
+ ChordType.MAJOR,
+ ChordType.MINOR,
+ ChordType.DIMINISHED
+ )
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/song/Scale.kt b/app/src/main/java/com/lukas/music/song/Scale.kt
deleted file mode 100644
index 8e08034..0000000
--- a/app/src/main/java/com/lukas/music/song/Scale.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2022 Lukas Eisenhauer
- *
- * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with this program. If not, see .
- */
-
-package com.lukas.music.song
-
-import com.lukas.music.song.chords.ChordType
-
-enum class Scale(val identifier: String, val steps: Array, val chordTypes: Array) {
- MAJOR(
- "major",
- arrayOf(0, 2, 4, 5, 7, 9, 11, 12),
- arrayOf(
- ChordType.MAJOR,
- ChordType.MINOR,
- ChordType.MINOR,
- ChordType.MAJOR,
- ChordType.MAJOR,
- ChordType.MINOR,
- ChordType.DIMINISHED
- )
- )
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/song/ScaleType.kt b/app/src/main/java/com/lukas/music/song/ScaleType.kt
new file mode 100644
index 0000000..4c6a0d9
--- /dev/null
+++ b/app/src/main/java/com/lukas/music/song/ScaleType.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2022 Lukas Eisenhauer
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program. If not, see .
+ */
+
+package com.lukas.music.song
+
+import com.lukas.music.song.chords.ChordType
+
+enum class ScaleType(
+ val identifier: String,
+ val steps: Array,
+ val chordTypes: Array
+) {
+ MAJOR(
+ "major",
+ arrayOf(0, 2, 4, 5, 7, 9, 11, 12),
+ arrayOf(
+ ChordType.MAJOR,
+ ChordType.MINOR,
+ ChordType.MINOR,
+ ChordType.MAJOR,
+ ChordType.MAJOR,
+ ChordType.MINOR,
+ ChordType.DIMINISHED
+ )
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/song/voice/VoiceType.kt b/app/src/main/java/com/lukas/music/song/voice/VoiceType.kt
index e254674..e06761a 100644
--- a/app/src/main/java/com/lukas/music/song/voice/VoiceType.kt
+++ b/app/src/main/java/com/lukas/music/song/voice/VoiceType.kt
@@ -8,17 +8,21 @@
* You should have received a copy of the GNU General Public License along with this program. If not, see .
*/
-package com.lukas.music.song.voice
+ package com.lukas.music.song.voice
+import com.lukas.music.song.ScaleType
import com.lukas.music.song.note.Note
+import com.lukas.music.util.transform
enum class VoiceType(
val title: String,
val noteCount: Int,
val getNotes: (Note, Array) -> Array
) {
- Bass("Bass Note", 1, { _, chordNotes -> arrayOf(chordNotes[0]) }),
- Chord("Chord Notes", 3, { _, chordNotes -> chordNotes }),
+ Bass("Bass note", 1, { _, chordNotes -> arrayOf(chordNotes[0]) }),
+ Chord("Chord notes", 3, { _, chordNotes -> chordNotes }),
+ Scale("Scale notes", 8, { root, _ -> ScaleType.MAJOR.steps.transform { root + it } }),
+ Root("Root note", 1, { root, _ -> arrayOf(root) }),
RootRelative("Song root relative", 12, { root, _ -> Array(12) { root + it } }),
;
diff --git a/app/src/main/java/com/lukas/music/song/Scale.kt b/app/src/main/java/com/lukas/music/song/Scale.kt
deleted file mode 100644
index 8e08034..0000000
--- a/app/src/main/java/com/lukas/music/song/Scale.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2022 Lukas Eisenhauer
- *
- * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with this program. If not, see .
- */
-
-package com.lukas.music.song
-
-import com.lukas.music.song.chords.ChordType
-
-enum class Scale(val identifier: String, val steps: Array, val chordTypes: Array) {
- MAJOR(
- "major",
- arrayOf(0, 2, 4, 5, 7, 9, 11, 12),
- arrayOf(
- ChordType.MAJOR,
- ChordType.MINOR,
- ChordType.MINOR,
- ChordType.MAJOR,
- ChordType.MAJOR,
- ChordType.MINOR,
- ChordType.DIMINISHED
- )
- )
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/song/ScaleType.kt b/app/src/main/java/com/lukas/music/song/ScaleType.kt
new file mode 100644
index 0000000..4c6a0d9
--- /dev/null
+++ b/app/src/main/java/com/lukas/music/song/ScaleType.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2022 Lukas Eisenhauer
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program. If not, see .
+ */
+
+package com.lukas.music.song
+
+import com.lukas.music.song.chords.ChordType
+
+enum class ScaleType(
+ val identifier: String,
+ val steps: Array,
+ val chordTypes: Array
+) {
+ MAJOR(
+ "major",
+ arrayOf(0, 2, 4, 5, 7, 9, 11, 12),
+ arrayOf(
+ ChordType.MAJOR,
+ ChordType.MINOR,
+ ChordType.MINOR,
+ ChordType.MAJOR,
+ ChordType.MAJOR,
+ ChordType.MINOR,
+ ChordType.DIMINISHED
+ )
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/song/voice/VoiceType.kt b/app/src/main/java/com/lukas/music/song/voice/VoiceType.kt
index e254674..e06761a 100644
--- a/app/src/main/java/com/lukas/music/song/voice/VoiceType.kt
+++ b/app/src/main/java/com/lukas/music/song/voice/VoiceType.kt
@@ -8,17 +8,21 @@
* You should have received a copy of the GNU General Public License along with this program. If not, see .
*/
-package com.lukas.music.song.voice
+ package com.lukas.music.song.voice
+import com.lukas.music.song.ScaleType
import com.lukas.music.song.note.Note
+import com.lukas.music.util.transform
enum class VoiceType(
val title: String,
val noteCount: Int,
val getNotes: (Note, Array) -> Array
) {
- Bass("Bass Note", 1, { _, chordNotes -> arrayOf(chordNotes[0]) }),
- Chord("Chord Notes", 3, { _, chordNotes -> chordNotes }),
+ Bass("Bass note", 1, { _, chordNotes -> arrayOf(chordNotes[0]) }),
+ Chord("Chord notes", 3, { _, chordNotes -> chordNotes }),
+ Scale("Scale notes", 8, { root, _ -> ScaleType.MAJOR.steps.transform { root + it } }),
+ Root("Root note", 1, { root, _ -> arrayOf(root) }),
RootRelative("Song root relative", 12, { root, _ -> Array(12) { root + it } }),
;
diff --git a/app/src/main/java/com/lukas/music/ui/fragments/EditChordFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/EditChordFragment.kt
index f01d9e4..6c3bae3 100644
--- a/app/src/main/java/com/lukas/music/ui/fragments/EditChordFragment.kt
+++ b/app/src/main/java/com/lukas/music/ui/fragments/EditChordFragment.kt
@@ -16,7 +16,7 @@
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import com.lukas.music.databinding.FragmentEditChordBinding
-import com.lukas.music.song.Scale
+import com.lukas.music.song.ScaleType
import com.lukas.music.song.Song
import com.lukas.music.song.chords.Chord
import com.lukas.music.song.chords.ChordType
@@ -42,12 +42,12 @@
private fun setupPitchSpinner() {
val pitches = if (songFragment.displayChordNames) {
- Array(Scale.MAJOR.steps.size) { (Song.currentSong.root + Scale.MAJOR.steps[it]).noteName.toString() }
+ Array(ScaleType.MAJOR.steps.size) { (Song.currentSong.root + ScaleType.MAJOR.steps[it]).noteName.toString() }
} else Interval.IntervalName.NAMES
binding.pitchSpinner.setup(pitches, chord.interval.name.ordinal) {
- chord.note = Scale.MAJOR.steps[it]
+ chord.note = ScaleType.MAJOR.steps[it]
if (binding.typeSpinner.selectedItemPosition == 0) {
- chord.chordType = Scale.MAJOR.chordTypes[chord.interval.name.ordinal]
+ chord.chordType = ScaleType.MAJOR.chordTypes[chord.interval.name.ordinal]
}
songFragment.updateChords()
}
@@ -60,11 +60,11 @@
}
binding.typeSpinner.setup(
values,
- if (chord.chordType == Scale.MAJOR.chordTypes[chord.interval.name.ordinal]) 0
+ if (chord.chordType == ScaleType.MAJOR.chordTypes[chord.interval.name.ordinal]) 0
else chord.chordType.ordinal + 1
) {
if (it == 0) {
- chord.chordType = Scale.MAJOR.chordTypes[chord.interval.name.ordinal]
+ chord.chordType = ScaleType.MAJOR.chordTypes[chord.interval.name.ordinal]
} else {
chord.chordType = ChordType.VALUES[it - 1]
}
diff --git a/app/src/main/java/com/lukas/music/song/Scale.kt b/app/src/main/java/com/lukas/music/song/Scale.kt
deleted file mode 100644
index 8e08034..0000000
--- a/app/src/main/java/com/lukas/music/song/Scale.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2022 Lukas Eisenhauer
- *
- * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with this program. If not, see .
- */
-
-package com.lukas.music.song
-
-import com.lukas.music.song.chords.ChordType
-
-enum class Scale(val identifier: String, val steps: Array, val chordTypes: Array) {
- MAJOR(
- "major",
- arrayOf(0, 2, 4, 5, 7, 9, 11, 12),
- arrayOf(
- ChordType.MAJOR,
- ChordType.MINOR,
- ChordType.MINOR,
- ChordType.MAJOR,
- ChordType.MAJOR,
- ChordType.MINOR,
- ChordType.DIMINISHED
- )
- )
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/song/ScaleType.kt b/app/src/main/java/com/lukas/music/song/ScaleType.kt
new file mode 100644
index 0000000..4c6a0d9
--- /dev/null
+++ b/app/src/main/java/com/lukas/music/song/ScaleType.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2022 Lukas Eisenhauer
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program. If not, see .
+ */
+
+package com.lukas.music.song
+
+import com.lukas.music.song.chords.ChordType
+
+enum class ScaleType(
+ val identifier: String,
+ val steps: Array,
+ val chordTypes: Array
+) {
+ MAJOR(
+ "major",
+ arrayOf(0, 2, 4, 5, 7, 9, 11, 12),
+ arrayOf(
+ ChordType.MAJOR,
+ ChordType.MINOR,
+ ChordType.MINOR,
+ ChordType.MAJOR,
+ ChordType.MAJOR,
+ ChordType.MINOR,
+ ChordType.DIMINISHED
+ )
+ )
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/song/voice/VoiceType.kt b/app/src/main/java/com/lukas/music/song/voice/VoiceType.kt
index e254674..e06761a 100644
--- a/app/src/main/java/com/lukas/music/song/voice/VoiceType.kt
+++ b/app/src/main/java/com/lukas/music/song/voice/VoiceType.kt
@@ -8,17 +8,21 @@
* You should have received a copy of the GNU General Public License along with this program. If not, see .
*/
-package com.lukas.music.song.voice
+ package com.lukas.music.song.voice
+import com.lukas.music.song.ScaleType
import com.lukas.music.song.note.Note
+import com.lukas.music.util.transform
enum class VoiceType(
val title: String,
val noteCount: Int,
val getNotes: (Note, Array) -> Array
) {
- Bass("Bass Note", 1, { _, chordNotes -> arrayOf(chordNotes[0]) }),
- Chord("Chord Notes", 3, { _, chordNotes -> chordNotes }),
+ Bass("Bass note", 1, { _, chordNotes -> arrayOf(chordNotes[0]) }),
+ Chord("Chord notes", 3, { _, chordNotes -> chordNotes }),
+ Scale("Scale notes", 8, { root, _ -> ScaleType.MAJOR.steps.transform { root + it } }),
+ Root("Root note", 1, { root, _ -> arrayOf(root) }),
RootRelative("Song root relative", 12, { root, _ -> Array(12) { root + it } }),
;
diff --git a/app/src/main/java/com/lukas/music/ui/fragments/EditChordFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/EditChordFragment.kt
index f01d9e4..6c3bae3 100644
--- a/app/src/main/java/com/lukas/music/ui/fragments/EditChordFragment.kt
+++ b/app/src/main/java/com/lukas/music/ui/fragments/EditChordFragment.kt
@@ -16,7 +16,7 @@
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import com.lukas.music.databinding.FragmentEditChordBinding
-import com.lukas.music.song.Scale
+import com.lukas.music.song.ScaleType
import com.lukas.music.song.Song
import com.lukas.music.song.chords.Chord
import com.lukas.music.song.chords.ChordType
@@ -42,12 +42,12 @@
private fun setupPitchSpinner() {
val pitches = if (songFragment.displayChordNames) {
- Array(Scale.MAJOR.steps.size) { (Song.currentSong.root + Scale.MAJOR.steps[it]).noteName.toString() }
+ Array(ScaleType.MAJOR.steps.size) { (Song.currentSong.root + ScaleType.MAJOR.steps[it]).noteName.toString() }
} else Interval.IntervalName.NAMES
binding.pitchSpinner.setup(pitches, chord.interval.name.ordinal) {
- chord.note = Scale.MAJOR.steps[it]
+ chord.note = ScaleType.MAJOR.steps[it]
if (binding.typeSpinner.selectedItemPosition == 0) {
- chord.chordType = Scale.MAJOR.chordTypes[chord.interval.name.ordinal]
+ chord.chordType = ScaleType.MAJOR.chordTypes[chord.interval.name.ordinal]
}
songFragment.updateChords()
}
@@ -60,11 +60,11 @@
}
binding.typeSpinner.setup(
values,
- if (chord.chordType == Scale.MAJOR.chordTypes[chord.interval.name.ordinal]) 0
+ if (chord.chordType == ScaleType.MAJOR.chordTypes[chord.interval.name.ordinal]) 0
else chord.chordType.ordinal + 1
) {
if (it == 0) {
- chord.chordType = Scale.MAJOR.chordTypes[chord.interval.name.ordinal]
+ chord.chordType = ScaleType.MAJOR.chordTypes[chord.interval.name.ordinal]
} else {
chord.chordType = ChordType.VALUES[it - 1]
}
diff --git a/app/src/main/java/com/lukas/music/util/MathUtil.kt b/app/src/main/java/com/lukas/music/util/MathUtil.kt
index 20b063b..166061d 100644
--- a/app/src/main/java/com/lukas/music/util/MathUtil.kt
+++ b/app/src/main/java/com/lukas/music/util/MathUtil.kt
@@ -12,4 +12,10 @@
fun Double.format(digits: Int) = "%.${digits}f".format(this)
-fun Float.format(digits: Int) = "%.${digits}f".format(this)
\ No newline at end of file
+fun Float.format(digits: Int) = "%.${digits}f".format(this)
+
+inline fun Array.transform(callback: (T) -> U): Array {
+ return Array(this.size) {
+ callback(this[it])
+ }
+}
\ No newline at end of file