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 #(define
(make-script x
)
55 (make-music
'ArticulationEvent
56 'articulation-type x
))
58 #(define
(add-script m x
)
59 (let
( (eventname
(ly
:music-property m
'name
)))
60 (if
(equal? eventname
'EventChord
)
61 (let
( (elements
(ly
:music-property m
'elements
)) )
62 (if
(not
(equal?
(ly
:music-property
(car elements
)
64 (set
! (ly
:music-property m
'elements
)
65 (append elements
(list
69 #(define
(double-script m t tt
)
70 (add-script
(add-script m t
) tt
))
73 #(define-music-function
(parser location music
)
75 (define
(make-script-music m
)
76 (add-script m
"staccato"))
77 (music-map make-script-music music
))
80 #(define-music-function
(parser location music
)
82 (define
(make-script-music m
)
83 (add-script m
"accent"))
84 (music-map make-script-music music
))
87 #(define-music-function
(parser location music
)
89 (define
(make-script-music m
)
90 (add-script m
"tenuto"))
91 (music-map make-script-music music
))
94 #(define-music-function
(parser location music
)
96 (define
(make-script-music m
)
97 (add-script m
"marcato"))
98 (music-map make-script-music music
))
101 #(define-music-function
(parser location music
)
103 (define
(make-script-music m
)
104 (add-script m
"portato"))
105 (music-map make-script-music music
))
108 #(define-music-function
(parser location music
)
110 (define
(make-script-music m
)
111 (double-script m
"tenuto" "accent"))
112 (music-map make-script-music music
))
115 #(define-music-function
(parser location music
)
117 (define
(make-script-music m
)
118 (double-script m
"tenuto" "marcato"))
119 (music-map make-script-music music
))
122 #(define-music-function
(parser location music
)
124 (define
(make-script-music m
)
125 (double-script m
"accent" "staccato"))
126 (music-map make-script-music music
))
129 #(define-music-function
(parser location music
)
131 (define
(make-script-music m
)
132 (double-script m
"marcato" "staccato"))
133 (music-map make-script-music music
))
137 #(let
((m
(make-music
'ArticulationEvent
138 'articulation-type
"flageolet")))
139 (set
! (ly
:music-property m
'tweaks
)
141 (ly
:music-property m
'tweaks
)))
145 %% Music shortcuts ------------------------------------------------%
147 #(define
(octave-up noteevent
)
148 (let
* ((pitch
(ly
:music-property noteevent
'pitch
))
149 (octave
(ly
:pitch-octave pitch
))
150 (note
(ly
:pitch-notename pitch
))
151 (alteration
(ly
:pitch-alteration pitch
))
152 (duration
(ly
:music-property noteevent
'duration
))
154 (make-music
'NoteEvent
156 'pitch
(ly
:make-pitch
(1- octave
) note alteration
))))
159 #(define
(octavize-chord elements
)
160 (cond
((null? elements
) elements
)
161 ((eq?
(ly
:music-property
(car elements
) 'name
) 'NoteEvent
)
163 (cons
(octave-up
(car elements
))
164 (octavize-chord
(cdr elements
)))))
165 (else
(cons
(car elements
) (octavize-chord
(cdr elements
))))))
167 #(define
(octavize music
)
168 (let
* ((es (ly
:music-property music
'elements
))
169 (e (ly
:music-property music
'element
))
170 (name
(ly
:music-property music
'name
)))
171 (cond
((eq? name
'EventChord
)
172 (ly
:music-set-property
! music
'elements
(octavize-chord
es)))
174 (for-each
(lambda
(x
) (octavize x
)) es))
179 oct
= #(define-music-function
(parser location mus
) (ly
:music?
)
182 %%%%%%%%%%%%%%%%%%%%%%%% Layout Functions %%%%%%%%%%%%%%%%%%%%%%%%%%
184 %% Music layout ---------------------------------------------------%
186 droite
= { \change StaffPiano
= "droite" }
188 gauche
= { \change StaffPiano
= "gauche" }
190 #(define modern-auto-beam-settings
191 (append default-auto-beam-settings
193 ((end
* * 3 4) . ,(ly
:make-moment
1 4))
194 ((end
* * 3 4) . ,(ly
:make-moment
1 2))
195 ((end
* * 4 4) . ,(ly
:make-moment
1 4))
196 ((end
* * 4 4) . ,(ly
:make-moment
3 4))
197 ((end
* * 2 2) . ,(ly
:make-moment
1 4))
198 ((end
* * 2 2) . ,(ly
:make-moment
1 2))
199 ((end
* * 2 2) . ,(ly
:make-moment
3 4))
200 ((end
* * 2 8) . ,(ly
:make-moment
1 4))
201 ((be
* * 5 8) . ,(ly
:make-moment
1 8))
202 ((end
* * 5 8) . ,(ly
:make-moment
5 8))
205 #(define modern-style
211 %% Music formatting -----------------------------------------------%
214 #(define-music-function
(parser location notes
) (ly
:music?
)
215 #{ \tiny $notes
\normalsize #})
218 #(define-music-function
(parser location notes
) (ly
:music?
)
219 #{ \override NoteHead
#'style
= #'cross
221 \revert NoteHead
#'style
#})
224 \once \override NoteHead
#'transparent
= ##t
225 \once \override NoteHead
#'no-ledgers
= ##t
226 \once \override Stem
#'transparent
= ##t
227 \once \override Beam
#'transparent
= ##t
228 \once \override Accidental
#'transparent
= ##t
230 %%%%%%%%%%%%%%%%%%%%%%%%%% In-score Text %%%%%%%%%%%%%%%%%%%%%%%%%%%
232 %% Expressive indications -----------------------------------------%
234 #(define-markup-command
(indic layout props arg
) (markup?
)
235 (interpret-markup layout props
236 (markup
#:whiteout
#:small
#:italic arg
)))
239 #(define-music-function
(parser location nuance texte
)
242 (markup
#:dynamic nuance
244 #:text
#:medium
#:upright texte
)))
248 #(define-music-function
(parser location music
) (ly
:music?
)
250 (equal?
(ly
:music-property music
'name
) 'EventChord
)
251 (set
! (ly
:music-property music
'elements
)
252 (append
(ly
:music-property music
'elements
)
253 (list
(make-music
'TextScriptEvent
'text
254 (markup
#:translate
(cons
4 0)
255 #:indic
"(ten.)"))))))
259 #(define-music-function
(parser location text music
) (string? ly
:music?
)
261 (equal?
(ly
:music-property music
'name
) 'EventChord
)
262 (set
! (ly
:music-property music
'elements
)
263 (append
(ly
:music-property music
'elements
)
264 (list
(make-music
'TextScriptEvent
'direction
1
265 'text
(markup
#:indic text
))))))
268 #(define
(make-text-span music t
)
269 (set
! (ly
:music-property music
'elements
)
270 (append
(ly
:music-property music
'elements
)
271 (list
(make-music
'TextSpanEvent
272 'span-direction t
))))
275 #(define-music-function
(parser location texte music
) (string? ly
:music?
)
276 #{ \override TextSpanner
#'bound-details
#'left
#'text
=
277 \markup { \bold $texte
}
278 $
(make-text-span music -
1)#})
281 #(define-music-function
(parser location music
) (ly
:music?
)
282 (make-text-span music
1))
284 %% Tempo indications ----------------------------------------------%
285 #(define-markup-command
(mvt layout props arg
) (markup?
)
286 (interpret-markup layout props
287 (markup
#:huge
#:bold arg
)))
289 %%%%%%%%%%%%%%%%%%%%%%%%%% Text Functions %%%%%%%%%%%%%%%%%%%%%%%%%%
291 %% Lyrics formatting ----------------------------------------------%
294 \override Lyrics
. LyricExtender
#'stencil
= ##f }
297 \revert Lyrics
. LyricExtender
#'stencil
}
300 \once \override LyricText
#'self-alignment-X
= #0.9 }
303 \once \override LyricHyphen
#'minimum-distance
= #4
304 \once \override LyricHyphen
#'length
= #2
305 \once \override LyricHyphen
#'thickness
= #1.2
309 \once \override LyricText
#'font-shape
= #'italic
}
312 \override LyricText
#'font-shape
= #'caps
}
315 \revert LyricText
#'font-shape
}
318 %% Scenography formatting ---------------------------------------%
320 \once \override TextScript
#'extra-spacing-width
= #'(0 . 0)
321 \once \override TextScript
#'infinite-spacing-height
= ##t
324 #(define-markup-command
(did layout props text
) (markup?
)
325 (interpret-markup layout props
326 (markup
#:override
'(line-width
. 40)
327 #:override
'(box-padding
. 1)
328 #:override
'(corner-radius
. 2)
329 #:rounded-box
#:sans
#:italic
#:small
#:justify-string text
)))
331 #(define-markup-command
(init-did layout props text
) (markup?
)
332 (interpret-markup layout props
334 ;
#:override
(cons
'line-width
(* 1 (chain-assoc-get
'line-width props
)))
336 #:override
'(line-width
. 50)
337 #:override
'(box-padding
. 1.5)
338 #:override
'(corner-radius
. 2)
339 #:rounded-box
#:sans
#:italic
#:small
#:justify-string text
))))
341 #(define-markup-command
(vspace layout props amount
) (number?
)
342 (let
((amount
(* amount
3.0)))
344 (ly
:make-stencil
"" (cons -
1 1) (cons
0 amount
))
345 (ly
:make-stencil
"" (cons -
1 1) (cons amount amount
)))))