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