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) {
|
if (idx >= events.size) {
|
||||||
val dc = getPendingDcStep()
|
isRunning = false
|
||||||
if (dc != null) {
|
allNotesOff()
|
||||||
allNotesOff()
|
resetTempoToNormal()
|
||||||
seekToGrid(dc.targetGrid)
|
onFinished()
|
||||||
clockNano = System.nanoTime()
|
break
|
||||||
clockTick = currentTickPos
|
|
||||||
idx = events.indexOfFirst { it.tickAbsolute >= currentTickPos }
|
|
||||||
.takeIf { it >= 0 } ?: events.size
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
isRunning = false
|
|
||||||
allNotesOff()
|
|
||||||
resetTempoToNormal()
|
|
||||||
onFinished()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val ev = events[idx]
|
val ev = events[idx]
|
||||||
|
|
@ -465,18 +454,12 @@ actual class FMediaPlayer actual constructor(
|
||||||
applyVoiceStates()
|
applyVoiceStates()
|
||||||
|
|
||||||
needsClockSync = true
|
needsClockSync = true
|
||||||
|
sharedScreenModel.updateActiveIndexByIndex(-1)
|
||||||
|
sharedScreenModel.updateActiveIndexByIndex(gridIndex)
|
||||||
}
|
}
|
||||||
private fun ticksToMs(ticks: Long) = (ticks * usPerTick / 1000.0).toLong()
|
private fun ticksToMs(ticks: Long) = (ticks * usPerTick / 1000.0).toLong()
|
||||||
private fun msToTicks(ms: Long) = (ms * 1000.0 / usPerTick).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() {
|
private fun resetNavigationFlags() {
|
||||||
navigationSteps.forEach {
|
navigationSteps.forEach {
|
||||||
|
|
@ -703,7 +686,6 @@ actual class FMediaPlayer actual constructor(
|
||||||
when {
|
when {
|
||||||
//♩
|
//♩
|
||||||
step.newBpm != null -> {
|
step.newBpm != null -> {
|
||||||
step.alreadyDone = true
|
|
||||||
if (step.gridIndex == 0 && userCustomTempo) {
|
if (step.gridIndex == 0 && userCustomTempo) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -717,7 +699,6 @@ actual class FMediaPlayer actual constructor(
|
||||||
|
|
||||||
// Modulation
|
// Modulation
|
||||||
step.newKey != null -> {
|
step.newKey != null -> {
|
||||||
step.alreadyDone = true
|
|
||||||
val baseKeyIdx = Transpose.keyToNumber.indexOf("C").coerceAtLeast(0)
|
val baseKeyIdx = Transpose.keyToNumber.indexOf("C").coerceAtLeast(0)
|
||||||
val targetKeyIdx = Transpose.keyToNumber.indexOf(step.newKey).coerceAtLeast(0)
|
val targetKeyIdx = Transpose.keyToNumber.indexOf(step.newKey).coerceAtLeast(0)
|
||||||
transpositionSemitones = targetKeyIdx - baseKeyIdx
|
transpositionSemitones = targetKeyIdx - baseKeyIdx
|
||||||
|
|
|
||||||
|
|
@ -439,7 +439,7 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun updateActiveIndexByIndex(index: Int) {
|
fun updateActiveIndexByIndex(index: Int) {
|
||||||
val clamped = index.coerceAtLeast(0)
|
val clamped = index.coerceAtLeast(-1)
|
||||||
if (_activeIndex.value != clamped) {
|
if (_activeIndex.value != clamped) {
|
||||||
_activeIndex.value = clamped
|
_activeIndex.value = clamped
|
||||||
}
|
}
|
||||||
|
|
@ -676,6 +676,7 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
||||||
_dcDone.value = false
|
_dcDone.value = false
|
||||||
_dsDone.value = false
|
_dsDone.value = false
|
||||||
_sourceModeState.value = false
|
_sourceModeState.value = false
|
||||||
|
updateActiveIndexByIndex(-1)
|
||||||
try {
|
try {
|
||||||
val midiFileName = fileRepository.getFileName(newMidiFile)
|
val midiFileName = fileRepository.getFileName(newMidiFile)
|
||||||
println("Opening xx129 $midiFileName")
|
println("Opening xx129 $midiFileName")
|
||||||
|
|
@ -786,6 +787,7 @@ class SharedScreenModel(private val fileRepository: FileRepository) : ScreenMode
|
||||||
_tuoTimestamps.value = emptyList()
|
_tuoTimestamps.value = emptyList()
|
||||||
_searchTitle.value = ""
|
_searchTitle.value = ""
|
||||||
_isPendingHairPinOnEdit.value = HairPinEditState(false, 0)
|
_isPendingHairPinOnEdit.value = HairPinEditState(false, 0)
|
||||||
|
_activeIndex.value = -1
|
||||||
tempTimeUnitObjectList.clear()
|
tempTimeUnitObjectList.clear()
|
||||||
resetGridCount()
|
resetGridCount()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,20 +102,7 @@ actual class FMediaPlayer actual constructor(
|
||||||
}
|
}
|
||||||
return@addMetaEventListener
|
return@addMetaEventListener
|
||||||
}
|
}
|
||||||
val totalGrids = (sequencer!!.sequence.tickLength / sequencer!!.sequence.resolution).toInt()
|
onFinished()
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
private fun startNavigationMonitor(sharedScreenModel: SharedScreenModel) {
|
||||||
var dcDone = sharedScreenModel.getDcDone()
|
var dcDone = sharedScreenModel.getDcDone()
|
||||||
val dsDone = sharedScreenModel.getDsDone()
|
val dsDone = sharedScreenModel.getDsDone()
|
||||||
|
|
@ -582,7 +560,6 @@ actual class FMediaPlayer actual constructor(
|
||||||
when {
|
when {
|
||||||
//♩
|
//♩
|
||||||
step.newBpm != null -> {
|
step.newBpm != null -> {
|
||||||
step.alreadyDone = true
|
|
||||||
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
|
||||||
forceTempo(targetBpm.toDouble())
|
forceTempo(targetBpm.toDouble())
|
||||||
|
|
@ -591,7 +568,6 @@ actual class FMediaPlayer actual constructor(
|
||||||
|
|
||||||
// Modulation
|
// Modulation
|
||||||
step.newKey != null -> {
|
step.newKey != null -> {
|
||||||
step.alreadyDone = true
|
|
||||||
//println("Exécution modulation vers tonalité ${step.newKey} à la grille $currentIndex")
|
//println("Exécution modulation vers tonalité ${step.newKey} à la grille $currentIndex")
|
||||||
val baseKeyIdx = Transpose.keyToNumber.indexOf("C").coerceAtLeast(0)
|
val baseKeyIdx = Transpose.keyToNumber.indexOf("C").coerceAtLeast(0)
|
||||||
val targetKeyIdx = Transpose.keyToNumber.indexOf(step.newKey).coerceAtLeast(0)
|
val targetKeyIdx = Transpose.keyToNumber.indexOf(step.newKey).coerceAtLeast(0)
|
||||||
|
|
@ -747,6 +723,8 @@ actual class FMediaPlayer actual constructor(
|
||||||
?.dynamic ?: Dynamic.MF
|
?.dynamic ?: Dynamic.MF
|
||||||
currentDynamicFactor = lastDynamic.factor
|
currentDynamicFactor = lastDynamic.factor
|
||||||
applyVoiceStates()
|
applyVoiceStates()
|
||||||
|
sharedScreenModel.updateActiveIndexByIndex(-1)
|
||||||
|
sharedScreenModel.updateActiveIndexByIndex(gridIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCountInBeats(measureStr: String): Int {
|
private fun getCountInBeats(measureStr: String): Int {
|
||||||
|
|
@ -860,6 +838,8 @@ actual class FMediaPlayer actual constructor(
|
||||||
sequencer?.start()
|
sequencer?.start()
|
||||||
println("La sequence vient d etre lancé ${sequencer?.isRunning}")
|
println("La sequence vient d etre lancé ${sequencer?.isRunning}")
|
||||||
// sequencer!!.open()
|
// sequencer!!.open()
|
||||||
|
val currentGrid = ((sequencer?.tickPosition ?: 0L) / 60L).toInt()
|
||||||
|
sharedScreenModel.updateActiveIndexByIndex(currentGrid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
actual fun pause(){
|
actual fun pause(){
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue