PJB Manager Mode for Emacs

This is a PJB100 manager mode written in elisp. This package makes the PJB (possibly) the first MP3 player which can be totally managed through emacs. It supports adding multiple tracks in one upload, renaming and reordering tracks, disc and sets and removing tracks.

Emacs PJB manager is based on modified SDK command line utilities. Original, unmodified SDK is available from Compaq. This package is also only tested with regular GNU Emacs (version 20.3.1). Note that to use this, you naturally need USB driver for the PJB (located in the package) and kernel with USB support (I am using 2.2.18).

Current CVS snapshot and new releases of this package are also available through OpenPJB SourceForge project.

And if you don't know what PJB is, read this and order one today. ;)

Short installation instructions

Download the pjbsdk-3.1.4.tar.gz package which contains current version of my modified SDK. The package contains a README with more detailed information about the command line utility and a change log. Specially the added features in command line utility pjb are documented in the README. Inside the package is pjbsdk directory which contains fairly standard configure system. Compile it with
  ./configure 
  make
If there are problems send me email and I'll try to help. Also check the INSTALL file in the package.

After compilation the main utility is in pjbcmds/pjb. This is a command line utility which can be used to view the contents of your PJB, add and remove tracks, discs and sets and sort sets and discs. Readme file in the package explains these features in depth (or at least tries to...).

Emacs mode (in pjbcmds/pjb-manager.el) needs to have the pjb binary located somewhere in your path. Either install it by copying it to /usr/bin/ (or somewhere) or add it's current location to your path.

After that you can load it with 'load' command within Emacs or by some other means such as adding line (load-file "~/.elisp/pjb-manager.el") to your .emacs file or using M-x eval-buffer command while viewing the file.

Using the Emacs PJB-manager mode

Actual pjb-manager mode is started with command M-x pjb-manager. At that point the window is split (or should be) into two buffers. Upper one contains usually the table of contents file for the PJB which can be modified. All commands are also given to this buffer. Lower buffer shows output of various operations.

Help on key bindings (show on startup too) can be seen with C-c h command (note: this means 'press 'ctrl-c' and the 'h'). Complete command listing is:
C-c r Read TOC from PJB. This discards the currently loaded (and possibly modified) TOC.
C-c w Write TOC to PJB. This commits all ordering and naming changes, removes deleted tracks and automatically uploads newly added files. If commit is already in progress, it will be aborted instead. This command asks confirmation before proceeding. Note that new tracks are first uploaded and TOC is written afterwards. This means that tracks deleted but not committed are still marked as used so if your PJB is almost full you must first delete unwanted tracks, commit and then add new files.
C-c v Verify edited TOC but don't commit it. Basically the same as above but does not write any thing. Can be used to see if there is any problems with files to be added. Also calculates total size for added tracks.
C-c a Add new track to current cursor position. Tries to read mp3 tags (if not disabled with C-c C-t command). If directory is given, a new disc is created for all files inside it and if it contains further subdirectories, a new set is made which will then contain all a new disc per each subdirectory. Variable 'pjb-artist-in-discname' can be used to control the disc name format. By default (if the varible is set to 't') the disc name is formed as 'ARTIST / ALBUM'. If 'pjb-artist-in-discname' is nil the disc name is just plain album name. This also does some minor modifications to names, mainly converts underscores to spaces.
C-c C-a Add cue file as a new disc. Cue file has to have filename defined which will point to the mp3 file. Disc is created with the album name got from the cue file and each track in the cue file is converted to a track on pjb. Disc, track and file names can be edited before commiting the TOC. Note that the offset on the first track is ignored (first track begins always at offset 0:00:00) and the last track ends at the end of the file.
C-c c Count the total size of all added (but uncommited) tracks.
C-c s Depending on cursor position, will either sort discs in a set (if cursor is on set line) or tracks within the disc (if cursor is somewhere inside that track definition). Can sort contents alphabetically in either normal or reverse order. Can also 'sort' into random order. Operation is made within emacs so all changes can be reviewed before commiting.
C-c p Play selected track by downloading it to external process. Stop the playing by pressing 'C-c p' in non-track context. Currently the only supported external player is mpg123.
C-c C-p Prettify track names inside a region. Currently just replaces '_' with ' '. Actually this is deprecated command as current version does this automatically.
C-c i Retrieve information from PJB. Shows remaining free space, number of sets, discs and tracks, etc.
C-c C-i Get statistics on current (based on cursor position) disc or set.
C-c C-t Toggle id3tag reading on and off.
C-c C-c C-b Make a backup from whole PJB contents. This command first asks for backup directory into which all sets, discs and tracks are then downloaded. Variable 'pjb-backup-options' can be set to modify this command. It's value must be a list of strings, each defining one command line argument. By default 'pjb-backup-options' is set to "-skip" "-ws2us" "-filter=?!*"\/" which will skip existing files, replace whitespace with underscore in directory and track names and filter all '?', '!', '*', '"', '\' and '/' charaters.
C-c C-b Make backup from selected subtree of PJB's contents. Set, disc or even single track can be selected by positioning cursor on that line. As above, this command first asks for backup directory but in case of track command, a new file can also be specified. In that case the track name in toc is ignored and track is written directly to the given file. Variable 'pjb-backup-options' is also used by this command.
C-c h Show help text.

Navigation and display management

Cursor keys can be used to navigate the listing. Up and down arrows are used to jump tracks with alt key, discs with control and sets with shift key.

Shift and right/left can be used to 'hide' parts of the listing. Pressing shift and left arrow will first hide all other track information except track name. Second button press will hide all track information and finally the third press hides disc names and leaves only sets visible. Process can be reversed using shift and left.

Hiding is implemented through 'selective display' feature in emacs. Some care should be taken as the hidden text isn't actually removed and can be accessed through cursor movements, matched in searches etc. So for example to copy whole disc while tracks are hidden, just pressing the C-k once on discs line isn't enough and will only copy that line. Correct sequence is to first set mark on beginning of that line, move to the start of next line and press C-w to cut whole region.

If you have any comments on this, please send me email to ttammisa@cc.hut.fi

Screenshot showing pjb-manager uploading some discs.

Uploading some music

More screenshots?