Put voices volumes & Add blank on tick 0 - Export midi
This commit is contained in:
parent
3bc0d72548
commit
7691fb981c
2 changed files with 20 additions and 5 deletions
|
|
@ -173,7 +173,9 @@ class MidiWriterforEXport constructor(private val fileRepository: FileRepositor
|
||||||
markers: List<MidiMarkers> = emptyList(),
|
markers: List<MidiMarkers> = emptyList(),
|
||||||
initialBpm: Float = 120.0f,
|
initialBpm: Float = 120.0f,
|
||||||
voiceInstruments: Map<Int, Int> = mapOf(1 to 0, 2 to 0, 3 to 0, 4 to 0),
|
voiceInstruments: Map<Int, Int> = mapOf(1 to 0, 2 to 0, 3 to 0, 4 to 0),
|
||||||
initialKey: String = "C"
|
voiceVolumes: Map<Int, Int> = mapOf(1 to 127, 2 to 127, 3 to 127, 4 to 127),
|
||||||
|
initialKey: String = "C",
|
||||||
|
initialOffsetTicks: Long = 480L
|
||||||
) {
|
) {
|
||||||
val (effectivePitches, effectiveMarkers) = expandDaCapoAndSegno(pitches, markers)
|
val (effectivePitches, effectiveMarkers) = expandDaCapoAndSegno(pitches, markers)
|
||||||
val lastTick = 0
|
val lastTick = 0
|
||||||
|
|
@ -184,7 +186,10 @@ class MidiWriterforEXport constructor(private val fileRepository: FileRepositor
|
||||||
voiceInstruments.forEach { (voiceIndex, programNumber) ->
|
voiceInstruments.forEach { (voiceIndex, programNumber) ->
|
||||||
setProgramChange(voiceNumber = voiceIndex, instrumentProgram = programNumber, tickPosition = 0L)
|
setProgramChange(voiceNumber = voiceIndex, instrumentProgram = programNumber, tickPosition = 0L)
|
||||||
}
|
}
|
||||||
|
voiceVolumes.forEach { (voiceIndex, volumeValue) ->
|
||||||
|
addControlChange(voiceNumber = voiceIndex, controller = 7, value = volumeValue, tickPosition = 0L)
|
||||||
|
}
|
||||||
|
var timeOffset = initialOffsetTicks
|
||||||
val nuanceMap = mutableMapOf<Long, Int>()
|
val nuanceMap = mutableMapOf<Long, Int>()
|
||||||
val fermataTicks = mutableSetOf<Long>()
|
val fermataTicks = mutableSetOf<Long>()
|
||||||
val textMetaMap = mutableMapOf<Long, MutableList<String>>()
|
val textMetaMap = mutableMapOf<Long, MutableList<String>>()
|
||||||
|
|
@ -253,7 +258,6 @@ class MidiWriterforEXport constructor(private val fileRepository: FileRepositor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var timeOffset = 0L
|
|
||||||
val holdDuration = 480L *3 // 480L:2noire *2:3noir *4:ronde
|
val holdDuration = 480L *3 // 480L:2noire *2:3noir *4:ronde
|
||||||
|
|
||||||
if (pendingHairpinStartTick != null && pendingHairpinType != null) {
|
if (pendingHairpinStartTick != null && pendingHairpinType != null) {
|
||||||
|
|
|
||||||
|
|
@ -302,8 +302,9 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
val midiWriter = MidiWriterforEXport(fileRepository)
|
val midiWriter = MidiWriterforEXport(fileRepository)
|
||||||
val totalGridsInStanza = currentTuoList.size
|
val totalGridsInStanza = currentTuoList.size
|
||||||
|
|
||||||
var currentTickOffset = 0L
|
val initialBlankTicks = 60L // un noire
|
||||||
var currentGridOffset = 0
|
var currentTickOffset = initialBlankTicks
|
||||||
|
var currentGridOffset = (initialBlankTicks / 60).toInt()
|
||||||
|
|
||||||
for (stanza in 1..nbStanzas) {
|
for (stanza in 1..nbStanzas) {
|
||||||
attachLyricsToPitches(tuoList = currentTuoList, stanzaNumber = stanza)
|
attachLyricsToPitches(tuoList = currentTuoList, stanzaNumber = stanza)
|
||||||
|
|
@ -371,6 +372,15 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
3 to prefs.getInt("voice_instrument", 0),
|
3 to prefs.getInt("voice_instrument", 0),
|
||||||
4 to prefs.getInt("voice_instrument", 0),
|
4 to prefs.getInt("voice_instrument", 0),
|
||||||
)
|
)
|
||||||
|
val voicesVols = prefs.getString("voices_volumes", "127,127,127,127")
|
||||||
|
val volumesArray = voicesVols.split(",")
|
||||||
|
|
||||||
|
val voiceVolumes = mapOf(
|
||||||
|
1 to (volumesArray.getOrNull(0)?.toFloatOrNull()?.toInt()?.coerceIn(0, 127) ?: 127),
|
||||||
|
2 to (volumesArray.getOrNull(1)?.toFloatOrNull()?.toInt()?.coerceIn(0, 127) ?: 127),
|
||||||
|
3 to (volumesArray.getOrNull(2)?.toFloatOrNull()?.toInt()?.coerceIn(0, 127) ?: 127),
|
||||||
|
4 to (volumesArray.getOrNull(3)?.toFloatOrNull()?.toInt()?.coerceIn(0, 127) ?: 127)
|
||||||
|
)
|
||||||
val originalKey = sharedScreenModel.songKey.value
|
val originalKey = sharedScreenModel.songKey.value
|
||||||
val transposedKey = Transpose.transposeKey(baseKey = originalKey, interval = transpI)
|
val transposedKey = Transpose.transposeKey(baseKey = originalKey, interval = transpI)
|
||||||
val initialSongBpm = meta["p"]?.toFloatOrNull() ?: bpm
|
val initialSongBpm = meta["p"]?.toFloatOrNull() ?: bpm
|
||||||
|
|
@ -380,6 +390,7 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
loopedMarkers,
|
loopedMarkers,
|
||||||
initialBpm = initialSongBpm,
|
initialBpm = initialSongBpm,
|
||||||
instruments,
|
instruments,
|
||||||
|
voiceVolumes = voiceVolumes,
|
||||||
initialKey = transposedKey
|
initialKey = transposedKey
|
||||||
)
|
)
|
||||||
midiWriter.save(outputPath)
|
midiWriter.save(outputPath)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue