Fix! reset activeIndex to -1 to prevent ignoring markers on grid 0
This commit is contained in:
parent
9bcd911740
commit
497fc8d998
3 changed files with 15 additions and 52 deletions
|
|
@ -348,22 +348,11 @@ actual class FMediaPlayer actual constructor(
|
|||
}
|
||||
|
||||
if (idx >= events.size) {
|
||||
val dc = getPendingDcStep()
|
||||
if (dc != null) {
|
||||
allNotesOff()
|
||||
seekToGrid(dc.targetGrid)
|
||||
clockNano = System.nanoTime()
|
||||
clockTick = currentTickPos
|
||||
idx = events.indexOfFirst { it.tickAbsolute >= currentTickPos }
|
||||
.takeIf { it >= 0 } ?: events.size
|
||||
continue
|
||||
} else {
|
||||
isRunning = false
|
||||
allNotesOff()
|
||||
resetTempoToNormal()
|
||||
onFinished()
|
||||
break
|
||||
}
|
||||
isRunning = false
|
||||
allNotesOff()
|
||||
resetTempoToNormal()
|
||||
onFinished()
|
||||
break
|
||||
}
|
||||
|
||||
val ev = events[idx]
|
||||
|
|
@ -465,18 +454,12 @@ actual class FMediaPlayer actual constructor(
|
|||
applyVoiceStates()
|
||||
|
||||
needsClockSync = true
|
||||
sharedScreenModel.updateActiveIndexByIndex(-1)
|
||||
sharedScreenModel.updateActiveIndexByIndex(gridIndex)
|
||||
}
|
||||
private fun ticksToMs(ticks: Long) = (ticks * usPerTick / 1000.0).toLong()
|
||||
private fun msToTicks(ms: Long) = (ms * 1000.0 / usPerTick).toLong()
|
||||
|
||||
private fun getPendingDcStep(): NavigationStep? =
|
||||
navigationSteps.firstOrNull {
|
||||
!it.alreadyDone &&
|
||||
it.hairPin == null &&
|
||||
it.dynamic == null &&
|
||||
!it.isHold &&
|
||||
!it.isFarany
|
||||
}
|
||||
|
||||
private fun resetNavigationFlags() {
|
||||
navigationSteps.forEach {
|
||||
|
|
@ -703,7 +686,6 @@ actual class FMediaPlayer actual constructor(
|
|||
when {
|
||||
//♩
|
||||
step.newBpm != null -> {
|
||||
step.alreadyDone = true
|
||||
if (step.gridIndex == 0 && userCustomTempo) {
|
||||
|
||||
}
|
||||
|
|
@ -717,7 +699,6 @@ actual class FMediaPlayer actual constructor(
|
|||
|
||||
// Modulation
|
||||
step.newKey != null -> {
|
||||
step.alreadyDone = true
|
||||
val baseKeyIdx = Transpose.keyToNumber.indexOf("C").coerceAtLeast(0)
|
||||
val targetKeyIdx = Transpose.keyToNumber.indexOf(step.newKey).coerceAtLeast(0)
|
||||
transpositionSemitones = targetKeyIdx - baseKeyIdx
|
||||
|
|
|
|||
|
|
@ -439,7 +439,7 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
|||
}
|
||||
}
|
||||
fun updateActiveIndexByIndex(index: Int) {
|
||||
val clamped = index.coerceAtLeast(0)
|
||||
val clamped = index.coerceAtLeast(-1)
|
||||
if (_activeIndex.value != clamped) {
|
||||
_activeIndex.value = clamped
|
||||
}
|
||||
|
|
@ -676,6 +676,7 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
|||
_dcDone.value = false
|
||||
_dsDone.value = false
|
||||
_sourceModeState.value = false
|
||||
updateActiveIndexByIndex(-1)
|
||||
try {
|
||||
val midiFileName = fileRepository.getFileName(newMidiFile)
|
||||
println("Opening xx129 $midiFileName")
|
||||
|
|
@ -786,6 +787,7 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
|||
_tuoTimestamps.value = emptyList()
|
||||
_searchTitle.value = ""
|
||||
_isPendingHairPinOnEdit.value = HairPinEditState(false, 0)
|
||||
_activeIndex.value = -1
|
||||
tempTimeUnitObjectList.clear()
|
||||
resetGridCount()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,20 +102,7 @@ actual class FMediaPlayer actual constructor(
|
|||
}
|
||||
return@addMetaEventListener
|
||||
}
|
||||
val totalGrids = (sequencer!!.sequence.tickLength / sequencer!!.sequence.resolution).toInt()
|
||||
val currentGrid = (sequencer!!.tickPosition / sequencer!!.sequence.resolution).toInt()
|
||||
val pendingDc = getPendingDcStep()
|
||||
|
||||
val isDcNearEnd = pendingDc != null && (totalGrids - pendingDc.gridIndex) <= 2
|
||||
|
||||
if (isDcNearEnd) {
|
||||
println("onFinished : DC pending → saut direct vers ${pendingDc.targetGrid}")
|
||||
pendingDc.alreadyDone = true
|
||||
seekToGrid(pendingDc.targetGrid)
|
||||
play()
|
||||
} else {
|
||||
onFinished()
|
||||
}
|
||||
onFinished()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -540,15 +527,6 @@ actual class FMediaPlayer actual constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
private fun getPendingDcStep(): NavigationStep? {
|
||||
return navigationSteps.firstOrNull { step ->
|
||||
!step.alreadyDone &&
|
||||
step.hairPin == null &&
|
||||
step.dynamic == null &&
|
||||
!step.isHold
|
||||
&& !step.isFin
|
||||
}
|
||||
}
|
||||
private fun startNavigationMonitor(sharedScreenModel: SharedScreenModel) {
|
||||
var dcDone = sharedScreenModel.getDcDone()
|
||||
val dsDone = sharedScreenModel.getDsDone()
|
||||
|
|
@ -582,7 +560,6 @@ actual class FMediaPlayer actual constructor(
|
|||
when {
|
||||
//♩
|
||||
step.newBpm != null -> {
|
||||
step.alreadyDone = true
|
||||
println("Exécution changement de tempo : ${step.newBpm} BPM à la grille $currentIndex")
|
||||
targetBpm = step.newBpm
|
||||
forceTempo(targetBpm.toDouble())
|
||||
|
|
@ -591,7 +568,6 @@ actual class FMediaPlayer actual constructor(
|
|||
|
||||
// Modulation
|
||||
step.newKey != null -> {
|
||||
step.alreadyDone = true
|
||||
//println("Exécution modulation vers tonalité ${step.newKey} à la grille $currentIndex")
|
||||
val baseKeyIdx = Transpose.keyToNumber.indexOf("C").coerceAtLeast(0)
|
||||
val targetKeyIdx = Transpose.keyToNumber.indexOf(step.newKey).coerceAtLeast(0)
|
||||
|
|
@ -747,6 +723,8 @@ actual class FMediaPlayer actual constructor(
|
|||
?.dynamic ?: Dynamic.MF
|
||||
currentDynamicFactor = lastDynamic.factor
|
||||
applyVoiceStates()
|
||||
sharedScreenModel.updateActiveIndexByIndex(-1)
|
||||
sharedScreenModel.updateActiveIndexByIndex(gridIndex)
|
||||
}
|
||||
|
||||
private fun getCountInBeats(measureStr: String): Int {
|
||||
|
|
@ -860,6 +838,8 @@ actual class FMediaPlayer actual constructor(
|
|||
sequencer?.start()
|
||||
println("La sequence vient d etre lancé ${sequencer?.isRunning}")
|
||||
// sequencer!!.open()
|
||||
val currentGrid = ((sequencer?.tickPosition ?: 0L) / 60L).toInt()
|
||||
sharedScreenModel.updateActiveIndexByIndex(currentGrid)
|
||||
}
|
||||
}
|
||||
actual fun pause(){
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue