]> git.eshelyaron.com Git - emacs.git/commitdiff
Add ability to crossfade between songs in 'mpc'
authorjohn muhl <jm@pub.pink>
Sun, 29 Sep 2024 00:11:03 +0000 (19:11 -0500)
committerEshel Yaron <me@eshelyaron.com>
Tue, 22 Oct 2024 19:00:15 +0000 (21:00 +0200)
* lisp/mpc.el (mpc-cmd-crossfade):
(mpc-toggle-crossfade): New function.
(mpc-crossfade-time): New option.
(mpc-mode-menu): Add menu item to toggle crossfade.  (Bug#73891)

(cherry picked from commit 08f3bc1b8e6a3583c8ccda02a7cf1b59c8d3f514)

etc/NEWS
lisp/mpc.el

index 6724994475aca8b8a2b46a5ae428a35165516c33..bda55a049ae4897f4d9df8e11b9887431d965f53 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -515,6 +515,11 @@ a desktop notification when the song changes, using
 customized using the new user options 'mpc-notifications-title' and
 'mpc-notifications-body'.
 
+*** New user option 'mpc-crossfade-time'.
+When non-nil, MPC will crossfade between songs for the specified number
+of seconds.  Crossfading can be toggled using the command
+'mpc-toggle-crossfade' or from the MPC menu.
+
 \f
 * New Modes and Packages in Emacs 31.1
 
index b71cd445738ad024198e978d7632e29160da3880..6c6ca4574f9bd60e9b6c358c114ce4fcfcfba1c8 100644 (file)
@@ -872,6 +872,11 @@ If PLAYLIST is t or nil or missing, use the main playlist."
 (defun mpc-cmd-tagtypes ()
   (mapcar #'cdr (mpc-proc-cmd-to-alist "tagtypes")))
 
+(defun mpc-cmd-crossfade (&optional arg)
+  "Set duration of crossfade to `mpc-crossfade-time' or ARG seconds."
+  (mpc-proc-cmd (list "crossfade" (or arg mpc-crossfade-time))
+                #'mpc-status-refresh))
+
 ;; This was never integrated into MPD.
 ;; (defun mpc-cmd-download (file)
 ;;   (with-current-buffer (generate-new-buffer " *mpc download*")
@@ -907,6 +912,11 @@ If PLAYLIST is t or nil or missing, use the main playlist."
   "Directory where MPC.el stores auxiliary data."
   :type 'directory)
 
+(defcustom mpc-crossfade-time 3
+  "Number of seconds to crossfade between songs."
+  :version "31.1"
+  :type 'natnum)
+
 (defun mpc-data-directory ()
   (unless (file-directory-p mpc-data-directory)
     (make-directory mpc-data-directory))
@@ -1177,6 +1187,8 @@ string POST."
      :selected (member '(single . "1") mpc-status)]
     ["Consume Mode" mpc-toggle-consume :style toggle
      :selected (member '(consume . "1") mpc-status)]
+    ["Crossfade Songs" mpc-toggle-crossfade :style toggle
+     :selected (alist-get 'xfade mpc-status)]
     "--"
     ["Add new browser" mpc-tagbrowser]
     ["Update DB" mpc-update]
@@ -2417,6 +2429,12 @@ This is used so that they can be compared with `eq', which is needed for
   (mpc-cmd-random
    (if (string= "0" (cdr (assq 'random (mpc-cmd-status)))) "1" "0")))
 
+(defun mpc-toggle-crossfade ()
+  "Toggle crossfading between songs."
+  (interactive)
+  (mpc-cmd-crossfade
+   (if (alist-get 'xfade mpc-status) "0" mpc-crossfade-time)))
+
 (defun mpc-stop ()
   "Stop playing the current queue of songs."
   (interactive)