juke.tar.gz
--rw-r--r-- M 0 rsc users  1124 Oct 10  2006 COPYRIGHT
--rwxr-xr-x M 0 rsc users   283 Oct 10  2006 Juke
--rw-r--r-- M 0 rsc users  3755 Oct 10  2006 README
--rw-r--r-- M 0 rsc users  8584 Oct 10  2006 acme.c
--rw-r--r-- M 0 rsc users  1499 Oct 10  2006 acme.h
--rw-r--r-- M 0 rsc users 21071 Oct 10  2006 ajuke.c
--rw-r--r-- M 0 rsc users   729 Oct 10  2006 aplay.c
--rw-r--r-- M 0 rsc users    25 Oct 10  2006 audio-FreeBSD.c
--rw-r--r-- M 0 rsc users  3396 Oct 10  2006 audio-Linux.c
--rw-r--r-- M 0 rsc users  3178 Oct 10  2006 audio-ssh.c
--rw-r--r-- M 0 rsc users   380 Oct 10  2006 audio.h
--rwxr-xr-x M 0 rsc users   328 Oct 10  2006 flacinfo
--rw-r--r-- M 0 rsc users    47 Aug 22 10:47 index.html
--rw-r--r-- M 0 rsc users  1867 Oct 10  2006 jukefmt.c
--rwxr-xr-x M 0 rsc users  3736 Oct 10  2006 jukeget
--rw-r--r-- M 0 rsc users 13767 Oct 10  2006 jukeindex.c
--rwxr-xr-x M 0 rsc users   202 Aug 22 10:47 jukeinfo
--rwxr-xr-x M 0 rsc users  1038 Aug 22 10:47 jukeplay
--rwxr-xr-x M 0 rsc users   277 Oct 10  2006 jukeput
--rwxr-xr-x M 0 rsc users   274 Oct 10  2006 jukesearch
--rwxr-xr-x M 0 rsc users    83 Oct 10  2006 jukesongfile
--rw-r--r-- M 0 rsc users  7078 Oct 10  2006 m4ainfo.c
--rw-r--r-- M 0 rsc users   861 Oct 10  2006 mkfile
--rw-r--r-- M 0 rsc users 10119 Oct 10  2006 mp3info.c
--rw-r--r-- M 0 rsc users  2556 Oct 10  2006 volume.c
--rw-r--r-- M 0 rsc users   626 Oct 10  2006 waitfor.c

This directory contains a collection of tools that
implement a music player for acme(1).  

Install on a plan9port system with

	mk install

Before running Juke, index your song files:

	mkdir -p $HOME/lib/jukedb
	jukeindex *.mp3 *.m4a

(replace the wildcards with real paths to your sound files).

Once you have indexed your songs, run Juke, which will
create an acme window named Juke/ that contains instructions
on using the browser.

There are two shell scripts you may need to customize to
your system: jukeinfo and jukeplay.  Jukeinfo is invoked by
jukeindex for each file name you specify.  It is expected to
print information about the music file, probably by invoking
a helper program like mp3info or m4ainfo.  See those programs
for the output format and field list.  Jukeplay is invoked to 
play the named file.  It must write the decoded audio to 
standard output, *not* to the audio device.  The audio must
be 44100 Hz, 16-bit stereo PCM.  A separate program 

Jukeinfo and jukeplay can handle MP3 and MP4 files with
extensions .mp3 and .m4a respectively.  Jukeinfo uses two
supplied programs mp3info and m4ainfo.  Jukeplay uses
madplay, faad, and flac.

Note that the programs cannot handle .m4p like you download
from iTunes.

The juke C programs never actually access the files,
so there's no need for them to be files at all.  You could
imagine changing jukeinfo and jukeplay to take URLs and
access files on a remote web server, and everything should
just work out.  Jukeplay does consult the environment variable
jukerx to get the files.  For example, to play MP3 files it uses:

	$jukerx cat $1 | madplay -q -S -o raw:/dev/stdout - 

If you run jukerx=(ssh tux) Juke, then files will be fetched
over ssh from the machine named tux.

The players write to standard output and Juke pipes that
into a helper program called aplay to redirect that into the
sound card.  

If you have installed aplay on a remote machine (named, say, amp)
then you can run aplay -x amp on the local machine to play
audio on the remote machine.  Juke will automatically do this
if you execute the internal "Dev" command, i.e. "Dev amp".
The special Dev local can be used to name the local machine.

There is also a standalone program "volume" included
that gives more detailed mixer access than Juke.

Comments and problems to Russ Cox <rsc@swtch.com>.

==================================================

The pieces of the player you shouldn't need to touch are:

Juke
	Shell script that starts ajuke after sanity-checking environment.

ajuke
	The program that talks to acme.  It manages all the windows
	named /juke/* and uses the following helper programs to
	make the windows useful.

aplay [-x machine]
	The program that reads 44.1kHz 16-bit stereo sound and plays
	it on a given audio device.  The -x flag says to play on a remote
	machine via ssh.

jukeget name
	Print the contents for a new window named name.
	Window names are:

		Juke/ - the playlist
		Juke/song/ - the list of songs
		Juke/song/n - song #n

	And also album, artist, composer, and genre, list in place of song.

jukesearch pattern
	Print the contents for a search window searching for pattern.

jukeput name
	Write standard input to the file for the window named name.
	Only the playlist Juke/ and the sublists Juke/list/* can
	be written.

jukefmt id
	Tab "song/n Title" lines so that they line up using the
	acme font in the window with the given id.

jukesongfile nnn
	Print the name of the song numbered nnn.

waitfor hh:mm
	Sleep until the given time.  Used to implement the alarm command.

The audio back end for volume and ajuke is system-specific,
and only Linux and FreeBSD are implemented.  If you add support
for another system, please mail it to me so I can include it.