Reset tempo only on stop; & keep on stanza change - Android
This commit is contained in:
parent
8b171fceaf
commit
ec9194ce14
1 changed files with 29 additions and 10 deletions
|
|
@ -181,6 +181,8 @@ actual class FMediaPlayer actual constructor(
|
||||||
private val navigationSteps = mutableListOf<NavigationStep>()
|
private val navigationSteps = mutableListOf<NavigationStep>()
|
||||||
private val prefs: Settings = provideSettings()
|
private val prefs: Settings = provideSettings()
|
||||||
|
|
||||||
|
|
||||||
|
@Volatile private var userCustomTempo: Boolean = false
|
||||||
init {
|
init {
|
||||||
midiDriver.start()
|
midiDriver.start()
|
||||||
loadVoiceVolumes()
|
loadVoiceVolumes()
|
||||||
|
|
@ -196,7 +198,9 @@ actual class FMediaPlayer actual constructor(
|
||||||
val usPerQuarter = ((md[0].toInt() and 0xFF) shl 16) or
|
val usPerQuarter = ((md[0].toInt() and 0xFF) shl 16) or
|
||||||
((md[1].toInt() and 0xFF) shl 8) or
|
((md[1].toInt() and 0xFF) shl 8) or
|
||||||
(md[2].toInt() and 0xFF)
|
(md[2].toInt() and 0xFF)
|
||||||
targetBpm = 60_000_000f / usPerQuarter
|
val parsedBpm = 60_000_000f / usPerQuarter
|
||||||
|
targetBpm = parsedBpm
|
||||||
|
initialBpm = parsedBpm
|
||||||
}
|
}
|
||||||
|
|
||||||
usPerTick = (60_000_000.0 / targetBpm) / resolution
|
usPerTick = (60_000_000.0 / targetBpm) / resolution
|
||||||
|
|
@ -292,8 +296,10 @@ actual class FMediaPlayer actual constructor(
|
||||||
private fun resetTempoToInitial() {
|
private fun resetTempoToInitial() {
|
||||||
tempoChangeJob?.cancel()
|
tempoChangeJob?.cancel()
|
||||||
isInTempoChange = false
|
isInTempoChange = false
|
||||||
targetBpm = initialBpm
|
//targetBpm = initialBpm
|
||||||
boundModel?.setBpmFlow(initialBpm)
|
userCustomTempo = false
|
||||||
|
usPerTick = (60_000_000.0 / targetBpm.toDouble()) / resolution.toDouble()
|
||||||
|
boundModel?.setBpmFlow(targetBpm)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun extractDynamic(marker: String) = Dynamic.entries.firstOrNull {
|
private fun extractDynamic(marker: String) = Dynamic.entries.firstOrNull {
|
||||||
|
|
@ -438,9 +444,13 @@ actual class FMediaPlayer actual constructor(
|
||||||
currentTickPos = gridIndex.toLong() * resolution
|
currentTickPos = gridIndex.toLong() * resolution
|
||||||
lastEventNano = System.nanoTime()
|
lastEventNano = System.nanoTime()
|
||||||
|
|
||||||
val initialOrPreviousBpm = navigationSteps
|
val initialOrPreviousBpm = if (gridIndex == 0 && userCustomTempo) {
|
||||||
|
targetBpm
|
||||||
|
} else {
|
||||||
|
navigationSteps
|
||||||
.filter { it.newBpm != null && it.gridIndex <= gridIndex }
|
.filter { it.newBpm != null && it.gridIndex <= gridIndex }
|
||||||
.maxByOrNull { it.gridIndex }?.newBpm ?: initialBpm
|
.maxByOrNull { it.gridIndex }?.newBpm ?: initialBpm
|
||||||
|
}
|
||||||
|
|
||||||
targetBpm = initialOrPreviousBpm
|
targetBpm = initialOrPreviousBpm
|
||||||
sharedScreenModel.setBpmFlow(initialOrPreviousBpm)
|
sharedScreenModel.setBpmFlow(initialOrPreviousBpm)
|
||||||
|
|
@ -691,10 +701,15 @@ actual class FMediaPlayer actual constructor(
|
||||||
//♩
|
//♩
|
||||||
step.newBpm != null -> {
|
step.newBpm != null -> {
|
||||||
step.alreadyDone = true
|
step.alreadyDone = true
|
||||||
|
if (step.gridIndex == 0 && userCustomTempo) {
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
println("Exécution changement de tempo : ${step.newBpm} BPM à la grille $currentIndex")
|
println("Exécution changement de tempo : ${step.newBpm} BPM à la grille $currentIndex")
|
||||||
targetBpm = step.newBpm
|
targetBpm = step.newBpm
|
||||||
sharedScreenModel.setBpmFlow(step.newBpm)
|
sharedScreenModel.setBpmFlow(step.newBpm)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Modulation
|
// Modulation
|
||||||
step.newKey != null -> {
|
step.newKey != null -> {
|
||||||
|
|
@ -922,7 +937,9 @@ actual class FMediaPlayer actual constructor(
|
||||||
allNotesOff(); currentTickPos = 0L
|
allNotesOff(); currentTickPos = 0L
|
||||||
resetNavigationFlags(); navigationSteps.clear(); clearLoop()
|
resetNavigationFlags(); navigationSteps.clear(); clearLoop()
|
||||||
currentDynamicFactor = Dynamic.MF.factor
|
currentDynamicFactor = Dynamic.MF.factor
|
||||||
resetTempoToNormal()
|
//resetTempoToNormal()
|
||||||
|
currentPlaybackBpm = targetBpm
|
||||||
|
usPerTick = (60_000_000.0 / targetBpm.toDouble()) / resolution.toDouble()
|
||||||
resetTempoToInitial()
|
resetTempoToInitial()
|
||||||
}
|
}
|
||||||
actual fun release() {
|
actual fun release() {
|
||||||
|
|
@ -943,7 +960,9 @@ actual class FMediaPlayer actual constructor(
|
||||||
actual fun setTempo(bpm: Float) {
|
actual fun setTempo(bpm: Float) {
|
||||||
targetBpm = bpm
|
targetBpm = bpm
|
||||||
currentPlaybackBpm = bpm
|
currentPlaybackBpm = bpm
|
||||||
|
userCustomTempo = true
|
||||||
usPerTick = (60_000_000.0 / bpm.toDouble()) / resolution.toDouble()
|
usPerTick = (60_000_000.0 / bpm.toDouble()) / resolution.toDouble()
|
||||||
|
boundModel?.setBpmFlow(bpm)
|
||||||
boundModel?.let { prepareNavigation(it) }
|
boundModel?.let { prepareNavigation(it) }
|
||||||
needsClockSync = true
|
needsClockSync = true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue