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