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?
)
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?
)
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 %% Articulation shortcuts -----------------------------------------%
87 #(define-music-function
(parser location chord result
) (ly
:music? ly
:music?
)
88 #{ << \oneVoice $chord
\\ { \voiceTwo %FIXME: ties could look better.
89 \override NoteHead
#'stencil
= #ly
:text-interface
::print
90 \override NoteHead
#'text
= \markup { \null \musicglyph #"noteheads.s2"}
91 \once \override NoteHead
#'text
= \markup {\null \override #'(direction
. 1)
92 \dir-column
{\musicglyph #"noteheads.s2" \teeny \musicglyph #"eight"}}
93 \override Stem
#'stencil
= ##f $result
94 \revert Stem
#'stencil
\revert NoteHead
#'stencil
} >> #})
96 % Are these really needed?
97 #(define
(make-script x
)
98 (make-music
'ArticulationEvent
99 'articulation-type x
))
101 #(define
(add-script m x
)
102 (let
( (eventname
(ly
:music-property m
'name
)))
103 (if
(equal? eventname
'EventChord
)
104 (let
( (elements
(ly
:music-property m
'elements
)) )
105 (if
(not
(equal?
(ly
:music-property
(car elements
)
107 (set
! (ly
:music-property m
'elements
)
108 (append elements
(list
109 (make-script x
)))))))
112 #(define
(double-script m t tt
)
113 (add-script
(add-script m t
) tt
))
116 #(define-music-function
(parser location music
)
118 (define
(make-script-music m
)
119 (add-script m
"staccato"))
120 (music-map make-script-music music
))
123 #(define-music-function
(parser location music
)
125 (define
(make-script-music m
)
126 (add-script m
"accent"))
127 (music-map make-script-music music
))
130 #(define-music-function
(parser location music
)
132 (define
(make-script-music m
)
133 (add-script m
"tenuto"))
134 (music-map make-script-music music
))
137 #(define-music-function
(parser location music
)
139 (define
(make-script-music m
)
140 (add-script m
"marcato"))
141 (music-map make-script-music music
))
144 #(define-music-function
(parser location music
)
146 (define
(make-script-music m
)
147 (add-script m
"portato"))
148 (music-map make-script-music music
))
151 #(define-music-function
(parser location music
)
153 (define
(make-script-music m
)
154 (double-script m
"tenuto" "accent"))
155 (music-map make-script-music music
))
158 #(define-music-function
(parser location music
)
160 (define
(make-script-music m
)
161 (double-script m
"tenuto" "marcato"))
162 (music-map make-script-music music
))
165 #(define-music-function
(parser location music
)
167 (define
(make-script-music m
)
168 (double-script m
"accent" "staccato"))
169 (music-map make-script-music music
))
172 #(define-music-function
(parser location music
)
174 (define
(make-script-music m
)
175 (double-script m
"marcato" "staccato"))
176 (music-map make-script-music music
))
180 #(let
((m
(make-music
'ArticulationEvent
181 'articulation-type
"flageolet")))
182 (set
! (ly
:music-property m
'tweaks
)
184 (ly
:music-property m
'tweaks
)))
188 #(make-music
'TextScriptEvent
190 'text
(markup
#:hspace
.4 #:rotate
45
191 #:musicglyph
"scripts.stopped"))
194 #(make-articulation
"stopped")
197 #(let
* ((m
(make-music
'ArpeggioEvent
)))
198 (ly
:music-set-property
! m
'tweaks
199 (acons
'arpeggio-direction
1
200 (ly
:music-property m
'tweaks
)))
204 #(let
* ((m
(make-music
'ArpeggioEvent
)))
205 (ly
:music-set-property
! m
'tweaks
206 (acons
'arpeggio-direction -
1
207 (ly
:music-property m
'tweaks
)))
211 #(let
* ((m
(make-music
'ArpeggioEvent
)))
212 (ly
:music-set-property
! m
'tweaks
213 (acons
'stencil ly
:arpeggio
::brew-chord-bracket
214 (ly
:music-property m
'tweaks
)))
217 %% Music shortcuts ------------------------------------------------%
219 sk
= \set Score
.skipTypesetting
= ##t
221 unsk
= \set Score
.skipTypesetting
= ##f
223 % This might not be needed
224 #(define
(octave-up noteevent
)
225 (let
* ((pitch
(ly
:music-property noteevent
'pitch
))
226 (octave
(ly
:pitch-octave pitch
))
227 (note
(ly
:pitch-notename pitch
))
228 (alteration
(ly
:pitch-alteration pitch
))
229 (duration
(ly
:music-property noteevent
'duration
))
231 (make-music
'NoteEvent
233 'pitch
(ly
:make-pitch
(1- octave
) note alteration
))))
236 #(define
(octavize-chord elements
)
237 (cond
((null? elements
) elements
)
238 ((eq?
(ly
:music-property
(car elements
) 'name
) 'NoteEvent
)
240 (cons
(octave-up
(car elements
))
241 (octavize-chord
(cdr elements
)))))
242 (else
(cons
(car elements
) (octavize-chord
(cdr elements
))))))
244 #(define
(octavize music
)
245 (let
* ((es (ly
:music-property music
'elements
))
246 (e (ly
:music-property music
'element
))
247 (name
(ly
:music-property music
'name
)))
248 (cond
((eq? name
'EventChord
)
249 (ly
:music-set-property
! music
'elements
(octavize-chord
es)))
251 (for-each
(lambda
(x
) (octavize x
)) es))
256 oct
= #(define-music-function
(parser location mus
) (ly
:music?
)
260 %%%%%%%%%%%%%%%%%%%%%%%% Layout Functions %%%%%%%%%%%%%%%%%%%%%%%%%%
262 %% Music layout ---------------------------------------------------%
264 #(define modern-auto-beam-settings
265 (append default-auto-beam-settings
267 ((end
* * 3 4) . ,(ly
:make-moment
1 4))
268 ((end
* * 3 4) . ,(ly
:make-moment
1 2))
269 ((end
* * 4 4) . ,(ly
:make-moment
1 4))
270 ((end
* * 4 4) . ,(ly
:make-moment
3 4))
271 ((end
* * 2 2) . ,(ly
:make-moment
1 4))
272 ((end
* * 2 2) . ,(ly
:make-moment
1 2))
273 ((end
* * 2 2) . ,(ly
:make-moment
3 4))
274 ((end
* * 2 8) . ,(ly
:make-moment
1 4))
275 ((be
* * 5 8) . ,(ly
:make-moment
1 8))
276 ((end
* * 5 8) . ,(ly
:make-moment
5 8))
279 #(define modern-accidentals-style
280 `
(Staff
,(make-accidental-rule
'same-octave
0)
281 ,(make-accidental-rule
'any-octave
0)
282 ,(make-accidental-rule
'same-octave
1)
283 ,neo-modern-accidental-rule
))
284 #(define modern-cautionaries-style
285 `
(Staff
,(make-accidental-rule
'same-octave
1)
286 ,(make-accidental-rule
'any-octave
1)))
288 %% Music formatting -----------------------------------------------%
291 #(define-music-function
(parser location notes
) (ly
:music?
)
292 #{ \tiny $notes
\normalsize #})
295 #(define-music-function
(parser location notes
) (ly
:music?
)
296 #{ \override NoteHead
#'style
= #'cross
298 \revert NoteHead
#'style
#})
301 #(define-music-function
(parser location music
) (ly
:music?
)
302 #{\override NoteHead
#'stencil
= #ly
:text-interface
::print
303 \override NoteHead
#'text
= \markup \musicglyph #"scripts.sforzato"
304 \override NoteHead
#'extra-offset
= #'(0.1 . 0.0 )
306 \revert NoteHead
#'stencil
307 \revert NoteHead
#'text
308 \revert NoteHead
#'extra-offset
#})
311 \once \override NoteHead
#'transparent
= ##t
312 \once \override NoteHead
#'no-ledgers
= ##t
313 \once \override Stem
#'transparent
= ##t
314 \once \override Beam
#'transparent
= ##t
315 \once \override Accidental
#'transparent
= ##t
319 \once \override TupletBracket
#'transparent
= ##t
320 \once \override TupletNumber
#'transparent
= ##t
324 \once \override Stem
#'direction
= #DOWN
328 \once \override Stem
#'direction
= #UP
331 %%-----------------------------------------------------------------%