Refactor smnp.music submodules

This commit is contained in:
2020-04-25 14:01:57 +02:00
parent 2fbd39ead8
commit 3136a08c63
11 changed files with 10 additions and 10 deletions

View File

View File

@@ -0,0 +1,7 @@
version=0.0.1
pluginVersion=0.1
pluginId=smnp.music.tool
pluginClass=
pluginProvider=Bartłomiej Pluta
pluginDependencies=

View File

@@ -0,0 +1,9 @@
package io.smnp.ext.musictool
import io.smnp.ext.provider.LanguageModuleProvider
import org.pf4j.Extension
@Extension
class MusicToolsModule : LanguageModuleProvider("smnp.music.tool") {
override fun dependencies() = listOf("smnp.audio.synth", "smnp.audio.midi", "smnp.music")
}

View File

@@ -0,0 +1,44 @@
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") {
i = instrument(108)
melodies = {
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)) {
throw "Unknown melody with name of '" + melody + "'";
}
A = melodies.get(melody);
B = transpose(6, melodies.get(melody));
true ^ synth({ bpm -> 400 }, A, B);
}
function alert(cycles: int, melody: string = "beep") {
i = instrument(108)
melodies = {
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)) {
throw "Unknown melody with name of '" + melody + "'";
}
A = melodies.get(melody);
B = transpose(6, melodies.get(melody));
cycles ^ synth({ bpm -> 400 }, A, B);
}