Remove deprecated VerticalAxisGroup #'minimum-Y-extent
[orchestrallily.git] / orchestrallily.ily
blobd98ee8f5195189efa0d386cce6fc16c05d30a1c4
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:part_combined_staff_handler parser piece name type children)
522   (let* ((rawmusic (map (lambda (c) (oly:musiccontent_for_voice parser piece name (oly:get_music_object piece c) '())) children))
523          (music (filter not-null? rawmusic)))
524   (cond
525       ((and (pair? music) (ly:music? (car music)) (not-null? (cdr music)) (ly:music? (cadr music)))
526           ;(ly:message "Part-combine with two music expressions")
527           (oly:staff_handler_internal parser piece name "Staff" (list (make-part-combine-music parser music))))
528       ((null? music)
529           ;;(ly:warning "Part-combine without any music expressions")
530           '())
531       ; exactly one is a music expression, simply use that by joining
532       ((list? music)
533           ;;(ly:message "Part-combine with only one music expressions")
534           (oly:staff_handler_internal parser piece name "Staff" (list (apply append music))))
535       (else
536           ;(ly:message "make_part_combined_staff: ~S ~S ~a" piece instr instruments)
537           '() )
538     )
539   )
542 % Figured bass is a special case, as it can be voice- or staff-type. When
543 % given as a staff type, simply call the voice handler, instead
545 #(define (oly:figured_bass_staff_handler parser piece name type children)
546   (let* ((c (if (not-null? children) children (list name)))
547          (voice  (oly:voice_handler parser piece (car c) type)))
548     (if (pair? voice) (car voice) ())
549   )
552 #(define (flatten lst)
553   (define (f remaining result)
554     (cond
555       ((null? remaining) result)
556       ((pair? (car remaining)) (f (cdr remaining) (f (car remaining) result)))
557       (else (f (cdr remaining) (cons (car remaining) result)))))
558   (reverse! (f lst '())))
560 #(define (oly:staff_group_handler parser piece name type children)
561   (let* (
562          (staves (flatten (map (lambda (i) (oly:create_staff_or_group parser piece i)) children)))
563          (nonemptystaves (filter not-null? staves))
564         )
565     (if (not-null? nonemptystaves)
566       (let* (
567              (musicexpr (if (= 1 (length nonemptystaves))
568                           (car nonemptystaves)
569                           (make-simultaneous-music nonemptystaves)))
570              (groupname (oly:generate_staff_name piece name))
571              (grouptype (oly:staff_type type))
572              (group     musicexpr)
573              (propops   (oly:staff_handler_properties piece name))
574             )
575         (case grouptype
576           ((SimultaneousMusic ParallelMusic) #f)
577           (else (set! group (context-spec-music group grouptype groupname)))
578         )
579         (if (pair? propops)
580           (set! (ly:music-property group 'property-operations) propops))
581         group
582       )
583       ; Return empty list if no staves are generated
584       '()
585     )
586   )
589 #(define (oly:create_voice parser piece name)
590   (let* ( (voice (namedPieceInstrObject piece name "Voice"))
591           (type (assoc-ref oly:voice_types name)) )
592     (if (not-null? voice)
593       ; Explicit voice variable, use that
594       voice
596       (if (not type)
597         ; No entry in structure found => simple voice
598         (oly:voice_handler parser piece name "Voice")
599         ; Entry found in structure => use the handler for the given type
600         (let* (
601                (voicetype (car type))
602                (handler (assoc-ref oly:voice_handlers voicetype))
603               )
604           (if handler
605             ((primitive-eval handler) parser piece name voicetype)
606             (begin
607               (ly:warning "No handler found for voice type ~a, using default voice handler" voicetype)
608               (oly:voice_handler parser piece name voicetype)
609             )
610           )
611         )
612       )
613     )
614   )
617 #(define (oly:create_staff_or_group parser piece name)
618   (let* ( (staff (namedPieceInstrObject piece name "Staff"))
619           (type_from_structure (assoc-ref oly:orchestral_score_structure name)) )
620     ;(if (not-null? staff)
621     ;  (ly:message "Found staff variable for instrument ~a in piece ~a"  instr piece)
622     ;  (ly:message "Staff variable for instrument ~a in piece ~a NOT FOUND"  instr piece)
623     ;)
624     (if (not-null? staff)
625       ; Explicit staff variable, use that
626       staff
628       (if (not (list? type_from_structure))
629         ; No entry in structure found => simple staff
630         (oly:staff_handler parser piece name "Staff" '())
632         ; Entry found in structure => use the handler for the given type
633         (let* ((type (car type_from_structure))
634                (handler (assoc-ref oly:staff_handlers type))
635                (children (cadr type_from_structure))
636               )
637           (if handler
638             ((primitive-eval handler) parser piece name type children)
639             (begin
640               (ly:warning "No handler found for staff type ~a, using default staff handler" type)
641               (oly:staff_handler parser piece name type children)
642             )
643           )
644         )
645       )
646     )
647   )
650 #(define (oly:dynamics_handler parser piece name type children)
651   (oly:voice_handler parser piece name type)
655 %%=====================================================================
656 %% Handler definitions
657 %%---------------------------------------------------------------------
659 #(define oly:staff_handlers
660   (list
661     ; staff group types
662     '("GrandStaff" . oly:staff_group_handler )
663     '("PianoStaff" . oly:staff_group_handler )
664     '("ChoirStaff" . oly:staff_group_handler )
665     '("StaffGroup" . oly:staff_group_handler )
666     '("ParallelMusic" . oly:staff_group_handler )
667     '("SimultaneousMusic" . oly:staff_group_handler )
668     ; staff types
669     '("Staff" . oly:staff_handler )
670     '("DrumStaff" . oly:staff_handler )
671     '("RhythmicStaff" . oly:staff_handler )
672     '("TabStaff" . oly:staff_handler )
673     '("GregorianTranscriptionStaff" . oly:staff_handler )
674     '("MensuralStaff" . oly:staff_handler )
675     '("VaticanaStaff" . oly:staff_handler )
676     ; staves with multiple voices
677     '("PartCombinedStaff" . oly:part_combined_staff_handler )
678     '("ParallelVoicesStaff" . oly:parallel_voices_staff_handler )
679     ; special cases: Figured bass can be staff or voice type!
680     '("FiguredBass" . oly:figured_bass_staff_handler )
681     ; Devnull is like a staff, only that it doesn't craete output
682     '("Devnull" . oly:devnull_handler )
683     '("Dynamics" . oly:dynamics_handler )
684   )
687 #(define oly:voice_handlers
688   (list
689     ; voice types
690     '("Voice" . oly:voice_handler )
691     '("CueVoice" . oly:voice_handler )
692     '("DrumVoice" . oly:voice_handler )
693     '("FiguredBass" . oly:voice_handler )
694     '("GregorianTranscriptionVoice" . oly:voice_handler )
695     '("NoteNames" . oly:voice_handler )
696     '("TabVoice" . oly:voice_handler )
697     '("VaticanaVoice" . oly:voice_handler )
698   )
702 #(define (oly:register_staff_type_handler type func)
703 ;  (ly:message "Registering staff handler ~a for type ~a" func type)
704   (set! oly:staff_handlers (assoc-set! oly:staff_handlers type func))
707 #(define (oly:register_voice_type_handler type func)
708 ;  (ly:message "Registering voice type handler ~a for type ~a" func type)
709   (set! oly:voice_handlers (assoc-set! oly:voice_handlers type func))
712 % handlers for deprecated API
713 #(oly:register_staff_type_handler 'StaffGroup 'oly:staff_group_handler)
714 #(oly:register_staff_type_handler 'GrandStaff 'oly:staff_group_handler)
715 #(oly:register_staff_type_handler 'PianoStaff 'oly:staff_group_handler)
716 #(oly:register_staff_type_handler 'ChoirStaff 'oly:staff_group_handler)
717 #(oly:register_staff_type_handler 'Staff 'oly:staff_handler )
718 #(oly:register_staff_type_handler 'ParallelMusic 'oly:staff_group_handler)
719 #(oly:register_staff_type_handler 'SimultaneousMusic 'oly:staff_group_handler)
720 #(oly:register_staff_type_handler #t 'oly:part_combined_staff_handler )
721 #(oly:register_staff_type_handler #f 'oly:parallel_voices_staff_handler )
725 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
726 % Automatic score generation
727 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
729 #(define oly:score_handler add-score)
730 #(define oly:music_handler add-music)
731 #(define oly:text_handler add-text)
734 % TODO: deprecate
735 setUseBook = #(define-music-function (parser location usebook) (boolean?)
736   (ly:warning "\\setUseBook has been deprecated! Books are now automatically handled without any hacks")
737   (make-music 'Music 'void #t)
741 % Two functions to handle midi-blocks: Either don't set one, or set an empty
742 % one so that MIDI is generated
743 #(define (oly:set_no_midi_block score) '())
744 #(define (oly:set_midi_block score)
745   (let* ((midiblock (if (defined? '$defaultmidi)
746                         (ly:output-def-clone $defaultmidi)
747                         (ly:make-output-def))))
748     (ly:output-def-set-variable! midiblock 'is-midi #t)
749     (ly:score-add-output-def! score midiblock)
750   )
753 % \setCreateMidi ##t/##f sets a flag to determine wheter MIDI output should
754 % be generated
755 #(define oly:apply_score_midi oly:set_no_midi_block)
756 setCreateMIDI = #(define-music-function (parser location createmidi) (boolean?)
757   (if createmidi
758     (set! oly:apply_score_midi oly:set_midi_block)
759     (set! oly:apply_score_midi oly:set_no_midi_block)
760   )
761   (make-music 'Music 'void #t)
765 % Two functions to handle layout-blocks: Either don't set one, or set an empty
766 % one so that a PDF is generated
767 #(define (oly:set_no_layout_block score) '())
768 #(define (oly:set_layout_block score)
769   (let* ((layoutblock (if (defined? '$defaultlayout)
770                         (ly:output-def-clone $defaultlayout)
771                         (ly:make-output-def))))
772     (ly:output-def-set-variable! layoutblock 'is-layout #t)
773     (ly:score-add-output-def! score layoutblock)
774   )
777 % \setCreatePDF ##t/##f sets a flag to determine wheter PDF output should
778 % be generated
779 #(define oly:apply_score_layout oly:set_no_layout_block)
780 setCreatePDF = #(define-music-function (parser location createlayout) (boolean?)
781   (if createlayout
782     (set! oly:apply_score_layout oly:set_layout_block)
783     (set! oly:apply_score_layout oly:set_no_layout_block)
784   )
785   (make-music 'Music 'void #t)
789 % Set the piece title in a new header block.
790 #(define (oly:set_piece_header score piecename)
791   (if (not-null? piecename)
792     (let* ((header (make-module)))
793       (module-define! header 'piece piecename)
794       (ly:score-set-header! score header)
795     )
796   )
800 % post-filter functions. By default, no filtering is done. However,
801 % for the *NoCues* function, the cue notes should be killed
802 identity = #(define-music-function (parser location music) (ly:music?) music)
803 cuefilter = #(define-music-function (parser location music) (ly:music?)
804   ((ly:music-function-extract removeWithTag) parser location 'cued ((ly:music-function-extract killCues) parser location music))
808 #(define (oly:create-toc-file layout pages)
809   (let* ((label-table (ly:output-def-lookup layout 'label-page-table)))
810     (if (not (null? label-table))
811       (let* ((format-line (lambda (toc-item)
812              (let* ((label (car toc-item))
813                     (text  (caddr toc-item))
814                     (label-page (and (list? label-table)
815                                      (assoc label label-table)))
816                     (page (and label-page (cdr label-page))))
817                (format #f "~a, section, 1, {~a}, ~a" page text label))))
818              (formatted-toc-items (map format-line (toc-items)))
819              (whole-string (string-join formatted-toc-items ",\n"))
820              (output-name (ly:parser-output-name parser))
821              (outfilename (format "~a.toc" output-name))
822              (outfile (open-output-file outfilename)))
823         (if (output-port? outfile)
824             (display whole-string outfile)
825             (ly:warning (_ "Unable to open output file ~a for the TOC information") outfilename))
826         (close-output-port outfile)))))
829 #(define-public (oly:add-toc-item parser markup-symbol text)
830   (oly:music_handler parser (add-toc-item! markup-symbol text)))
833 #(define (oly:add-score parser score piecename)
834   (if (not-null? piecename)
835     (oly:add-toc-item parser 'tocItemMarkup piecename))
836   (oly:score_handler parser score)
838 % The helper function to build a score.
839 #(define (oly:createScoreHelper parser location piece children func)
840   (let* (
841          (staves    (oly:staff_group_handler parser piece "" "SimultaneousMusic" children))
842          (music     (if (not-null? staves)
843                         ((ly:music-function-extract func) parser location staves)
844                         '()
845                     ))
846          (score     '())
847          (piecename (namedPieceInstrObject piece (car children) "PieceName"))
848          (piecenametacet (namedPieceInstrObject piece (car children) "PieceNameTacet"))
849          (header    '())
850         )
851     (if (null? music)
852       ; No staves, print tacet
853       (begin
854         (if (not-null? piecenametacet) (set! piecename piecenametacet))
855         (if (not-null? piecename)
856           (oly:add-score parser (list (oly:piece-title-markup piecename)) piecename)
857           (ly:warning (_ "No music and no score title found for part ~a and instrument ~a") piece children)
858         )
859       )
860       ; we have staves, apply the piecename to the score and add layout/midi blocks if needed
861       (begin
862         (set! score (scorify-music music parser))
863         (oly:set_piece_header score piecename)
864         (oly:apply_score_midi score)
865         (oly:apply_score_layout score)
866         ; Schedule the score for typesetting
867         (oly:add-score parser score piecename)
868       )
869     )
870   )
871   ; This is a void function, the score has been schedulled for typesetting already
872   (make-music 'Music 'void #t)
875 createScore = #(define-music-function (parser location piece children) (string? list?)
876   (oly:createScoreHelper parser location piece children identity)
878 createNoCuesScore = #(define-music-function (parser location piece children) (string? list?)
879   (oly:createScoreHelper parser location piece children cuefilter)
882 createHeadline = #(define-music-function (parser location headline) (string?)
883   (oly:add-toc-item parser 'tocItemMarkup headline)
884   (oly:score_handler parser (list (oly:piece-title-markup headline)))
885   (make-music 'Music 'void #t)
890 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
891 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
892 %%%%%   CUE NOTES
893 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
894 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
896 newInstrument = #(define-music-function (parser location instr) (string?)
898   \set Voice.instrumentCueName = #$(string-join (list "+" instr))
901 cueText = #(define-music-function (parser location instr) (string?)
903   \set Voice.instrumentCueName = $instr
907 clearCueText = #(define-music-function (parser location) ()
909   \unset Voice.instrumentCueName
913 insertCueText = #(define-music-function (parser location instr) (string?)
914   (if (string-null? instr)
915     #{ \tag #'cued \clearCueText #}
916     #{ \tag #'cued \cueText #$instr #}
919 % generate a cue music section with instrument names
920 % Parameters: \namedCueDuring NameOfQuote CueDirection CueInstrument OriginalInstrument music
921 %                 -) NameOfQuote CueDirection music are the parameters for \cueDuring
922 %                 -) CueInstrument and OriginalInstrument are the displayed instrument names
923 % typical call:
924 % \namedCueDuring #"vIQuote" #UP #"V.I" #"Sop." { R1*3 }
925 %      This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
926 %      the beginning of the cue notes and "Sop." at the end
927 namedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr cuemusic) (string? number? string? string? ly:music?)
929   \cueDuring #$cuevoice #$direction {
930     \insertCueText #$instrcue
931     $cuemusic
932     \insertCueText #$instr
933   }
936 namedTransposedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr trans cuemusic) (string? number? string? string? ly:music? ly:music?)
937    #{
938      \transposedCueDuring #$cuevoice #$direction $trans {
939        \insertCueText #$instrcue
940        $cuemusic
941        \insertCueText #$instr
942      }
943    #}
946 % set the cue instrument name and clef
947 setClefCue = #(define-music-function (parser location instr clef)
948                                                      (string? ly:music?)
949    #{
950      \once \override Staff.Clef #'font-size = #-3 $clef
951      \insertCueText $instr
952    #} )
954 % generate a cue music section with instrument names and clef changes
955 % Parameters: \cleffedCueDuring NameOfQuote CueDirection CueInstrument CueClef OriginalInstrument OriginalClef music
956 %                 -) NameOfQuote CueDirection music are the parameters for \cueDuring
957 %                 -) CueInstrument and OriginalInstrument are the displayed instrument names
958 %                 -) CueClef and OriginalClef are the clefs for the the cue notes and the clef of the containing voice
959 % typical call:
960 % \cleffedCueDuring #"vIQuote" #UP #"V.I" #"treble" #"Basso" #"bass" { R1*3 }
961 %      This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
962 %      the beginning of the cue notes and "Basso" at the end. The clef is changed to treble at the
963 %      beginning of the cue notes and reset to bass at the end
964 cleffedCueDuring = #(define-music-function (parser location cuevoice direction instrcue clefcue instr clefinstr cuemusic)
965                                                         (string? number? string? ly:music? string? ly:music? ly:music?)
966    #{
967      \cueDuring #$cuevoice #$direction {
968        \tag #'cued \setClefCue #$instrcue $clefcue
969        $cuemusic
970        \tag #'cued \setClefCue #$instr $clefinstr
971      }
972    #}
978 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
979 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
980 %%%%%   DYNAMICS
981 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
982 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
985 dynamicsX = #(define-music-function (parser location offset) (number?)
987     \once \override DynamicText #'X-offset = $offset
988     \once \override DynamicLineSpanner #'Y-offset = #0
991 % Move the dynamic sign inside the staff to a fixed staff-relative position
992 % posY (where 0 means vertically starts at the middle staff line)
993 dynamicsAllInside = #(define-music-function (parser location offsetX posY)
994 (number? number?)
996   % Invalid y-extent -> hidden from skyline calculation and collisions
997 %   \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
998   \once \override DynamicLineSpanner #'Y-extent = $(lambda (grob)
999     (let* ((ext (ly:axis-group-interface::height grob))
1000            (dir (ly:grob-property grob 'direction)))
1001       (if (eq? dir UP)
1002             (cons (- (cdr ext) 0.1) (cdr ext))
1003             (cons (car ext)         (+ (car ext) 0.1)))))
1004   % move by X offset and to fixed Y-position (use Y-offset of parent!)
1005   \once \override DynamicText #'X-offset = $offsetX
1006   \once \override DynamicText #'Y-offset =
1007     $(lambda (grob)
1008        (let* ((head (ly:grob-parent grob Y))
1009               (offset (ly:grob-property head 'Y-offset)))
1010          (- posY  offset (- 0.6))))
1011   \once \override DynamicLineSpanner #'Y-offset = $posY
1014 dynamicsUpInside = #(define-music-function (parser location offsetX) (number?)
1015   ((ly:music-function-extract dynamicsAllInside) parser location offsetX 1.5)
1018 dynamicsDownInside = #(define-music-function (parser location offsetX) (number?)
1019   ((ly:music-function-extract dynamicsAllInside) parser location offsetX -3.5)
1022 hairpinOffset = #(define-music-function (parser location posY) (number?)
1024   \once \override DynamicLineSpanner #'Y-offset = $posY
1025   \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
1028 #(define ((line-break-offset before after) grob)
1029   (let* ((orig (ly:grob-original grob))
1030          ; All siblings if line-broken:
1031          (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
1032     (if (>= (length siblings) 2)
1033       ; We have been line-broken
1034       (if (eq? (car (last-pair siblings)) grob)
1035         ; Last sibling:
1036         (ly:grob-set-property! grob 'Y-offset after)
1037         ; Others get the before value:
1038         (ly:grob-set-property! grob 'Y-offset before)
1039       )
1040     )
1041   )
1044 ffz = #(make-dynamic-script "ffz")
1045 pf = #(make-dynamic-script "pf")
1046 sempp = #(make-dynamic-script (markup #:line( #:with-dimensions '(0 . 0)
1047 '(0 . 0) #:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
1048 parenf = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")" )))
1049 parenp = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "p" #:normal-text #:italic #:fontsize 2 ")" )))
1050 pdolce = #(make-dynamic-script (markup #:line(#:dynamic "p" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce"  )))
1051 sfpdolce = #(make-dynamic-script (markup #:line(#:dynamic "sfp" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce"  )))
1052 bracketf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 3 "[" #:dynamic "f" #:hspace 0.1 #:normal-text #:fontsize 3 "]"))))
1053 bracketmf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 3 "[" #:dynamic "mf" #:hspace 0.1 #:normal-text #:fontsize 3 "]"))))
1054 bracketmp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 2 "[" #:hspace 0.2 #:dynamic "mp" #:normal-text #:fontsize 2 "]"))))
1055 bracketp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 2 "[" #:hspace 0.2 #:dynamic "p" #:normal-text #:fontsize 2 "]"))))
1059 % cresc = #(make-music 'CrescendoEvent 'span-direction START 'crescendoSpanner 'text 'crescendoText "cresc.")
1060 % endcresc =  #(make-span-event 'CrescendoEvent STOP)
1061 % dim = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "dim.")
1062 % enddim =  #(make-span-event 'DecrescendoEvent STOP)
1063 % decresc = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "decresc.")
1064 % enddecresc =  #(make-span-event 'DecrescendoEvent STOP)
1066 % setCresc = {}
1067 % setDecresc = {}
1068 % setDim = {}
1069 cresc = #(make-music 'CrescendoEvent 'span-direction START
1070                      'span-type 'text 'span-text "cresc.")
1071 dim = #(make-music 'DecrescendoEvent 'span-direction START
1072                    'span-type 'text 'span-text "dim.")
1073 decresc = #(make-music 'DecrescendoEvent 'span-direction START
1074                        'span-type 'text 'span-text "decresc.")
1076 newOrOldClef = #(define-music-function (parser location new old ) (string? string?)
1077     (if (ly:get-option 'old-clefs) #{ \clef $old #} #{ \clef $new #})
1082 %%% Thanks to "Gilles THIBAULT" <gilles.thibault@free.fr>, there is a way
1083 %   to remove also the fermata from R1-\fermataMarkup: By filtering the music
1084 %   and removing the corresponding events.
1085 %   Documented as an LSR snippet: http://lsr.dsi.unimi.it/LSR/Item?id=372
1086 #(define (filterOneEventsMarkup event)
1087 ( let ( (eventname (ly:music-property  event 'name)) )
1088  (not
1089   (or     ;; add here event name you do NOT want
1090    (eq? eventname 'MultiMeasureTextEvent)
1091    (eq? eventname 'AbsoluteDynamicEvent)
1092    (eq? eventname 'TextScriptEvent)
1093    (eq? eventname 'ArticulationEvent)
1094    (eq? eventname 'CrescendoEvent)
1095    (eq? eventname 'DecrescendoEvent)
1096   )
1100 filterArticulations = #(define-music-function (parser location music) (ly:music?)
1101    (music-filter filterOneEventsMarkup music)
1108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1110 %%%%%   Tempo markings
1111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1116 rit = \markup {\italic "rit."}
1117 pocorit = \markup {\italic "poco rit."}
1118 ppmosso = \markup {\italic "poco più mosso"}
1119 dolce = \markup {\italic "dolce"}
1120 pizz = \markup {\italic "pizz."}
1121 arco = \markup {\italic "arco"}
1122 perd = \markup {\italic "perdend."}
1127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1129 %%%%%   REST COMBINATION
1130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1135 %% REST COMBINING, TAKEN FROM http://lsr.dsi.unimi.it/LSR/Item?id=336
1137 %% Usage:
1138 %%   \new Staff \with {
1139 %%     \override RestCollision #'positioning-done = #merge-rests-on-positioning
1140 %%   } << \somevoice \\ \othervoice >>
1141 %% or (globally):
1142 %%   \layout {
1143 %%     \context {
1144 %%       \Staff
1145 %%       \override RestCollision #'positioning-done = #merge-rests-on-positioning
1146 %%     }
1147 %%   }
1149 %% Limitations:
1150 %% - only handles two voices
1151 %% - does not handle multi-measure/whole-measure rests
1153 #(define (rest-score r)
1154   (let ((score 0)
1155   (yoff (ly:grob-property-data r 'Y-offset))
1156   (sp (ly:grob-property-data r 'staff-position)))
1157     (if (number? yoff)
1158   (set! score (+ score 2))
1159   (if (eq? yoff 'calculation-in-progress)
1160       (set! score (- score 3))))
1161     (and (number? sp)
1162    (<= 0 2 sp)
1163    (set! score (+ score 2))
1164    (set! score (- score (abs (- 1 sp)))))
1165     score))
1167 #(define (merge-rests-on-positioning grob)
1168   (let* ((can-merge #f)
1169    (elts (ly:grob-object grob 'elements))
1170    (num-elts (and (ly:grob-array? elts)
1171       (ly:grob-array-length elts)))
1172    (two-voice? (= num-elts 2)))
1173     (if two-voice?
1174   (let* ((v1-grob (ly:grob-array-ref elts 0))
1175          (v2-grob (ly:grob-array-ref elts 1))
1176          (v1-rest (ly:grob-object v1-grob 'rest))
1177          (v2-rest (ly:grob-object v2-grob 'rest)))
1178     (and
1179      (ly:grob? v1-rest)
1180      (ly:grob? v2-rest)
1181      (let* ((v1-duration-log (ly:grob-property v1-rest 'duration-log))
1182       (v2-duration-log (ly:grob-property v2-rest 'duration-log))
1183       (v1-dot (ly:grob-object v1-rest 'dot))
1184       (v2-dot (ly:grob-object v2-rest 'dot))
1185       (v1-dot-count (and (ly:grob? v1-dot)
1186              (ly:grob-property v1-dot 'dot-count -1)))
1187       (v2-dot-count (and (ly:grob? v2-dot)
1188              (ly:grob-property v2-dot 'dot-count -1))))
1189        (set! can-merge
1190        (and
1191         (number? v1-duration-log)
1192         (number? v2-duration-log)
1193         (= v1-duration-log v2-duration-log)
1194         (eq? v1-dot-count v2-dot-count)))
1195        (if can-merge
1196      ;; keep the rest that looks best:
1197      (let* ((keep-v1? (>= (rest-score v1-rest)
1198               (rest-score v2-rest)))
1199       (rest-to-keep (if keep-v1? v1-rest v2-rest))
1200       (dot-to-kill (if keep-v1? v2-dot v1-dot)))
1201        ;; uncomment if you're curious of which rest was chosen:
1202        ;;(ly:grob-set-property! v1-rest 'color green)
1203        ;;(ly:grob-set-property! v2-rest 'color blue)
1204        (ly:grob-suicide! (if keep-v1? v2-rest v1-rest))
1205        (if (ly:grob? dot-to-kill)
1206            (ly:grob-suicide! dot-to-kill))
1207        (ly:grob-set-property! rest-to-keep 'direction 0)
1208        (ly:rest::y-offset-callback rest-to-keep)))))))
1209     (if can-merge
1210   #t
1211   (ly:rest-collision::calc-positioning-done grob))))
1217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1219 %%%%%   TABLE OF CONTENTS
1220 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1224 contentsTitle = "Inhalt / Contents"
1226 \paper {
1227   tocTitleMarkup = \markup \fill-line{
1228     \null
1229     \column {
1230       \override #(cons 'line-width (* 7 cm))
1231       \line{ \fill-line {\piece-title {\contentsTitle} \null }}
1232       \hspace #1
1233     }
1234     \null
1235   }
1236   tocItemMarkup = \markup \fill-line {
1237     \null
1238     \column {
1239       \override #(cons 'line-width (* 7 cm ))
1240       \line { \fill-line{\fromproperty #'toc:text \fromproperty #'toc:page }}
1241     }
1242     \null
1243   }
1247 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1249 %%%%%   TITLE PAGE / HEADER
1250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1253 #(define-markup-command (when-property layout props symbol markp) (symbol? markup?)
1254   (if (chain-assoc-get symbol props)
1255       (interpret-markup layout props markp)
1256       (ly:make-stencil '()  '(1 . -1) '(1 . -1))))
1258 #(define-markup-command (vspace layout props amount) (number?)
1259   "This produces a invisible object taking vertical space."
1260   (let ((amount (* amount 3.0)))
1261     (if (> amount 0)
1262         (ly:make-stencil "" (cons -1 1) (cons 0 amount))
1263         (ly:make-stencil "" (cons -1 1) (cons amount amount)))))
1267 titlePageMarkup = \markup \abs-fontsize #10 \when-property #'header:title \column {
1268     \vspace #4
1269     \fill-line { \fontsize #8 \fromproperty #'header:composer }
1270     \vspace #1
1271     \fill-line { \fontsize #8 \fromproperty #'header:poet }
1272     \vspace #4
1273     \fill-line { \fontsize #10 \bold \fromproperty #'header:titlepagetitle }
1274     \vspace #1
1275     \fontsize #2 \when-property #'header:titlepagesubtitle {
1276       \fill-line { \fromproperty #'header:titlepagesubtitle }
1277       \vspace #1
1278     }
1279     \fill-line { \postscript #"-20 0 moveto 40 0 rlineto stroke" }
1280     \vspace #8
1281     \fill-line { \fontsize #5 \fromproperty #'header:ensemble }
1282     \vspace #0.02
1283     \fill-line { \fontsize #2 \fromproperty #'header:instruments }
1284     \vspace #9
1285     \fill-line { \fontsize #5 \fromproperty #'header:date }
1286     \vspace #1
1287     \fill-line { \fontsize #5 \fromproperty #'header:scoretype }
1288     \vspace #8
1289     \fontsize #2 \when-property #'header:enteredby {
1290       \fill-line { "Herausgegeben von: / Edited by:"}
1291       \vspace #0.
1292       \fill-line { \fromproperty #'header:enteredby }
1293     }
1294     \fill-line {
1295       \when-property #'header:arrangement \column {
1296         \vspace #8
1297         \fill-line { \fontsize #3 \fromproperty #'header:arrangement }
1298       }
1299     }
1302 titleHeaderMarkup = \markup {
1303   \override #'(baseline-skip . 3.5)
1304   \column {
1305     \fill-line {
1306       \fromproperty #'header:logo
1307       \center-column {
1308         \huge \larger \bold \larger \fromproperty #'header:title
1309         \large \smaller \bold \larger \fromproperty #'header:subtitle
1310         \smaller \bold \fromproperty #'header:subsubtitle
1311       }
1312       \bold \when-property #'header:instrument \rounded-box \fromproperty #'header:instrument
1313     }
1314     \fill-line {
1315       \with-dimensions #'( 0 . 0) #'( 0 . 1 ) \null
1316     }
1318 %     \fill-line {
1319 %       { \large \bold \fromproperty #'header:instrument }
1320 %     }
1321     \fill-line {
1322       \fromproperty #'header:poet
1323       \fromproperty #'header:composer
1324     }
1325     \fill-line {
1326       \fromproperty #'header:meter
1327       \fromproperty #'header:arranger
1328     }
1329   }
1332 titleScoreMarkup = \markup \piece-title \fromproperty #'header:piece
1334 \paper {
1335   scoreTitleMarkup = \titleScoreMarkup
1336   bookTitleMarkup = \titleHeaderMarkup
1341 %%%%%%%%%%%%%% headers and footers %%%%%%%%%%%%%%%%%%%%%%%%%%
1343 #(define (first-score-page layout props arg)
1344   (let* ((label 'first-score-page)
1345          (table (ly:output-def-lookup layout 'label-page-table))
1346          (label-page (and (list? table) (assoc label table)))
1347          (page-number (and label-page (cdr label-page)))
1348         )
1349     (if (eq? (chain-assoc-get 'page:page-number props -1) page-number)
1350       (interpret-markup layout props arg)
1351       empty-stencil)))
1353 #(define no-header-table '())
1354 thisPageNoHeader = #(define-music-function (parser location) ()
1355   (let* ((label (gensym "header")))
1356     (set! no-header-table (cons label no-header-table))
1357     (make-music 'Music
1358       'page-marker #t
1359       'page-label label)))
1362 % TODO: Use the no-header-table!
1363 #(define (is-header-page layout props arg)
1364   (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1365         )
1366     ;(if (and (> page-number 2) (!= page-number 7))
1367     (if (> page-number 1)
1368       (interpret-markup layout props arg)
1369       empty-stencil)))
1371 #(define no-footer-table '())
1372 thisPageNoFooter = #(define-music-function (parser location) ()
1373   (let* ((label (gensym "footer")))
1374     (set! no-footer-table (cons label no-footer-table))
1375     (make-music 'Music
1376       'page-marker #t
1377       'page-label label)))
1379 % TODO: Use the no-footer-table!
1380 #(define (is-footer-page layout props arg)
1381   (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1382          (label 'first-score-page)
1383          (table (ly:output-def-lookup layout 'label-page-table))
1384          (label-page (and (list? table) (assoc label table)))
1385          ;(page-number (and label-page (cdr label-page)))
1386         )
1387     (if (and (> page-number 1))
1388       (interpret-markup layout props arg)
1389       empty-stencil)))
1392 #(define copyright-footer-table '())
1393 thisPageCopyrightFooter = #(define-music-function (parser location) ()
1394   (let* ((label (gensym "copyrightfooter")))
1395     (set! copyright-footer-table (cons label copyright-footer-table))
1396     (make-music 'Music
1397       'page-marker #t
1398       'page-label label)))
1400 #(define copyright-pg 1)
1401 #(define (set-copyright-page page)
1402   (set! copyright-pg page)
1405 % TODO: Use the copyright-footer-table!
1406 #(define (copyright-page layout props arg)
1407     (if (= (chain-assoc-get 'page:page-number props -1) copyright-pg)
1408       (interpret-markup layout props arg)
1409       empty-stencil))
1412 \paper {
1413   oddHeaderMarkup = \markup \fill-line {
1414     %% force the header to take some space, otherwise the
1415     %% page layout becomes a complete mess.
1416     " "
1417     \on-the-fly #is-header-page \fromproperty #'header:title
1418     \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1419   }
1420   evenHeaderMarkup = \markup \fill-line {
1421     \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1422     \on-the-fly #is-header-page \fromproperty #'header:composer
1423     " "
1424   }
1426   oddFooterMarkup = \markup {
1427     \column {
1428       \fill-line {
1429         %% publisher header field only on title page.
1430         \on-the-fly #first-page \fromproperty #'header:publisher
1431       }
1432       \fill-line {
1433         %% copyright on the first real score page
1434         \on-the-fly #copyright-page \fromproperty #'header:copyright
1435         \on-the-fly #copyright-page \null
1436       }
1437       \fill-line {
1438         %% All other pages get the number of the edition centered
1439         \on-the-fly #is-footer-page \fromproperty #'header:scorenumber
1440       }
1441     }
1442   }
1456 % Interpret the given markup with the header fields added to the props.
1457 % This way, one can re-use the same functions (using fromproperty
1458 % #'header:field) in the header block and as top-level markup.
1460 % This function is originally copied from mark-up-title (file scm/titling.scm),
1461 % which is lilypond's internal function to handle the title markups. I needed
1462 % to replace the scopes and manually add the $defaultheader (which is internally
1463 % done in paper-book.cc before calling mark-up-title. Also, I don't extract the
1464 % markup from the header block, but use the given markup.
1466 % I'm not sure if I really need the page properties in props, too... But I
1467 % suppose it does not hurt, either.
1468 #(define-markup-command (markupWithHeader layout props markup) (markup?)
1469   "Interpret the given markup with the header fields added to the props.
1470    This way, one can re-use the same functions (using fromproperty
1471    #'header:field) in the header block and as top-level markup."
1472   (let* (
1473       ; TODO: If we are inside a score, add the score's local header block, too!
1474       ; Currently, I only use the global header block, stored in $defaultheader
1475       (scopes (list $defaultheader))
1476       (alists (map ly:module->alist scopes))
1478       (prefixed-alist
1479         (map (lambda (alist)
1480           (map (lambda (entry)
1481             (cons
1482               (string->symbol (string-append "header:" (symbol->string (car entry))))
1483               (cdr entry)))
1484             alist))
1485           alists))
1486       (props (append prefixed-alist
1487               props
1488               (layout-extract-page-properties layout)))
1489     )
1490     (interpret-markup layout props markup)
1491   )
1499 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1500 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1501 %%%%%   Equally spacing multiple columns (e.g. for translations)
1502 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1503 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1505 % Credits: Nicolas Sceaux on the lilypond-user mailinglist
1506 #(define-markup-command (columns layout props args) (markup-list?)
1507    (let ((line-width (/ (chain-assoc-get 'line-width props
1508                          (ly:output-def-lookup layout 'line-width))
1509                         (max (length args) 1))))
1510      (interpret-markup layout props
1511        (make-line-markup (map (lambda (line)
1512                                 (markup #:pad-to-box `(0 . ,line-width) '(0 . 0)
1513                                   #:override `(line-width . ,line-width)
1514                                   line))
1515                                args)))))
1519 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1520 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1521 %%%%%   SCORE (HEADER / LAYOUT) SETTINGS
1522 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1526 startSlashedGraceMusic =  {
1527   \override Stem  #'stroke-style = #"grace"
1530 stopSlashedGraceMusic =  {
1531   \revert Stem #'stroke-style
1534 slashedGrace =
1535 #(def-grace-function startSlashedGraceMusic stopSlashedGraceMusic
1536    (_i "Create slashed graces (slashes through stems, but no slur)from the following music expression"))
1539 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1540 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1541 %%%%%   SCORE (HEADER / LAYOUT) SETTINGS
1542 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1543 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1545 \paper {
1546   left-margin = 2\cm
1547   right-margin = 1.5\cm
1548   line-width = 17.5\cm
1549 %   bottom-margin = 1.5\cm
1550   top-margin = 1.2\cm
1551 %   after-title-space = 0.5\cm
1552   ragged-right = ##f
1553   ragged-last = ##f
1554   ragged-bottom = ##f
1555   ragged-last-bottom = ##f
1557 \layout {
1558   \context {
1559     \ChoirStaff
1560     % If only one non-empty staff in a system exists, still print the backet
1561     \override SystemStartBracket #'collapse-height = #1
1562     \consists "Instrument_name_engraver"
1563   }
1564   \context {
1565     \StaffGroup
1566     % If only one non-empty staff in a system exists, still print the backet
1567     \override SystemStartBracket #'collapse-height = #1
1568     \consists "Instrument_name_engraver"
1569   }
1570   \context {
1571     \GrandStaff
1572     \override SystemStartBracket #'collapse-height = #1
1573     \consists "Instrument_name_engraver"
1574   }
1575   \context {
1576     \FiguredBass
1577 %     \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1578 %     \override VerticalAxisGroup #'minimum-Y-extent  = #' % TODO: Removed
1579     \override VerticalAxisGroup #'padding = #0
1580   }
1581   \context {
1582     \Score
1583     % Force multi-measure rests to be written as one span
1584     \override MultiMeasureRest #'expand-limit = #3
1585     skipBars = ##t
1586     autoBeaming = ##f
1587 %     \override Hairpin #'to-barline = ##f
1588 %     \override BarNumber #'break-visibility = #end-of-line-invisible
1589 %     \override BarNumber #'self-alignment-X = #0
1590 %     barNumberVisibility = #(every-nth-bar-number-visible 5)
1591     \override CombineTextScript #'avoid-slur = #'outside
1592     \override DynamicTextSpanner #'dash-period = #-1.0
1593     \override InstrumentSwitch #'font-size = #-1
1595     % Rest collision
1596     \override RestCollision #'positioning-done = #merge-rests-on-positioning
1597     % Auto-Accidentals: Use modern-cautionary style...
1598     extraNatural = ##f
1599     autoAccidentals = #`(Staff  ,(make-accidental-rule 'same-octave 0)
1600                                 ,(make-accidental-rule 'any-octave 0)
1601                                 ,(make-accidental-rule 'same-octave 1))
1602 %     autoCautionaries = #`(Staff ,(make-accidental-rule 'any-octave 0)
1603 %                                 ,(make-accidental-rule 'same-octave 1))
1604     printKeyCancellation = ##t
1605     quotedEventTypes = #'(StreamEvent)
1606     implicitBassFigures = #'(0 100)
1607   }
1608   \context {
1609     \Staff
1610     \RemoveEmptyStaves
1611   }
1615 ts = ^\markup{"t.s."}
1616 tt = ^\markup{"Tutti"}
1617 solo = ^\markup{"Solo"}
1618 tutti = ^\markup{"Tutti"}
1619 bracketts = ^\markup{"[Solo]"}
1620 brackettt = ^\markup{"[Tutti]"}
1621 bracketsolo = ^\markup{"[Solo]"}
1623 dashedSlur = -\tweak #'dash-definition #'((0 1 0.4 0.75))(
1624 dashedTie = -\tweak #'dash-definition #'((0 1 0.4 0.75))~
1626 divisi = #(define-music-function (parser location vc1 vc2) (ly:music? ly:music?)
1628   << { \voiceOne $vc1 \oneVoice} \new Voice = "divisi2" { \voiceTwo $vc2 } >>
1632 #(define twoVoice divisi)
1634 #(define-public (bracket-stencils grob)
1635   (let ((lp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "[")))
1636         (rp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "]"))))
1637     (list lp rp)))
1639 bracketify = #(define-music-function (parser loc arg) (ly:music?)
1640    (_i "Tag @var{arg} to be parenthesized.")
1642   \once \override ParenthesesItem #'stencils = #bracket-stencils
1643   \parenthesize $arg
1648 #(define-markup-command (hat layout props arg) (markup?)
1649   "Draw a hat above the given string @var{arg}."
1650   (interpret-markup layout props (markup #:combine #:raise 1.5 "^" arg)))
1654 smallFlageolet =
1655 #(let ((m (make-music 'ArticulationEvent
1656                       'articulation-type "flageolet")))
1657    (ly:music-set-property! m 'tweaks
1658      (acons 'font-size -2
1659        (ly:music-property m 'tweaks)))
1660   m)
1663 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1664 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1665 %%%%%   LICENSE TEXTS
1666 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1667 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1669 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" }}
1670 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" }}
1671 LicenseNoRestrictions = \markup{\line {Die Ausgabe darf kopiert und ohne Einschränkungen aufgeführt werden. / May be copied and performed without restriction.}}
1673 \include "sceaux_clef-key.ily"
1676 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1677 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1678 %%%%%   VARIOUS
1679 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1680 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1682 startUnremovableSection = \set Staff.keepAliveInterfaces =
1683  #'(rhythmic-grob-interface
1684     rest-interface
1685     lyric-interface
1686     percent-repeat-item-interface
1687     percent-repeat-interface
1688     stanza-number-interface)
1690 endUnremovableSection = \unset Staff.keepAliveInterfaces
1693 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1694 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1695 %%%%%   EDITORIAL ANNOTATIONS
1696 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1697 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1699 #(define-public (editorial-bracket-stencil stil padding widen)
1700 "Add brackets for editorial annoations around STIL, producing a new stencil."
1701 (let* ((axis Y)
1702        (other-axis (lambda (a) (remainder (+ a 1) 2)))
1703        (ext (interval-widen (ly:stencil-extent stil axis) widen))
1704        (thick 0.15)
1705        (protrusion 0.3)
1706        (lb (ly:bracket axis ext thick protrusion))
1707        (rb (ly:bracket axis ext thick (- protrusion))))
1708   (set! stil (ly:stencil-combine-at-edge stil (other-axis axis) 1 rb padding))
1709   (set! stil
1710     (ly:stencil-combine-at-edge lb (other-axis axis) 1 stil padding))
1711   stil))
1713 editorialHairpin = \once \override Hairpin     #'stencil = #(lambda (grob) (editorial-bracket-stencil (ly:hairpin::print grob) 0.2 0.55))
1714 editorialDynamic = \once \override DynamicText #'stencil = #(lambda (grob) (editorial-bracket-stencil (ly:text-interface::print grob) 0.2 0.55))
1715 editorialMarkup =  \once \override TextScript  #'stencil = #(lambda (grob) (editorial-bracket-stencil (ly:text-interface::print grob) 0.2 0.55))