generated from rnentjes/kotlin-server-web-empty
Update MIDI message handling and version increment
Refactored MIDI message classes to improve modularity and flexibility, introducing separate classes for distinct MIDI message types. Updated `build.gradle.kts` version to `0.2.0` to reflect these changes. Removed `.idea/.name` file as part of cleanup.
This commit is contained in:
1
.idea/.name
generated
1
.idea/.name
generated
@@ -1 +0,0 @@
|
|||||||
template
|
|
||||||
@@ -8,7 +8,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "nl.astraeus"
|
group = "nl.astraeus"
|
||||||
version = "0.1.0"
|
version = "0.2.0"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -9,21 +9,31 @@ import nl.astraeus.tba.blob
|
|||||||
import nl.astraeus.tba.double
|
import nl.astraeus.tba.double
|
||||||
import nl.astraeus.tba.long
|
import nl.astraeus.tba.long
|
||||||
|
|
||||||
class MidiMessage() : TypedByteArray(
|
open class MidiMessage(
|
||||||
|
vararg types: Type
|
||||||
|
) : TypedByteArray(
|
||||||
Type("type", DataType.LONG),
|
Type("type", DataType.LONG),
|
||||||
Type("generated", DataType.DOUBLE),
|
*types,
|
||||||
Type("playTime", DataType.DOUBLE),
|
|
||||||
Type("midi", DataType.BLOB, 240),
|
|
||||||
) {
|
) {
|
||||||
var type by long("type")
|
var type by long("type")
|
||||||
var generated by double("generated")
|
|
||||||
var playTime by double("playTime")
|
|
||||||
var midi by blob("data")
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
this.type = MidiMessageTypes.MIDI_DATA.typeId
|
this.type = MidiMessageTypes.MIDI_DATA.typeId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constructor(data: ByteArray): this() {
|
||||||
|
this.data = MutableByteArrayHandler(buffer = data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MidiDataMessage() : MidiMessage(
|
||||||
|
Type("midi", DataType.BLOB, 48),
|
||||||
|
) {
|
||||||
|
var midi by blob("data")
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.type = MidiMessageTypes.MIDI_DATA.typeId
|
||||||
|
}
|
||||||
|
|
||||||
constructor(data: ByteArray): this() {
|
constructor(data: ByteArray): this() {
|
||||||
check(data.size == definition.size) {
|
check(data.size == definition.size) {
|
||||||
@@ -33,10 +43,33 @@ class MidiMessage() : TypedByteArray(
|
|||||||
this.data = MutableByteArrayHandler(data)
|
this.data = MutableByteArrayHandler(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(playTime: Double, midi: ByteArray): this() {
|
}
|
||||||
this.generated = getCurrentTime()
|
|
||||||
this.playTime = playTime
|
class TimedMidiMessage() : MidiMessage(
|
||||||
this.midi = SlicedByteArray(midi)
|
Type("timeToPlay", DataType.DOUBLE),
|
||||||
|
Type("midi", DataType.BLOB, 48),
|
||||||
|
) {
|
||||||
|
var timeToPlay by double("timeToPlay")
|
||||||
|
var midi by blob("data")
|
||||||
|
|
||||||
|
init {
|
||||||
|
this.type = MidiMessageTypes.MIDI_DATA.typeId
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(data: ByteArray): this() {
|
||||||
|
check(data.size == definition.size) {
|
||||||
|
"Invalid data size: ${data.size} != ${definition.size}"
|
||||||
|
}
|
||||||
|
|
||||||
|
this.data = MutableByteArrayHandler(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
timeToPlay: Double,
|
||||||
|
vararg data: Byte
|
||||||
|
): this() {
|
||||||
|
this.timeToPlay = timeToPlay
|
||||||
|
this.midi = SlicedByteArray(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,5 +37,7 @@ enum class MidiMessageTypes(
|
|||||||
val typeId: Long,
|
val typeId: Long,
|
||||||
) {
|
) {
|
||||||
NONE("Unknown", 0L),
|
NONE("Unknown", 0L),
|
||||||
MIDI_DATA("Timestamped midi data", "TimeMidi".encodeToNumber()),
|
MIDI_MESSAGE("Midi message base", "MidiMsg".encodeToNumber()),
|
||||||
|
MIDI_DATA("Midi data", "TimeData".encodeToNumber()),
|
||||||
|
MIDI_TIMED("Timed midi data", "MidiTimd".encodeToNumber()),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user