Vertical stretching/spacing; part-combine texts
[orchestrallily.git] / orchestrallily.ily
blobd86ed7230faa8eef381a274215a0cfb353b1db20
1 \version "2.13.17"
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 % OrchestralLily
5 % ==============
6 % Desciption:  Lilypond package to make writing large orchestral scores easier.
7 % Documentation: http://wiki.kainhofer.com/lilypond/orchestrallily
8 % Version: 0.02, 2008-03-06
9 % Author: Reinhold Kainhofer, reinhold@kainhofer.com
10 % Copyright: (C) 2008 by Reinhold Kainhofer
11 % License: Dual-licensed under either:
12 %      -) GPL v3.0, http://www.gnu.org/licenses/gpl.html
13 %      -) Creative Commons BY-NC 3.0, http://creativecommons.org/licenses/by-nc/3.0/at/
15 % Version History:
16 % 0.01 (2008-03-02): Initial Version
17 % 0.02 (2008-03-06): Added basic MIDI support (*MidiInstrument and \setCreateMIDI)
18 % 0.03 (2008-07-xx): General staff/voice types, title pages, etc.
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
21 #(use-modules (ice-9 match))
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25 % GLOBAL OPTIONS
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 % Use relative include pathes!
29 #(ly:set-option 'relative-includes #t)
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 %%%%%   SCORE STRUCTURE AND AUTOMATIC GENERATION
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % Helper functions
43 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45 % Helper function to filter all non-null entries
46 #(define (not-null? x) (not (null? x)))
48 % Helper function to extract a given variable, built from [Piece][Instrument]Identifier
49 #(define (namedPieceInstrObject piece instr name)
50   (let* (
51          (fullname  (string->symbol (string-append piece instr name)))
52          (instrname (string->symbol (string-append instr name)))
53          (piecename (string->symbol (string-append piece name)))
54          (fallback  (string->symbol name))
55         )
56     (cond
57       ((defined? fullname) (primitive-eval fullname))
58       ((defined? instrname) (primitive-eval instrname))
59       ((defined? piecename) (primitive-eval piecename))
60       ((defined? fallback) (primitive-eval fallback))
61       (else '())
62     )
63   )
66 %% Print text as a justified paragraph, taken from the lilypond Notation Reference
67 #(define-markup-list-command (paragraph layout props args) (markup-list?)
68    (let ((indent (chain-assoc-get 'par-indent props 2)))
69      (interpret-markup-list layout props
70        (make-justified-lines-markup-list (cons (make-hspace-markup indent)
71                                                args)))))
73 conditionalBreak = #(define-music-function (parser location) ()
74    #{ \tag #'instrumental-score \pageBreak #}
77 #(define (oly:piece-title-markup title) (markup #:column (#:line (#:fontsize #'3 #:bold title))) )
79 #(define-markup-command (piece-title layout props title) (markup?)
80      (interpret-markup layout props (oly:piece-title-markup title))
83 #(define (oly:generate_object_name piece instr obj )
84   (if (and (string? piece) (string? instr) (string? obj))
85     (string-append piece instr obj)
86     #f
87   )
89 #(define (oly:generate_staff_name piece instr) (oly:generate_object_name piece instr "St"))
91 #(define (set-context-property context property value)
92   (set! (ly:music-property context property) value)
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97 % Score structure and voice types
98 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100 #(define oly:LiedScoreStructure '(
101   ("SoloScore" "SimultaneousMusic" ("Singstimme"))
102   ("Pfe" "PianoStaff" ("PfeI" "PfeII"))
103   ;("PfeI" "ParallelVoicesStaff" ("OIa" "OIb"))
104   ;("PfeII" "ParallelVoicesStaff" ("OIIa" "OIIb"))
105   ("FullScore" "SimultaneousMusic" ("Singstimme" "Pfe"))
106   ("VocalScore" "SimultaneousMusic" ("Singstimme" "Pfe"))
109 #(define oly:fullOrchestraScoreStructure '(
110 ; Part-combined staves for full score
111   ("Fl" "PartCombinedStaff" ("FlI" "FlII"))
112   ("Ob" "PartCombinedStaff" ("ObI" "ObII"))
113   ("Cl" "PartCombinedStaff" ("ClI" "ClII"))
114   ("Fag" "PartCombinedStaff" ("FagI" "FagII"))
115   ("Wd" "StaffGroup" ("Fl" "Ob" "Cl" "Fag" "CFag"))
117   ("Cor" "PartCombinedStaff" ("CorI" "CorII"))
118   ("Trb" "PartCombinedStaff" ("TrbI" "TrbII"))
119   ("Tbe" "PartCombinedStaff" ("TbeI" "TbeII"))
120   ("Br" "StaffGroup" ("Cor" "Trb" "Tbe" "Tba"))
122 ; long score; no part-combined staves, but GrandStaves instead
123   ("FlLong" "GrandStaff" ("FlI" "FlII"))
124   ("ObLong" "GrandStaff" ("ObI" "ObII"))
125   ("ClLong" "GrandStaff" ("ClI" "ClII"))
126   ("FagLong" "GrandStaff" ("FagI" "FagII"))
127   ("WdLong" "StaffGroup" ("FlLong" "ObLong" "ClLong" "FagLong" "CFag"))
129   ("CorLong" "GrandStaff" ("CorI" "CorII"))
130   ("TrbLong" "GrandStaff" ("TrbI" "TrbII"))
131   ("TbeLong" "GrandStaff" ("TbeI" "TbeII" "TbeIII"))
132   ("BrLong" "StaffGroup" ("CorLong" "TrbLong" "TbeLong" "Tba"))
134 ; Percussion
135   ("Perc" "StaffGroup" ("Tim"))
137 ; Strings, they are the same in long and short full score
138   ("VV" "GrandStaff" ("VI" "VII"))
139   ("Str" "StaffGroup" ("VV" "Va"))
140   ("VceB" "StaffGroup" ("Vc" "Cb" "VcB"))
141   ("FullStr" "StaffGroup" ("VV" "Va" "Vc" "Cb" "VcB"))
143 ; Choral score
144   ("Solo" "SimultaneousMusic" ("SSolo" "ASolo" "TSolo" "BSolo"))
145   ("Ch" "ChoirStaff" ("S" "A" "T" "B"))
146   ("ChoralScore" "SimultaneousMusic" ("Ch"))
147   ("SoloScore" "SimultaneousMusic" ("Solo"))
148   ("SoloChoirScore" "SimultaneousMusic" ("Solo" "Ch"))
150 ; Organ score (inkl. Figured bass)
151   ("BCFb" "FiguredBass" ())
152   ("FiguredBass" "FiguredBass" ())
153   ;("Organ" "SimultaneousMusic" ("BCFb" "O"))
154   ("Continuo" "ParallelVoicesStaff" ("BCFb" "BC" "FiguredBass"))
155   ("RealizedContinuo" "PianoStaff" ("BCRealization" "Continuo"))
156   ("BassGroup" "StaffGroup" ("Continuo"))
158   ("P" "PianoStaff" ("PI" "PII"))
159   ("O" "PianoStaff" ("OI" "OII"))
160   ("OI" "ParallelVoicesStaff" ("OIa" "OIb"))
161   ("OII" "ParallelVoicesStaff" ("OIIa" "OIIb"))
162   ("Organ" "SimultaneousMusic" ("OGroup" "RealizedContinuo"))
163   ;("BassGroup" "ParallelVoicesStaff" ("Organ" "O" "BC" "VceB"))
165 ; Full Scores
166   ("FullScore" "SimultaneousMusic" ("Wd" "Br" "Perc" "Str" "SoloChoirScore" "O" "Continuo"))
167   ("LongScore" "SimultaneousMusic" ("WdLong" "BrLong" "Perc" "Str" "SoloChoirScore" "O" "Continuo"))
168   ("OriginalScore" "SimultaneousMusic" ("BrLong" "WdLong" "Perc" "Str" "SoloChoirScore" "O" "BassGroup"))
170 ; Piano reduction
171   ;("Piano" "SimultaneousMusic" ("Organ"))
172   ("OrganScore" "SimultaneousMusic" ("ChoralScore" "O"))
173   ("VocalScore" "SimultaneousMusic" ("ChoralScore" "P"))
174   ("Particell"  "SimultaneousMusic" ("ChoralScore" "BassGroup"))
176 ; Full scores: Orchestral score and long score including organ
177   ("ChStrQ" "SimultaneousMusic" ("Str" "Ch" "VceB"))
179 #(define oly:orchestral_score_structure oly:fullOrchestraScoreStructure)
181 #(define (oly:set_score_structure struct)
182   (if (list? struct)
183     (set! oly:orchestral_score_structure struct)
184     (ly:warning (_ "oly:set_score_structure needs an association list as argument!"))
185   )
188 #(define (oly:modify_score_structure entry)
189   (if (list? entry)
190     (set! oly:orchestral_score_structure (assoc-set! oly:orchestral_score_structure  (car entry) (cdr entry)))
191     (ly:warning (_ "oly:modify_score_structure expects a list (\"key\" \"type\" '(children)) as argument!"))))
193 #(define (oly:remove_from_score_structure entry)
194   (if (list? entry)
195     (map oly:remove_from_score_structure entry)
196     (set! oly:orchestral_score_structure (assoc-remove! oly:orchestral_score_structure  entry))))
198 orchestralScoreStructure = #(define-music-function (parser location structure) (list?)
199   (oly:set_score_structure structure)
200   (make-music 'Music 'void #t)
203 #(define oly:voice_types '())
205 #(define (oly:set_voice_types types)
206   (if (list? types)
207     (set! oly:voice_types types)
208     (ly:warning (_ "oly:set_voice_types needs an association list as argument!"))
209   )
212 orchestralVoiceTypes = #(define-music-function (parser location types) (list?)
213   (oly:set_voice_types types)
214   (make-music 'Music 'void #t)
218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
219 % Automatic staff and group generation
220 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
222 % Retrieve all music definitions for the given
223 #(define (oly:get_music_object piece instrument)
224   (namedPieceInstrObject piece instrument "Music")
226 #(define (oly:get_music_objects piece instruments)
227   (filter not-null? (map (lambda (i) (oly:get_music_object piece i)) instruments))
230 % Given a property name and the extensions, either generate the pair to set
231 % the property or an empty list, if no pre-defined variable could be found
232 #(define (oly:generate_property_pair prop piece instr type)
233   (let* ((val (namedPieceInstrObject piece instr type)))
234     (if (not-null? val) (list 'assign prop val) '() )
235   )
238 #(define (oly:staff_type type)
239   (cond
240     ((string? type) (string->symbol type))
241     ((symbol? type) type)
242     (else 'Staff)
243   )
246 #(define (oly:extractPitch music)
247   (let* (
248          (elems  (if (ly:music? music) (ly:music-property music 'elements)))
249          (note   (if (pair? elems) (car elems)))
250          (pitch  (if (ly:music? note) (ly:music-property note 'pitch)))
251         )
252     (if (and (not-null? music) (not (ly:pitch? pitch)))
253       (ly:warning "Unable to interpret as a pitch!")
254     )
255     pitch
256   )
259 #(define (oly:extractTranspositionPitch piece name)
260   (let* (
261          (trpFromPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeFrom")))
262          (trpToPitch   (oly:extractPitch (namedPieceInstrObject piece name "TransposeTo")))
263         )
264     (if (ly:pitch? trpFromPitch)
265       (if (ly:pitch? trpToPitch)
266         ; Both pitches
267         (ly:pitch-diff trpFromPitch trpToPitch)
268         (ly:pitch-diff trpFromPitch (ly:make-pitch 0 0 0))
269       )
270       (if (ly:pitch? trpToPitch)
271         (ly:pitch-diff (ly:make-pitch 0 0 0) trpToPitch)
272         #f
273       )
274     )
275   )
279 %%=====================================================================
280 %% Extract context modifications for given objects
281 %%---------------------------------------------------------------------
284 % TODO: join these property extractors to avoid code duplication
286 % Generate the properties for the lyrics for piece and instr.
287 % Also check whether we have a modifications object to fech mods from.
288 % return a (possibly empty) list of all assignments.
289 #(define (oly:lyrics_handler_properties piece name lyricsid)
290   (let* (
291          (mods (namedPieceInstrObject piece name (string-append lyricsid "Modifications")))
292          (mod-list (if (not-null? mods) (ly:get-context-mods mods) '()))
293          (mapping '(
294              ;(instrumentName . "InstrumentName")
295              ;(shortInstrumentName . "ShortInstrumentName")
296              ;(midiInstrument . "MidiInstrument")
297             ))
298          (assignments (map
299              (lambda (pr)
300                  (oly:generate_property_pair (car pr) piece name (cdr pr))
301              )
302              mapping))
303          (olyprops (filter not-null? assignments))
304          (props (append mod-list olyprops))
305         )
306     props
307   )
310 % Generate the properties for the voice for piece and instr.
311 % Also check whether we have a modifications object to fech mods from.
312 % return a (possibly empty) list of all assignments.
313 #(define (oly:voice_handler_properties piece name)
314   (let* (
315          (mods (namedPieceInstrObject piece name "VoiceModifications"))
316          (mod-list (if (not-null? mods) (ly:get-context-mods mods) '()))
317          (mapping '(
318              ;(instrumentName . "InstrumentName")
319              ;(shortInstrumentName . "ShortInstrumentName")
320              ;(midiInstrument . "MidiInstrument")
321             ))
322          (assignments (map
323              (lambda (pr)
324                  (oly:generate_property_pair (car pr) piece name (cdr pr))
325              )
326              mapping))
327          (olyprops (filter not-null? assignments))
328          (props (append mod-list olyprops))
329         )
330     props
331   )
334 % Generate the properties for the staff for piece and instr. Typically, these
335 % are the instrument name and the short instrument name (if defined).
336 % Also check whether we have a modifications object to fech mods from.
337 % return a (possibly empty) list of all assignments.
338 #(define (oly:staff_handler_properties piece instr)
339   (let* (
340          (mods (namedPieceInstrObject piece instr "StaffModifications"))
341          (mod-list (if (not-null? mods) (ly:get-context-mods mods) '()))
342          (mapping '(
343               (instrumentName . "InstrumentName")
344               (shortInstrumentName . "ShortInstrumentName")
345               (midiInstrument . "MidiInstrument")
346             ))
347          (assignments (map
348              (lambda (pr)
349                  (oly:generate_property_pair (car pr) piece instr (cdr pr))
350              )
351              mapping))
352          (olyprops (filter not-null? assignments))
353          (props (append mod-list olyprops))
354         )
355     props
356   )
362 %%=====================================================================
363 %% Extract contents for voices
364 %%---------------------------------------------------------------------
366 #(define (oly:musiccontent_for_voice parser piece name music additional)
367   (let* ((musiccontent additional))
369     ; Append the settings, key and clef (if defined)
370     (map
371       (lambda (type)
372         (let* ((object (namedPieceInstrObject piece name type)))
373           (if (ly:music? object)
374             (set! musiccontent (append musiccontent (list (ly:music-deep-copy object))))
375             (if (not-null? object) (ly:warning (_ "Wrong type (no ly:music) for ~S for instrument ~S in piece ~S") type name piece))
376           )
377         )
378       )
379       ; TODO: Does the "Tempo" work here???
380       '("Settings" "Key" "Clef" "TimeSignature" "ExtraSettings";"Tempo"
381       )
382     )
384     (if (ly:music? music)
385       (begin
386         (set! musiccontent (make-simultaneous-music (append musiccontent (list music))))
387         ;(ly:message "Generating staff for ~a" name)
388         (let* ((trpPitch (oly:extractTranspositionPitch piece name)))
389           (if (ly:pitch? trpPitch)
390             (set! musiccontent (ly:music-transpose musiccontent trpPitch))
391           )
392         )
393         musiccontent
394       )
395       ; For empty music, return empty
396       '()
397     )
398   )
403 %%=====================================================================
404 %% create Lyrics
405 %%---------------------------------------------------------------------
408 #(define (oly:lyrics_create_single_context parser piece name voicename lyricsid)
409   ; If we have lyrics, create a lyrics context containing LyricCombineMusic
410   ; and add that as second element to the staff's elements list...
411   ; Also add possibly configured LyricsModifications
412   (let* ((id (string-append "Lyrics" lyricsid))
413          (lyricsmods (oly:lyrics_handler_properties piece name id))
414          (lyrics (namedPieceInstrObject piece name id))
415          (ctx (if (ly:music? lyrics)
416                   (context-spec-music (make-music 'LyricCombineMusic
417                                                   'element lyrics
418                                                   'associated-context voicename)
419                                       'Lyrics
420                                       (oly:generate_object_name piece name id))
421                   '())))
422     (if (and (not-null? lyricsmods) (not-null? ctx))
423       (set! (ly:music-property ctx 'property-operations) lyricsmods)
424     )
425     ctx
426   )
429 #(define (oly:lyrics_create_contexts parser piece name voicename)
430   (filter not-null?
431     (map (lambda (str)
432                  (oly:lyrics_create_single_context parser piece name voicename str))
433          (list "" "I" "II" "III"  "IV" "V" "VI"))))
436 %%=====================================================================
437 %% Voice handling
438 %%---------------------------------------------------------------------
441 #(define (oly:voice_handler_internal parser piece name type music)
442   (if (ly:music? music)
443     (let* (
444            (voicename    (oly:generate_object_name piece name "Voice" ))
445            (lyrics       (oly:lyrics_create_contexts parser piece name voicename))
446            (additional   (if (not-null? lyrics) (list dynamicUp) '()))
447            (musiccontent (oly:musiccontent_for_voice parser piece name music additional))
448            (voicetype    (oly:staff_type type))
449            (voice        (context-spec-music musiccontent voicetype voicename))
450            (voiceprops   (oly:voice_handler_properties piece name))
451           )
452       (if (not-null? voiceprops)
453         (set! (ly:music-property voice 'property-operations) voiceprops)
454       )
455       (cons voice lyrics)
456     )
457     ; For empty music, return empty
458     '()
459   )
462 #(define (oly:voice_handler parser piece name type)
463   (oly:voice_handler_internal parser piece name type (oly:get_music_object piece name)))
466 %%=====================================================================
467 %% Staff/Group handling
468 %%---------------------------------------------------------------------
471 #(define (oly:staff_handler_internal parser piece name type voices)
472   (if (not-null? voices)
473     (let* (
474            (staffname  (oly:generate_staff_name piece name))
475            (stafftype  (oly:staff_type type))
476            (staff      (make-simultaneous-music voices))
477            (propops    (oly:staff_handler_properties piece name))
478           )
479       (case stafftype
480         ((SimultaneousMusic ParallelMusic) #f)
481         (else (set! staff (context-spec-music staff stafftype staffname)))
482       )
483       (if (not-null? propops)
484         (set! (ly:music-property staff 'property-operations) propops)
485       )
486       staff
487     )
488     ; For empty music, return empty
489     '()
490   )
493 #(define (oly:staff_handler parser piece name type children)
494   (let* ((c (if (not-null? children) children (list name)))
495          (voices (apply append (map (lambda (v) (oly:create_voice parser piece v)) c)) )
496         )
497     (if (not-null? voices)
498       (oly:staff_handler_internal parser piece name type voices)
499       '()
500     )
501   )
504 #(define (oly:devnull_handler parser piece name type children)
505   (oly:voice_handler parser piece name type)
508 #(define (oly:parallel_voices_staff_handler parser piece name type children)
509   (let* (
510          (voices (map (lambda (i) (oly:create_voice parser piece i)) children))
511          ; get the list of non-empty voices and flatten it!
512          (nonemptyvoices (apply append (filter not-null? voices)))
513         )
514     (if (not-null? nonemptyvoices)
515       (oly:staff_handler_internal parser piece name "Staff" nonemptyvoices)
516       '()
517     )
518   )
521 #(define (oly:remove-with-tag tag music)
522   (if (ly:music? music)
523       (music-filter
524         (lambda (m)
525           (let* ((tags (ly:music-property m 'tags))
526                  (res (memq tag tags)))
527             (not res)))
528         music)
529       music))
531 % Remove all music tagged a not-part-combine
532 #(define (oly:remove-non-part-combine-events music)
533   (oly:remove-with-tag 'non-partcombine music))
535 #(define (oly:part_combined_staff_handler parser piece name type children)
536   (let* ((rawmusic (map (lambda (c) (oly:musiccontent_for_voice parser piece name (oly:get_music_object piece c) '())) children))
537          (filteredmusic (map (lambda (m) (oly:remove-non-part-combine-events m)) rawmusic))
538          (music (filter not-null? filteredmusic)))
539   (cond
540       ((and (pair? music) (ly:music? (car music)) (not-null? (cdr music)) (ly:music? (cadr music)))
541           ;(ly:message "Part-combine with two music expressions")
542           (oly:staff_handler_internal parser piece name "Staff" (list (make-part-combine-music parser music))))
543       ((null? music)
544           ;;(ly:warning "Part-combine without any music expressions")
545           '())
546       ; exactly one is a music expression, simply use that by joining
547       ((list? music)
548           ;;(ly:message "Part-combine with only one music expressions")
549           (oly:staff_handler_internal parser piece name "Staff" (list (apply append music))))
550       (else
551           ;(ly:message "make_part_combined_staff: ~S ~S ~a" piece instr instruments)
552           '() )
553     )
554   )
557 % Figured bass is a special case, as it can be voice- or staff-type. When
558 % given as a staff type, simply call the voice handler, instead
560 #(define (oly:figured_bass_staff_handler parser piece name type children)
561   (let* ((c (if (not-null? children) children (list name)))
562          (voice  (oly:voice_handler parser piece (car c) type)))
563     (if (pair? voice) (car voice) ())
564   )
567 #(define (flatten lst)
568   (define (f remaining result)
569     (cond
570       ((null? remaining) result)
571       ((pair? (car remaining)) (f (cdr remaining) (f (car remaining) result)))
572       (else (f (cdr remaining) (cons (car remaining) result)))))
573   (reverse! (f lst '())))
575 #(define (oly:staff_group_handler parser piece name type children)
576   (let* (
577          (staves (flatten (map (lambda (i) (oly:create_staff_or_group parser piece i)) children)))
578          (nonemptystaves (filter not-null? staves))
579         )
580     (if (not-null? nonemptystaves)
581       (let* (
582              (musicexpr (if (= 1 (length nonemptystaves))
583                           (car nonemptystaves)
584                           (make-simultaneous-music nonemptystaves)))
585              (groupname (oly:generate_staff_name piece name))
586              (grouptype (oly:staff_type type))
587              (group     musicexpr)
588              (propops   (oly:staff_handler_properties piece name))
589             )
590         (case grouptype
591           ((SimultaneousMusic ParallelMusic) #f)
592           (else (set! group (context-spec-music group grouptype groupname)))
593         )
594         (if (pair? propops)
595           (set! (ly:music-property group 'property-operations) propops))
596         group
597       )
598       ; Return empty list if no staves are generated
599       '()
600     )
601   )
604 #(define (oly:create_voice parser piece name)
605   (let* ( (voice (namedPieceInstrObject piece name "Voice"))
606           (type (assoc-ref oly:voice_types name)) )
607     (if (not-null? voice)
608       ; Explicit voice variable, use that
609       voice
611       (if (not type)
612         ; No entry in structure found => simple voice
613         (oly:voice_handler parser piece name "Voice")
614         ; Entry found in structure => use the handler for the given type
615         (let* (
616                (voicetype (car type))
617                (handler (assoc-ref oly:voice_handlers voicetype))
618               )
619           (if handler
620             ((primitive-eval handler) parser piece name voicetype)
621             (begin
622               (ly:warning "No handler found for voice type ~a, using default voice handler" voicetype)
623               (oly:voice_handler parser piece name voicetype)
624             )
625           )
626         )
627       )
628     )
629   )
632 #(define (oly:create_staff_or_group parser piece name)
633   (let* ( (staff (namedPieceInstrObject piece name "Staff"))
634           (type_from_structure (assoc-ref oly:orchestral_score_structure name)) )
635     ;(if (not-null? staff)
636     ;  (ly:message "Found staff variable for instrument ~a in piece ~a"  instr piece)
637     ;  (ly:message "Staff variable for instrument ~a in piece ~a NOT FOUND"  instr piece)
638     ;)
639     (if (not-null? staff)
640       ; Explicit staff variable, use that
641       staff
643       (if (not (list? type_from_structure))
644         ; No entry in structure found => simple staff
645         (oly:staff_handler parser piece name "Staff" '())
647         ; Entry found in structure => use the handler for the given type
648         (let* ((type (car type_from_structure))
649                (handler (assoc-ref oly:staff_handlers type))
650                (children (cadr type_from_structure))
651               )
652           (if handler
653             ((primitive-eval handler) parser piece name type children)
654             (begin
655               (ly:warning "No handler found for staff type ~a, using default staff handler" type)
656               (oly:staff_handler parser piece name type children)
657             )
658           )
659         )
660       )
661     )
662   )
665 #(define (oly:dynamics_handler parser piece name type children)
666   (oly:voice_handler parser piece name type)
670 %%=====================================================================
671 %% Handler definitions
672 %%---------------------------------------------------------------------
674 #(define oly:staff_handlers
675   (list
676     ; staff group types
677     '("GrandStaff" . oly:staff_group_handler )
678     '("PianoStaff" . oly:staff_group_handler )
679     '("ChoirStaff" . oly:staff_group_handler )
680     '("StaffGroup" . oly:staff_group_handler )
681     '("ParallelMusic" . oly:staff_group_handler )
682     '("SimultaneousMusic" . oly:staff_group_handler )
683     ; staff types
684     '("Staff" . oly:staff_handler )
685     '("DrumStaff" . oly:staff_handler )
686     '("RhythmicStaff" . oly:staff_handler )
687     '("TabStaff" . oly:staff_handler )
688     '("GregorianTranscriptionStaff" . oly:staff_handler )
689     '("MensuralStaff" . oly:staff_handler )
690     '("VaticanaStaff" . oly:staff_handler )
691     ; staves with multiple voices
692     '("PartCombinedStaff" . oly:part_combined_staff_handler )
693     '("ParallelVoicesStaff" . oly:parallel_voices_staff_handler )
694     ; special cases: Figured bass can be staff or voice type!
695     '("FiguredBass" . oly:figured_bass_staff_handler )
696     ; Devnull is like a staff, only that it doesn't craete output
697     '("Devnull" . oly:devnull_handler )
698     '("Dynamics" . oly:dynamics_handler )
699   )
702 #(define oly:voice_handlers
703   (list
704     ; voice types
705     '("Voice" . oly:voice_handler )
706     '("CueVoice" . oly:voice_handler )
707     '("DrumVoice" . oly:voice_handler )
708     '("FiguredBass" . oly:voice_handler )
709     '("GregorianTranscriptionVoice" . oly:voice_handler )
710     '("NoteNames" . oly:voice_handler )
711     '("TabVoice" . oly:voice_handler )
712     '("VaticanaVoice" . oly:voice_handler )
713   )
717 #(define (oly:register_staff_type_handler type func)
718 ;  (ly:message "Registering staff handler ~a for type ~a" func type)
719   (set! oly:staff_handlers (assoc-set! oly:staff_handlers type func))
722 #(define (oly:register_voice_type_handler type func)
723 ;  (ly:message "Registering voice type handler ~a for type ~a" func type)
724   (set! oly:voice_handlers (assoc-set! oly:voice_handlers type func))
727 % handlers for deprecated API
728 #(oly:register_staff_type_handler 'StaffGroup 'oly:staff_group_handler)
729 #(oly:register_staff_type_handler 'GrandStaff 'oly:staff_group_handler)
730 #(oly:register_staff_type_handler 'PianoStaff 'oly:staff_group_handler)
731 #(oly:register_staff_type_handler 'ChoirStaff 'oly:staff_group_handler)
732 #(oly:register_staff_type_handler 'Staff 'oly:staff_handler )
733 #(oly:register_staff_type_handler 'ParallelMusic 'oly:staff_group_handler)
734 #(oly:register_staff_type_handler 'SimultaneousMusic 'oly:staff_group_handler)
735 #(oly:register_staff_type_handler #t 'oly:part_combined_staff_handler )
736 #(oly:register_staff_type_handler #f 'oly:parallel_voices_staff_handler )
740 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
741 % Automatic score generation
742 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
744 #(define oly:score_handler add-score)
745 #(define oly:music_handler add-music)
746 #(define oly:text_handler add-text)
749 % TODO: deprecate
750 setUseBook = #(define-music-function (parser location usebook) (boolean?)
751   (ly:warning "\\setUseBook has been deprecated! Books are now automatically handled without any hacks")
752   (make-music 'Music 'void #t)
756 % Two functions to handle midi-blocks: Either don't set one, or set an empty
757 % one so that MIDI is generated
758 #(define (oly:set_no_midi_block score) '())
759 #(define (oly:set_midi_block score)
760   (let* ((midiblock (if (defined? '$defaultmidi)
761                         (ly:output-def-clone $defaultmidi)
762                         (ly:make-output-def))))
763     (ly:output-def-set-variable! midiblock 'is-midi #t)
764     (ly:score-add-output-def! score midiblock)
765   )
768 % \setCreateMidi ##t/##f sets a flag to determine wheter MIDI output should
769 % be generated
770 #(define oly:apply_score_midi oly:set_no_midi_block)
771 setCreateMIDI = #(define-music-function (parser location createmidi) (boolean?)
772   (if createmidi
773     (set! oly:apply_score_midi oly:set_midi_block)
774     (set! oly:apply_score_midi oly:set_no_midi_block)
775   )
776   (make-music 'Music 'void #t)
780 % Two functions to handle layout-blocks: Either don't set one, or set an empty
781 % one so that a PDF is generated
782 #(define (oly:set_no_layout_block score) '())
783 #(define (oly:set_layout_block score)
784   (let* ((layoutblock (if (defined? '$defaultlayout)
785                         (ly:output-def-clone $defaultlayout)
786                         (ly:make-output-def))))
787     (ly:output-def-set-variable! layoutblock 'is-layout #t)
788     (ly:score-add-output-def! score layoutblock)
789   )
792 % \setCreatePDF ##t/##f sets a flag to determine wheter PDF output should
793 % be generated
794 #(define oly:apply_score_layout oly:set_no_layout_block)
795 setCreatePDF = #(define-music-function (parser location createlayout) (boolean?)
796   (if createlayout
797     (set! oly:apply_score_layout oly:set_layout_block)
798     (set! oly:apply_score_layout oly:set_no_layout_block)
799   )
800   (make-music 'Music 'void #t)
804 % Set the piece title in a new header block.
805 #(define (oly:set_piece_header score piecename)
806   (if (not-null? piecename)
807     (let* ((header (make-module)))
808       (module-define! header 'piece piecename)
809       (ly:score-set-header! score header)
810     )
811   )
815 % post-filter functions. By default, no filtering is done. However,
816 % for the *NoCues* function, the cue notes should be killed
817 identity = #(define-music-function (parser location music) (ly:music?) music)
818 cuefilter = #(define-music-function (parser location music) (ly:music?)
819   ((ly:music-function-extract removeWithTag) parser location 'cued ((ly:music-function-extract killCues) parser location music))
823 #(define (oly:create-toc-file layout pages)
824   (let* ((label-table (ly:output-def-lookup layout 'label-page-table)))
825     (if (not (null? label-table))
826       (let* ((format-line (lambda (toc-item)
827              (let* ((label (car toc-item))
828                     (text  (caddr toc-item))
829                     (label-page (and (list? label-table)
830                                      (assoc label label-table)))
831                     (page (and label-page (cdr label-page))))
832                (format #f "~a, section, 1, {~a}, ~a" page text label))))
833              (formatted-toc-items (map format-line (toc-items)))
834              (whole-string (string-join formatted-toc-items ",\n"))
835              (output-name (ly:parser-output-name parser))
836              (outfilename (format "~a.toc" output-name))
837              (outfile (open-output-file outfilename)))
838         (if (output-port? outfile)
839             (display whole-string outfile)
840             (ly:warning (_ "Unable to open output file ~a for the TOC information") outfilename))
841         (close-output-port outfile)))))
844 #(define-public (oly:add-toc-item parser markup-symbol text)
845   (oly:music_handler parser (add-toc-item! markup-symbol text)))
848 #(define (oly:add-score parser score piecename)
849   (if (not-null? piecename)
850     (oly:add-toc-item parser 'tocItemMarkup piecename))
851   (oly:score_handler parser score)
853 % The helper function to build a score.
854 #(define (oly:createScoreHelper parser location piece children func)
855   (let* (
856          (staves    (oly:staff_group_handler parser piece "" "SimultaneousMusic" children))
857          (music     (if (not-null? staves)
858                         ((ly:music-function-extract func) parser location staves)
859                         '()
860                     ))
861          (score     '())
862          (piecename (namedPieceInstrObject piece (car children) "PieceName"))
863          (piecenametacet (namedPieceInstrObject piece (car children) "PieceNameTacet"))
864          (header    '())
865         )
866     (if (null? music)
867       ; No staves, print tacet
868       (begin
869         (if (not-null? piecenametacet) (set! piecename piecenametacet))
870         (if (not-null? piecename)
871           (oly:add-score parser (list (oly:piece-title-markup piecename)) piecename)
872           (ly:warning (_ "No music and no score title found for part ~a and instrument ~a") piece children)
873         )
874       )
875       ; we have staves, apply the piecename to the score and add layout/midi blocks if needed
876       (begin
877         (set! score (scorify-music music parser))
878         (oly:set_piece_header score piecename)
879         (oly:apply_score_midi score)
880         (oly:apply_score_layout score)
881         ; Schedule the score for typesetting
882         (oly:add-score parser score piecename)
883       )
884     )
885   )
886   ; This is a void function, the score has been schedulled for typesetting already
887   (make-music 'Music 'void #t)
890 createScore = #(define-music-function (parser location piece children) (string? list?)
891   (oly:createScoreHelper parser location piece children identity)
893 createNoCuesScore = #(define-music-function (parser location piece children) (string? list?)
894   (oly:createScoreHelper parser location piece children cuefilter)
897 createHeadline = #(define-music-function (parser location headline) (string?)
898   (oly:add-toc-item parser 'tocItemMarkup headline)
899   (oly:score_handler parser (list (oly:piece-title-markup headline)))
900   (make-music 'Music 'void #t)
905 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
906 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
907 %%%%%   CUE NOTES
908 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
909 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
911 newInstrument = #(define-music-function (parser location instr) (string?)
913   \set Voice.instrumentCueName = #$(string-join (list "+" instr))
916 cueText = #(define-music-function (parser location instr) (string?)
918   \set Voice.instrumentCueName = $instr
922 clearCueText = #(define-music-function (parser location) ()
924   \unset Voice.instrumentCueName
928 insertCueText = #(define-music-function (parser location instr) (string?)
929   (if (string-null? instr)
930     #{ \tag #'cued \clearCueText #}
931     #{ \tag #'cued \cueText #$instr #}
934 % generate a cue music section with instrument names
935 % Parameters: \namedCueDuring NameOfQuote CueDirection CueInstrument OriginalInstrument music
936 %                 -) NameOfQuote CueDirection music are the parameters for \cueDuring
937 %                 -) CueInstrument and OriginalInstrument are the displayed instrument names
938 % typical call:
939 % \namedCueDuring #"vIQuote" #UP #"V.I" #"Sop." { R1*3 }
940 %      This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
941 %      the beginning of the cue notes and "Sop." at the end
942 namedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr cuemusic) (string? number? string? string? ly:music?)
944   \cueDuring #$cuevoice #$direction {
945     \insertCueText #$instrcue
946     $cuemusic
947     \insertCueText #$instr
948   }
951 namedTransposedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr trans cuemusic) (string? number? string? string? ly:music? ly:music?)
952    #{
953      \transposedCueDuring #$cuevoice #$direction $trans {
954        \insertCueText #$instrcue
955        $cuemusic
956        \insertCueText #$instr
957      }
958    #}
961 % set the cue instrument name and clef
962 setClefCue = #(define-music-function (parser location instr clef)
963                                                      (string? ly:music?)
964    #{
965      \once \override Staff.Clef #'font-size = #-3 $clef
966      \insertCueText $instr
967    #} )
969 % generate a cue music section with instrument names and clef changes
970 % Parameters: \cleffedCueDuring NameOfQuote CueDirection CueInstrument CueClef OriginalInstrument OriginalClef music
971 %                 -) NameOfQuote CueDirection music are the parameters for \cueDuring
972 %                 -) CueInstrument and OriginalInstrument are the displayed instrument names
973 %                 -) CueClef and OriginalClef are the clefs for the the cue notes and the clef of the containing voice
974 % typical call:
975 % \cleffedCueDuring #"vIQuote" #UP #"V.I" #"treble" #"Basso" #"bass" { R1*3 }
976 %      This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
977 %      the beginning of the cue notes and "Basso" at the end. The clef is changed to treble at the
978 %      beginning of the cue notes and reset to bass at the end
979 cleffedCueDuring = #(define-music-function (parser location cuevoice direction instrcue clefcue instr clefinstr cuemusic)
980                                                         (string? number? string? ly:music? string? ly:music? ly:music?)
981    #{
982      \cueDuring #$cuevoice #$direction {
983        \tag #'cued \setClefCue #$instrcue $clefcue
984        $cuemusic
985        \tag #'cued \setClefCue #$instr $clefinstr
986      }
987    #}
993 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
994 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
995 %%%%%   DYNAMICS
996 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
997 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1000 dynamicsX = #(define-music-function (parser location offset) (number?)
1002     \once \override DynamicText #'X-offset = $offset
1003     \once \override DynamicLineSpanner #'Y-offset = #0
1006 % Move the dynamic sign inside the staff to a fixed staff-relative position
1007 % posY (where 0 means vertically starts at the middle staff line)
1008 dynamicsAllInside = #(define-music-function (parser location offsetX posY)
1009 (number? number?)
1011   % Invalid y-extent -> hidden from skyline calculation and collisions
1012 %   \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
1013   \once \override DynamicLineSpanner #'Y-extent = $(lambda (grob)
1014     (let* ((ext (ly:axis-group-interface::height grob))
1015            (dir (ly:grob-property grob 'direction)))
1016       (if (eq? dir UP)
1017             (cons (- (cdr ext) 0.1) (cdr ext))
1018             (cons (car ext)         (+ (car ext) 0.1)))))
1019   % move by X offset and to fixed Y-position (use Y-offset of parent!)
1020   \once \override DynamicText #'X-offset = $offsetX
1021   \once \override DynamicText #'Y-offset =
1022     $(lambda (grob)
1023        (let* ((head (ly:grob-parent grob Y))
1024               (offset (ly:grob-property head 'Y-offset)))
1025          (- posY  offset (- 0.6))))
1026   \once \override DynamicLineSpanner #'Y-offset = $posY
1029 dynamicsUpInside = #(define-music-function (parser location offsetX) (number?)
1030   ((ly:music-function-extract dynamicsAllInside) parser location offsetX 1.5)
1033 dynamicsDownInside = #(define-music-function (parser location offsetX) (number?)
1034   ((ly:music-function-extract dynamicsAllInside) parser location offsetX -3.5)
1037 hairpinOffset = #(define-music-function (parser location posY) (number?)
1039   \once \override DynamicLineSpanner #'Y-offset = $posY
1040   \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
1043 #(define ((line-break-offset before after) grob)
1044   (let* ((orig (ly:grob-original grob))
1045          ; All siblings if line-broken:
1046          (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
1047     (if (>= (length siblings) 2)
1048       ; We have been line-broken
1049       (if (eq? (car (last-pair siblings)) grob)
1050         ; Last sibling:
1051         (ly:grob-set-property! grob 'Y-offset after)
1052         ; Others get the before value:
1053         (ly:grob-set-property! grob 'Y-offset before)
1054       )
1055     )
1056   )
1059 ffz = #(make-dynamic-script "ffz")
1060 pf = #(make-dynamic-script "pf")
1061 sempp = #(make-dynamic-script (markup #:line( #:with-dimensions '(0 . 0)
1062 '(0 . 0) #:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
1063 parenf = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")")))
1064 parenp = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "p" #:normal-text #:italic #:fontsize 2 ")")))
1065 pdolce = #(make-dynamic-script (markup #:line(#:dynamic "p" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce")))
1066 dolce = #(make-dynamic-script (markup #:line(#:normal-text #:italic "dolce")))
1067 sfpdolce = #(make-dynamic-script (markup #:line(#:dynamic "sfp" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce"  )))
1068 bracketf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 3 "[" #:dynamic "f" #:hspace 0.1 #:normal-text #:fontsize 3 "]"))))
1069 bracketmf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 3 "[" #:dynamic "mf" #:hspace 0.1 #:normal-text #:fontsize 3 "]"))))
1070 bracketmp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 2 "[" #:hspace 0.2 #:dynamic "mp" #:normal-text #:fontsize 2 "]"))))
1071 bracketp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 2 "[" #:hspace 0.2 #:dynamic "p" #:normal-text #:fontsize 2 "]"))))
1075 % cresc = #(make-music 'CrescendoEvent 'span-direction START 'crescendoSpanner 'text 'crescendoText "cresc.")
1076 % endcresc =  #(make-span-event 'CrescendoEvent STOP)
1077 % dim = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "dim.")
1078 % enddim =  #(make-span-event 'DecrescendoEvent STOP)
1079 % decresc = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "decresc.")
1080 % enddecresc =  #(make-span-event 'DecrescendoEvent STOP)
1082 % setCresc = {}
1083 % setDecresc = {}
1084 % setDim = {}
1085 cresc = #(make-music 'CrescendoEvent 'span-direction START
1086                      'span-type 'text 'span-text "cresc.")
1087 dim = #(make-music 'DecrescendoEvent 'span-direction START
1088                    'span-type 'text 'span-text "dim.")
1089 decresc = #(make-music 'DecrescendoEvent 'span-direction START
1090                        'span-type 'text 'span-text "decresc.")
1092 newOrOldClef = #(define-music-function (parser location new old ) (string? string?)
1093     (if (ly:get-option 'old-clefs) #{ \clef $old #} #{ \clef $new #})
1098 %%% Thanks to "Gilles THIBAULT" <gilles.thibault@free.fr>, there is a way
1099 %   to remove also the fermata from R1-\fermataMarkup: By filtering the music
1100 %   and removing the corresponding events.
1101 %   Documented as an LSR snippet: http://lsr.dsi.unimi.it/LSR/Item?id=372
1102 #(define (filterOneEventsMarkup event)
1103 ( let ( (eventname (ly:music-property  event 'name)) )
1104  (not
1105   (or     ;; add here event name you do NOT want
1106    (eq? eventname 'MultiMeasureTextEvent)
1107    (eq? eventname 'AbsoluteDynamicEvent)
1108    (eq? eventname 'TextScriptEvent)
1109    (eq? eventname 'ArticulationEvent)
1110    (eq? eventname 'CrescendoEvent)
1111    (eq? eventname 'DecrescendoEvent)
1112   )
1116 filterArticulations = #(define-music-function (parser location music) (ly:music?)
1117    (music-filter filterOneEventsMarkup music)
1124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1126 %%%%%   Tempo markings
1127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1132 rit = \markup {\italic "rit."}
1133 pocorit = \markup {\italic "poco rit."}
1134 ppmosso = \markup {\italic "poco più mosso"}
1135 pizz = \markup {\italic "pizz."}
1136 arco = \markup {\italic "arco"}
1137 perd = \markup {\italic "perdend."}
1142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1144 %%%%%   REST COMBINATION
1145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1146 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1150 %% REST COMBINING, TAKEN FROM http://lsr.dsi.unimi.it/LSR/Item?id=336
1152 %% Usage:
1153 %%   \new Staff \with {
1154 %%     \override RestCollision #'positioning-done = #merge-rests-on-positioning
1155 %%   } << \somevoice \\ \othervoice >>
1156 %% or (globally):
1157 %%   \layout {
1158 %%     \context {
1159 %%       \Staff
1160 %%       \override RestCollision #'positioning-done = #merge-rests-on-positioning
1161 %%     }
1162 %%   }
1164 %% Limitations:
1165 %% - only handles two voices
1166 %% - does not handle multi-measure/whole-measure rests
1168 #(define (rest-score r)
1169   (let ((score 0)
1170   (yoff (ly:grob-property-data r 'Y-offset))
1171   (sp (ly:grob-property-data r 'staff-position)))
1172     (if (number? yoff)
1173   (set! score (+ score 2))
1174   (if (eq? yoff 'calculation-in-progress)
1175       (set! score (- score 3))))
1176     (and (number? sp)
1177    (<= 0 2 sp)
1178    (set! score (+ score 2))
1179    (set! score (- score (abs (- 1 sp)))))
1180     score))
1182 #(define (merge-rests-on-positioning grob)
1183   (let* ((can-merge #f)
1184    (elts (ly:grob-object grob 'elements))
1185    (num-elts (and (ly:grob-array? elts)
1186       (ly:grob-array-length elts)))
1187    (two-voice? (= num-elts 2)))
1188     (if two-voice?
1189   (let* ((v1-grob (ly:grob-array-ref elts 0))
1190          (v2-grob (ly:grob-array-ref elts 1))
1191          (v1-rest (ly:grob-object v1-grob 'rest))
1192          (v2-rest (ly:grob-object v2-grob 'rest)))
1193     (and
1194      (ly:grob? v1-rest)
1195      (ly:grob? v2-rest)
1196      (let* ((v1-duration-log (ly:grob-property v1-rest 'duration-log))
1197       (v2-duration-log (ly:grob-property v2-rest 'duration-log))
1198       (v1-dot (ly:grob-object v1-rest 'dot))
1199       (v2-dot (ly:grob-object v2-rest 'dot))
1200       (v1-dot-count (and (ly:grob? v1-dot)
1201              (ly:grob-property v1-dot 'dot-count -1)))
1202       (v2-dot-count (and (ly:grob? v2-dot)
1203              (ly:grob-property v2-dot 'dot-count -1))))
1204        (set! can-merge
1205        (and
1206         (number? v1-duration-log)
1207         (number? v2-duration-log)
1208         (= v1-duration-log v2-duration-log)
1209         (eq? v1-dot-count v2-dot-count)))
1210        (if can-merge
1211      ;; keep the rest that looks best:
1212      (let* ((keep-v1? (>= (rest-score v1-rest)
1213               (rest-score v2-rest)))
1214       (rest-to-keep (if keep-v1? v1-rest v2-rest))
1215       (dot-to-kill (if keep-v1? v2-dot v1-dot)))
1216        ;; uncomment if you're curious of which rest was chosen:
1217        ;;(ly:grob-set-property! v1-rest 'color green)
1218        ;;(ly:grob-set-property! v2-rest 'color blue)
1219        (ly:grob-suicide! (if keep-v1? v2-rest v1-rest))
1220        (if (ly:grob? dot-to-kill)
1221            (ly:grob-suicide! dot-to-kill))
1222        (ly:grob-set-property! rest-to-keep 'direction 0)
1223        (ly:rest::y-offset-callback rest-to-keep)))))))
1224     (if can-merge
1225   #t
1226   (ly:rest-collision::calc-positioning-done grob))))
1232 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1234 %%%%%   TABLE OF CONTENTS
1235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1236 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1239 contentsTitle = "Inhalt / Contents"
1241 \paper {
1242   tocTitleMarkup = \markup \fill-line{
1243     \null
1244     \column {
1245       \override #(cons 'line-width (* 7 cm))
1246       \line{ \fill-line {\piece-title {\contentsTitle} \null }}
1247       \hspace #1
1248     }
1249     \null
1250   }
1251   tocItemMarkup = \markup \fill-line {
1252     \null
1253     \column {
1254       \override #(cons 'line-width (* 7 cm ))
1255       \line { \fill-line{\fromproperty #'toc:text \fromproperty #'toc:page }}
1256     }
1257     \null
1258   }
1262 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1264 %%%%%   TITLE PAGE / HEADER
1265 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1266 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1268 #(define-markup-command (when-property layout props symbol markp) (symbol? markup?)
1269   (if (chain-assoc-get symbol props)
1270       (interpret-markup layout props markp)
1271       (ly:make-stencil '()  '(1 . -1) '(1 . -1))))
1273 #(define-markup-command (vspace layout props amount) (number?)
1274   "This produces a invisible object taking vertical space."
1275   (let ((amount (* amount 3.0)))
1276     (if (> amount 0)
1277         (ly:make-stencil "" (cons -1 1) (cons 0 amount))
1278         (ly:make-stencil "" (cons -1 1) (cons amount amount)))))
1282 titlePageMarkup = \markup \abs-fontsize #10 \when-property #'header:title \column {
1283     \vspace #4
1284     \fill-line { \fontsize #8 \fromproperty #'header:composer }
1285     \vspace #1
1286     \fill-line { \fontsize #8 \fromproperty #'header:poet }
1287     \vspace #4
1288     \fill-line { \fontsize #10 \bold \fromproperty #'header:titlepagetitle }
1289     \vspace #1
1290     \fontsize #2 \when-property #'header:titlepagesubtitle {
1291       \fill-line { \fromproperty #'header:titlepagesubtitle }
1292       \vspace #1
1293     }
1294     \fill-line { \postscript #"-20 0 moveto 40 0 rlineto stroke" }
1295     \vspace #8
1296     \fill-line { \fontsize #5 \fromproperty #'header:ensemble }
1297     \vspace #0.02
1298     \fill-line { \fontsize #2 \fromproperty #'header:instruments }
1299     \vspace #9
1300     \fill-line { \fontsize #5 \fromproperty #'header:date }
1301     \vspace #1
1302     \fill-line { \fontsize #5 \fromproperty #'header:scoretype }
1303     \when-property #'header:instrument {
1304       \fill-line { \bold \fontsize #6 \rounded-box \fromproperty #'header:instrument }
1305     }
1306     \vspace #8
1307     \fontsize #2 \when-property #'header:enteredby {
1308       \fill-line { "Herausgegeben von: / Edited by:"}
1309       \vspace #0.
1310       \fill-line { \fromproperty #'header:enteredby }
1311     }
1312     \fill-line {
1313       \when-property #'header:arrangement \column {
1314         \vspace #8
1315         \fill-line { \fontsize #3 \fromproperty #'header:arrangement }
1316       }
1317     }
1318   \vspace #6
1319   \fill-line { \fromproperty #'header:copyright }
1322 titleHeaderMarkup = \markup {
1323   \override #'(baseline-skip . 3.5)
1324   \column {
1325     \fill-line {
1326       \fromproperty #'header:logo
1327       \center-column {
1328         \huge \larger \bold \larger \fromproperty #'header:title
1329         \large \smaller \bold \larger \fromproperty #'header:subtitle
1330         \smaller \bold \fromproperty #'header:subsubtitle
1331       }
1332       \bold \when-property #'header:instrument \rounded-box \fromproperty #'header:instrument
1333     }
1334     \fill-line {
1335       \with-dimensions #'( 0 . 0) #'( 0 . 1 ) \null
1336     }
1338 %     \fill-line {
1339 %       { \large \bold \fromproperty #'header:instrument }
1340 %     }
1341     \fill-line {
1342       \fromproperty #'header:poet
1343       \fromproperty #'header:composer
1344     }
1345     \fill-line {
1346       \fromproperty #'header:meter
1347       \fromproperty #'header:arranger
1348     }
1349   }
1352 titleScoreMarkup = \markup \piece-title \fromproperty #'header:piece
1354 \paper {
1355   scoreTitleMarkup = \titleScoreMarkup
1356   bookTitleMarkup = \titleHeaderMarkup
1361 %%%%%%%%%%%%%% headers and footers %%%%%%%%%%%%%%%%%%%%%%%%%%
1363 #(define (first-score-page layout props arg)
1364   (let* ((label 'first-score-page)
1365          (table (ly:output-def-lookup layout 'label-page-table))
1366          (label-page (and (list? table) (assoc label table)))
1367          (page-number (and label-page (cdr label-page)))
1368         )
1369     (if (eq? (chain-assoc-get 'page:page-number props -1) page-number)
1370       (interpret-markup layout props arg)
1371       empty-stencil)))
1373 #(define no-header-table '())
1374 thisPageNoHeader = #(define-music-function (parser location) ()
1375   (let* ((label (gensym "header")))
1376     (set! no-header-table (cons label no-header-table))
1377     (make-music 'Music
1378       'page-marker #t
1379       'page-label label)))
1382 % TODO: Use the no-header-table!
1383 #(define (is-header-page layout props arg)
1384   (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1385         )
1386     ;(if (and (> page-number 2) (!= page-number 7))
1387     (if (> page-number 1)
1388       (interpret-markup layout props arg)
1389       empty-stencil)))
1391 #(define no-footer-table '())
1392 thisPageNoFooter = #(define-music-function (parser location) ()
1393   (let* ((label (gensym "footer")))
1394     (set! no-footer-table (cons label no-footer-table))
1395     (make-music 'Music
1396       'page-marker #t
1397       'page-label label)))
1399 % TODO: Use the no-footer-table!
1400 #(define (is-footer-page layout props arg)
1401   (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1402          (label 'first-score-page)
1403          (table (ly:output-def-lookup layout 'label-page-table))
1404          (label-page (and (list? table) (assoc label table)))
1405          ;(page-number (and label-page (cdr label-page)))
1406         )
1407     (if (and (> page-number 1))
1408       (interpret-markup layout props arg)
1409       empty-stencil)))
1412 #(define copyright-footer-table '())
1413 thisPageCopyrightFooter = #(define-music-function (parser location) ()
1414   (let* ((label (gensym "copyrightfooter")))
1415     (set! copyright-footer-table (cons label copyright-footer-table))
1416     (make-music 'Music
1417       'page-marker #t
1418       'page-label label)))
1420 #(define copyright-pg 1)
1421 #(define (set-copyright-page page)
1422   (set! copyright-pg page)
1425 % TODO: Use the copyright-footer-table!
1426 #(define (copyright-page layout props arg)
1427     (if (= (chain-assoc-get 'page:page-number props -1) copyright-pg)
1428       (interpret-markup layout props arg)
1429       empty-stencil))
1432 \paper {
1433   oddHeaderMarkup = \markup \fill-line {
1434     %% force the header to take some space, otherwise the
1435     %% page layout becomes a complete mess.
1436     " "
1437     \on-the-fly #is-header-page \fromproperty #'header:title
1438     \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1439   }
1440   evenHeaderMarkup = \markup \fill-line {
1441     \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1442     \on-the-fly #is-header-page \fromproperty #'header:composer
1443     " "
1444   }
1446   oddFooterMarkup = \markup {
1447     \column {
1448       \fill-line {
1449         %% publisher header field only on title page.
1450         \on-the-fly #first-page \fromproperty #'header:publisher
1451       }
1452       \fill-line {
1453         %% copyright on the first real score page
1454         \on-the-fly #copyright-page \fromproperty #'header:copyright
1455         \on-the-fly #copyright-page \null
1456       }
1457       \fill-line {
1458         %% All other pages get the number of the edition centered
1459         \on-the-fly #is-footer-page \fromproperty #'header:scorenumber
1460       }
1461     }
1462   }
1476 % Interpret the given markup with the header fields added to the props.
1477 % This way, one can re-use the same functions (using fromproperty
1478 % #'header:field) in the header block and as top-level markup.
1480 % This function is originally copied from mark-up-title (file scm/titling.scm),
1481 % which is lilypond's internal function to handle the title markups. I needed
1482 % to replace the scopes and manually add the $defaultheader (which is internally
1483 % done in paper-book.cc before calling mark-up-title. Also, I don't extract the
1484 % markup from the header block, but use the given markup.
1486 % I'm not sure if I really need the page properties in props, too... But I
1487 % suppose it does not hurt, either.
1488 #(define-markup-command (markupWithHeader layout props markup) (markup?)
1489   "Interpret the given markup with the header fields added to the props.
1490    This way, one can re-use the same functions (using fromproperty
1491    #'header:field) in the header block and as top-level markup."
1492   (let* (
1493       ; TODO: If we are inside a score, add the score's local header block, too!
1494       ; Currently, I only use the global header block, stored in $defaultheader
1495       (scopes (list $defaultheader))
1496       (alists (map ly:module->alist scopes))
1498       (prefixed-alist
1499         (map (lambda (alist)
1500           (map (lambda (entry)
1501             (cons
1502               (string->symbol (string-append "header:" (symbol->string (car entry))))
1503               (cdr entry)))
1504             alist))
1505           alists))
1506       (props (append prefixed-alist
1507               props
1508               (layout-extract-page-properties layout)))
1509     )
1510     (interpret-markup layout props markup)
1511   )
1519 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1520 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1521 %%%%%   Equally spacing multiple columns (e.g. for translations)
1522 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1525 % Credits: Nicolas Sceaux on the lilypond-user mailinglist
1526 #(define-markup-command (columns layout props args) (markup-list?)
1527    (let ((line-width (/ (chain-assoc-get 'line-width props
1528                          (ly:output-def-lookup layout 'line-width))
1529                         (max (length args) 1))))
1530      (interpret-markup layout props
1531        (make-line-markup (map (lambda (line)
1532                                 (markup #:pad-to-box `(0 . ,line-width) '(0 . 0)
1533                                   #:override `(line-width . ,line-width)
1534                                   line))
1535                                args)))))
1539 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1540 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1541 %%%%%   SCORE (HEADER / LAYOUT) SETTINGS
1542 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1543 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1546 startSlashedGraceMusic =  {
1547   \override Stem  #'stroke-style = #"grace"
1550 stopSlashedGraceMusic =  {
1551   \revert Stem #'stroke-style
1554 slashedGrace =
1555 #(def-grace-function startSlashedGraceMusic stopSlashedGraceMusic
1556    (_i "Create slashed graces (slashes through stems, but no slur)from the following music expression"))
1559 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1560 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1561 %%%%%   SCORE (HEADER / LAYOUT) SETTINGS
1562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1563 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1565 \paper {
1566   left-margin = 2\cm
1567   right-margin = 1.5\cm
1568   line-width = 17.5\cm
1569 %   bottom-margin = 1.5\cm
1570   top-margin = 1.2\cm
1571 %   after-title-space = 0.5\cm
1572   ragged-right = ##f
1573   ragged-last = ##f
1574   ragged-bottom = ##f
1575   ragged-last-bottom = ##f
1577 \layout {
1578   \context {
1579     \ChoirStaff
1580     % If only one non-empty staff in a system exists, still print the backet
1581     \override SystemStartBracket #'collapse-height = #1
1582     \consists "Instrument_name_engraver"
1583   }
1584   \context {
1585     \StaffGroup
1586     % If only one non-empty staff in a system exists, still print the backet
1587     \override SystemStartBracket #'collapse-height = #1
1588     \consists "Instrument_name_engraver"
1589   }
1590   \context {
1591     \GrandStaff
1592     \override SystemStartBracket #'collapse-height = #1
1593     \consists "Instrument_name_engraver"
1594   }
1595   \context {
1596     \FiguredBass
1597 %     \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1598 %     \override VerticalAxisGroup #'minimum-Y-extent  = #'(0 . 1) % TODO: Removed
1599     \override VerticalAxisGroup #'padding = #0
1600   }
1601   \context {
1602     \Score
1603     % Force multi-measure rests to be written as one span
1604     \override MultiMeasureRest #'expand-limit = #3
1605     skipBars = ##t
1606     autoBeaming = ##f
1607 %     \override Hairpin #'to-barline = ##f
1608 %     \override BarNumber #'break-visibility = #end-of-line-invisible
1609 %     \override BarNumber #'self-alignment-X = #0
1610 %     barNumberVisibility = #(every-nth-bar-number-visible 5)
1611     \override CombineTextScript #'avoid-slur = #'outside
1612     \override DynamicTextSpanner #'dash-period = #-1.0
1613     \override InstrumentSwitch #'font-size = #-1
1615     % Rest collision
1616     \override RestCollision #'positioning-done = #merge-rests-on-positioning
1617     % Auto-Accidentals: Use modern-cautionary style...
1618     extraNatural = ##f
1619     % Accidental rules (the rule giving the most accidentals wins!)
1620     % -) Reset accidentals at each barline -> accs not in key sig will always be printed
1621     % -) Same octave accidentals are remembered for two measures -> cancellation
1622     % -) other octave accidentals are remembered for next measure -> cancellation
1623     autoAccidentals = #`(Staff  ,(make-accidental-rule 'same-octave 0)
1624                                 ,(make-accidental-rule 'any-octave 0)
1625                                 ,(make-accidental-rule 'any-octave 1)
1626                                 ,(make-accidental-rule 'same-octave 2))
1627     % No auto-cautionaries, we always use autoAccidentals!
1628 %     autoCautionaries = #`(Staff ,(make-accidental-rule 'any-octave 0)
1629 %                                 ,(make-accidental-rule 'same-octave 1))
1630     printKeyCancellation = ##t
1631     quotedEventTypes = #'(StreamEvent)
1632     implicitBassFigures = #'(0 100)
1633   }
1634   \context {
1635     \Staff
1636     \RemoveEmptyStaves
1637   }
1641 ts = ^\markup{"t.s."}
1642 tt = ^\markup{"Tutti"}
1643 solo = ^\markup{"Solo"}
1644 tutti = ^\markup{"Tutti"}
1645 bracketts = ^\markup{"[Solo]"}
1646 brackettt = ^\markup{"[Tutti]"}
1647 bracketsolo = ^\markup{"[Solo]"}
1649 sottovoce = \markup "sotto voce"
1651 dashedSlur = -\tweak #'dash-definition #'((0 1 0.4 0.75))(
1652 dashedTie = -\tweak #'dash-definition #'((0 1 0.4 0.75))~
1654 divisi = #(define-music-function (parser location vc1 vc2) (ly:music? ly:music?)
1656   << { \voiceOne $vc1 \oneVoice} \context Voice = "divisi2" { \voiceTwo $vc2 } >>
1660 #(define twoVoice divisi)
1662 #(define-public (bracket-stencils grob)
1663   (let ((lp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "[")))
1664         (rp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "]"))))
1665     (list lp rp)))
1667 bracketify = #(define-music-function (parser loc arg) (ly:music?)
1668    (_i "Tag @var{arg} to be parenthesized.")
1670   \once \override ParenthesesItem #'stencils = #bracket-stencils
1671   \parenthesize $arg
1676 #(define-markup-command (hat layout props arg) (markup?)
1677   "Draw a hat above the given string @var{arg}."
1678   (interpret-markup layout props (markup #:combine #:raise 1.5 "^" arg)))
1682 smallFlageolet =
1683 #(let ((m (make-music 'ArticulationEvent
1684                       'articulation-type "flageolet")))
1685    (ly:music-set-property! m 'tweaks
1686      (acons 'font-size -2
1687        (ly:music-property m 'tweaks)))
1688   m)
1691 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1692 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1693 %%%%%   LICENSE TEXTS
1694 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1697 LicenseCCBY = \markup {Lizensiert unter / Licensed under: Creative Commons BY \with-url #"http://creativecommons.org/licenses/by/3.0/at/" {\translate #'(0 . -0.7) \epsfile #Y #3 #"orchestrallily/cc-by.eps" }}
1698 LicenseCCBYNC = \markup {Lizensiert unter / Licensed under: Creative Commons BY-NC \with-url #"http://creativecommons.org/licenses/by-nc/3.0/at/" {\translate #'(0 . -0.7) \epsfile #Y #3 #"orchestrallily/cc-by-nc.eps" }}
1699 LicenseNoRestrictions = \markup{\line {Die Ausgabe darf kopiert und ohne Einschränkungen aufgeführt werden. / May be copied and performed without restriction.}}
1701 \include "sceaux_clef-key.ily"
1704 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1705 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1706 %%%%%   VARIOUS
1707 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1708 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1710 startUnremovableSection = \set Staff.keepAliveInterfaces =
1711  #'(rhythmic-grob-interface
1712     rest-interface
1713     lyric-interface
1714     percent-repeat-item-interface
1715     percent-repeat-interface
1716     stanza-number-interface)
1718 endUnremovableSection = \unset Staff.keepAliveInterfaces
1721 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1722 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1723 %%%%%   EDITORIAL ANNOTATIONS
1724 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1725 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1727 #(define-public (editorial-bracket-stencil stil padding widen)
1728 "Add brackets for editorial annoations around STIL, producing a new stencil."
1729 (let* ((axis Y)
1730        (other-axis (lambda (a) (remainder (+ a 1) 2)))
1731        (ext (interval-widen (ly:stencil-extent stil axis) widen))
1732        (thick 0.15)
1733        (protrusion 0.3)
1734        (lb (ly:bracket axis ext thick protrusion))
1735        (rb (ly:bracket axis ext thick (- protrusion))))
1736   (set! stil (ly:stencil-combine-at-edge stil (other-axis axis) 1 rb padding))
1737   (set! stil
1738     (ly:stencil-combine-at-edge lb (other-axis axis) 1 stil padding))
1739   stil))
1741 editorialHairpin = \once \override Hairpin     #'stencil = #(lambda (grob) (editorial-bracket-stencil (ly:hairpin::print grob) 0.2 0.55))
1742 editorialDynamic = \once \override DynamicText #'stencil = #(lambda (grob) (editorial-bracket-stencil (ly:text-interface::print grob) 0.2 0.55))
1743 editorialMarkup =  \once \override TextScript  #'stencil = #(lambda (grob) (editorial-bracket-stencil (ly:text-interface::print grob) 0.2 0.55))
1745 % videStart = \mark \markup { \hspace #1 \musicglyph #"scripts.coda"  \with-dimensions #'(0 . 0) #'(0 . 0) \left-align { vi-} }
1746 videStart = \mark \markup \halign #-2.3 \concat { \hspace #4.5 \musicglyph #"scripts.coda" \left-align { vi- } }
1747 % videEnd = \notemode {
1748 %   \once \override Score.RehearsalMark #'break-visibility = #begin-of-line-invisible
1749 %   \mark \markup \concat{ \with-dimensions #'(0 . 0) #'(0 . 0) \right-align { -de } \hspace #1 \musicglyph #"scripts.coda" }
1751 videEnd = \notemode {
1752         \once \override Score.RehearsalMark #'break-visibility = #begin-of-line-invisible
1753         \mark \markup \concat{ \right-align { -de } \hspace #1.5 \musicglyph #"scripts.coda" \hspace #4.2 }
1758 \layout {
1759         \context {\Staff
1760                 soloText = #"I"
1761                 soloIIText = #"II"
1762                 aDueText = #"a2"
1763         }
1766 \paper {
1767         %   after-title-spacing = #'((space . 2) (padding . 2) (stretchability . 5))
1768         %   between-system-spacing = #'((space . 0) (padding . 2) (stretchability . 35))
1769         %   bottom-system-spacing = #'((space . 10) (padding . 2) (stretchability . 5))
1770           after-title-spacing = #'((space . 4) (padding . 2) (stretchability . 20))
1771           between-system-spacing = #'((space . 0) (padding . 1) (stretchability . 35))
1772           top-system-spacing = #'((space . 5) (padding . 1) (stretchability . 15))
1773           bottom-system-spacing = #'((space . 5) (padding . 1) (stretchability . 15))
1775 \layout {
1776         \context { \StaffGroup
1777                 \override StaffGrouper #'between-staff-spacing #'stretchability = #4
1778         }
1779         \context { \ChoirStaff
1780                 \override StaffGrouper #'between-staff-spacing #'stretchability = #3
1781         }