Fix: DC Farany DC
This commit is contained in:
commit
9472859308
1 changed files with 4 additions and 50 deletions
|
|
@ -3,13 +3,16 @@ package mg.dot.feufaro.midi
|
||||||
import SharedScreenModel
|
import SharedScreenModel
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import mg.dot.feufaro.getConfigDirectoryPath
|
import mg.dot.feufaro.getConfigDirectoryPath
|
||||||
|
import mg.dot.feufaro.viewmodel.MidiMarkers
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.prefs.Preferences
|
import java.util.prefs.Preferences
|
||||||
import javax.sound.midi.MetaMessage
|
import javax.sound.midi.MetaMessage
|
||||||
import javax.sound.midi.MidiSystem
|
import javax.sound.midi.MidiSystem
|
||||||
import javax.sound.midi.Sequence
|
import javax.sound.midi.Sequence
|
||||||
import javax.sound.midi.Sequencer
|
import javax.sound.midi.Sequencer
|
||||||
|
import javax.sound.midi.ShortMessage
|
||||||
import javax.sound.midi.Synthesizer
|
import javax.sound.midi.Synthesizer
|
||||||
|
import javax.sound.midi.Track
|
||||||
import javax.sound.sampled.AudioSystem
|
import javax.sound.sampled.AudioSystem
|
||||||
import javax.sound.sampled.FloatControl
|
import javax.sound.sampled.FloatControl
|
||||||
|
|
||||||
|
|
@ -56,8 +59,6 @@ actual class FMediaPlayer actual constructor(
|
||||||
val hairPinEndGrid: Int = -1,
|
val hairPinEndGrid: Int = -1,
|
||||||
val hairPinFromFactor: Float = 1.0f,
|
val hairPinFromFactor: Float = 1.0f,
|
||||||
val hairPinToFactor: Float = 1.0f,
|
val hairPinToFactor: Float = 1.0f,
|
||||||
val isFin: Boolean = false, // Farany D.C.
|
|
||||||
var finActive: Boolean =false,
|
|
||||||
)
|
)
|
||||||
private val navigationSteps = mutableListOf<NavigationStep>()
|
private val navigationSteps = mutableListOf<NavigationStep>()
|
||||||
|
|
||||||
|
|
@ -83,13 +84,9 @@ actual class FMediaPlayer actual constructor(
|
||||||
applyVoiceStates()
|
applyVoiceStates()
|
||||||
sequencer?.addMetaEventListener { meta ->
|
sequencer?.addMetaEventListener { meta ->
|
||||||
if(meta.type == 47){
|
if(meta.type == 47){
|
||||||
val totalGrids = (sequencer!!.sequence.tickLength / sequencer!!.sequence.resolution).toInt()
|
|
||||||
val currentGrid = (sequencer!!.tickPosition / sequencer!!.sequence.resolution).toInt()
|
|
||||||
val pendingDc = getPendingDcStep()
|
val pendingDc = getPendingDcStep()
|
||||||
|
|
||||||
val isDcNearEnd = pendingDc != null && (totalGrids - pendingDc.gridIndex) <= 2
|
if (pendingDc != null) {
|
||||||
|
|
||||||
if (isDcNearEnd && pendingDc != null) {
|
|
||||||
println("onFinished : DC pending → saut direct vers ${pendingDc.targetGrid}")
|
println("onFinished : DC pending → saut direct vers ${pendingDc.targetGrid}")
|
||||||
pendingDc.alreadyDone = true
|
pendingDc.alreadyDone = true
|
||||||
seekToGrid(pendingDc.targetGrid)
|
seekToGrid(pendingDc.targetGrid)
|
||||||
|
|
@ -284,27 +281,6 @@ actual class FMediaPlayer actual constructor(
|
||||||
println("Lien DC créé : $marker à $indx vers le début")
|
println("Lien DC créé : $marker à $indx vers le début")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Farany
|
|
||||||
marker.trim().equals("Farany_GROUP_PART", ignoreCase = true) -> {
|
|
||||||
val hasDcAfter = metadataList.any { (_, gi, _, _, mk, _, _, _) ->
|
|
||||||
(gi ?: 0) > currentIndex &&
|
|
||||||
(dcGPattern.matches(mk.trim()) ||
|
|
||||||
dcRegex.matches(mk.trim()))
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasDcAfter) {
|
|
||||||
navigationSteps.add(
|
|
||||||
NavigationStep(
|
|
||||||
marker = marker,
|
|
||||||
gridIndex = currentIndex,
|
|
||||||
targetGrid = last_grid,
|
|
||||||
isFin = true,
|
|
||||||
finActive = false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
println("Farany mémorisé à la grille $currentIndex")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// velocité
|
// velocité
|
||||||
extractDynamic(marker) != null && marker.trim() != "=" -> {
|
extractDynamic(marker) != null && marker.trim() != "=" -> {
|
||||||
val dyn = extractDynamic(marker) ?: return@forEach
|
val dyn = extractDynamic(marker) ?: return@forEach
|
||||||
|
|
@ -386,7 +362,6 @@ actual class FMediaPlayer actual constructor(
|
||||||
step.hairPin == null &&
|
step.hairPin == null &&
|
||||||
step.dynamic == null &&
|
step.dynamic == null &&
|
||||||
!step.isHold
|
!step.isHold
|
||||||
&& !step.isFin
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun startNavigationMonitor(sharedScreenModel: SharedScreenModel) {
|
private fun startNavigationMonitor(sharedScreenModel: SharedScreenModel) {
|
||||||
|
|
@ -414,19 +389,6 @@ actual class FMediaPlayer actual constructor(
|
||||||
|
|
||||||
if (step != null) {
|
if (step != null) {
|
||||||
when {
|
when {
|
||||||
step.isFin -> {
|
|
||||||
if(step.finActive) {
|
|
||||||
step.alreadyDone = true
|
|
||||||
// println("Farany passage → FIN à grille $currentIndex")
|
|
||||||
sequencer?.stop()
|
|
||||||
sequencer?.tempoFactor = 1f
|
|
||||||
synthetizer?.channels?.forEach {
|
|
||||||
it?.controlChange(64, 0)
|
|
||||||
it?.controlChange(123, 0)
|
|
||||||
}
|
|
||||||
onFinished()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Point d'orgue
|
// Point d'orgue
|
||||||
step.isHold -> {
|
step.isHold -> {
|
||||||
val currentBpm = sequencer?.tempoInBPM ?: targetBpm
|
val currentBpm = sequencer?.tempoInBPM ?: targetBpm
|
||||||
|
|
@ -481,14 +443,6 @@ actual class FMediaPlayer actual constructor(
|
||||||
seekToGrid(step.targetGrid)
|
seekToGrid(step.targetGrid)
|
||||||
synthetizer?.channels?.forEach { it?.controlChange(64, 0) }
|
synthetizer?.channels?.forEach { it?.controlChange(64, 0) }
|
||||||
sequencer?.tempoFactor = 1f
|
sequencer?.tempoFactor = 1f
|
||||||
|
|
||||||
navigationSteps.filter { it.isFin }.forEach { faranyStep ->
|
|
||||||
if (step.gridIndex > faranyStep.gridIndex) {
|
|
||||||
faranyStep.finActive = true
|
|
||||||
faranyStep.alreadyDone = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sequencer?.isRunning == false) {
|
if (sequencer?.isRunning == false) {
|
||||||
sequencer?.tempoInBPM = targetBpm
|
sequencer?.tempoInBPM = targetBpm
|
||||||
sequencer?.start()
|
sequencer?.start()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue