This will play random notes in midi fashion. This will only work if you place the code in a text file (typing in 'perl' and then pasting it in and hitting ctrl+d will not work) and you must have the timidity player installed. There is one optional argument you can pass to the script and that's how many quarter note beats per minute you want. Gentle music is generally 120 beats, the default if you don't pass it is 360. Anything above 450ish and you are grooving! No matter how fast you play the music, this snippet will play for one entire minute. Have fun!
#!/usr/bin/perl 'timidity' . '-'; sub i{eval shift};i do{eval <DATA>},@ARGV[0], (seek DATA, 0,0 and <DATA>),int rand 2; __DATA__ $/='; ';(<DATA>)[2]; close STDERR; die 'died!'; warn 'still alive';use MIDI::Simple; new_score;$a=$_[0]||360;set_tempo 10**7*6/$a;while ($a--){if(eval $_[2]){noop c9;n int(rand 53)+35} else{noop c1;patch_change 1,int(rand 128);n int rand 128;}}open Q,"| $_[1]";write_score\*Q
If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Random midi player
by zentara (Cardinal) on Mar 21, 2003 at 12:47 UTC | |
by Coruscate (Sexton) on Mar 21, 2003 at 15:21 UTC |