Minor simplification
This commit is contained in:
parent
2cc1f230f4
commit
d217017796
1 changed files with 3 additions and 7 deletions
|
|
@ -7,11 +7,6 @@ class MidiSequence(val resolution: Int = 60) {
|
|||
val out: MutableList<Byte> = mutableListOf<Byte>()
|
||||
private var lastTick = 0L
|
||||
|
||||
fun getDeltaAndSync(channel: Int, currentTick: Long): Long {
|
||||
val delta = currentTick - lastTick
|
||||
lastTick = currentTick
|
||||
return delta
|
||||
}
|
||||
fun createTrack(): MutableList<Byte> {
|
||||
val newTrack = mutableListOf<Byte>()
|
||||
tracks.add(newTrack)
|
||||
|
|
@ -45,7 +40,8 @@ class MidiSequence(val resolution: Int = 60) {
|
|||
}
|
||||
fun MutableList<Byte>.addNote(channel: Int, pitch: Int, currentTick: Long, type: Int = 80, finalVelocity: Int = 100) {
|
||||
// Calcul du Delta-Time
|
||||
val delta = getDeltaAndSync(channel, currentTick)
|
||||
val delta = currentTick - lastTick
|
||||
lastTick = currentTick
|
||||
|
||||
val status = if (type == 80) (0x80 or channel) else (0x90 or channel)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue