diff --git a/.idea/misc.xml b/.idea/misc.xml
index cb4089b..c6cbeaf 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index cb4089b..c6cbeaf 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
index 98888de..228e053 100644
--- a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
+++ b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
@@ -12,6 +12,7 @@
set(value) {
field = value
setInstrumentWaveform(id, value.id)
+ // this is to resend the setInstrumentActive for the new waveform in the internal c++ code
active = active
}
diff --git a/.idea/misc.xml b/.idea/misc.xml
index cb4089b..c6cbeaf 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
index 98888de..228e053 100644
--- a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
+++ b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
@@ -12,6 +12,7 @@
set(value) {
field = value
setInstrumentWaveform(id, value.id)
+ // this is to resend the setInstrumentActive for the new waveform in the internal c++ code
active = active
}
diff --git a/app/src/main/java/com/lukas/music/song/ChordProgression.kt b/app/src/main/java/com/lukas/music/song/ChordProgression.kt
index 24b5adf..144c272 100644
--- a/app/src/main/java/com/lukas/music/song/ChordProgression.kt
+++ b/app/src/main/java/com/lukas/music/song/ChordProgression.kt
@@ -1,6 +1,6 @@
package com.lukas.music.song
-class ChordProgression(private val chords: List) {
+class ChordProgression(val chords: List) {
private var index = 0
fun step(): Chord {
diff --git a/.idea/misc.xml b/.idea/misc.xml
index cb4089b..c6cbeaf 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
index 98888de..228e053 100644
--- a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
+++ b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
@@ -12,6 +12,7 @@
set(value) {
field = value
setInstrumentWaveform(id, value.id)
+ // this is to resend the setInstrumentActive for the new waveform in the internal c++ code
active = active
}
diff --git a/app/src/main/java/com/lukas/music/song/ChordProgression.kt b/app/src/main/java/com/lukas/music/song/ChordProgression.kt
index 24b5adf..144c272 100644
--- a/app/src/main/java/com/lukas/music/song/ChordProgression.kt
+++ b/app/src/main/java/com/lukas/music/song/ChordProgression.kt
@@ -1,6 +1,6 @@
package com.lukas.music.song
-class ChordProgression(private val chords: List) {
+class ChordProgression(val chords: List) {
private var index = 0
fun step(): Chord {
diff --git a/app/src/main/java/com/lukas/music/song/Song.kt b/app/src/main/java/com/lukas/music/song/Song.kt
index cd59930..ae8c5e2 100644
--- a/app/src/main/java/com/lukas/music/song/Song.kt
+++ b/app/src/main/java/com/lukas/music/song/Song.kt
@@ -1,24 +1,34 @@
package com.lukas.music.song
+import android.os.Handler
+import android.os.Looper
+import android.widget.RadioButton
import com.lukas.music.instruments.Instrument
import com.lukas.music.song.note.Note
class Song(
private val root: Note,
private val chordProgression: ChordProgression,
+ val beats: Int
) {
private var beat = 0
- private var chord: Chord = chordProgression.step()
+ private var chord: Chord = chordProgression.chords[0]
+ val stepButtons = mutableListOf()
fun step() {
- val chordNotes = chord.getNotes(root)
- for (voice in Instrument.voice) {
+ Handler(Looper.getMainLooper()).post {
+ stepButtons[beat].isChecked = false
+ beat++
+ if (beat >= beats) {
+ beat = 0
+ chord = chordProgression.step()
+ }
+ stepButtons[beat].isChecked = true
+ // this should not be executed here, but otherwise timing problems show up...
+ val chordNotes = chord.getNotes(root)
+ for (voice in Instrument.voice) {
voice.step(root, chordNotes)
- }
- beat++
- if (beat > 4) {
- beat -= 4
- chord = chordProgression.step()
+ }
}
}
@@ -32,7 +42,8 @@
Chord(2, ChordType.Minor),
Chord(7, ChordType.Major),
)
- )
+ ),
+ 4
)
}
}
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index cb4089b..c6cbeaf 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
index 98888de..228e053 100644
--- a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
+++ b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
@@ -12,6 +12,7 @@
set(value) {
field = value
setInstrumentWaveform(id, value.id)
+ // this is to resend the setInstrumentActive for the new waveform in the internal c++ code
active = active
}
diff --git a/app/src/main/java/com/lukas/music/song/ChordProgression.kt b/app/src/main/java/com/lukas/music/song/ChordProgression.kt
index 24b5adf..144c272 100644
--- a/app/src/main/java/com/lukas/music/song/ChordProgression.kt
+++ b/app/src/main/java/com/lukas/music/song/ChordProgression.kt
@@ -1,6 +1,6 @@
package com.lukas.music.song
-class ChordProgression(private val chords: List) {
+class ChordProgression(val chords: List) {
private var index = 0
fun step(): Chord {
diff --git a/app/src/main/java/com/lukas/music/song/Song.kt b/app/src/main/java/com/lukas/music/song/Song.kt
index cd59930..ae8c5e2 100644
--- a/app/src/main/java/com/lukas/music/song/Song.kt
+++ b/app/src/main/java/com/lukas/music/song/Song.kt
@@ -1,24 +1,34 @@
package com.lukas.music.song
+import android.os.Handler
+import android.os.Looper
+import android.widget.RadioButton
import com.lukas.music.instruments.Instrument
import com.lukas.music.song.note.Note
class Song(
private val root: Note,
private val chordProgression: ChordProgression,
+ val beats: Int
) {
private var beat = 0
- private var chord: Chord = chordProgression.step()
+ private var chord: Chord = chordProgression.chords[0]
+ val stepButtons = mutableListOf()
fun step() {
- val chordNotes = chord.getNotes(root)
- for (voice in Instrument.voice) {
+ Handler(Looper.getMainLooper()).post {
+ stepButtons[beat].isChecked = false
+ beat++
+ if (beat >= beats) {
+ beat = 0
+ chord = chordProgression.step()
+ }
+ stepButtons[beat].isChecked = true
+ // this should not be executed here, but otherwise timing problems show up...
+ val chordNotes = chord.getNotes(root)
+ for (voice in Instrument.voice) {
voice.step(root, chordNotes)
- }
- beat++
- if (beat > 4) {
- beat -= 4
- chord = chordProgression.step()
+ }
}
}
@@ -32,7 +42,8 @@
Chord(2, ChordType.Minor),
Chord(7, ChordType.Major),
)
- )
+ ),
+ 4
)
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt
index 0493d29..899cefe 100644
--- a/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt
+++ b/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt
@@ -4,10 +4,14 @@
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.RadioButton
+import android.widget.RadioGroup
import android.widget.SeekBar
+import android.widget.Space
import androidx.fragment.app.Fragment
import com.lukas.music.databinding.FragmentPlayBinding
import com.lukas.music.instruments.Rhythm
+import com.lukas.music.song.Song
class PlayFragment : Fragment() {
lateinit var binding: FragmentPlayBinding
@@ -42,6 +46,24 @@
}
})
binding.masterVolumeSlider.progress = 100
+ val layout = RadioGroup.LayoutParams(
+ RadioGroup.LayoutParams.WRAP_CONTENT,
+ RadioGroup.LayoutParams.MATCH_PARENT
+ )
+ layout.weight = 1.0f
+ val spacer = Space(binding.root.context)
+ spacer.layoutParams = layout
+ binding.beatIndicator.addView(spacer)
+ for (i in 0 until Song.currentSong.beats) {
+ val child = RadioButton(binding.root.context)
+ child.layoutParams = layout
+ child.isClickable = false
+ if (i == 0) {
+ child.isChecked = true
+ }
+ Song.currentSong.stepButtons += child
+ binding.beatIndicator.addView(child)
+ }
return binding.root
}
diff --git a/.idea/misc.xml b/.idea/misc.xml
index cb4089b..c6cbeaf 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
index 98888de..228e053 100644
--- a/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
+++ b/app/src/main/java/com/lukas/music/instruments/InternalInstrument.kt
@@ -12,6 +12,7 @@
set(value) {
field = value
setInstrumentWaveform(id, value.id)
+ // this is to resend the setInstrumentActive for the new waveform in the internal c++ code
active = active
}
diff --git a/app/src/main/java/com/lukas/music/song/ChordProgression.kt b/app/src/main/java/com/lukas/music/song/ChordProgression.kt
index 24b5adf..144c272 100644
--- a/app/src/main/java/com/lukas/music/song/ChordProgression.kt
+++ b/app/src/main/java/com/lukas/music/song/ChordProgression.kt
@@ -1,6 +1,6 @@
package com.lukas.music.song
-class ChordProgression(private val chords: List) {
+class ChordProgression(val chords: List) {
private var index = 0
fun step(): Chord {
diff --git a/app/src/main/java/com/lukas/music/song/Song.kt b/app/src/main/java/com/lukas/music/song/Song.kt
index cd59930..ae8c5e2 100644
--- a/app/src/main/java/com/lukas/music/song/Song.kt
+++ b/app/src/main/java/com/lukas/music/song/Song.kt
@@ -1,24 +1,34 @@
package com.lukas.music.song
+import android.os.Handler
+import android.os.Looper
+import android.widget.RadioButton
import com.lukas.music.instruments.Instrument
import com.lukas.music.song.note.Note
class Song(
private val root: Note,
private val chordProgression: ChordProgression,
+ val beats: Int
) {
private var beat = 0
- private var chord: Chord = chordProgression.step()
+ private var chord: Chord = chordProgression.chords[0]
+ val stepButtons = mutableListOf()
fun step() {
- val chordNotes = chord.getNotes(root)
- for (voice in Instrument.voice) {
+ Handler(Looper.getMainLooper()).post {
+ stepButtons[beat].isChecked = false
+ beat++
+ if (beat >= beats) {
+ beat = 0
+ chord = chordProgression.step()
+ }
+ stepButtons[beat].isChecked = true
+ // this should not be executed here, but otherwise timing problems show up...
+ val chordNotes = chord.getNotes(root)
+ for (voice in Instrument.voice) {
voice.step(root, chordNotes)
- }
- beat++
- if (beat > 4) {
- beat -= 4
- chord = chordProgression.step()
+ }
}
}
@@ -32,7 +42,8 @@
Chord(2, ChordType.Minor),
Chord(7, ChordType.Major),
)
- )
+ ),
+ 4
)
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt
index 0493d29..899cefe 100644
--- a/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt
+++ b/app/src/main/java/com/lukas/music/ui/fragments/PlayFragment.kt
@@ -4,10 +4,14 @@
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.RadioButton
+import android.widget.RadioGroup
import android.widget.SeekBar
+import android.widget.Space
import androidx.fragment.app.Fragment
import com.lukas.music.databinding.FragmentPlayBinding
import com.lukas.music.instruments.Rhythm
+import com.lukas.music.song.Song
class PlayFragment : Fragment() {
lateinit var binding: FragmentPlayBinding
@@ -42,6 +46,24 @@
}
})
binding.masterVolumeSlider.progress = 100
+ val layout = RadioGroup.LayoutParams(
+ RadioGroup.LayoutParams.WRAP_CONTENT,
+ RadioGroup.LayoutParams.MATCH_PARENT
+ )
+ layout.weight = 1.0f
+ val spacer = Space(binding.root.context)
+ spacer.layoutParams = layout
+ binding.beatIndicator.addView(spacer)
+ for (i in 0 until Song.currentSong.beats) {
+ val child = RadioButton(binding.root.context)
+ child.layoutParams = layout
+ child.isClickable = false
+ if (i == 0) {
+ child.isChecked = true
+ }
+ Song.currentSong.stepButtons += child
+ binding.beatIndicator.addView(child)
+ }
return binding.root
}
diff --git a/app/src/main/res/layout/fragment_play.xml b/app/src/main/res/layout/fragment_play.xml
index ebf9a54..5b0cc4a 100644
--- a/app/src/main/res/layout/fragment_play.xml
+++ b/app/src/main/res/layout/fragment_play.xml
@@ -46,5 +46,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/playButton" />
+
+
\ No newline at end of file