Create new module: smnp.music.tools
This commit is contained in:
0
modules/music-tools/build.gradle
Normal file
0
modules/music-tools/build.gradle
Normal file
7
modules/music-tools/gradle.properties
Normal file
7
modules/music-tools/gradle.properties
Normal file
@@ -0,0 +1,7 @@
|
||||
version=0.0.1
|
||||
|
||||
pluginVersion=0.1
|
||||
pluginId=smnp.music.tools
|
||||
pluginClass=
|
||||
pluginProvider=Bartłomiej Pluta
|
||||
pluginDependencies=
|
||||
@@ -0,0 +1,9 @@
|
||||
package io.smnp.ext.musictools
|
||||
|
||||
import io.smnp.ext.LanguageModuleProvider
|
||||
import org.pf4j.Extension
|
||||
|
||||
@Extension
|
||||
class MusicToolsModule : LanguageModuleProvider("smnp.music.tools") {
|
||||
override fun dependencies() = listOf("smnp.audio.midi", "smnp.music")
|
||||
}
|
||||
33
modules/music-tools/src/main/resources/main.mus
Normal file
33
modules/music-tools/src/main/resources/main.mus
Normal file
@@ -0,0 +1,33 @@
|
||||
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 + "'";
|
||||
}
|
||||
|
||||
true ^ midi({ bpm -> 400 }, melodies.get(melody));
|
||||
}
|
||||
|
||||
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 + "'";
|
||||
}
|
||||
cycles ^ midi({ bpm -> 400 }, melodies.get(melody));
|
||||
}
|
||||
Reference in New Issue
Block a user