]> git.donarmstrong.com Git - lib.git/blob - emacs_el/lyqi-rumor.el
update templates, add lyqi and update ls-R
[lib.git] / emacs_el / lyqi-rumor.el
1 ;;      $RCSfile: lyqi-rumor.el,v $     
2 ;;      $Revision: 1.2 $        
3 ;;      $Date: 2004/03/14 15:15:24 $    
4 ;;      $Author: nicolas $      
5 ;;; 
6 ;;; Part of lyqi, a major emacs mode derived from LilyPond-Mode,
7 ;;; for quick note insertion while editing GNU LilyPond music scores.
8 ;;; 
9 ;;; (c) copyright 2003 Nicolas Sceaux <nicolas.sceaux@free.fr>
10 ;;; See http://nicolas.sceaux.free.fr/lilypond/
11 ;;;     
12
13 (require 'eieio)
14 (require 'lyqi-base)
15 (require 'lyqi-midi)
16
17 (defcustom lyqi-rumor-command "rumor"
18   "Command used to start the rumor process."
19   :group 'lyqi
20   :type  'string)
21
22 ;;; rumor options
23 (defcustom lyqi-rumor-default-grain 16
24   "Set minimum time resolution to the NUMth note. Only powers of two are valid, from 1 up to 128."
25   :group 'lyqi
26   :type  'number)
27
28 (defcustom lyqi-rumor-default-tempo 80
29   "Metronome speed in beats per minute."
30   :group 'lyqi
31   :type  'number)
32
33 (defcustom lyqi-rumor-default-legato nil
34   "If true, ignore any rests between notes."
35   :group 'lyqi
36   :type  'boolean)
37
38 (defcustom lyqi-rumor-default-no-dots nil
39   "If true, do not use dotted notes."
40   :group 'lyqi
41   :type  'boolean)
42
43 (defcustom lyqi-rumor-default-flat nil
44   "If true, output only pitches as you play, no lengths."
45   :group 'lyqi
46   :type  'boolean)
47
48 (defcustom lyqi-rumor-default-strip t
49   "If true, strip leading and trailing rests from output."
50   :group 'lyqi
51   :type  'boolean)
52
53 ;; the two following are obiously score-dependant, not really
54 ;; custom vars. However, with defcustom, they can be set thanks 
55 ;; to set-variable.
56 (defcustom lyqi-rumor-default-meter "4/4"
57   "P/Q. Set time signature. Bar will have P beats of duration of the Qth note. Q must be a power of two."
58   :group 'lyqi
59   :type  'string)
60
61 (defcustom lyqi-rumor-default-key "c"
62   "Set base note of current scale.
63 Valid values for KEY are ces, c, cis, des, .... Double sharps/flats are not allowed.
64 Note that KEY has to be given using note language `nederlands'."
65   :group 'lyqi
66   :type  'string)
67
68 (defcustom lyqi-rumor-default-alsa-port 64
69   "rumor ALSA port"
70   :group 'lyqi
71   :type  'number)
72
73 (defvar lyqi-rumor-process nil
74   "The rumor process.")
75
76 (defclass rumor (midi-process)
77   ((grain   :initarg :grain)
78    (tempo   :initarg :tempo)
79    (legato  :initarg :legato)
80    (no-dots :initarg :no-dots)
81    (flat    :initarg :flat)
82    (strip   :initarg :strip)
83    (meter   :initarg :meter)
84    (key     :initarg :key)
85    (port    :initarg :alsa-port)))
86
87 (defmethod process-start :BEFORE ((rumor rumor))
88   "Start a rumor recording session"
89   (with-slots (grain tempo legato no-dots flat strip meter key port) rumor
90     (setf (slot-value rumor 'args)
91           (list "2>/dev/null"
92                 (format "--meter=%s" meter)
93                 (format "--tempo=%d" tempo)
94                 (format "--grain=%d" grain)
95                 (format "--key=%s"   key)
96                 (format "--alsa=%d:0,%d:0" port port)))
97     (when legato
98       (push "--legato" (slot-value rumor 'args)))
99     (when no-dots
100       (push "--no-dots" (slot-value rumor 'args)))
101     (when flat
102       (push "--flat" (slot-value rumor 'args)))
103     (when strip
104       (push "--strip" (slot-value rumor 'args)))
105     (push (format "--lang=%s" (case (slot-value lyqi-editing-state 'language)
106                                 (nederlands "ne")
107                                 (english "en-short")
108                                 (deutsch "de")
109                                 (norsk "no")
110                                 (svenska "sv")
111                                 (italiano "it")
112                                 (catalan "ca")
113                                 (espanol"es")))
114           (slot-value rumor 'args))
115     (when (slot-value lyqi-editing-state 'force-duration)
116       (push "--explicit-duration" (slot-value rumor 'args)))
117     (unless (slot-value lyqi-editing-state 'relative-octave)
118       (push "--absolute-pitches" (slot-value rumor 'args)))
119     (push "--no-chords" (slot-value rumor 'args))
120     (setf (slot-value rumor 'args) (nreverse (slot-value rumor 'args)))))
121
122 (defmethod process-start :AFTER ((rumor rumor))
123   (set-process-filter (slot-value rumor 'process) 'rumor-filter))
124
125 (defun rumor-filter (process output)
126   "Process Filter Function for rumor.
127  Just insert rumor output in current buffer."
128   (insert output)
129   (accept-process-output process 0.3 0))
130
131 (provide 'lyqi-rumor)
132