1 %------------------------------------------------------------------%
2 % Opéra Libre -- functions.ly %
4 % (c) Valentin Villenave, 2008 %
6 %------------------------------------------------------------------%
8 % Various additional functions.
10 %%%%%%%%%%%%%%%%%%%%%%%%% Music Shortcuts %%%%%%%%%%%%%%%%%%%%%%%%%%
12 %% Rhythm shortcuts -----------------------------------------------%
15 #(define-music-function
(parser location music
) (ly
:music?
)
16 #{ \times 2/3 $music
#})
19 #(define-music-function
(parser location music
) (ly
:music?
)
20 #{ \times 4/5 $music
#})
23 #(define-music-function
(parser location music
) (ly
:music?
)
24 #{ \times 4/6 $music
#})
27 #(define-music-function
(parser location music
) (ly
:music?
)
28 #{ \times 4/7 $music
#})
31 %% Polyphony shortcuts --------------------------------------------%
34 #(define-music-function
(parser location one two
) (ly
:music? ly
:music?
)
35 #{ << { \voiceTwo $one
} \\ { \voiceOne $two
} >> #})
38 #(define-music-function
(parser location one two
) (ly
:music? ly
:music?
)
39 #{ << { \stemDown $one
\stemNeutral } \new DrumVoice
{ \stemUp $two
} >> #})
42 #(define-music-function
(parser location droite gauche
) (ly
:music? ly
:music?
)
44 \context Staff
= "md" $droite
45 \context Staff
= "mg" $gauche
48 md
= { \change Staff
= "md" }
50 mg
= { \change Staff
= "mg" }
53 #(define-music-function
(parser location droite gauche
) (ly
:music? ly
:music?
)
54 #{ \new PianoStaff
<< %%%FIXME: get rid of this option.
55 \new Staff
= "md" \with { \override VerticalAxisGroup
#'remove-empty
= ##f }
56 { \clef treble $droite
}
57 \new Staff
= "mg" \with { \override VerticalAxisGroup
#'remove-empty
= ##f }
58 { \clef bass $gauche
}
61 droite
= { \change Staff
= "percuDroite" }
63 gauche
= { \change Staff
= "percuGauche" }
66 #(define-music-function
(parser location droite gauche
) (ly
:music? ly
:music?
)
67 #{ << %%%FIXME: I /definitely/ should get rid of this option.
68 \new Staff
= "percuDroite" \with { \override VerticalAxisGroup
#'remove-empty
= ##f }
69 { \clef treble $droite
}
70 \new Staff
= "percuGauche" \with { \override VerticalAxisGroup
#'remove-empty
= ##f }
71 { \clef bass $gauche
}
75 #(define-music-function
(parser location music
) (ly
:music?
)
77 \unset Score
.keepAliveInterfaces
79 \set Score
.keepAliveInterfaces
= #'(rhythmic-grob-interface
80 lyric-interface percent-repeat-item-interface
81 percent-repeat-interface stanza-number-interface
)
84 %% Music formatting -----------------------------------------------%
87 #(define-music-function
(parser location notes
) (ly
:music?
)
88 #{ \tiny $notes
\normalsize #})
91 #(define-music-function
(parser location notes
) (ly
:music?
)
92 #{ \override NoteHead
#'style
= #'cross
94 \revert NoteHead
#'style
#})
97 #(define-music-function
(parser location music
) (ly
:music?
)
98 #{\override NoteHead
#'stencil
= #ly
:text-interface
::print
99 \override NoteHead
#'text
= \markup \musicglyph #"scripts.sforzato"
100 \override NoteHead
#'extra-offset
= #'(0.1 . 0.0 )
102 \revert NoteHead
#'stencil
103 \revert NoteHead
#'text
104 \revert NoteHead
#'extra-offset
#})
107 \once \override NoteHead
#'transparent
= ##t
108 \once \override NoteHead
#'no-ledgers
= ##t
109 \once \override Stem
#'transparent
= ##t
110 \once \override Beam
#'transparent
= ##t
111 \once \override Accidental
#'transparent
= ##t
115 \once \override TupletBracket
#'transparent
= ##t
116 \once \override TupletNumber
#'transparent
= ##t
120 \once \override Stem
#'direction
= #DOWN
124 \once \override Stem
#'direction
= #UP
127 %% Music shortcuts ------------------------------------------------%
129 sk
= \set Score
.skipTypesetting
= ##t
131 unsk
= \set Score
.skipTypesetting
= ##f
133 % This might not be needed
134 #(define
(octave-up noteevent
)
135 (let
* ((pitch
(ly
:music-property noteevent
'pitch
))
136 (octave
(ly
:pitch-octave pitch
))
137 (note
(ly
:pitch-notename pitch
))
138 (alteration
(ly
:pitch-alteration pitch
))
139 (duration
(ly
:music-property noteevent
'duration
))
141 (make-music
'NoteEvent
143 'pitch
(ly
:make-pitch
(1- octave
) note alteration
))))
146 #(define
(octavize-chord elements
)
147 (cond
((null? elements
) elements
)
148 ((eq?
(ly
:music-property
(car elements
) 'name
) 'NoteEvent
)
150 (cons
(octave-up
(car elements
))
151 (octavize-chord
(cdr elements
)))))
152 (else
(cons
(car elements
) (octavize-chord
(cdr elements
))))))
154 #(define
(octavize music
)
155 (let
* ((es (ly
:music-property music
'elements
))
156 (e (ly
:music-property music
'element
))
157 (name
(ly
:music-property music
'name
)))
158 (cond
((eq? name
'EventChord
)
159 (ly
:music-set-property
! music
'elements
(octavize-chord
es)))
161 (for-each
(lambda
(x
) (octavize x
)) es))
166 oct
= #(define-music-function
(parser location mus
) (ly
:music?
)
170 %%%%%%%%%%%%%%%%%%%%%%%%% Music Decoration %%%%%%%%%%%%%%%%%%%%%%%%%
172 %% Articulation marks ---------------------------------------------%
174 #(define
(make-script x
)
175 (make-music
'ArticulationEvent
176 'articulation-type x
))
178 #(define
(add-script m x
)
179 (let
( (eventname
(ly
:music-property m
'name
)))
180 (if
(equal? eventname
'EventChord
)
181 (let
( (elements
(ly
:music-property m
'elements
)) )
182 (if
(not
(equal?
(ly
:music-property
(car elements
)
184 (set
! (ly
:music-property m
'elements
)
185 (append elements
(list
186 (make-script x
)))))))
189 #(define
(double-script m t tt
)
190 (add-script
(add-script m t
) tt
))
193 #(define-music-function
(parser location music
)
195 (define
(make-script-music m
)
196 (add-script m
"staccato"))
197 (music-map make-script-music music
))
200 #(define-music-function
(parser location music
)
202 (define
(make-script-music m
)
203 (add-script m
"accent"))
204 (music-map make-script-music music
))
207 #(define-music-function
(parser location music
)
209 (define
(make-script-music m
)
210 (add-script m
"tenuto"))
211 (music-map make-script-music music
))
214 #(define-music-function
(parser location music
)
216 (define
(make-script-music m
)
217 (add-script m
"marcato"))
218 (music-map make-script-music music
))
221 #(define-music-function
(parser location music
)
223 (define
(make-script-music m
)
224 (add-script m
"portato"))
225 (music-map make-script-music music
))
228 #(define-music-function
(parser location music
)
230 (define
(make-script-music m
)
231 (double-script m
"tenuto" "accent"))
232 (music-map make-script-music music
))
235 #(define-music-function
(parser location music
)
237 (define
(make-script-music m
)
238 (double-script m
"tenuto" "marcato"))
239 (music-map make-script-music music
))
242 #(define-music-function
(parser location music
)
244 (define
(make-script-music m
)
245 (double-script m
"accent" "staccato"))
246 (music-map make-script-music music
))
249 #(define-music-function
(parser location music
)
251 (define
(make-script-music m
)
252 (double-script m
"marcato" "staccato"))
253 (music-map make-script-music music
))
257 #(let
((m
(make-music
'ArticulationEvent
258 'articulation-type
"flageolet")))
259 (set
! (ly
:music-property m
'tweaks
)
261 (ly
:music-property m
'tweaks
)))
264 #(define-music-function
(parser location chord result
) (ly
:music? ly
:music?
)
265 #{ << \oneStemDown $chord
\\ { \stemUp %FIXME: ties could look better.
266 \override NoteHead
#'stencil
= #ly
:text-interface
::print
267 \override NoteHead
#'text
= \markup { \null \musicglyph #"noteheads.s2"}
268 \once \override NoteHead
#'text
= \markup {\null \override #'(direction
. 1)
269 \dir-column
{\musicglyph #"noteheads.s2" \teeny \musicglyph #"eight"}}
270 \override Stem
#'stencil
= ##f $result
271 \revert Stem
#'stencil
\revert NoteHead
#'stencil
\stemNeutral } >> #})
274 #(make-music
'TextScriptEvent
276 'text
(markup
#:hspace
.4 #:rotate
45
277 #:musicglyph
"scripts.stopped"))
280 #(make-articulation
"stopped")
283 #(let
* ((m
(make-music
'ArpeggioEvent
)))
284 (ly
:music-set-property
! m
'tweaks
285 (acons
'arpeggio-direction
1
286 (ly
:music-property m
'tweaks
)))
290 #(let
* ((m
(make-music
'ArpeggioEvent
)))
291 (ly
:music-set-property
! m
'tweaks
292 (acons
'arpeggio-direction -
1
293 (ly
:music-property m
'tweaks
)))
297 #(let
* ((m
(make-music
'ArpeggioEvent
)))
298 (ly
:music-set-property
! m
'tweaks
299 (acons
'stencil ly
:arpeggio
::brew-chord-bracket
300 (ly
:music-property m
'tweaks
)))
303 %%%%%%%%%%%%%%%%%%%%%%%% Layout Functions %%%%%%%%%%%%%%%%%%%%%%%%%%
305 %% Music layout ---------------------------------------------------%
307 #(define modern-auto-beam-settings
308 (append default-auto-beam-settings
310 ((end
* * 3 4) . ,(ly
:make-moment
1 4))
311 ((end
* * 3 4) . ,(ly
:make-moment
1 2))
312 ((end
* * 4 4) . ,(ly
:make-moment
1 4))
313 ((end
* * 4 4) . ,(ly
:make-moment
3 4))
314 ((end
* * 2 2) . ,(ly
:make-moment
1 4))
315 ((end
* * 2 2) . ,(ly
:make-moment
1 2))
316 ((end
* * 2 2) . ,(ly
:make-moment
3 4))
317 ((end
* * 2 8) . ,(ly
:make-moment
1 4))
318 ((be
* * 5 8) . ,(ly
:make-moment
1 8))
319 ((end
* * 5 8) . ,(ly
:make-moment
5 8))
322 #(define modern-accidentals-style
323 `
(Staff
,(make-accidental-rule
'same-octave
0)
324 ,(make-accidental-rule
'any-octave
0)
325 ,(make-accidental-rule
'same-octave
1)
326 ,neo-modern-accidental-rule
))
327 #(define modern-cautionaries-style
328 `
(Staff
,(make-accidental-rule
'same-octave
1)
329 ,(make-accidental-rule
'any-octave
1)))
331 %%%%%%%%%%%%%%%%%%%%%%%%%%%% Editorial %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
333 %% Individual parts -----------------------------------------------%
336 #(define-music-function
(parser location part ref
)
337 (ly
:music? ly
:music?
)
338 #{\context Staff
<< $part
\new GhostVoice $ref
>> #})
341 #(define-music-function
(parser location part-one part-two ref
)
342 (ly
:music? ly
:music? ly
:music?
)
344 \new Staff
<< $part-one
\new GhostVoice $ref
>>
348 makeExtraSection
= % for violins
349 #(define-music-function
(parser location part-one part-two part-three ref
)
350 (ly
:music? ly
:music? ly
:music? ly
:music?
)
352 \new Staff
<< $part-one
\new GhostVoice $ref
>>
354 \new Staff $part-three
358 #(define-music-function
(parser location part-one ref
)
359 (ly
:music? ly
:music?
)
360 #{<< $part-one
\new GhostVoice $ref
>> #})
362 %%-----------------------------------------------------------------%