Create midi preset and improve the rest ones
This commit is contained in:
@@ -7,14 +7,14 @@ if(__param__.containsKey("help")) {
|
||||
println("Run sound alarm");
|
||||
println();
|
||||
println("Optional parameters:");
|
||||
println(" - cycles: int - set number of cycles that running alarm has to reach to get quiet");
|
||||
println(" infinite on absence of argument");
|
||||
println(" - melody: string - set melody of alert");
|
||||
println(" available melodies:");
|
||||
println(" - beep (default)");
|
||||
println(" - bell");
|
||||
println(" - alarm1");
|
||||
println(" - alarm2");
|
||||
println(" - cycles: int - set number of cycles that running alarm has to reach to get quiet");
|
||||
println(" infinite on absence of argument");
|
||||
println(" - melody: string [beep] - set melody of alert");
|
||||
println(" available melodies:");
|
||||
println(" - beep");
|
||||
println(" - bell");
|
||||
println(" - alarm1");
|
||||
println(" - alarm2");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ if(__param__.containsKey("help")) {
|
||||
println("Simple metronome");
|
||||
println();
|
||||
println("Optional parameters:");
|
||||
println(" - bpm: int - set BPM of metronome");
|
||||
println(" - beats: int - set time signature of metronome (4 = 4/4, 3 = 3/4 and so on)");
|
||||
println(" - accent: note - set note for accent beat (General MIDI, channel 10)");
|
||||
println(" - beat: note - set note for regular beat (General MIDI, channel 10)");
|
||||
println(" - bpm: int [120] - set BPM of metronome");
|
||||
println(" - beats: int [4] - set time signature of metronome (4 = 4/4, 3 = 3/4 and so on)");
|
||||
println(" - accent: note [@A#2] - set note for accent beat (General MIDI, channel 10)");
|
||||
println(" - beat: note [@F#2] - set note for regular beat (General MIDI, channel 10)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
50
app/src/main/resources/presets/midi.mus
Normal file
50
app/src/main/resources/presets/midi.mus
Normal file
@@ -0,0 +1,50 @@
|
||||
import smnp.audio.midi;
|
||||
import smnp.io;
|
||||
import smnp.system;
|
||||
import smnp.text;
|
||||
|
||||
if(__param__.containsKey("help")) {
|
||||
println("Print available MIDI instruments or play notes of selected one");
|
||||
println();
|
||||
println("Optional parameters:");
|
||||
println(" - instrument: int - play notes of instrument with given ID");
|
||||
println();
|
||||
println("Optional parameters applied if 'instrument' parameter is passed:");
|
||||
println(" - bpm: int [120] - specify the BPM of playing notes");
|
||||
println(" - begin: note [@C1] - the lower bound of playing notes");
|
||||
println(" - end: note [@C9] - the upper bound of playing notes");
|
||||
println(" - channel: int [1] - MIDI channel to be used")
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(__param__.containsKey("instrument")) {
|
||||
instrument = __param__.get("instrument").toInt();
|
||||
|
||||
if(typeOf(instrument) != "int") {
|
||||
throw "Expected 'instrument' to be of int type";
|
||||
}
|
||||
|
||||
bpm = __param__.getOrDefault("bpm", "120").toInt();
|
||||
if(typeOf(bpm) != "int") {
|
||||
throw "Expected 'bpm' to be of int type";
|
||||
}
|
||||
|
||||
begin = __param__.getOrDefault("begin", "@C1").toNote();
|
||||
if(typeOf(begin) != "note") {
|
||||
throw "Expected 'begin' to be of note type";
|
||||
}
|
||||
|
||||
end = __param__.getOrDefault("end", "@C9").toNote();
|
||||
if(typeOf(end) != "note") {
|
||||
throw "Expected 'end' to be of note type";
|
||||
}
|
||||
|
||||
channel = __param__.getOrDefault("channel", "1").toInt();
|
||||
if(typeOf(channel) != "int") {
|
||||
throw "Expected 'channel' to be of int type";
|
||||
}
|
||||
|
||||
midiHelp(instrument, bpm, begin, end, channel);
|
||||
} else {
|
||||
midiHelp("instruments");
|
||||
}
|
||||
@@ -33,8 +33,8 @@ class MidiHelpFunction : Function("midiHelp") {
|
||||
) body { environment, args ->
|
||||
val instrument = args[0].value as Int
|
||||
val bpm = args.getOrNull(1)?.value as Int? ?: 120
|
||||
val begin = args.getOrNull(2) ?: Value.note(Note(Pitch.C, 0, 4, false))
|
||||
val end = args.getOrNull(3) ?: Value.note(Note(Pitch.H, 5, 4, false))
|
||||
val begin = args.getOrNull(2) ?: Value.note(Note(Pitch.C, 1, 4, false))
|
||||
val end = args.getOrNull(3) ?: Value.note(Note(Pitch.H, 9, 4, false))
|
||||
val channel = args.getOrNull(4)?.value as Int? ?: 1
|
||||
|
||||
if(channel > 16) {
|
||||
|
||||
Reference in New Issue
Block a user