1 %------------------------------------------------------------------%
2 % Opéra Libre -- functions.ly %
4 % (c) Valentin Villenave, 2008 %
6 %------------------------------------------------------------------%
9 %%%%%%%%%%%%%%%%%%%%%%%%% Music Shortcuts %%%%%%%%%%%%%%%%%%%%%%%%%%
11 %% Rhythm shortcuts -----------------------------------------------%
14 #(define-music-function
(parser location music
) (ly
:music?
)
15 #{ \times 2/3 $music
#})
18 #(define-music-function
(parser location music
) (ly
:music?
)
19 #{ \times 4/5 $music
#})
22 #(define-music-function
(parser location music
) (ly
:music?
)
23 #{ \times 4/6 $music
#})
26 #(define-music-function
(parser location music
) (ly
:music?
)
27 #{ \times 4/7 $music
#})
30 %% Polyphony shortcuts --------------------------------------------%
33 #(define-music-function
(parser location one two
) (ly
:music? ly
:music?
)
34 #{ << { \voiceTwo $one
} \\ { \voiceOne $two
} >> #})
37 #(define-music-function
(parser location droite gauche
) (ly
:music? ly
:music?
)
39 \context Staff
= "droite" $droite
40 \context Staff
= "gauche" $gauche
44 #(define-music-function
(parser location droite gauche
) (ly
:music? ly
:music?
)
46 \new Staff
= "droite" \with { \override VerticalAxisGroup
#'remove-empty
= ##f }
47 { \clef treble $droite
}
48 \new Staff
= "gauche" \with { \override VerticalAxisGroup
#'remove-empty
= ##f }
49 { \clef bass $gauche
}
52 %% Articulation shortcuts -----------------------------------------%
54 % Are these really needed?
55 #(define
(make-script x
)
56 (make-music
'ArticulationEvent
57 'articulation-type x
))
59 #(define
(add-script m x
)
60 (let
( (eventname
(ly
:music-property m
'name
)))
61 (if
(equal? eventname
'EventChord
)
62 (let
( (elements
(ly
:music-property m
'elements
)) )
63 (if
(not
(equal?
(ly
:music-property
(car elements
)
65 (set
! (ly
:music-property m
'elements
)
66 (append elements
(list
70 #(define
(double-script m t tt
)
71 (add-script
(add-script m t
) tt
))
74 #(define-music-function
(parser location music
)
76 (define
(make-script-music m
)
77 (add-script m
"staccato"))
78 (music-map make-script-music music
))
81 #(define-music-function
(parser location music
)
83 (define
(make-script-music m
)
84 (add-script m
"accent"))
85 (music-map make-script-music music
))
88 #(define-music-function
(parser location music
)
90 (define
(make-script-music m
)
91 (add-script m
"tenuto"))
92 (music-map make-script-music music
))
95 #(define-music-function
(parser location music
)
97 (define
(make-script-music m
)
98 (add-script m
"marcato"))
99 (music-map make-script-music music
))
102 #(define-music-function
(parser location music
)
104 (define
(make-script-music m
)
105 (add-script m
"portato"))
106 (music-map make-script-music music
))
109 #(define-music-function
(parser location music
)
111 (define
(make-script-music m
)
112 (double-script m
"tenuto" "accent"))
113 (music-map make-script-music music
))
116 #(define-music-function
(parser location music
)
118 (define
(make-script-music m
)
119 (double-script m
"tenuto" "marcato"))
120 (music-map make-script-music music
))
123 #(define-music-function
(parser location music
)
125 (define
(make-script-music m
)
126 (double-script m
"accent" "staccato"))
127 (music-map make-script-music music
))
130 #(define-music-function
(parser location music
)
132 (define
(make-script-music m
)
133 (double-script m
"marcato" "staccato"))
134 (music-map make-script-music music
))
138 #(let
((m
(make-music
'ArticulationEvent
139 'articulation-type
"flageolet")))
140 (set
! (ly
:music-property m
'tweaks
)
142 (ly
:music-property m
'tweaks
)))
146 %% Music shortcuts ------------------------------------------------%
148 % This might not be needed
149 #(define
(octave-up noteevent
)
150 (let
* ((pitch
(ly
:music-property noteevent
'pitch
))
151 (octave
(ly
:pitch-octave pitch
))
152 (note
(ly
:pitch-notename pitch
))
153 (alteration
(ly
:pitch-alteration pitch
))
154 (duration
(ly
:music-property noteevent
'duration
))
156 (make-music
'NoteEvent
158 'pitch
(ly
:make-pitch
(1- octave
) note alteration
))))
161 #(define
(octavize-chord elements
)
162 (cond
((null? elements
) elements
)
163 ((eq?
(ly
:music-property
(car elements
) 'name
) 'NoteEvent
)
165 (cons
(octave-up
(car elements
))
166 (octavize-chord
(cdr elements
)))))
167 (else
(cons
(car elements
) (octavize-chord
(cdr elements
))))))
169 #(define
(octavize music
)
170 (let
* ((es (ly
:music-property music
'elements
))
171 (e (ly
:music-property music
'element
))
172 (name
(ly
:music-property music
'name
)))
173 (cond
((eq? name
'EventChord
)
174 (ly
:music-set-property
! music
'elements
(octavize-chord
es)))
176 (for-each
(lambda
(x
) (octavize x
)) es))
181 oct
= #(define-music-function
(parser location mus
) (ly
:music?
)
184 %%%%%%%%%%%%%%%%%%%%%%%% Layout Functions %%%%%%%%%%%%%%%%%%%%%%%%%%
186 %% Music layout ---------------------------------------------------%
188 droite
= { \change Staff
= "droite" }
190 gauche
= { \change Staff
= "gauche" }
192 #(define modern-auto-beam-settings
193 (append default-auto-beam-settings
195 ((end
* * 3 4) . ,(ly
:make-moment
1 4))
196 ((end
* * 3 4) . ,(ly
:make-moment
1 2))
197 ((end
* * 4 4) . ,(ly
:make-moment
1 4))
198 ((end
* * 4 4) . ,(ly
:make-moment
3 4))
199 ((end
* * 2 2) . ,(ly
:make-moment
1 4))
200 ((end
* * 2 2) . ,(ly
:make-moment
1 2))
201 ((end
* * 2 2) . ,(ly
:make-moment
3 4))
202 ((end
* * 2 8) . ,(ly
:make-moment
1 4))
203 ((be
* * 5 8) . ,(ly
:make-moment
1 8))
204 ((end
* * 5 8) . ,(ly
:make-moment
5 8))
207 #(define modern-style
208 `
(Staff
,(make-accidental-rule
'same-octave
0)
209 ,(make-accidental-rule
'any-octave
0)
210 ,(make-accidental-rule
'same-octave
1)
211 ,neo-modern-accidental-rule
))
213 %% Music formatting -----------------------------------------------%
216 #(define-music-function
(parser location notes
) (ly
:music?
)
217 #{ \tiny $notes
\normalsize #})
220 #(define-music-function
(parser location notes
) (ly
:music?
)
221 #{ \override NoteHead
#'style
= #'cross
223 \revert NoteHead
#'style
#})
226 \once \override NoteHead
#'transparent
= ##t
227 \once \override NoteHead
#'no-ledgers
= ##t
228 \once \override Stem
#'transparent
= ##t
229 \once \override Beam
#'transparent
= ##t
230 \once \override Accidental
#'transparent
= ##t
232 %%%%%%%%%%%%%%%%%%%%%%%%%% In-score Text %%%%%%%%%%%%%%%%%%%%%%%%%%%
234 %% Expressive indications -----------------------------------------%
236 #(define-markup-command
(indic layout props arg
) (markup?
)
237 (interpret-markup layout props
238 (markup
#:whiteout
#:small
#:italic arg
)))
240 %FIXME: because of the use of a music-function,
241 % Composite dynamics have to be entered *before*
242 % the affected beat (unlike standard dynamics).
244 #(define-music-function
(parser location dyn str
) (string? string?
)
245 (make-music
'SequentialMusic
'elements
247 (make-music
'OverrideProperty
249 'grob-property-path
(list
'self-alignment-X
)
250 'grob-value -
0.6 'once
#t
)
251 (make-music
'AbsoluteDynamicEvent
253 (markup
#:dynamic dyn
255 #:text
#:medium
#:upright str
)))))
258 #(define-music-function
(parser location str dyn
) (string? string?
)
259 (make-music
'SequentialMusic
'elements
261 (make-music
'OverrideProperty
263 'grob-property-path
(list
'self-alignment-X
)
264 'grob-value -
0.6 'once
#t
)
265 (make-music
'AbsoluteDynamicEvent
267 (markup
#:text
#:medium
#:upright str
272 #(define-music-function
(parser location texte
)
275 (markup
#:text
#:indic texte
)))
278 #(define-music-function
(parser location music
) (ly
:music?
)
280 (equal?
(ly
:music-property music
'name
) 'EventChord
)
281 (set
! (ly
:music-property music
'elements
)
282 (append
(ly
:music-property music
'elements
)
283 (list
(make-music
'TextScriptEvent
'text
284 (markup
#:translate
(cons
4 0)
285 #:indic
"(ten.)"))))))
289 #(define-music-function
(parser location text music
) (string? ly
:music?
)
291 (equal?
(ly
:music-property music
'name
) 'EventChord
)
292 (set
! (ly
:music-property music
'elements
)
293 (append
(ly
:music-property music
'elements
)
294 (list
(make-music
'TextScriptEvent
'direction
1
295 'text
(markup
#:indic text
))))))
299 #(define-music-function
(parser location music
) (ly
:music?
)
300 #{ \ind #"pizz." $music
#})
303 #(define-music-function
(parser location music
) (ly
:music?
)
304 #{ \ind #"arco" $music
#})
307 #(define-music-function
(parser location music
) (ly
:music?
)
308 #{ \ind #"simile" $music
#})
311 #(define-music-function
(parser location music
) (ly
:music?
)
312 #{ \ind #"loco" $music
#})
315 #(define-music-function
(parser location music
) (ly
:music?
)
316 #{ \ind #"(ordin.)" $music
#})
318 #(define
(make-text-span music t
)
319 (set
! (ly
:music-property music
'elements
)
320 (append
(ly
:music-property music
'elements
)
321 (list
(make-music
'TextSpanEvent
322 'span-direction t
))))
325 #(define-music-function
(parser location texte music
) (string? ly
:music?
)
326 #{ \override TextSpanner
#'bound-details
#'left
#'text
=
327 \markup { \bold $texte
}
328 $
(make-text-span music -
1)#})
331 #(define-music-function
(parser location music
) (ly
:music?
)
332 (make-text-span music
1))
334 %% Tempo indications ----------------------------------------------%
335 #(define-markup-command
(mvt layout props arg
) (markup?
)
336 (interpret-markup layout props
337 (markup
#:huge
#:bold arg
)))
339 %%%%%%%%%%%%%%%%%%%%%%%%%% Text Functions %%%%%%%%%%%%%%%%%%%%%%%%%%
341 %% Lyrics formatting ----------------------------------------------%
344 \override Lyrics
. LyricExtender
#'stencil
= ##f }
347 \revert Lyrics
. LyricExtender
#'stencil
}
350 \once \override LyricText
#'self-alignment-X
= #0.9 }
353 \once \override LyricHyphen
#'minimum-distance
= #4
354 \once \override LyricHyphen
#'length
= #2
355 \once \override LyricHyphen
#'thickness
= #1.2
359 \once \override LyricText
#'font-shape
= #'italic
}
362 \override LyricText
#'font-shape
= #'caps
}
365 \revert LyricText
#'font-shape
}
368 %% Scenography formatting ---------------------------------------%
370 \once \override TextScript
#'extra-spacing-width
= #'(0 . 0)
371 \once \override TextScript
#'infinite-spacing-height
= ##t
374 #(define-markup-command
(did layout props text
) (markup?
)
375 (interpret-markup layout props
376 (markup
#:override
'(line-width
. 40)
377 #:override
'(box-padding
. 1)
378 #:override
'(corner-radius
. 2)
379 #:rounded-box
#:sans
#:italic
#:small
#:justify-string text
)))
381 #(define-markup-command
(init-did layout props text
) (markup?
)
382 (interpret-markup layout props
384 ;
#:override
(cons
'line-width
(* 1 (chain-assoc-get
'line-width props
)))
386 #:override
'(line-width
. 60)
387 #:override
'(box-padding
. 1.5)
388 #:override
'(corner-radius
. 2)
389 #:rounded-box
#:sans
#:italic
#:small
#:justify-string text
))))
391 #(define-markup-command
(vspace layout props amount
) (number?
)
392 (let
((amount
(* amount
3.0)))
394 (ly
:make-stencil
"" (cons -
1 1) (cons
0 amount
))
395 (ly
:make-stencil
"" (cons -
1 1) (cons amount amount
)))))