Create basic scaffolding for MIDI sequencing module

This commit is contained in:
2020-03-14 12:22:21 +01:00
parent a0a09ecb55
commit c7f251cbce
11 changed files with 210 additions and 13 deletions

View File

@@ -54,6 +54,6 @@ object ActualSignatureFormatter {
}
}
return "map<${output.keys.toSet().joinToString()}><${output.values.toSet().joinToString()}}>"
return "map<${output.keys.toSet().joinToString()}><${output.values.toSet().joinToString()}>"
}
}

View File

@@ -2,16 +2,25 @@ package io.smnp.data.entity
import io.smnp.data.enumeration.Pitch
data class Note (val pitch: Pitch, val octave: Int, val duration: Int, val dot: Boolean) {
data class Builder(var pitch: Pitch = Pitch.A, var octave: Int = 4, var duration: Int = 4, var dot: Boolean = false) {
fun pitch(pitch: Pitch) = apply { this.pitch = pitch }
fun octave(octave: Int) = apply { this.octave = octave }
fun duration(duration: Int) = apply { this.duration = duration }
fun dot(dot: Boolean) = apply { this.dot = dot }
fun build() = Note(pitch, octave, duration, dot)
}
data class Note(val pitch: Pitch, val octave: Int, val duration: Int, val dot: Boolean) {
data class Builder(
var pitch: Pitch = Pitch.A,
var octave: Int = 4,
var duration: Int = 4,
var dot: Boolean = false
) {
fun pitch(pitch: Pitch) = apply { this.pitch = pitch }
fun octave(octave: Int) = apply { this.octave = octave }
fun duration(duration: Int) = apply { this.duration = duration }
fun dot(dot: Boolean) = apply { this.dot = dot }
fun build() = Note(pitch, octave, duration, dot)
}
override fun toString(): String {
return "${pitch}${octave}:${duration}${if (dot) "d" else ""}"
}
override fun toString(): String {
return "${pitch}${octave}:${duration}${if (dot) "d" else ""}"
}
fun intPitch(): Int {
return octave * 12 + pitch.ordinal
}
}

View File

@@ -1,10 +1,12 @@
package io.smnp.ext
import io.smnp.environment.Environment
import io.smnp.interpreter.Interpreter
import io.smnp.type.module.Module
import org.pf4j.ExtensionPoint
abstract class ModuleProvider(val path: String) : ExtensionPoint {
open fun onModuleLoad(environment: Environment) {}
open fun dependencies(): List<String> = emptyList()
abstract fun provideModule(interpreter: Interpreter): Module
}

View File

@@ -40,6 +40,10 @@ class Matcher(val type: DataType?, private val matcher: (Value) -> Boolean, priv
)
}
fun mapOfMatchers(keyMatcher: Matcher, valueMatcher: Matcher): Matcher {
return mapOfMatchers(listOf(keyMatcher), listOf(valueMatcher))
}
fun mapOfMatchers(keyMatchers: List<Matcher>, valueMatchers: List<Matcher>): Matcher {
return Matcher(
DataType.MAP,