Execute DC before finished song
This commit is contained in:
parent
810ebb38e6
commit
ab221a6355
1 changed files with 22 additions and 13 deletions
|
|
@ -84,18 +84,18 @@ actual class FMediaPlayer actual constructor(
|
||||||
applyVoiceStates()
|
applyVoiceStates()
|
||||||
sequencer?.addMetaEventListener { meta ->
|
sequencer?.addMetaEventListener { meta ->
|
||||||
if(meta.type == 47){
|
if(meta.type == 47){
|
||||||
|
val pendingDc = getPendingDcStep()
|
||||||
|
|
||||||
|
if (pendingDc != null) {
|
||||||
|
println("onFinished : DC pending → saut direct vers ${pendingDc.targetGrid}")
|
||||||
|
pendingDc.alreadyDone = true
|
||||||
|
seekToGrid(pendingDc.targetGrid)
|
||||||
|
play()
|
||||||
|
} else {
|
||||||
onFinished()
|
onFinished()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
sequencer?.addMetaEventListener { meta ->
|
|
||||||
if (meta.type == 0x51) { // 0x51 "Set Tempo"
|
|
||||||
if (sequencer?.tempoInBPM != targetBpm) {
|
|
||||||
println("Tempo MIDI détecté (120), forçage à $targetBpm")
|
|
||||||
applyBpm()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}*/
|
|
||||||
} else {
|
} else {
|
||||||
// Créeons une fichier vide au 1er lancement de l'application, après MidiWriterKotlin l'écrasera
|
// Créeons une fichier vide au 1er lancement de l'application, après MidiWriterKotlin l'écrasera
|
||||||
val f0file = File("${getConfigDirectoryPath()}whawyd3.mid")
|
val f0file = File("${getConfigDirectoryPath()}whawyd3.mid")
|
||||||
|
|
@ -253,9 +253,10 @@ actual class FMediaPlayer actual constructor(
|
||||||
|
|
||||||
// DC
|
// DC
|
||||||
dcGPattern.matches(marker.trim()) -> {
|
dcGPattern.matches(marker.trim()) -> {
|
||||||
var indx = if((last_grid - currentIndex) <= 0) {
|
val indx = if((last_grid - currentIndex) <= 0) {
|
||||||
currentIndex - 1
|
currentIndex - 1
|
||||||
} else currentIndex
|
} else currentIndex
|
||||||
|
// println("monn index est $indx car dernier est $last_grid et curr $currentIndex")
|
||||||
navigationSteps.add(
|
navigationSteps.add(
|
||||||
NavigationStep(
|
NavigationStep(
|
||||||
marker,
|
marker,
|
||||||
|
|
@ -355,6 +356,14 @@ actual class FMediaPlayer actual constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private fun getPendingDcStep(): NavigationStep? {
|
||||||
|
return navigationSteps.firstOrNull { step ->
|
||||||
|
!step.alreadyDone &&
|
||||||
|
step.hairPin == null &&
|
||||||
|
step.dynamic == null &&
|
||||||
|
!step.isHold
|
||||||
|
}
|
||||||
|
}
|
||||||
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()
|
||||||
|
|
@ -364,8 +373,8 @@ actual class FMediaPlayer actual constructor(
|
||||||
sharedScreenModel.activeIndex.collect { currentIndex ->
|
sharedScreenModel.activeIndex.collect { currentIndex ->
|
||||||
|
|
||||||
val availableIndices = navigationSteps.map { it.gridIndex }
|
val availableIndices = navigationSteps.map { it.gridIndex }
|
||||||
// println("bpm:$targetBpm _ ${sequencer?.tempoInBPM}")
|
// println("bpm:$targetBpm _ ${sequencer?.tempoInBPM}| Index en mémoire : $availableIndices")
|
||||||
// println("MONITOR : Reçu Index $currentIndex | Index en mémoire : $availableIndices ")
|
// println("i $currentIndex ")
|
||||||
|
|
||||||
if (sequencer?.isRunning == true) {
|
if (sequencer?.isRunning == true) {
|
||||||
if (Math.abs(sequencer!!.tempoInBPM - targetBpm) > 0.1) {
|
if (Math.abs(sequencer!!.tempoInBPM - targetBpm) > 0.1) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue