notes/Generate Random Midi Music from text-Bm3HYzuR.sh
#Install
sudo apt install midge
#example file
http://www.undef.org.uk/code/midge/dont_fear_the_reaper.mg
#script for creating random music
#!/bin/bash
t=( a b c d e f g)
notes=$(for i in {1..50};do NUMBER=$[ ( $RANDOM % 6 ) + 1 ];echo "${t[$NUMBER]}";done|tr "\n" " ")
cat > tmp.mg << EOF
@head {
\$tempo 240
\$time_sig 4/4
\$title "song"
\$resolution 960
}
@body {
@channel 1 "1-Track" {
\$attack 64
\$decay 0
/l4/c6 $notes
}
@channel 2 "2-Track" {
\$attack 64
\$decay 0
/l4/c4 $notes
}
}
midge source written to 2-Track_1-1.mg
EOF
midge tmp.mg
timidity tmp.mid
syntax highlighted by Code2HTML, v. 0.9.1