;; ecatest.el - simple jack/ecasound functions ;; borrowed from ecaspace.el ;; http://dto.freeshell.org/e/ecaspace.el ;; ref also http://delysid.org/emacs/ecasound-el.html ;; (eca-global-reinit) ;; (play "/root/jelly7oct.wav") ;; (jack-start) ;; (connect-it 5 1) ;; (disconnect-it 3 2) ;; (stop-it) (defvar eca-state :stopped "One of nil, :stopped, :running, :crashed.") (defvar eca-record-enabled-p nil "When non-nil at start of playback, enable recording on all tracks for which record-p is set.") (defvar eca-buffer nil "Buffer for interaction with ecasound.") (defvar monk 0) (defmacro with-ecasound (&rest body) `(with-current-buffer eca-buffer ,@body)) (defun eca-global-init () "Start up ecasound daemon if necessary." (interactive) (when (null eca-buffer) (setf eca-buffer (eci-init)) (setf eca-state :stopped))) (defun eca-global-reinit () (interactive) (setf eca-buffer nil) (eca-global-init)) (defun play (file &optional session) (with-ecasound (stop-it) (eci-c-add (format "chain_%d" monk)) (eci-ai-add file) (eci-ao-add "jack") (setq monk (+ 1 monk)) (eci-start))) (defun stop-it () (with-ecasound (eci-cs-disconnect))) (defun connect-it (in_port out_port) (let* ((in-client (format "ecasound")) (in-port (format "out_%d" in_port)) (out-client "alsa_pcm") (out-port (format "playback_%d" out_port))) (jack-connect in-client in-port out-client out-port))) (defun disconnect-it (in_port out_port) (let* ((in-client (format "ecasound")) (in-port (format "out_%d" in_port)) (out-client "alsa_pcm") (out-port (format "playback_%d" out_port))) (jack-disconnect in-client in-port out-client out-port)))