Files
smnp-kt/modules/music-tools/src/main/resources/main.mus

40 lines
1.4 KiB
Plaintext

function metronome(bpm: int = 120, beats: int = 4, accent: note = @A#2, beat: note = @F#2) {
measure = [accent] + ((beats-1) ^ beat)
true ^ midi({ bpm -> bpm }, { 10 -> [measure] });
}
function alert(melody: string = "beep") {
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()
};
if(not melodies.containsKey(melody)) {
throw "Unknown melody with name of '" + melody + "'";
}
A = melodies.get(melody);
B = transpose(6, melodies.get(melody));
true ^ midi({ bpm -> 400 }, A, B);
}
function alert(cycles: int, melody: string = "beep") {
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()
};
if(not melodies.containsKey(melody)) {
throw "Unknown melody with name of '" + melody + "'";
}
A = melodies.get(melody);
B = transpose(6, melodies.get(melody));
cycles ^ midi({ bpm -> 400 }, A, B);
}