Dynamics to ActeUnSceneTroisTer
[opera_libre.git] / definitions / functions.ly
blob20bddeab7da8fc811b94daf35babe4f3097c5fcf
1 %------------------------------------------------------------------%
2 % Opéra Libre -- functions.ly %
3 % %
4 % (c) Valentin Villenave, 2008 %
5 % %
6 %------------------------------------------------------------------%
8 % Various additional functions.
10 %%%%%%%%%%%%%%%%%%%%%%%%% Music Shortcuts %%%%%%%%%%%%%%%%%%%%%%%%%%
12 %% Rhythm shortcuts -----------------------------------------------%
14 t =
15 #(define-music-function (parser location music) (ly:music?)
16 #{ \times 2/3 $music #})
18 tt =
19 #(define-music-function (parser location music) (ly:music?)
20 #{ \times 4/5 $music #})
22 ttt =
23 #(define-music-function (parser location music) (ly:music?)
24 #{ \times 4/6 $music #})
26 tttt =
27 #(define-music-function (parser location music) (ly:music?)
28 #{ \times 4/7 $music #})
31 %% Polyphony shortcuts --------------------------------------------%
33 pl =
34 #(define-music-function (parser location one two) (ly:music? ly:music?)
35 #{ << { \voiceTwo $one } \\ { \voiceOne $two } >> #})
37 plperc =
38 #(define-music-function (parser location one two) (ly:music? ly:music?)
39 #{ << { \stemDown $one \stemNeutral } \new DrumVoice { \stemUp $two } >> #})
41 parallel=
42 #(define-music-function (parser location droite gauche) (ly:music? ly:music?)
43 #{ <<
44 \context Staff = "md" $droite
45 \context Staff = "mg" $gauche
46 >> #})
48 md = { \change Staff = "md" }
50 mg = { \change Staff = "mg" }
52 PianoDeuxMains=
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 }
59 >> #})
61 droite = { \change Staff = "percuDroite" }
63 gauche = { \change Staff = "percuGauche" }
65 PercuDeuxMains=
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 }
72 >> #})
74 showAnyway =
75 #(define-music-function (parser location music) (ly:music?)
77 \unset Score.keepAliveInterfaces
78 $music
79 \set Score.keepAliveInterfaces = #'(rhythmic-grob-interface
80 lyric-interface percent-repeat-item-interface
81 percent-repeat-interface stanza-number-interface)
82 #})
84 %% Music formatting -----------------------------------------------%
86 graceNotes =
87 #(define-music-function (parser location notes) (ly:music?)
88 #{ \tiny $notes \normalsize #})
90 parlato =
91 #(define-music-function (parser location notes) (ly:music?)
92 #{ \override NoteHead #'style = #'cross
93 $notes
94 \revert NoteHead #'style #})
96 slap =
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 )
101 $music
102 \revert NoteHead #'stencil
103 \revert NoteHead #'text
104 \revert NoteHead #'extra-offset #})
106 hideNote = {
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
114 noTuplet = {
115 \once \override TupletBracket #'transparent = ##t
116 \once \override TupletNumber #'transparent = ##t
119 oneStemDown = {
120 \once \override Stem #'direction = #DOWN
123 oneStemUp = {
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))
140 (newnoteevent
141 (make-music 'NoteEvent
142 'duration duration
143 'pitch (ly:make-pitch (1- octave) note alteration))))
144 newnoteevent))
146 #(define (octavize-chord elements)
147 (cond ((null? elements) elements)
148 ((eq? (ly:music-property (car elements) 'name) 'NoteEvent)
149 (cons (car elements)
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)))
160 ((pair? es)
161 (for-each (lambda(x) (octavize x)) es))
162 ((ly:music? e)
163 (octavize e))))
164 music)
166 oct = #(define-music-function (parser location mus) (ly:music?)
167 (octavize mus))
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)
183 'name) 'RestEvent))
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))
192 st =
193 #(define-music-function (parser location music)
194 (ly:music?)
195 (define (make-script-music m)
196 (add-script m "staccato"))
197 (music-map make-script-music music))
199 acc =
200 #(define-music-function (parser location music)
201 (ly:music?)
202 (define (make-script-music m)
203 (add-script m "accent"))
204 (music-map make-script-music music))
206 det =
207 #(define-music-function (parser location music)
208 (ly:music?)
209 (define (make-script-music m)
210 (add-script m "tenuto"))
211 (music-map make-script-music music))
213 marc =
214 #(define-music-function (parser location music)
215 (ly:music?)
216 (define (make-script-music m)
217 (add-script m "marcato"))
218 (music-map make-script-music music))
220 stdet =
221 #(define-music-function (parser location music)
222 (ly:music?)
223 (define (make-script-music m)
224 (add-script m "portato"))
225 (music-map make-script-music music))
227 accdet =
228 #(define-music-function (parser location music)
229 (ly:music?)
230 (define (make-script-music m)
231 (double-script m "tenuto" "accent"))
232 (music-map make-script-music music))
234 marcdet =
235 #(define-music-function (parser location music)
236 (ly:music?)
237 (define (make-script-music m)
238 (double-script m "tenuto" "marcato"))
239 (music-map make-script-music music))
241 accst =
242 #(define-music-function (parser location music)
243 (ly:music?)
244 (define (make-script-music m)
245 (double-script m "accent" "staccato"))
246 (music-map make-script-music music))
248 marcst =
249 #(define-music-function (parser location music)
250 (ly:music?)
251 (define (make-script-music m)
252 (double-script m "marcato" "staccato"))
253 (music-map make-script-music music))
256 CaV=
257 #(let ((m (make-music 'ArticulationEvent
258 'articulation-type "flageolet")))
259 (set! (ly:music-property m 'tweaks)
260 (acons 'font-size -3
261 (ly:music-property m 'tweaks)))
263 harmo =
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 } >> #})
273 thumbpizz =
274 #(make-music 'TextScriptEvent
275 'direction 1
276 'text (markup #:hspace .4 #:rotate 45
277 #:musicglyph "scripts.stopped"))
279 leftpizz =
280 #(make-articulation "stopped")
282 arpeggUp =
283 #(let* ((m (make-music 'ArpeggioEvent)))
284 (ly:music-set-property! m 'tweaks
285 (acons 'arpeggio-direction 1
286 (ly:music-property m 'tweaks)))
289 arpeggDown =
290 #(let* ((m (make-music 'ArpeggioEvent)))
291 (ly:music-set-property! m 'tweaks
292 (acons 'arpeggio-direction -1
293 (ly:music-property m 'tweaks)))
296 plak =
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 -----------------------------------------------%
335 makePart =
336 #(define-music-function (parser location part ref)
337 (ly:music? ly:music?)
338 #{\context Staff << $part \new GhostVoice $ref >> #})
340 makeSection =
341 #(define-music-function (parser location part-one part-two ref)
342 (ly:music? ly:music? ly:music?)
343 #{\new StaffGroup <<
344 \new Staff << $part-one \new GhostVoice $ref >>
345 \new Staff $part-two
346 >> #})
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?)
351 #{\new StaffGroup <<
352 \new Staff << $part-one \new GhostVoice $ref >>
353 \new Staff $part-two
354 \new Staff $part-three
355 >> #})
357 makePianoPart =
358 #(define-music-function (parser location part-one ref)
359 (ly:music? ly:music?)
360 #{<< $part-one \new GhostVoice $ref >> #})
362 %%-----------------------------------------------------------------%