Refactor smnp.music submodules
This commit is contained in:
0
modules/music-tool/build.gradle
Normal file
0
modules/music-tool/build.gradle
Normal file
7
modules/music-tool/gradle.properties
Normal file
7
modules/music-tool/gradle.properties
Normal file
@@ -0,0 +1,7 @@
|
||||
version=0.0.1
|
||||
|
||||
pluginVersion=0.1
|
||||
pluginId=smnp.music.tool
|
||||
pluginClass=
|
||||
pluginProvider=Bartłomiej Pluta
|
||||
pluginDependencies=
|
||||
@@ -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")
|
||||
}
|
||||
44
modules/music-tool/src/main/resources/main.mus
Normal file
44
modules/music-tool/src/main/resources/main.mus
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user