Update hardcoded commands invocation in modules to new syntax

This commit is contained in:
2020-04-25 14:15:28 +02:00
parent faa38111c1
commit 2fbd39ead8
2 changed files with 14 additions and 10 deletions

View File

@@ -44,7 +44,7 @@ class MidiHelpFunction : Function("midiHelp") {
}
val notes = Value.list(
listOf(Value.string("i:$instrument")) + environment.invokeFunction(
listOf(Value.map(mapOf(Value.string("instrument") to Value.int(instrument)))) + environment.invokeFunction(
"range",
listOf(begin, end)
).value as List<Value>
@@ -60,7 +60,7 @@ class MidiHelpFunction : Function("midiHelp") {
println(it)
Midi
.with(ConfigMap(mapOf(Value.string("bpm") to Value.int(bpm))))
.play(mapOf(channel to listOf(listOf("i:$instrument", it))))
.play(mapOf(channel to listOf(listOf(mapOf("instrument" to instrument), it))))
Thread.sleep(100)
}
}

View File

@@ -4,11 +4,13 @@ function metronome(bpm: int = 120, beats: int = 4, accent: note = @A#2, beat: no
}
function alert(melody: string = "beep") {
i = instrument(108)
melodies = {
beep -> ["i:108", @c5, 4, @c5, 1, 4],
bell -> ["i:108", @c5:8, @db5:8],
alarm1 -> ["i:108", (range(@g, @g5) as n ^ n.withDuration(32))].flatten(),
alarm2 -> ["i:108", (range(@g, @g5) as n ^ n.withDuration(32)), -(range(@c, @c5) as n ^ n.withDuration(32))].flatten()
beep -> [i, @c5, 4, @c5, 1, 4],
bell -> [i, @c5:8, @db5:8],
alarm1 -> [i, (range(@g, @g5) as n ^ n.withDuration(32))].flatten(),
alarm2 -> [i, (range(@g, @g5) as n ^ n.withDuration(32)), -(range(@c, @c5) as n ^ n.withDuration(32))].flatten()
};
if(not melodies.containsKey(melody)) {
@@ -22,11 +24,13 @@ function alert(melody: string = "beep") {
}
function alert(cycles: int, melody: string = "beep") {
i = instrument(108)
melodies = {
beep -> ["i:108", @c5, 4, @c5, 1, 4],
bell -> ["i:108", @c5:8, @db5:8],
alarm1 -> ["i:108", (range(@g, @g5) as n ^ n.withDuration(32))].flatten(),
alarm2 -> ["i:108", (range(@g, @g5) as n ^ n.withDuration(32)), -(range(@c, @c5) as n ^ n.withDuration(32))].flatten()
beep -> [i, @c5, 4, @c5, 1, 4],
bell -> [i, @c5:8, @db5:8],
alarm1 -> [i, (range(@g, @g5) as n ^ n.withDuration(32))].flatten(),
alarm2 -> [i, (range(@g, @g5) as n ^ n.withDuration(32)), -(range(@c, @c5) as n ^ n.withDuration(32))].flatten()
};
if(not melodies.containsKey(melody)) {