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 }
48 \new Staff
= "gauche" \with { \override VerticalAxisGroup
#'remove-empty
= ##f }
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 StaffPiano
= "droite" }
190 gauche
= { \change StaffPiano
= "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
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
)))
241 #(define-music-function
(parser location nuance texte
)
244 (markup
#:dynamic nuance
246 #:text
#:medium
#:upright texte
)))
249 #(define-music-function
(parser location texte nuance
)
252 (markup
#:text
#:medium
#:upright texte
257 #(define-music-function
(parser location music
) (ly
:music?
)
259 (equal?
(ly
:music-property music
'name
) 'EventChord
)
260 (set
! (ly
:music-property music
'elements
)
261 (append
(ly
:music-property music
'elements
)
262 (list
(make-music
'TextScriptEvent
'text
263 (markup
#:translate
(cons
4 0)
264 #:indic
"(ten.)"))))))
268 #(define-music-function
(parser location text music
) (string? ly
:music?
)
270 (equal?
(ly
:music-property music
'name
) 'EventChord
)
271 (set
! (ly
:music-property music
'elements
)
272 (append
(ly
:music-property music
'elements
)
273 (list
(make-music
'TextScriptEvent
'direction
1
274 'text
(markup
#:indic text
))))))
278 #(define-music-function
(parser location music
) (ly
:music?
)
279 #{ \ind #"pizz." $music
#})
282 #(define-music-function
(parser location music
) (ly
:music?
)
283 #{ \ind #"arco" $music
#})
286 #(define-music-function
(parser location music
) (ly
:music?
)
287 #{ \ind #"simile" $music
#})
289 #(define
(make-text-span music t
)
290 (set
! (ly
:music-property music
'elements
)
291 (append
(ly
:music-property music
'elements
)
292 (list
(make-music
'TextSpanEvent
293 'span-direction t
))))
296 #(define-music-function
(parser location texte music
) (string? ly
:music?
)
297 #{ \override TextSpanner
#'bound-details
#'left
#'text
=
298 \markup { \bold $texte
}
299 $
(make-text-span music -
1)#})
302 #(define-music-function
(parser location music
) (ly
:music?
)
303 (make-text-span music
1))
305 %% Tempo indications ----------------------------------------------%
306 #(define-markup-command
(mvt layout props arg
) (markup?
)
307 (interpret-markup layout props
308 (markup
#:huge
#:bold arg
)))
310 %%%%%%%%%%%%%%%%%%%%%%%%%% Text Functions %%%%%%%%%%%%%%%%%%%%%%%%%%
312 %% Lyrics formatting ----------------------------------------------%
315 \override Lyrics
. LyricExtender
#'stencil
= ##f }
318 \revert Lyrics
. LyricExtender
#'stencil
}
321 \once \override LyricText
#'self-alignment-X
= #0.9 }
324 \once \override LyricHyphen
#'minimum-distance
= #4
325 \once \override LyricHyphen
#'length
= #2
326 \once \override LyricHyphen
#'thickness
= #1.2
330 \once \override LyricText
#'font-shape
= #'italic
}
333 \override LyricText
#'font-shape
= #'caps
}
336 \revert LyricText
#'font-shape
}
339 %% Scenography formatting ---------------------------------------%
341 \once \override TextScript
#'extra-spacing-width
= #'(0 . 0)
342 \once \override TextScript
#'infinite-spacing-height
= ##t
345 #(define-markup-command
(did layout props text
) (markup?
)
346 (interpret-markup layout props
347 (markup
#:override
'(line-width
. 40)
348 #:override
'(box-padding
. 1)
349 #:override
'(corner-radius
. 2)
350 #:rounded-box
#:sans
#:italic
#:small
#:justify-string text
)))
352 #(define-markup-command
(init-did layout props text
) (markup?
)
353 (interpret-markup layout props
355 ;
#:override
(cons
'line-width
(* 1 (chain-assoc-get
'line-width props
)))
357 #:override
'(line-width
. 60)
358 #:override
'(box-padding
. 1.5)
359 #:override
'(corner-radius
. 2)
360 #:rounded-box
#:sans
#:italic
#:small
#:justify-string text
))))
362 #(define-markup-command
(vspace layout props amount
) (number?
)
363 (let
((amount
(* amount
3.0)))
365 (ly
:make-stencil
"" (cons -
1 1) (cons
0 amount
))
366 (ly
:make-stencil
"" (cons -
1 1) (cons amount amount
)))))