randomising tracks: scripting question

Peter Vereshagin peter at vereshagin.org
Tue Jan 4 08:57:58 UTC 2011


You know St. Peter won't call my name, freebsd-questions!
2011/01/03 20:23:38 -0800 Joseph Olatt <joji at eskimo.com> => To Frank Shute :
JO> On Sun, Dec 26, 2010 at 05:09:30PM +0000, Frank Shute wrote:
JO> > 
JO> > I generally play my tracks of an album like so:
JO> > 
JO> > for track in $(cat trombone_shorty-backatown.m3u); do
JO> > mplayer $track
JO> > done
JO> > 
JO> > They then play in the correct order.
JO> > 
JO> > How would I go about randomising the order of play using
JO> > sh (preferably) or perl?

I have several tens of thousands of MIDI files from 90s. They are too many for 'random play' feature of the Timidity++ which is used with 'eawpats', the GUS patches.
Here is my bash script to play them in random order:
===
#!/usr/local/bin/bash
IFS='
'
fns=(`find ~/mid/ -iname '*.mid'`)
while :; do 
        timidity -a -OdS -in -j -t 1251 -E t -p a -R 500 -EFreverb=127 -EFns=4 ${fns[$((${#fns[@]}*$RANDOM/32767))]}
done
===

Of course I miss the 'Previous track' functionality.

73! Peter pgp: A0E26627 (4A42 6841 2871 5EA7 52AB  12F8 0CE1 4AAC A0E2 6627)
--
http://vereshagin.org


More information about the freebsd-questions mailing list