corrections dans la lib commune
[nenuvar.git] / common / baroque.ily
blob4dede20cf9254b3bcedecf9b794a96b40a94ee62
1 %% Custom bar lines
2 \defineBarLine "!!:" #'("" "!!:" "!! ")
3 \defineBarLine ".!:" #'("|" ".!:" ".! ")
4 \defineBarLine "|!:" #'("|" "|!:" "|! ")
5 \defineBarLine "!:" #'("" "!:" "! ")
6 \defineBarLine ":!." #'(":!." "" " !.")
7 \defineBarLine ":!|" #'(":!|" "" " !|")
8 \defineBarLine ":||:" #'(":||:" "" " || ")
9 \defineBarLine "|;|" #'("|;|" "" "| |")
10 \defineBarLine " .|:" #'("" ".|:" ".| ")
12 %% Breathing signs from Hippolyte et Aricie
13 cesure = {
14   \once\override BreathingSign #'text = \markup \fontsize #2 "|"
15   \once\override BreathingSign #'Y-offset = #0
16   \breathe
18 cesureCenter = {
19   \once\override BreathingSign #'text = \markup \fontsize #2 "|"
20   \once\override BreathingSign #'Y-offset = #-1
21   \breathe
23 cesureDown = {
24   \once\override BreathingSign #'text = \markup \fontsize #2 "|"
25   \once\override BreathingSign #'Y-offset = #-2
26   \breathe
29 cesureInstr = {
30   \once\override BreathingSign #'text = \markup \musicglyph #"scripts.caesura.straight"
31   \breathe
34 cesureInstrCenter = {
35   \once\override BreathingSign #'text = \markup \musicglyph #"scripts.caesura.straight"
36   \once\override BreathingSign #'Y-offset = #-1
37   \breathe
39 cesureInstrDown = {
40   \once\override BreathingSign #'text = \markup \musicglyph #"scripts.caesura.straight"
41   \once\override BreathingSign #'Y-offset = #-2
42   \breathe
45 dotSign=\markup\vcenter "╸"
47 %% New baroque scripts (Charpentier, Rameau...)
48 #(define-public baroque-script-alist
49    (append!
50     `(("t"
51        (script-stencil
52         . (markup . ,(markup #:center-align #:sans #:fontsize -2 #:bold "t")))
53        (padding . 0.20)
54        (avoid-slur . around)
55        (direction . ,UP))
56       ("trillSharp"
57        (script-stencil
58         . (markup . , #{ \markup\center-align\concat\vcenter {
59                            \smaller\smaller\sharp
60                            \musicglyph #"scripts.stopped" } #}))
61        (padding . 0.20)
62        (avoid-slur . around)
63        (direction . ,UP))
64       ("trillNatural"
65        (script-stencil
66         . (markup . , #{ \markup\center-align\concat\vcenter {
67                            \smaller\smaller\natural
68                            \musicglyph #"scripts.stopped" } #}))
69        (padding . 0.20)
70        (avoid-slur . around)
71        (direction . ,UP))
72       ("trillSug"
73        (script-stencil
74         . (markup . , #{ \markup\center-align\concat {
75      \smaller\smaller\musicglyph #"accidentals.leftparen"
76      \musicglyph #"scripts.stopped"
77      \translate #'(-0.6 . 0) \smaller\smaller\musicglyph #"accidentals.rightparen"
78    } #}))
79        (padding . 0.20)
80        (avoid-slur . around)
81        (direction . ,UP))
82        ("prallSug"
83        (script-stencil
84         . (markup . , #{ \markup\center-align\concat {
85      \smaller\smaller\musicglyph #"accidentals.leftparen"
86      \musicglyph #"scripts.prall"
87      \translate #'(-0.6 . 0) \smaller\smaller\musicglyph #"accidentals.rightparen"
88    } #}))
89        (padding . 0.20)
90        (avoid-slur . around)
91        (direction . ,UP))
92       ("arcTrill" ; + with an arc above (like a formata with a + signe instead of dot)
93        (script-stencil
94         . (markup . ,(markup #:combine
95                              #:concat (#:null #:translate '(0.3 . 0.8) #:rotate -90
96                                               #:musicglyph "accidentals.leftparen")
97                              #:musicglyph "scripts.stopped")))
98        (padding . 0.20)
99        (avoid-slur . around)
100        (direction . ,UP))
101       ("arcDot"
102        (script-stencil
103         . (markup . ,(markup #:combine
104                              #:concat (#:null #:translate '(0.3 . 0.65) #:rotate -90
105                                               #:musicglyph "accidentals.leftparen")
106                              #:musicglyph "scripts.staccato")))
107        (padding . 0.40)
108        (avoid-slur . around)
109        (direction . ,UP))
110       ("arcArc"
111        (script-stencil
112         . (markup
113            . , #{
114      \markup\combine\combine
115      \translate #'(0 . 1) \musicglyph #"scripts.ufermata"
116      \with-color #white \translate #'(0 . 1.2) \draw-circle #0.4 #0 ##t
117      \combine
118      \smaller\smaller\translate #'(0 . 0) \musicglyph #"scripts.ufermata"
119      \with-color #white \translate #'(0 . 0.2) \draw-circle #0.4 #0 ##t
120      #}))
121        (padding . 0.40)
122        (avoid-slur . around)
123        (direction . ,UP))
124       ("arcArcDot"
125        (script-stencil
126         . (markup
127            . , #{
128      \markup\combine\combine
129      \translate #'(0 . 1) \musicglyph #"scripts.ufermata"
130      \with-color #white \translate #'(0 . 1.2) \draw-circle #0.4 #0 ##t
131      \smaller\smaller \translate #'(0 . 0) \musicglyph #"scripts.ufermata"
132      #}))
133        (padding . 0.40)
134        (avoid-slur . around)
135        (direction . ,UP))
136       ("dotDot"
137        (script-stencil
138         . (markup . ,(markup #:center-align #:line (#:musicglyph "period" #:musicglyph "period"))))
139        (padding . 0.20)
140        (avoid-slur . around)
141        (direction . ,UP))
142       ("dotPrall" ; Articulation used Charpentier: a dot, followed by a prall sign
143        (script-stencil
144         . (markup . ,(markup #:override '(word-space . 1)
145                              #:line (#:vcenter "╸" #:vcenter #:musicglyph "scripts.prall"))))
146        (padding . 0.20)
147        (avoid-slur . around)
148        (direction . ,UP))
149       ("dotDoublePrallDoublePrall"
150        (script-stencil
151         . (markup . ,(markup #:override '(word-space . 2) #:override '(baseline-skip . 0)
152                            #:column (#:line (#:vcenter "╸"
153                                              #:vcenter #:musicglyph "scripts.prallprall" )
154                                      #:line (#:transparent #:vcenter "╸"
155                                              #:vcenter #:musicglyph "scripts.prallprall")))))
156        (padding . 0.20)
157        (avoid-slur . around)
158        (direction . ,UP))
159       ("doublePrall"
160        (script-stencil
161         . (markup . ,(markup #:override '(baseline-skip . 0)
162                              #:center-align #:column (#:musicglyph "scripts.prall"
163                                                       #:musicglyph "scripts.prall"))))
164        (padding . 0.20)
165        (avoid-slur . around)
166        (direction . ,UP))
167       )
168     default-script-alist))
170 #(define (baroque-script-interface::print grob)
171    (let ((script-stencil (ly:grob-property grob 'script-stencil)))
172      (cond ((and (pair? script-stencil)
173                  (eqv? 'markup (car script-stencil)))
174             (set! (ly:grob-property grob 'font-encoding) 'latin1)
175             (grob-interpret-markup grob (cdr script-stencil)))
176            (else
177             (ly:script-interface::print grob)))))
179 \layout {
180   \context {
181     \Score
182     scriptDefinitions = #baroque-script-alist
183   }
184   \context {
185     \Voice
186     \override Script #'stencil = #baroque-script-interface::print
187   }
189 trill = #(make-articulation "stopped")
190 trillSharp = #(make-articulation "trillSharp")
191 trillNatural = #(make-articulation "trillNatural")
192 tr = #(make-articulation "t")
193 trillSug = #(make-articulation "trillSug")
194 prallSug = #(make-articulation "prallSug")
195 arcTrill = #(make-articulation "arcTrill")
196 arcDot = #(make-articulation "arcDot")
197 arcArc = #(make-articulation "arcArc")
198 arcArcDot = #(make-articulation "arcArcDot")
199 dotDot = #(make-articulation "dotDot")
200 dotPrall = #(make-articulation "dotPrall")
201 dotDoublePrallDoublePrall = #(make-articulation "dotDoublePrallDoublePrall")
202 doublePrall = #(make-articulation "doublePrall")
204 \layout {
205   \context {
206     \Voice
207     \name "Voice"
208     \override Script #'avoid-slur = #'outside
209   }
210   \context {
211     \CueVoice
212     \name "CueVoice"
213     \override Script #'avoid-slur = #'outside
214   }
217 %% A slur and a prall, both joined on their right ends
218 slurPrall = {
219   \once\override Slur #'direction = #UP
220   \once\override Slur #'text = \markup\musicglyph #"scripts.prall"
221   \once\override Slur #'stencil =
222   #(lambda (grob)
223      (let* ((slur-stencil (ly:slur::print grob))
224             (coords (ly:slur::calc-control-points grob))
225             (X-ext (ly:stencil-extent slur-stencil X))
226             (Y-ext (ly:stencil-extent slur-stencil Y))
227             (text-stencil (ly:text-interface::print grob))
228             (text-width (interval-length (ly:stencil-extent text-stencil X)))
229             (prall-stencil (ly:stencil-translate
230                             (ly:stencil-aligned-to text-stencil X LEFT)
231                             (cons (- (cdr X-ext) text-width 0.17)
232                                   (+ (if (< (cdr (list-ref coords 3)) 2.8)
233                                          (- 2.8 (cdr (list-ref coords 3)))
234                                          0.5)
235                                      (- (cdr (list-ref coords 3)) 0.15)))))
236             (combo-stencil (ly:stencil-add slur-stencil prall-stencil)))
237        (ly:stencil-translate combo-stencil (cons 0 0))))
238   \once\override Slur #'control-points =
239   #(lambda (grob)
240      (let* ((coords (ly:slur::calc-control-points grob))
241             (point-0 (list-ref coords 0))
242             (point-1 (list-ref coords 1))
243             (point-2 (list-ref coords 2))
244             (point-3 (list-ref coords 3))
245             (text-stencil (ly:text-interface::print grob))
246             (text-width (interval-length (ly:stencil-extent text-stencil X))))
247        (set-cdr! point-1 (+ (cdr point-1) 1))
248        (set-car! point-2 (+ (car point-2) (/ text-width 1.0)))
249        (set-car! point-3 (+ (car point-3) 0.34 (/ text-width 2.0)))
250        (set-cdr! point-3 (if (< (cdr point-3) 2.8)
251                              2.8
252                              (+ 0.5 (cdr point-3))))
253        (set-cdr! point-2 (+ (cdr point-3) 2.0))
254        coords))
257 %% Charpentier
258 %% For quarter note with eighth note flag and half note note head (in e.g. 3/2)
259 #(define-public (calc-white-note-head-glyph grob)
260    (let ((style (ly:grob-property grob 'style))
261          (duration-log (min 1 (ly:grob-property grob 'duration-log))))
262      (select-head-glyph style duration-log)))
264 whiteNoteHeadsOn = {
265   \override Staff.NoteHead #'style = #'baroque
266   \override Staff.NoteHead #'glyph-name = #calc-white-note-head-glyph
268 whiteNoteHeadsOff = {
269   \revert Staff.NoteHead #'style
270   \revert Staff.NoteHead #'glyph-name
273 %% Black notation, for breve and whole notes
274 #(define-public (ly:note-head::print-black grob)
275    (let ((head-style (ly:grob-property grob 'style)))
276      (case head-style
277        ((baroque default)
278         (let* ((head-stencil (ly:note-head::print grob))
279                (duration (ly:grob-property grob 'duration-log))
280                (glyph-name (format #f "noteheads.s~a"
281                                    (ly:grob-property grob 'glyph-name)))
282                (glyph (grob-interpret-markup
283                        grob
284                        (make-musicglyph-markup glyph-name))))
285           (ly:stencil-add
286            (ly:stencil-translate
287             (ly:stencil-aligned-to
288              (stencil-with-color
289               (if (>= duration 0)
290                   ;; oval for whole note
291                   (make-oval-stencil
292                    (* 0.9 (/ (interval-length (ly:stencil-extent glyph X)) 2))
293                    (* 1.1 (/ (interval-length (ly:stencil-extent glyph Y)) 2))
294                    0 #t)
295                   ;; rectangle for breve
296                   (make-filled-box-stencil (ly:stencil-extent glyph X)
297                                            (ly:stencil-extent glyph Y)))
298               black)
299              X CENTER)
300             (cons (/ (interval-length (ly:stencil-extent head-stencil X)) 2)
301                   0))
302            head-stencil)))
303        ((petrucci)
304         (set! (ly:grob-property grob 'style) 'blackpetrucci)
305         (ly:note-head::print grob))
306        (else
307         (ly:note-head::print grob)))))
309 blackNotation =
310 #(define-music-function (parser location music) (ly:music?)
311    #{ \override NoteHead #'stencil = #ly:note-head::print-black
312       \override NoteHead #'Y-extent =
313       #(ly:make-unpure-pure-container
314         ly:grob::stencil-height
315         (lambda (grob b e) (ly:grob::stencil-height grob)))
316       $music
317       \revert NoteHead #'stencil #})
319 ficta = { \once\set suggestAccidentals = ##t }
321 %% Figured bass
322 %% change a flat or sharp alteration into natural
323 %% unless 'ancient-style option is true
324 naturalFig =
325 #(define-music-function (parser location fig) (ly:music?)
326    (if (eqv? #t (ly:get-option 'ancient-style))
327        fig
328        (music-map
329         (lambda (music)
330           (if (eqv? 'BassFigureEvent (ly:music-property music 'name))
331               (let ((alteration (ly:music-property music 'alteration)))
332                 (if (and (number? alteration)
333                          (or (= alteration 1/2) (= alteration -1/2)))
334                     (set! (ly:music-property music 'alteration) 0))))
335           music)
336         fig)))
338 %% Nuances
339 tresdoux =
340 #(make-music 'TextScriptEvent
341              'text (markup #:whiteout #:italic #:general-align X -0.75
342                            "tres doux"))
343 tresdouxSug =
344 #(make-music 'TextScriptEvent
345              'text (markup #:whiteout #:italic #:general-align X -0.75
346                            "[tres doux]"))
348 doux =
349 #(make-music 'TextScriptEvent
350              'text (markup #:whiteout #:italic #:general-align X -0.5 "doux"))
351 douxSug =
352 #(make-music 'TextScriptEvent
353              'text (markup #:whiteout #:italic #:general-align X -0.5 "[doux]"))
355 ademi =
356 #(make-music 'TextScriptEvent
357              'text (markup #:whiteout #:italic #:general-align X -0.75
358                            "a demi"))
359 ademiSug =
360 #(make-music 'TextScriptEvent
361              'text (markup #:whiteout #:italic #:general-align X -0.75
362                            "[a demi]"))
364 enadoucissant =
365 #(make-music 'TextScriptEvent
366              'text (markup #:whiteout #:italic #:general-align X -0.9
367                            "en adoucissant"))
368 enadoucissantSug =
369 #(make-music 'TextScriptEvent
370              'text (markup #:whiteout #:italic #:general-align X -0.9
371                            "[en adoucissant]"))
373 plusdoux =
374 #(make-music 'TextScriptEvent
375              'text (markup #:whiteout #:italic #:general-align X -0.75
376                            "plus doux"))
377 moinsdoux =
378 #(make-music 'TextScriptEvent
379              'text (markup #:whiteout #:italic #:general-align X -0.75
380                            "moins doux"))
381 moinsdouxSug =
382 #(make-music 'TextScriptEvent
383              'text (markup #:whiteout #:italic #:general-align X -0.75
384                            "[moins doux]"))
386 moinsfort =
387 #(make-music 'TextScriptEvent
388              'text (markup #:whiteout #:italic #:general-align X -0.75
389                            "moins fort"))
390 moinsfortSug =
391 #(make-music 'TextScriptEvent
392              'text (markup #:whiteout #:italic #:general-align X -0.75
393                            "[moins fort]"))
395 unpeufort =
396 #(make-music 'TextScriptEvent
397              'text (markup #:whiteout #:italic #:general-align X -0.75
398                            "un peu fort"))
400 plusfort =
401 #(make-music 'TextScriptEvent
402              'text (markup #:whiteout #:italic #:general-align X -0.75
403                            "plus fort"))
404 plusfortSug =
405 #(make-music 'TextScriptEvent
406              'text (markup #:whiteout #:italic #:general-align X -0.75
407                            "[plus fort]"))
409 fort =
410 #(make-music 'TextScriptEvent
411              'text (markup #:whiteout #:italic #:general-align X -0.5 "fort"))
412 fortSug =
413 #(make-music 'TextScriptEvent
414              'text (markup #:whiteout #:italic #:general-align X -0.5 "[fort]"))
416 tresfort =
417 #(make-music 'TextScriptEvent
418              'text (markup #:whiteout #:italic #:general-align X -0.75
419                            "tres fort"))
420 tresfortSug =
421 #(make-music 'TextScriptEvent
422              'text (markup #:whiteout #:italic #:general-align X -0.75
423                            "[tres fort]"))
425 viste =
426 #(make-music
427   'TextScriptEvent
428   'text #{\markup\whiteout\italic\general-align #X #-0.5 viste #})