  Hi,

  I've finally got a sound card in my machine at work this afternoon, so
I hacked together a simple bash gadget for playing music from my home
workstation. Then I thought that I might share it since I think others
might find it useful as well, and there are couple of interesting ideas
in the script which might serve as general inspiration for other tasks
as well.

  It basically cats the mp3 over ssh and feeds it to stdin of any
reasonable mp3 player (see below). But does a lot more:

  * Cache the mp3 files locally. The mp3 file is tee'd to a directory
structure on the local filesystem mirroring the server directory
structure. By default it never prunes the cache, but a LRU cache removal
should be pretty easy (O(N) trivial, O(1) possible too if you modify
smp3 accordingly).

  * Server-side globs expansion - smp3 music/Vangelis/* will expand to
all the relevant mp3s on the server side

  * Shuffle the playlist (-z), fully random play (-Z) - smp3 can shuffle
the playlist after doing the server-side expansions

  * Server-side tab completion - smp3 music/Van<tab> will complete to
Vangelis (or whatever based on what's on the server)

  I think it's pretty convenient and usable now. Have a look yourself:

	http://pasky.or.cz/~pasky/dev/mp3/

  It is all bash - actually, I think everything should be POSIX except
for the tab completion thing, which is bash-specific (but nonvital).
Aside of the main smp3 command, it also provides sls, sl and scat
commands which do the obvious thing and have the same nice
tab completion. Those alone should be very useful on their own. The only
problem is specifying the server - the only information I have in the
completion function is the command name, current string and previous
parameter. One possible way might be invoking the commands like:

	h=pasky@occam scat /etc/passwd1 /etc/passwd2 \>/etc/passwd


  Another TODO item would be skipping a song - currently, it can be done
by getting the list of processes and then killing the mpg123 and ssh
processes. ^C works only if the mp3 is played from cache, for some
strange reason.


  smp3 works fine for me with the server on a 256kbit upstream line
(standard UPC CZ setup). Most of my mp3s have bitrate of 128, with 196
and higher you may experience _infrequent_ hangs. And this is where the
trouble comes in, your mp3 player has to deal with the stream suddenly
drying up for a moment.

  Short story - mpg123 does fine, mpg321 does not.  So if you are using
mpg321 (which poses itself as mpg123 too), your listening session may
turn to a horrid experience as mpg321 messes up.

  Have fun,

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
<Espy> be careful, some twit might quote you out of context..
