metalx1000

Generate Random Midi Music from text

Dec 11th, 2017
791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.65 KB | None | 0 0
  1. #Install
  2. sudo apt install midge
  3.  
  4. #example file
  5. http://www.undef.org.uk/code/midge/dont_fear_the_reaper.mg
  6.  
  7. #script for creating random music
  8. #!/bin/bash
  9.  
  10. t=( a b c d e f g)
  11. notes=$(for i in {1..50};do NUMBER=$[ ( $RANDOM % 6 )  + 1 ];echo "${t[$NUMBER]}";done|tr "\n" " ")
  12.  
  13. cat > tmp.mg << EOF
  14. @head {
  15.     \$tempo 240
  16.     \$time_sig 4/4
  17.     \$title "song"
  18.     \$resolution 960
  19. }
  20. @body {
  21.  
  22.     @channel 1 "1-Track" {
  23.      \$attack 64
  24.      \$decay 0
  25.      /l4/c6 $notes
  26.     }
  27.  
  28.     @channel 2 "2-Track" {
  29.      \$attack 64
  30.      \$decay 0
  31.      /l4/c4 $notes
  32.     }
  33. }
  34. midge source written to 2-Track_1-1.mg
  35. EOF
  36.  
  37. midge tmp.mg
  38. timidity tmp.mid
Add Comment
Please, Sign In to add comment