launch fluidsynth with -s (among other things)
the program will return to the menu after playing a few notes, select cancel to exit
#!/usr/bin/awk -f
BEGIN {
#get instrument names from fluidsynth instance
cmd = "/inet/tcp/0/localhost/9800"
print "inst 1" |& cmd
while (( cmd |& getline out) > 0) {
instrument[substr(out,8)]= substr(out,0,7);
if (match(out,"SFX")) { break }
}
close(cmd);
asorti(instrument,instrumentS)
while(1) {
sel=""
for (i in instrumentS) ds= ds" \""instrumentS[i]"\" \"\""
("dialog --stdout --menu \"Select Instrument\" 15 35 10 " ds)|getline sel
system("clear")
if (sel=="") break
print "Selected "sel , instrument[sel]
setting=instrument[sel]
setInst= "select 0 0 "substr(setting,0,3)" "substr(setting,5,8)
#send the select command to fluidsynth
print setInst |& cmd
#play a few notes
for (n=50;n<55;n++) {
print "noteon 0 "n" 90" |& cmd
system("sleep 0.4")
print "noteoff 0 "n" 90" |& cmd
}
close(cmd)
}
}
No comments:
Post a Comment