2015-02-07 Emms and transcripts

A few days ago there was a question on the org-mode mailing list about using Org-mode as a transcript tool. While I do not do exactly this – what I needed was basically editing transcripts done by someone else, and they were rather simplistic, with no time information – I thought that sharing my (simple) config might be useful.

Basically, what is needed is an integration of Emacs and a player, so that I can pause and unpause (is that a word?) the sound from Emacs. Also, seeking a few seconds back is useful so that if I didn’t understand something, I can easily go back to that place. Implement this, and that’s it.

Of course, nobody needs to do it from scratch. Since I wanted to be able to listen to music from within Emacs anyway, I wanted to install Emms. So, without further ado, here’s my config (I do not (require 'emms), since I package-installed it).

(emms-standard)
(require 'emms-player-mpg321-remote)
(setq emms-player-list
      '(emms-player-mpg321-remote
        emms-player-ogg123
	emms-player-mplayer-playlist
	emms-player-mplayer
	emms-player-vlc))

(setq emms-source-file-directory-tree-function #'emms-source-file-directory-tree-find)
(setq emms-source-file-default-directory "~/Muzyka/")

(defun mb/emms-forward (&optional seconds)
  "Play next track if SECONDS is nil, and seek forward SECONDS if
given.  In particular, if called with \\[universal-argument], seek 4 seconds
forward."
  (interactive "P")
  (if seconds
      (emms-seek (prefix-numeric-value seconds))
    (emms-next)))

(defun mb/emms-backward (&optional seconds)
  "Play previous track if SECONDS is nil, and seek backward SECONDS if
given.  In particular, if called with \\[universal-argument], seek 4 seconds
backward."
  (interactive "P")
  (if seconds
      (emms-seek (- (prefix-numeric-value seconds)))
    (emms-previous)))

(global-set-key (kbd "<XF86AudioPlay>") #'emms-pause)
(global-set-key (kbd "<XF86AudioStop>") #'emms-stop)
(global-set-key (kbd "<XF86AudioPrev>") #'mb/emms-backward)
(global-set-key (kbd "<XF86AudioNext>") #'mb/emms-forward)
(global-set-key (kbd "<XF86AudioLowerVolume>") #'emms-volume-lower)
(global-set-key (kbd "<XF86AudioRaiseVolume>") #'emms-volume-raise)

I have to admit that I did have some problems with seeking back. First of all, it seems not to be supported by mpg321 – that’s why I put it after vlc in the emms-player-list. Then, while vlc seems to support it, I have a strong suspicion that the timing is wrong; it seems to seek back less than it should. Strange. I ended up using emms-player-mpg321-remote (quod google). Now my setup uses only four “multimedia” keys: the previous/next key with a prefix argument seeks backward/forward. Thanks to Emacs’ handling of plain C-u, with just this I get seeking by 4 seconds, which seems a right amount for replaying a not-that-well-understood word for the transcript.

Notice also a few niceties: emms-pause will start playing if the music is paused or stopped, and emms-volume-raise/-lower will modify the systemwide volume setting. And, I can now play music from within Emacs – no more terminal windows dedicated to cmus!

CategoryEnglish, CategoryBlog, CategoryEmacs