From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Mon, 31 Jan 2005 02:03:33 -0500 From: Russ Cox To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] playing music (was RSA) In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <200411062237.iA6MbCZ16674@zamenhof.cs.utwente.nl> Topicbox-Message-UUID: 38e50434-eace-11e9-9e20-41e7f4b1d025 On Sat, 6 Nov 2004 17:56:14 -0500, Russ Cox wrote: > a few weeks ago, > i wrote an acme equivalent of ken's juke box, > kind of like acd but driven by a database of > audio files instead of a single cd. the whole > thing is a handful of shell scripts and is pretty > nice. after i iron out some more bugs i will > clean it up and put it somewhere for people > to play with. I finished cleaning. There are C programs now. http://swtch.com/juke.tar.gz. The gui instructions and README file are below. The tgz assumes you're using plan9port on a Unix system but it should be trivial to move over to real Plan 9. Juke depends on some recent additions to acme. They are in CVS in plan9port and also on sources as of a few minutes ago. Enjoy. Russ --- from jukeget script jukewelcome=' Welcome to Juke. This window, /juke/, is the playlist window. It contains a list of songs to be played, along with any other text. Songs are lines that begin with song/nnn, where nnn is a number. They might have other text (like the name of the song) as well. If you button 2 click on a line in this window, juke starts playing the first song it finds on that line or following. The currently playing song is marked with a >. When the song ends, juke picks up the > and scans forward for the next song, and then starts that song. If juke finds a line beginning "repeat" instead, then it moves back to the top of the file. Otherwise, if juke reaches the end of the window, it stops playing. If the playlist window contains a line beginning "shuffle", the playing algorithm changes: when one song ends, juke chooses the next song at random from all the songs in the window. Juke never stops playing in shuffle mode. This window's contents *are* the play list. If you move songs in this window, that changes the play order. If you move the >, then juke will think that was the song being played when the current song ends. Juke recognizes some builtin commands, which are displayed in the tag of this window. V- and V+ change the volume. In addition to song tags (song/nnn), there are album, artist, composer, and genre tags. Button 3 clicking on any of these opens a new window named, e.g., /juke/song/nnn, displaying information about the song, the contents of the albums, works by the artist or composer, or songs in the genre. In the results window, button 2 clicking on a line appends that line to the end of the playlist. Button 3 clicks behave as just described. If you button 3 click on text that is not a tag, then the new window will be named /juke/search, and it will be filled with a list of tags whose titles match the clicked text. The search windows behave just like the song windows. Button 3 clicking on the single words song, album, artist, composer, and genre shows lists of the given category. This is an intimidating amount of explanation. Just try it. Enjoy. ' --- README 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. 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 mpg123 and faad. It contains a workaround for a faad bug. If the bug is ever fixed, remove the echo -n xxx. Note that the programs cannot handle .m4p like you download from iTunes, though the Windows program iOpener can turn these into .m4a files. 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. I haven't tried this, but it seems like a neat idea. There is also a standalone program "volume" included that gives more detailed mixer access than Juke. Comments and problems to Russ Cox . ================================ 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. 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. The audio back end for volume and ajuke is system-specific, and only Linux is implemented. If you add support for another system, please mail it to me so I can include it. ---