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