Sunday, August 9, 2015

Emacs tool for browsing audio files

In this post on another blog of mine I posted emacs lisp code for a tool, which I boldly stole from dired-mplayer: dired-vlc.  Vlc is an excellent video player.  The code I posted allows one to rapidly and immediately play a video file/clip in Emacs dired, the directory browsing tool that I like the best. 

I have some video files, wav and mp3, and I wish to sort them.  So I edited the above mentioned code, and saved it to the file dired-audacious.el.  It was unbelievably easy and speedy to browse through the dozens of files, and delete the unwanted ones. 

In the above linked post, I mentioned another tool I cobbled together from other people's code, an improvement to org-mode's time marking code, to enable me to save a time mark within the video I am watching and type notes.  From these I have been able to easily compile indexes to videos and clips, for teaching purposes.  Dired-vlc was crucial. 

Here is the code for dired-audacious.  It works only if one runs linux and has audacious installed as a sound player.  

;==== %<===== Begin dired-audacious.el  =========
(require 'org)

(defvar dired-audacious-program "/usr/bin/audacious")

(defun dired-audacious (&optional timer)
  "Asynchronously start vlc on file through dired.  If an optional
argument is given (C-u), the org relative timer is started.  This
function purports to start vlc in rc mode, to leave open the
possibility of remote control."
  (interactive "P")
  (let ((file (expand-file-name (dired-get-filename)))
        ext files basename dir curr-file ;idx-file sub-file srt-file
    command options)
    (setq basename (file-name-nondirectory
            (file-name-sans-extension file)))
    (setq dir (file-name-directory file))
    (setq files (directory-files dir t basename))
    (delete file files)
    (setq command (format "\"%s\" \"%s" dired-audacious-program "--intf rc"))
    (if (y-or-n-p (format "Run command %s?" command))
        (start-process "junk" nil dired-audacious-program file)))
  (if (equal timer '(4)) (org-timer-start))

;; end dired-audacious.el

For explanation, please contact me

No comments:

Post a Comment