3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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/
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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 % Use relative include pathes!
29 #(ly:set-option 'relative-includes #t)
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 %%%%% SCORE STRUCTURE AND AUTOMATIC GENERATION
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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)
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))
57 ((defined? fullname) (primitive-eval fullname))
58 ((defined? instrname) (primitive-eval instrname))
59 ((defined? piecename) (primitive-eval piecename))
60 ((defined? fallback) (primitive-eval fallback))
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)
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)
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:StringEnsembleScoreStructure '(
110 ("FullScore" "StaffGroup" ("VI" "VII" "Va" "Vc" "Cb" "VcB"))
113 #(define oly:fullOrchestraScoreStructure '(
114 ; Part-combined staves for full score
115 ("Fl" "PartCombinedStaff" ("FlI" "FlII"))
116 ("Ob" "PartCombinedStaff" ("ObI" "ObII"))
117 ("Cl" "PartCombinedStaff" ("ClI" "ClII"))
118 ("Fag" "PartCombinedStaff" ("FagI" "FagII"))
119 ("Wd" "StaffGroup" ("Fl" "Ob" "Cl" "Fag" "CFag"))
121 ("Cor" "PartCombinedStaff" ("CorI" "CorII"))
122 ("Tbe" "PartCombinedStaff" ("TbeI" "TbeII"))
123 ("Clni" "PartCombinedStaff" ("ClnoI" "ClnoII"))
124 ("Trb" "PartCombinedStaff" ("TrbI" "TrbII"))
125 ("Br" "StaffGroup" ("Cor" "Tbe" "Clni" "Trb" "Tba"))
127 ; long score; no part-combined staves, but GrandStaves instead
128 ("FlLong" "GrandStaff" ("FlI" "FlII"))
129 ("ObLong" "GrandStaff" ("ObI" "ObII"))
130 ("ClLong" "GrandStaff" ("ClI" "ClII"))
131 ("FagLong" "GrandStaff" ("FagI" "FagII"))
132 ("WdLong" "StaffGroup" ("FlLong" "ObLong" "ClLong" "FagLong" "CFag"))
134 ("CorLong" "GrandStaff" ("CorI" "CorII"))
135 ("TbeLong" "GrandStaff" ("TbeI" "TbeII"))
136 ("ClniLong" "GrandStaff" ("ClnoI" "ClnoII" "ClnoIII"))
137 ("TrbLong" "GrandStaff" ("TrbI" "TrbII" "TrbIII"))
138 ("BrLong" "StaffGroup" ("CorLong" "TbeLong" "ClniLong" "TrbLong" "Tba"))
141 ("Perc" "StaffGroup" ("Tim"))
143 ; Strings, they are the same in long and short full score
144 ("VV" "GrandStaff" ("VI" "VII"))
145 ("Str" "StaffGroup" ("VV" "Va"))
146 ("VceB" "StaffGroup" ("Vc" "Cb" "VcB"))
147 ("FullStr" "StaffGroup" ("VV" "Va" "Vc" "Cb" "VcB"))
150 ("Solo" "SimultaneousMusic" ("SSolo" "ASolo" "TSolo" "BSolo"))
151 ("Ch" "ChoirStaff" ("S" "A" "T" "B"))
152 ("ChoralScore" "SimultaneousMusic" ("Ch"))
153 ("SoloScore" "SimultaneousMusic" ("Solo"))
154 ("SoloChoirScore" "SimultaneousMusic" ("Solo" "Ch"))
156 ; Organ score (inkl. Figured bass)
157 ("BCFb" "FiguredBass" ())
158 ("FiguredBass" "FiguredBass" ())
159 ;("Organ" "SimultaneousMusic" ("BCFb" "O"))
160 ("Continuo" "ParallelVoicesStaff" ("BCFb" "BC" "FiguredBass"))
161 ("RealizedContinuo" "PianoStaff" ("BCRealization" "Continuo"))
163 ("P" "PianoStaff" ("PI" "PII"))
164 ("O" "PianoStaff" ("OI" "OII"))
165 ("OI" "ParallelVoicesStaff" ("OIa" "OIb"))
166 ("OII" "ParallelVoicesStaff" ("OIIa" "OIIb"))
168 ;("Organ" "SimultaneousMusic" ("OGroup" "RealizedContinuo"))
169 ;("BassGroup" "ParallelVoicesStaff" ("Organ" "O" "BC" "VceB"))
170 ("BassGroup" "StaffGroup" ("O" "RealizedContinuo" "Vc" "Cb" "VcB"))
173 ("FullScore" "SimultaneousMusic" ("Wd" "Br" "Perc" "Str" "SoloChoirScore" "BassGroup"))
174 ("LongScore" "SimultaneousMusic" ("WdLong" "BrLong" "Perc" "Str" "SoloChoirScore" "BassGroup"))
175 ("OriginalScore" "SimultaneousMusic" ("BrLong" "WdLong" "Perc" "Str" "SoloChoirScore" "BassGroup"))
178 ;("Piano" "SimultaneousMusic" ("Organ"))
179 ("OrganScore" "SimultaneousMusic" ("SoloChoirScore" "O"))
180 ("VocalScore" "SimultaneousMusic" ("SoloChoirScore" "P"))
181 ("Particell" "SimultaneousMusic" ("ChoralScore" "BassGroup"))
183 ; Full scores: Orchestral score and long score including organ
184 ("ChStrQ" "SimultaneousMusic" ("Str" "Ch" "VceB"))
186 #(define oly:orchestral_score_structure oly:fullOrchestraScoreStructure)
188 #(define (oly:set_score_structure struct)
190 (set! oly:orchestral_score_structure struct)
191 (ly:warning (_ "oly:set_score_structure needs an association list as argument!"))
195 #(define (oly:modify_score_structure entry)
197 (set! oly:orchestral_score_structure (assoc-set! oly:orchestral_score_structure (car entry) (cdr entry)))
198 (ly:warning (_ "oly:modify_score_structure expects a list (\"key\" \"type\" '(children)) as argument!"))))
200 #(define (oly:remove_from_score_structure entry)
202 (map oly:remove_from_score_structure entry)
203 (set! oly:orchestral_score_structure (assoc-remove! oly:orchestral_score_structure entry))))
205 orchestralScoreStructure = #(define-music-function (parser location structure) (list?)
206 (oly:set_score_structure structure)
207 (make-music 'Music 'void #t)
210 #(define oly:voice_types '())
212 #(define (oly:set_voice_types types)
214 (set! oly:voice_types types)
215 (ly:warning (_ "oly:set_voice_types needs an association list as argument!"))
219 orchestralVoiceTypes = #(define-music-function (parser location types) (list?)
220 (oly:set_voice_types types)
221 (make-music 'Music 'void #t)
225 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226 % Automatic staff and group generation
227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
229 % Retrieve all music definitions for the given
230 #(define (oly:get_music_object piece instrument)
231 (namedPieceInstrObject piece instrument "Music")
233 #(define (oly:get_music_objects piece instruments)
234 (filter not-null? (map (lambda (i) (oly:get_music_object piece i)) instruments))
237 % Given a property name and the extensions, either generate the pair to set
238 % the property or an empty list, if no pre-defined variable could be found
239 #(define (oly:generate_property_pair prop piece instr type)
240 (let* ((val (namedPieceInstrObject piece instr type)))
241 (if (not-null? val) (list 'assign prop val) '() )
245 #(define (oly:staff_type type)
247 ((string? type) (string->symbol type))
248 ((symbol? type) type)
253 % extract the pitch from the music (can also be a raw pitch object!)
254 #(define (oly:extractPitch music)
256 (elems (if (ly:music? music) (ly:music-property music 'elements)))
257 (note (if (pair? elems) (car elems)))
258 (mpitch (if (ly:music? note) (ly:music-property note 'pitch)))
259 (pitch (if (ly:pitch? music) music mpitch))
261 (if (and (not-null? music) (not (ly:pitch? pitch)))
262 (ly:warning "Unable to interpret as a pitch!")
268 #(define (oly:extractTranspositionPitch piece name)
270 (trpFromPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeFrom")))
271 (trpToPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeTo")))
273 (if (ly:pitch? trpFromPitch)
274 (if (ly:pitch? trpToPitch)
276 (ly:pitch-diff trpFromPitch trpToPitch)
277 (ly:pitch-diff trpFromPitch (ly:make-pitch 0 0 0))
279 (if (ly:pitch? trpToPitch)
280 (ly:pitch-diff (ly:make-pitch 0 0 0) trpToPitch)
288 %%=====================================================================
289 %% Extract context modifications for given objects
290 %%---------------------------------------------------------------------
293 % TODO: join these property extractors to avoid code duplication
295 % Generate the properties for the lyrics for piece and instr.
296 % Also check whether we have a modifications object to fech mods from.
297 % return a (possibly empty) list of all assignments.
298 #(define (oly:lyrics_handler_properties piece name lyricsid)
300 (mods (namedPieceInstrObject piece name (string-append lyricsid "Modifications")))
301 (mod-list (if (not-null? mods) (ly:get-context-mods mods) '()))
303 ;(instrumentName . "InstrumentName")
304 ;(shortInstrumentName . "ShortInstrumentName")
305 ;(midiInstrument . "MidiInstrument")
309 (oly:generate_property_pair (car pr) piece name (cdr pr))
312 (olyprops (filter not-null? assignments))
313 (props (append mod-list olyprops))
319 % Generate the properties for the voice for piece and instr.
320 % Also check whether we have a modifications object to fech mods from.
321 % return a (possibly empty) list of all assignments.
322 #(define (oly:voice_handler_properties piece name)
324 (mods (namedPieceInstrObject piece name "VoiceModifications"))
325 (mod-list (if (not-null? mods) (ly:get-context-mods mods) '()))
327 ;(instrumentName . "InstrumentName")
328 ;(shortInstrumentName . "ShortInstrumentName")
329 ;(midiInstrument . "MidiInstrument")
333 (oly:generate_property_pair (car pr) piece name (cdr pr))
336 (olyprops (filter not-null? assignments))
337 (props (append mod-list olyprops))
343 % Generate the properties for the staff for piece and instr. Typically, these
344 % are the instrument name and the short instrument name (if defined).
345 % Also check whether we have a modifications object to fech mods from.
346 % return a (possibly empty) list of all assignments.
347 #(define (oly:staff_handler_properties piece instr)
349 (mods (namedPieceInstrObject piece instr "StaffModifications"))
350 (mod-list (if (not-null? mods) (ly:get-context-mods mods) '()))
352 (instrumentName . "InstrumentName")
353 (shortInstrumentName . "ShortInstrumentName")
354 (midiInstrument . "MidiInstrument")
358 (oly:generate_property_pair (car pr) piece instr (cdr pr))
361 (olyprops (filter not-null? assignments))
362 (props (append mod-list olyprops))
371 %%=====================================================================
372 %% Extract contents for voices
373 %%---------------------------------------------------------------------
375 #(define (oly:musiccontent_for_voice parser piece name music additional)
376 (let* ((musiccontent additional))
378 ; Append the settings, key and clef (if defined)
381 (let* ((object (namedPieceInstrObject piece name type)))
382 (if (ly:music? object)
383 (set! musiccontent (append musiccontent (list (ly:music-deep-copy object))))
384 (if (not-null? object) (ly:warning (_ "Wrong type (no ly:music) for ~S for instrument ~S in piece ~S") type name piece))
388 ; TODO: Does the "Tempo" work here???
389 '("Settings" "Key" "Clef" "TimeSignature" "ExtraSettings";"Tempo"
393 (if (ly:music? music)
395 (set! musiccontent (make-sequential-music (append musiccontent (list music))))
396 ;(ly:message "Generating staff for ~a" name)
397 (let* ((trpPitch (oly:extractTranspositionPitch piece name)))
398 (if (ly:pitch? trpPitch)
399 (set! musiccontent (ly:music-transpose musiccontent trpPitch))
404 ; For empty music, return empty
412 %%=====================================================================
414 %%---------------------------------------------------------------------
417 #(define (oly:lyrics_create_single_context parser piece name voicename lyricsid)
418 ; If we have lyrics, create a lyrics context containing LyricCombineMusic
419 ; and add that as second element to the staff's elements list...
420 ; Also add possibly configured LyricsModifications
421 (let* ((id (string-append "Lyrics" lyricsid))
422 (lyricsmods (oly:lyrics_handler_properties piece name id))
423 (lyrics (namedPieceInstrObject piece name id))
424 (ctx (if (ly:music? lyrics)
425 (context-spec-music (make-music 'LyricCombineMusic
427 'associated-context voicename)
429 (oly:generate_object_name piece name id))
431 (if (and (not-null? lyricsmods) (not-null? ctx))
432 (set! (ly:music-property ctx 'property-operations) lyricsmods)
438 #(define (oly:lyrics_create_contexts parser piece name voicename)
441 (oly:lyrics_create_single_context parser piece name voicename str))
442 (list "" "I" "II" "III" "IV" "V" "VI"))))
445 %%=====================================================================
447 %%---------------------------------------------------------------------
450 #(define (oly:voice_handler_internal parser piece name type music)
451 (if (ly:music? music)
453 (voicename (oly:generate_object_name piece name "Voice" ))
454 (lyrics (oly:lyrics_create_contexts parser piece name voicename))
455 (additional (if (not-null? lyrics) (list dynamicUp) '()))
456 (musiccontent (oly:musiccontent_for_voice parser piece name music additional))
457 (voicetype (oly:staff_type type))
458 (voice (context-spec-music musiccontent voicetype voicename))
459 (voiceprops (oly:voice_handler_properties piece name))
461 (if (not-null? voiceprops)
462 (set! (ly:music-property voice 'property-operations) voiceprops)
466 ; For empty music, return empty
471 #(define (oly:voice_handler parser piece name type)
472 (oly:voice_handler_internal parser piece name type (oly:get_music_object piece name)))
475 %%=====================================================================
476 %% Staff/Group handling
477 %%---------------------------------------------------------------------
480 #(define (oly:staff_handler_internal parser piece name type voices)
481 (if (not-null? voices)
483 (staffname (oly:generate_staff_name piece name))
484 (stafftype (oly:staff_type type))
485 (staff (make-simultaneous-music voices))
486 (propops (oly:staff_handler_properties piece name))
489 ((SimultaneousMusic ParallelMusic) #f)
490 (else (set! staff (context-spec-music staff stafftype staffname)))
492 (if (not-null? propops)
493 (set! (ly:music-property staff 'property-operations) propops)
497 ; For empty music, return empty
502 #(define (oly:staff_handler parser piece name type children)
503 (let* ((c (if (not-null? children) children (list name)))
504 (voices (apply append (map (lambda (v) (oly:create_voice parser piece v)) c)) )
506 (if (not-null? voices)
507 (oly:staff_handler_internal parser piece name type voices)
513 #(define (oly:devnull_handler parser piece name type children)
514 (oly:voice_handler parser piece name type)
517 #(define (oly:parallel_voices_staff_handler parser piece name type children)
519 (voices (map (lambda (i) (oly:create_voice parser piece i)) children))
520 ; get the list of non-empty voices and flatten it!
521 (nonemptyvoices (apply append (filter not-null? voices)))
523 (if (not-null? nonemptyvoices)
524 (oly:staff_handler_internal parser piece name "Staff" nonemptyvoices)
530 #(define (oly:remove-with-tag tag music)
531 (if (ly:music? music)
534 (let* ((tags (ly:music-property m 'tags))
535 (res (memq tag tags)))
540 % Remove all music tagged a not-part-combine
541 #(define (oly:remove-non-part-combine-events music)
542 (oly:remove-with-tag 'non-partcombine music))
544 #(define (oly:part_combined_staff_handler parser piece name type children)
545 (let* ((rawmusic (map (lambda (c) (oly:musiccontent_for_voice parser piece name (oly:get_music_object piece c) '())) children))
546 (filteredmusic (map (lambda (m) (oly:remove-non-part-combine-events m)) rawmusic))
547 (music (filter not-null? filteredmusic)))
549 ((and (pair? music) (ly:music? (car music)) (not-null? (cdr music)) (ly:music? (cadr music)))
550 ;(ly:message "Part-combine with two music expressions")
551 (oly:staff_handler_internal parser piece name "Staff" (list (make-part-combine-music parser music #f))))
553 ;;(ly:warning "Part-combine without any music expressions")
555 ; exactly one is a music expression, simply use that by joining
557 ;;(ly:message "Part-combine with only one music expressions")
558 (oly:staff_handler_internal parser piece name "Staff" (list (apply append music))))
560 ;(ly:message "make_part_combined_staff: ~S ~S ~a" piece instr instruments)
566 % Figured bass is a special case, as it can be voice- or staff-type. When
567 % given as a staff type, simply call the voice handler, instead
569 #(define (oly:figured_bass_staff_handler parser piece name type children)
570 (let* ((c (if (not-null? children) children (list name)))
571 (voice (oly:voice_handler parser piece (car c) type)))
572 (if (pair? voice) (car voice) ())
576 #(define (flatten lst)
577 (define (f remaining result)
579 ((null? remaining) result)
580 ((pair? (car remaining)) (f (cdr remaining) (f (car remaining) result)))
581 (else (f (cdr remaining) (cons (car remaining) result)))))
582 (reverse! (f lst '())))
584 #(define (oly:staff_group_handler parser piece name type children)
586 (staves (flatten (map (lambda (i) (oly:create_staff_or_group parser piece i)) children)))
587 (nonemptystaves (filter not-null? staves))
589 (if (not-null? nonemptystaves)
591 (musicexpr (if (= 1 (length nonemptystaves))
593 (make-simultaneous-music nonemptystaves)))
594 (groupname (oly:generate_staff_name piece name))
595 (grouptype (oly:staff_type type))
597 (propops (oly:staff_handler_properties piece name))
600 ((SimultaneousMusic ParallelMusic) #f)
601 (else (set! group (context-spec-music group grouptype groupname)))
604 (set! (ly:music-property group 'property-operations) propops))
607 ; Return empty list if no staves are generated
613 #(define (oly:create_voice parser piece name)
614 (let* ( (voice (namedPieceInstrObject piece name "Voice"))
615 (type (assoc-ref oly:voice_types name)) )
616 (if (not-null? voice)
617 ; Explicit voice variable, use that
621 ; No entry in structure found => simple voice
622 (oly:voice_handler parser piece name "Voice")
623 ; Entry found in structure => use the handler for the given type
625 (voicetype (car type))
626 (handler (assoc-ref oly:voice_handlers voicetype))
629 ((primitive-eval handler) parser piece name voicetype)
631 (ly:warning "No handler found for voice type ~a, using default voice handler" voicetype)
632 (oly:voice_handler parser piece name voicetype)
641 #(define (oly:create_staff_or_group parser piece name)
642 (let* ( (staff (namedPieceInstrObject piece name "Staff"))
643 (type_from_structure (assoc-ref oly:orchestral_score_structure name)) )
644 ;(if (not-null? staff)
645 ; (ly:message "Found staff variable for instrument ~a in piece ~a" instr piece)
646 ; (ly:message "Staff variable for instrument ~a in piece ~a NOT FOUND" instr piece)
648 (if (not-null? staff)
649 ; Explicit staff variable, use that
652 (if (not (list? type_from_structure))
653 ; No entry in structure found => simple staff
654 (oly:staff_handler parser piece name "Staff" '())
656 ; Entry found in structure => use the handler for the given type
657 (let* ((type (car type_from_structure))
658 (handler (assoc-ref oly:staff_handlers type))
659 (children (cadr type_from_structure))
662 ((primitive-eval handler) parser piece name type children)
664 (ly:warning "No handler found for staff type ~a, using default staff handler" type)
665 (oly:staff_handler parser piece name type children)
674 #(define (oly:dynamics_handler parser piece name type children)
675 (oly:voice_handler parser piece name type)
679 %%=====================================================================
680 %% Handler definitions
681 %%---------------------------------------------------------------------
683 #(define oly:staff_handlers
686 '("GrandStaff" . oly:staff_group_handler )
687 '("PianoStaff" . oly:staff_group_handler )
688 '("ChoirStaff" . oly:staff_group_handler )
689 '("StaffGroup" . oly:staff_group_handler )
690 '("ParallelMusic" . oly:staff_group_handler )
691 '("SimultaneousMusic" . oly:staff_group_handler )
693 '("Staff" . oly:staff_handler )
694 '("DrumStaff" . oly:staff_handler )
695 '("RhythmicStaff" . oly:staff_handler )
696 '("TabStaff" . oly:staff_handler )
697 '("GregorianTranscriptionStaff" . oly:staff_handler )
698 '("MensuralStaff" . oly:staff_handler )
699 '("VaticanaStaff" . oly:staff_handler )
700 '("ChordNames" . oly:staff_handler )
701 ; staves with multiple voices
702 '("PartCombinedStaff" . oly:part_combined_staff_handler )
703 '("ParallelVoicesStaff" . oly:parallel_voices_staff_handler )
704 ; special cases: Figured bass can be staff or voice type!
705 '("FiguredBass" . oly:figured_bass_staff_handler )
706 ; Devnull is like a staff, only that it doesn't craete output
707 '("Devnull" . oly:devnull_handler )
708 '("Dynamics" . oly:dynamics_handler )
712 #(define oly:voice_handlers
715 '("Voice" . oly:voice_handler )
716 '("CueVoice" . oly:voice_handler )
717 '("DrumVoice" . oly:voice_handler )
718 '("FiguredBass" . oly:voice_handler )
719 '("ChordNames" . oly:voice_handler )
720 '("GregorianTranscriptionVoice" . oly:voice_handler )
721 '("NoteNames" . oly:voice_handler )
722 '("TabVoice" . oly:voice_handler )
723 '("VaticanaVoice" . oly:voice_handler )
728 #(define (oly:register_staff_type_handler type func)
729 ; (ly:message "Registering staff handler ~a for type ~a" func type)
730 (set! oly:staff_handlers (assoc-set! oly:staff_handlers type func))
733 #(define (oly:register_voice_type_handler type func)
734 ; (ly:message "Registering voice type handler ~a for type ~a" func type)
735 (set! oly:voice_handlers (assoc-set! oly:voice_handlers type func))
738 % handlers for deprecated API
739 #(oly:register_staff_type_handler 'StaffGroup 'oly:staff_group_handler)
740 #(oly:register_staff_type_handler 'GrandStaff 'oly:staff_group_handler)
741 #(oly:register_staff_type_handler 'PianoStaff 'oly:staff_group_handler)
742 #(oly:register_staff_type_handler 'ChoirStaff 'oly:staff_group_handler)
743 #(oly:register_staff_type_handler 'Staff 'oly:staff_handler )
744 #(oly:register_staff_type_handler 'ParallelMusic 'oly:staff_group_handler)
745 #(oly:register_staff_type_handler 'SimultaneousMusic 'oly:staff_group_handler)
746 #(oly:register_staff_type_handler #t 'oly:part_combined_staff_handler )
747 #(oly:register_staff_type_handler #f 'oly:parallel_voices_staff_handler )
751 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
752 % Automatic score generation
753 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
755 #(define oly:score_handler add-score)
756 #(define oly:music_handler add-music)
757 #(define oly:text_handler add-text)
761 setUseBook = #(define-music-function (parser location usebook) (boolean?)
762 (ly:warning "\\setUseBook has been deprecated! Books are now automatically handled without any hacks")
763 (make-music 'Music 'void #t)
767 % Two functions to handle midi-blocks: Either don't set one, or set an empty
768 % one so that MIDI is generated
769 #(define (oly:set_no_midi_block score) '())
770 #(define (oly:set_midi_block score)
771 (let* ((midiblock (if (defined? '$defaultmidi)
772 (ly:output-def-clone $defaultmidi)
773 (ly:make-output-def))))
774 (ly:output-def-set-variable! midiblock 'is-midi #t)
775 (ly:score-add-output-def! score midiblock)
779 % \setCreateMidi ##t/##f sets a flag to determine wheter MIDI output should
781 #(define oly:apply_score_midi oly:set_no_midi_block)
782 setCreateMIDI = #(define-music-function (parser location createmidi) (boolean?)
784 (set! oly:apply_score_midi oly:set_midi_block)
785 (set! oly:apply_score_midi oly:set_no_midi_block)
787 (make-music 'Music 'void #t)
791 % Two functions to handle layout-blocks: Either don't set one, or set an empty
792 % one so that a PDF is generated
793 #(define (oly:set_no_layout_block score) '())
794 #(define (oly:set_layout_block score)
795 (let* ((layoutblock (if (defined? '$defaultlayout)
796 (ly:output-def-clone $defaultlayout)
797 (ly:make-output-def))))
798 (ly:output-def-set-variable! layoutblock 'is-layout #t)
799 (ly:score-add-output-def! score layoutblock)
803 % \setCreatePDF ##t/##f sets a flag to determine wheter PDF output should
805 #(define oly:apply_score_layout oly:set_no_layout_block)
806 setCreatePDF = #(define-music-function (parser location createlayout) (boolean?)
808 (set! oly:apply_score_layout oly:set_layout_block)
809 (set! oly:apply_score_layout oly:set_no_layout_block)
811 (make-music 'Music 'void #t)
815 % Set the piece title in a new header block.
816 #(define (oly:set_piece_header score piecename)
817 (if (not-null? piecename)
818 (let* ((header (make-module)))
819 (module-define! header 'piece piecename)
820 (ly:score-set-header! score header)
826 % post-filter functions. By default, no filtering is done. However,
827 % for the *NoCues* function, the cue notes should be killed
828 keepcuefilter = #(define-music-function (parser location music) (ly:music?)
829 ((ly:music-function-extract removeWithTag) parser location 'non-cued music))
830 removecuefilter = #(define-music-function (parser location music) (ly:music?)
831 ((ly:music-function-extract removeWithTag) parser location 'cued ((ly:music-function-extract killCues) parser location music)))
834 #(define (oly:create-toc-file layout pages)
835 (let* ((label-table (ly:output-def-lookup layout 'label-page-table))
836 ;; The page numbers are pages counts in the pdf file, not visible page number!
837 ;; So we have to offset them if the first page is not page #1
838 (first-page-offset (1- (ly:output-def-lookup layout 'first-page-number))))
839 (if (not (null? label-table))
840 (let* ((format-line (lambda (toc-item)
841 (let* ((label (car toc-item))
842 (text (caddr toc-item))
843 (label-page (and (list? label-table)
844 (assoc label label-table)))
845 (page (and label-page (cdr label-page))))
846 (format #f "~a, section, 1, {~a}, ~a" (- page first-page-offset) text label))))
847 (formatted-toc-items (map format-line (toc-items)))
848 (whole-string (string-join formatted-toc-items ",\n"))
849 (output-name (ly:parser-output-name parser))
850 (outfilename (format "~a.toc" output-name))
851 (outfile (open-output-file outfilename)))
852 (if (output-port? outfile)
853 (display whole-string outfile)
854 (ly:warning (_ "Unable to open output file ~a for the TOC information") outfilename))
855 (close-output-port outfile)))))
858 #(define-public (oly:add-toc-item parser markup-symbol text)
859 (oly:music_handler parser (add-toc-item! markup-symbol text)))
862 #(define (oly:add-score parser score piecename)
863 (if (not-null? piecename)
864 (oly:add-toc-item parser 'tocItemMarkup piecename))
865 (oly:score_handler parser score)
867 % The helper function to build a score.
868 #(define (oly:createScoreHelper parser location piece children func)
870 (staves (oly:staff_group_handler parser piece "" "SimultaneousMusic" children))
871 (music (if (not-null? staves)
872 ((ly:music-function-extract func) parser location staves)
876 (piecename (namedPieceInstrObject piece (car children) "PieceName"))
877 (piecenametacet (namedPieceInstrObject piece (car children) "PieceNameTacet"))
881 ; No staves, print tacet
883 (if (not-null? piecenametacet) (set! piecename piecenametacet))
884 (if (not-null? piecename)
885 (oly:add-score parser (list (oly:piece-title-markup piecename)) piecename)
886 (ly:warning (_ "No music and no score title found for part ~a and instrument ~a") piece children)
889 ; we have staves, apply the piecename to the score and add layout/midi blocks if needed
891 (set! score (scorify-music music parser))
892 (oly:set_piece_header score piecename)
893 (oly:apply_score_midi score)
894 (oly:apply_score_layout score)
895 ; Schedule the score for typesetting
896 (oly:add-score parser score piecename)
900 ; This is a void function, the score has been schedulled for typesetting already
901 (make-music 'Music 'void #t)
904 createVoice = #(define-music-function (parser location piece name) (string? string?)
905 (let* ((vc (oly:create_voice parser piece name)))
906 (make-music 'SimultaneousMusic
909 createStaff = #(define-music-function (parser location piece name) (string? string?)
910 (oly:create_staff_or_group parser piece name))
911 createStaffForContents = #(define-music-function (parser location piece name contents) (string? string? ly:music?)
912 (let* ((tstruct (assoc-ref oly:orchestral_score_structure name))
913 (type (if (list? tstruct) (car tstruct) "Staff")))
914 (oly:staff_handler_internal parser piece name type (list contents))))
917 createScore = #(define-music-function (parser location piece children) (string? list?)
918 (oly:createScoreHelper parser location piece children keepcuefilter)
920 createNoCuesScore = #(define-music-function (parser location piece children) (string? list?)
921 (oly:createScoreHelper parser location piece children removecuefilter)
924 createHeadline = #(define-music-function (parser location headline) (string?)
925 (oly:add-toc-item parser 'tocItemMarkup headline)
926 (oly:score_handler parser (list (oly:piece-title-markup headline)))
927 (make-music 'Music 'void #t)
932 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
933 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
935 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
936 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
938 newInstrument = #(define-music-function (parser location instr) (string?)
940 \set Voice.instrumentCueName = #(string-join (list "+" instr))
943 cueText = #(define-music-function (parser location instr) (string?)
945 \set Voice.instrumentCueName = $instr
948 cueMarkup = #(define-music-function (parser location instr) (markup?)
950 \set Voice.instrumentCueName = $instr
954 clearCueText = #(define-music-function (parser location) ()
956 \unset Voice.instrumentCueName
960 insertCueText = #(define-music-function (parser location instr) (string?)
961 (if (string-null? instr)
962 #{ \tag #'cued \clearCueText #}
963 #{ \tag #'cued \cueText #instr #}
966 % generate a cue music section with instrument names
967 % Parameters: \namedCueDuring NameOfQuote CueDirection CueInstrument OriginalInstrument music
968 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
969 % -) CueInstrument and OriginalInstrument are the displayed instrument names
971 % \namedCueDuring #"vIQuote" #UP #"V.I" #"Sop." { R1*3 }
972 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
973 % the beginning of the cue notes and "Sop." at the end
974 namedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr cuemusic) (string? number? string? string? ly:music?)
976 \cueDuring #cuevoice #direction {
977 \insertCueText #instrcue
979 \insertCueText #instr
983 namedTransposedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr trans cuemusic) (string? number? string? string? ly:music? ly:music?)
985 \transposedCueDuring #cuevoice #direction #trans {
986 \insertCueText #instrcue
988 \insertCueText #instr
993 % set the cue instrument name and clef
994 setClefCue = #(define-music-function (parser location instr clef)
997 \once \override Staff.Clef #'font-size = #-3 #clef
998 \insertCueText #instr
1001 % generate a cue music section with instrument names and clef changes
1002 % Parameters: \cleffedCueDuring NameOfQuote CueDirection CueInstrument CueClef OriginalInstrument OriginalClef music
1003 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
1004 % -) CueInstrument and OriginalInstrument are the displayed instrument names
1005 % -) CueClef and OriginalClef are the clefs for the the cue notes and the clef of the containing voice
1007 % \cleffedCueDuring #"vIQuote" #UP #"V.I" #"treble" #"Basso" #"bass" { R1*3 }
1008 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
1009 % the beginning of the cue notes and "Basso" at the end. The clef is changed to treble at the
1010 % beginning of the cue notes and reset to bass at the end
1011 cleffedCueDuring = #(define-music-function (parser location cuevoice direction instrcue clefcue instr clefinstr cuemusic)
1012 (string? number? string? ly:music? string? ly:music? ly:music?)
1014 \cueDuring #cuevoice #direction {
1015 \tag #'cued \setClefCue #instrcue #clefcue
1017 \tag #'cued \setClefCue #instr #clefinstr
1021 % generate a cue music section with instrument names and clef changes
1022 % Parameters: \namedCueDuringClef NameOfQuote CueDirection CueInstrument CueClef OriginalInstrument music
1023 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
1024 % -) CueInstrument and OriginalInstrument are the displayed instrument names
1025 % -) CueClef is the clef for the the cue notes
1027 % \namedCueDuringClef #"vIQuote" #UP #"V.I" #"treble" #"Basso" { R1*3 }
1028 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
1029 % the beginning of the cue notes and "Basso" at the end. The clef is changed to treble at the
1030 % beginning of the cue notes and reset to bass at the end
1031 namedCueDuringWithClef = #(define-music-function (parser location cuevoice direction instrcue clefcue instr cuemusic)
1032 (string? number? string? string? string? ly:music?)
1034 \cueDuringWithClef #cuevoice #direction #clefcue {
1035 \insertCueText #instrcue
1037 \insertCueText #instr
1044 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1047 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1048 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1051 dynamicsX = #(define-music-function (parser location offset) (number?)
1053 \once \override DynamicText #'X-offset = $offset
1054 \once \override DynamicLineSpanner #'Y-offset = #0
1057 % Move the dynamic sign inside the staff to a fixed staff-relative position
1058 % posY (where 0 means vertically starts at the middle staff line)
1059 dynamicsAllInside = #(define-music-function (parser location offsetX posY)
1062 % Invalid y-extent -> hidden from skyline calculation and collisions
1063 % \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
1064 \once \override DynamicLineSpanner #'Y-extent = $(lambda (grob)
1065 (let* ((ext (ly:axis-group-interface::height grob))
1066 (dir (ly:grob-property grob 'direction)))
1068 (cons (- (cdr ext) 0.1) (cdr ext))
1069 (cons (car ext) (+ (car ext) 0.1)))))
1070 % move by X offset and to fixed Y-position (use Y-offset of parent!)
1071 \once \override DynamicText #'X-offset = $offsetX
1072 \once \override DynamicText #'Y-offset =
1074 (let* ((head (ly:grob-parent grob Y))
1075 (offset (ly:grob-property head 'Y-offset)))
1076 (- posY offset (- 0.6))))
1077 \once \override DynamicLineSpanner #'Y-offset = $posY
1080 dynamicsUpInside = #(define-music-function (parser location offsetX) (number?)
1081 ((ly:music-function-extract dynamicsAllInside) parser location offsetX 1.5)
1084 dynamicsDownInside = #(define-music-function (parser location offsetX) (number?)
1085 ((ly:music-function-extract dynamicsAllInside) parser location offsetX -3.5)
1088 hairpinOffset = #(define-music-function (parser location posY) (number?)
1090 \once \override DynamicLineSpanner #'Y-offset = $posY
1091 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
1094 #(define ((line-break-offset before after) grob)
1095 (let* ((orig (ly:grob-original grob))
1096 ; All siblings if line-broken:
1097 (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
1098 (if (>= (length siblings) 2)
1099 ; We have been line-broken
1100 (if (eq? (car (last-pair siblings)) grob)
1102 (ly:grob-set-property! grob 'Y-offset after)
1103 ; Others get the before value:
1104 (ly:grob-set-property! grob 'Y-offset before)
1110 ffz = #(make-dynamic-script "ffz")
1111 pf = #(make-dynamic-script "pf")
1112 sempp = #(make-dynamic-script (markup #:line( #:with-dimensions '(0 . 0)
1113 '(0 . 0) #:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
1114 parenf = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")")))
1115 parenp = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "p" #:normal-text #:italic #:fontsize 2 ")")))
1116 pdolce = #(make-dynamic-script (markup #:line(#:dynamic "p" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce")))
1117 ppdolce = #(make-dynamic-script (markup #:line(#:dynamic "pp" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce")))
1118 dolce = #(make-dynamic-script (markup #:line(#:normal-text #:italic "dolce")))
1119 sfpdolce = #(make-dynamic-script (markup #:line(#:dynamic "sfp" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
1120 bracketf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 3 "[" #:dynamic "f" #:hspace 0.1 #:normal-text #:fontsize 3 "]"))))
1121 bracketmf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 3 "[" #:dynamic "mf" #:hspace 0.1 #:normal-text #:fontsize 3 "]"))))
1122 bracketmp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 2 "[" #:hspace 0.2 #:dynamic "mp" #:normal-text #:fontsize 2 "]"))))
1123 bracketp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 2 "[" #:hspace 0.2 #:dynamic "p" #:normal-text #:fontsize 2 "]"))))
1125 whiteoutp = #(make-dynamic-script (markup #:whiteout #:pad-markup 0.5 #:dynamic "p"))
1126 whiteoutf = #(make-dynamic-script (markup #:whiteout #:pad-markup 0.5 #:dynamic "f"))
1127 whiteoutff = #(make-dynamic-script (markup #:whiteout #:pad-markup 0.5 #:dynamic "ff"))
1130 cresc = #(make-music 'CrescendoEvent 'span-direction START
1131 'span-type 'text 'span-text "cresc.")
1132 dim = #(make-music 'DecrescendoEvent 'span-direction START
1133 'span-type 'text 'span-text "dim.")
1134 decresc = #(make-music 'DecrescendoEvent 'span-direction START
1135 'span-type 'text 'span-text "decresc.")
1139 %%% Thanks to "Gilles THIBAULT" <gilles.thibault@free.fr>, there is a way
1140 % to remove also the fermata from R1-\fermataMarkup: By filtering the music
1141 % and removing the corresponding events.
1142 % Documented as an LSR snippet: http://lsr.dsi.unimi.it/LSR/Item?id=372
1143 #(define (filterOneEventsMarkup event)
1144 ( let ( (eventname (ly:music-property event 'name)) )
1146 (or ;; add here event name you do NOT want
1147 (eq? eventname 'MultiMeasureTextEvent)
1148 (eq? eventname 'AbsoluteDynamicEvent)
1149 (eq? eventname 'TextScriptEvent)
1150 (eq? eventname 'ArticulationEvent)
1151 (eq? eventname 'CrescendoEvent)
1152 (eq? eventname 'DecrescendoEvent)
1157 filterArticulations = #(define-music-function (parser location music) (ly:music?)
1158 (music-filter filterOneEventsMarkup music)
1163 %%% Add the same articulation to a longer sequence of notes:
1164 #(define (make-script x)
1165 (make-music 'ArticulationEvent
1166 'articulation-type x))
1168 #(define (add-articulation music art)
1171 (cond ((music-is-of-type? m 'event-chord)
1172 (set! (ly:music-property m 'elements)
1173 (append (ly:music-property m 'elements)
1174 (list (make-script art))))
1176 ((music-is-of-type? m 'note-event)
1177 (set! (ly:music-property m 'articulations)
1178 (append (ly:music-property m 'articulations)
1179 (list (make-script art))))
1184 addArticulation = #(define-music-function (parser location type music)
1185 (string? ly:music? )
1186 (add-articulation music type))
1191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1193 %%%%% Tempo markings
1194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1199 rit = \markup {\italic "rit."}
1200 atempo = \markup {\italic "a tempo"}
1201 pocorit = \markup {\italic "poco rit."}
1202 ppmosso = \markup {\italic "poco più mosso"}
1203 pizz = \markup {\italic "pizz."}
1204 arco = \markup {\italic "arco"}
1205 perd = \markup {\italic "perdend."}
1210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1212 %%%%% REST COMBINATION
1213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1214 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1218 %% REST COMBINING, TAKEN FROM http://lsr.dsi.unimi.it/LSR/Item?id=336
1221 %% \new Staff \with {
1222 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1223 %% } << \somevoice \\ \othervoice >>
1228 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1233 %% - only handles two voices
1234 %% - does not handle multi-measure/whole-measure rests
1236 #(define (rest-score r)
1238 (yoff (ly:grob-property-data r 'Y-offset))
1239 (sp (ly:grob-property-data r 'staff-position)))
1241 (set! score (+ score 2))
1242 (if (eq? yoff 'calculation-in-progress)
1243 (set! score (- score 3))))
1246 (set! score (+ score 2))
1247 (set! score (- score (abs (- 1 sp)))))
1250 #(define (merge-rests-on-positioning grob)
1251 (let* ((can-merge #f)
1252 (elts (ly:grob-object grob 'elements))
1253 (num-elts (and (ly:grob-array? elts)
1254 (ly:grob-array-length elts)))
1255 (two-voice? (= num-elts 2)))
1257 (let* ((v1-grob (ly:grob-array-ref elts 0))
1258 (v2-grob (ly:grob-array-ref elts 1))
1259 (v1-rest (ly:grob-object v1-grob 'rest))
1260 (v2-rest (ly:grob-object v2-grob 'rest)))
1264 (let* ((v1-duration-log (ly:grob-property v1-rest 'duration-log))
1265 (v2-duration-log (ly:grob-property v2-rest 'duration-log))
1266 (v1-dot (ly:grob-object v1-rest 'dot))
1267 (v2-dot (ly:grob-object v2-rest 'dot))
1268 (v1-dot-count (and (ly:grob? v1-dot)
1269 (ly:grob-property v1-dot 'dot-count -1)))
1270 (v2-dot-count (and (ly:grob? v2-dot)
1271 (ly:grob-property v2-dot 'dot-count -1))))
1274 (number? v1-duration-log)
1275 (number? v2-duration-log)
1276 (= v1-duration-log v2-duration-log)
1277 (eq? v1-dot-count v2-dot-count)))
1279 ;; keep the rest that looks best:
1280 (let* ((keep-v1? (>= (rest-score v1-rest)
1281 (rest-score v2-rest)))
1282 (rest-to-keep (if keep-v1? v1-rest v2-rest))
1283 (dot-to-kill (if keep-v1? v2-dot v1-dot)))
1284 ;; uncomment if you're curious of which rest was chosen:
1285 ;;(ly:grob-set-property! v1-rest 'color green)
1286 ;;(ly:grob-set-property! v2-rest 'color blue)
1287 (ly:grob-suicide! (if keep-v1? v2-rest v1-rest))
1288 (if (ly:grob? dot-to-kill)
1289 (ly:grob-suicide! dot-to-kill))
1290 (ly:grob-set-property! rest-to-keep 'direction 0)
1291 (ly:rest::y-offset-callback rest-to-keep)))))))
1294 (ly:rest-collision::calc-positioning-done grob))))
1300 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1302 %%%%% TABLE OF CONTENTS
1303 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1307 contentsTitle = "Inhalt / Contents"
1310 tocTitleMarkup = \markup \fill-line{
1313 \override #(cons 'line-width (* 7 cm))
1314 \line{ \fill-line {\piece-title {\contentsTitle} \null }}
1319 tocItemMarkup = \markup \fill-line {
1322 \override #(cons 'line-width (* 7 cm ))
1323 \line { \fill-line{\fromproperty #'toc:text \fromproperty #'toc:page }}
1330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1332 %%%%% TITLE PAGE / HEADER
1333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1336 #(define-markup-command (when-property layout props symbol markp) (symbol? markup?)
1337 (if (chain-assoc-get symbol props)
1338 (interpret-markup layout props markp)
1339 (ly:make-stencil '() '(1 . -1) '(1 . -1))))
1341 #(define-markup-command (vspace layout props amount) (number?)
1342 "This produces a invisible object taking vertical space."
1343 (let ((amount (* amount 3.0)))
1345 (ly:make-stencil "" (cons -1 1) (cons 0 amount))
1346 (ly:make-stencil "" (cons -1 1) (cons amount amount)))))
1350 titlePageMarkup = \markup \abs-fontsize #10 \when-property #'header:title \column {
1352 \fill-line { \fontsize #8 \fromproperty #'header:composer }
1354 \fill-line { \fontsize #8 \fromproperty #'header:poet }
1356 \fill-line { \fontsize #10 \bold \fromproperty #'header:titlepagetitle }
1358 \fontsize #2 \when-property #'header:titlepagesubtitle {
1359 \fill-line { \fromproperty #'header:titlepagesubtitle }
1362 \fill-line { \postscript #"-20 0 moveto 40 0 rlineto stroke" }
1364 \fill-line { \fontsize #5 \fromproperty #'header:ensemble }
1366 \fill-line { \fontsize #2 \fromproperty #'header:instruments }
1368 \fill-line { \fontsize #5 \fromproperty #'header:date }
1370 \fill-line { \fontsize #5 \fromproperty #'header:scoretype }
1372 \when-property #'header:instrument {
1373 \fill-line { \bold \fontsize #6 \rounded-box \fromproperty #'header:instrument }
1376 \fontsize #2 \when-property #'header:enteredby \override #'(baseline-skip . 3.75) \left-align\center-column {
1377 \fill-line { "Herausgegeben von: / Edited by:"}
1379 \fill-line { \fromproperty #'header:enteredby }
1382 \when-property #'header:arrangement \column {
1384 \fill-line { \fontsize #3 \fromproperty #'header:arrangement }
1388 \fill-line { \fromproperty #'header:copyright }
1391 titleHeaderMarkup = \markup {
1392 \override #'(baseline-skip . 3.5)
1395 \fromproperty #'header:logo
1396 \override #'(baseline-skip . 4.5) \center-column {
1397 \bold \abs-fontsize #18 \fromproperty #'header:title
1398 \bold \abs-fontsize #12 \fromproperty #'header:subtitle
1399 \abs-fontsize #11 \fromproperty #'header:subsubtitle
1401 \bold \abs-fontsize #11 \when-property #'header:instrument \rounded-box \fromproperty #'header:instrument
1404 \with-dimensions #'( 0 . 0) #'( 0 . 1 ) \null
1408 \abs-fontsize #10 \fromproperty #'header:poet
1409 \abs-fontsize #10 \fromproperty #'header:composer
1412 \abs-fontsize #10 \fromproperty #'header:meter
1413 \abs-fontsize #10 \fromproperty #'header:arranger
1417 date = #(strftime "%d-%m-%Y" (localtime (current-time)))
1423 titleScoreMarkup = \markup \piece-title \fromproperty #'header:piece
1426 scoreTitleMarkup = \titleScoreMarkup
1427 bookTitleMarkup = \titleHeaderMarkup
1432 %%%%%%%%%%%%%% headers and footers %%%%%%%%%%%%%%%%%%%%%%%%%%
1434 #(define (first-score-page layout props arg)
1435 (let* ((label 'first-score-page)
1436 (table (ly:output-def-lookup layout 'label-page-table))
1437 (label-page (and (list? table) (assoc label table)))
1438 (page-number (and label-page (cdr label-page)))
1440 (if (eq? (chain-assoc-get 'page:page-number props -1) page-number)
1441 (interpret-markup layout props arg)
1444 #(define no-header-table '(1))
1445 addNoHeaderPage = #(define-music-function (parser location nr) (number?)
1446 (set! no-header-table (cons nr no-header-table))
1447 (make-music 'Music 'void #t))
1448 setNoHeaderPages = #(define-music-function (parser location pages) (list?)
1449 (set! no-header-table pages)
1450 (make-music 'Music 'void #t))
1452 #(define (is-header-page layout props arg)
1453 (let* ((page-number (chain-assoc-get 'page:page-number props -1)))
1454 (if (not (member page-number no-header-table))
1455 (interpret-markup layout props arg)
1458 #(define no-footer-table '(1))
1459 addNoFooterPage = #(define-music-function (parser location nr) (number?)
1460 (set! no-footer-table (cons nr no-footer-table))
1461 (make-music 'Music 'void #t))
1462 setNoFooterPages = #(define-music-function (parser location pages) (list?)
1463 (set! no-footer-table pages)
1464 (make-music 'Music 'void #t))
1466 #(define (is-footer-page layout props arg)
1467 (let* ((page-number (chain-assoc-get 'page:page-number props -1)))
1468 (if (not (member page-number no-footer-table))
1469 (interpret-markup layout props arg)
1472 #(define copyright-pages-table '(1))
1473 addCopyrightPage = #(define-music-function (parser location nr) (number?)
1474 (set! copyright-pages-table (cons nr copyright-pages-table))
1475 (make-music 'Music 'void #t))
1476 setCopyrightPages = #(define-music-function (parser location pages) (list?)
1477 (set! copyright-pages-table pages)
1478 (make-music 'Music 'void #t))
1480 #(define (is-copyright-page layout props arg)
1481 (let* ((page-number (chain-assoc-get 'page:page-number props -1)))
1482 (if (member page-number copyright-pages-table)
1483 (interpret-markup layout props arg)
1489 olyStdOddHeaderMarkup = \markup \fill-line {
1490 %% force the header to take some space, otherwise the
1491 %% page layout becomes a complete mess.
1493 \on-the-fly #is-header-page \fromproperty #'header:title
1494 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1496 olyStdEvenHeaderMarkup = \markup \fill-line {
1497 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1498 \on-the-fly #is-header-page \fromproperty #'header:composer
1501 olyInstrumentOddHeaderMarkup = \markup \fill-line {
1503 \on-the-fly #is-header-page \concat { \fromproperty #'header:instrument }
1504 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1506 olyInstrumentEvenHeaderMarkup = \markup \fill-line {
1507 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1508 \on-the-fly #is-header-page \concat { \fromproperty #'header:composer ": " \fromproperty #'header:title }
1511 oddHeaderMarkup = \olyStdOddHeaderMarkup
1512 evenHeaderMarkup = \olyStdEvenHeaderMarkup
1514 olyStdOddFooterMarkup = \markup {
1517 %% publisher header field only on title page.
1518 \on-the-fly #first-page \fromproperty #'header:publisher
1521 %% copyright on the first real score page
1522 \on-the-fly #is-copyright-page \fromproperty #'header:copyright
1523 \on-the-fly #is-copyright-page \null
1526 %% All other pages get the number of the edition centered
1527 \on-the-fly #is-footer-page \fromproperty #'header:scorenumber
1531 olyInstrumentOddFooterMarkup = \markup {
1534 %% copyright on the first real score page
1535 \on-the-fly #is-copyright-page \fromproperty #'header:copyright
1536 \on-the-fly #is-copyright-page \null
1539 %% All other pages get the number of the edition centered
1540 \on-the-fly #is-footer-page \fromproperty #'header:scorenumber
1544 oddFooterMarkup = \olyStdOddFooterMarkup
1557 % Interpret the given markup with the header fields added to the props.
1558 % This way, one can re-use the same functions (using fromproperty
1559 % #'header:field) in the header block and as top-level markup.
1561 % This function is originally copied from mark-up-title (file scm/titling.scm),
1562 % which is lilypond's internal function to handle the title markups. I needed
1563 % to replace the scopes and manually add the $defaultheader (which is internally
1564 % done in paper-book.cc before calling mark-up-title. Also, I don't extract the
1565 % markup from the header block, but use the given markup.
1567 % I'm not sure if I really need the page properties in props, too... But I
1568 % suppose it does not hurt, either.
1569 #(define-markup-command (markupWithHeader layout props markup) (markup?)
1570 "Interpret the given markup with the header fields added to the props.
1571 This way, one can re-use the same functions (using fromproperty
1572 #'header:field) in the header block and as top-level markup."
1574 ; TODO: If we are inside a score, add the score's local header block, too!
1575 ; Currently, I only use the global header block, stored in $defaultheader
1576 (scopes (list $defaultheader))
1577 (alists (map ly:module->alist scopes))
1580 (map (lambda (alist)
1581 (map (lambda (entry)
1583 (string->symbol (string-append "header:" (symbol->string (car entry))))
1587 (props (append prefixed-alist
1589 (layout-extract-page-properties layout)))
1591 (interpret-markup layout props markup)
1600 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1601 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1602 %%%%% Equally spacing multiple columns (e.g. for translations)
1603 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1604 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1606 % Credits: Nicolas Sceaux on the lilypond-user mailinglist
1607 #(define-markup-command (columns layout props args) (markup-list?)
1608 (let ((line-width (/ (chain-assoc-get 'line-width props
1609 (ly:output-def-lookup layout 'line-width))
1610 (max (length args) 1))))
1611 (interpret-markup layout props
1612 (make-line-markup (map (lambda (line)
1613 (markup #:pad-to-box `(0 . ,line-width) '(0 . 0)
1614 #:override `(line-width . ,line-width)
1620 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1621 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1622 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1623 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1624 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1627 startSlashedGraceMusic = {
1628 \override Flag #'stroke-style = #"grace"
1631 stopSlashedGraceMusic = {
1632 \revert Flag #'stroke-style
1636 #(def-grace-function startSlashedGraceMusic stopSlashedGraceMusic
1637 (_i "Create slashed graces (slashes through stems, but no slur)from the following music expression"))
1640 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1641 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1642 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1643 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1644 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1647 footnote-separator-markup = \markup { \fill-line { \override #`(span-factor . 1/4) { \draw-hline } \null }}
1650 right-margin = 1.5\cm
1651 line-width = 17.5\cm
1652 % bottom-margin = 1.5\cm
1657 ragged-last-bottom = ##f
1662 % If only one non-empty staff in a system exists, still print the backet
1663 \override SystemStartBracket #'collapse-height = #1
1664 \consists "Instrument_name_engraver"
1665 \consists "Keep_alive_together_engraver"
1669 % If only one non-empty staff in a system exists, still print the backet
1670 \override SystemStartBracket #'collapse-height = #1
1671 \consists "Instrument_name_engraver"
1675 \override SystemStartBracket #'collapse-height = #1
1676 \consists "Instrument_name_engraver"
1680 \override VerticalAxisGroup #'padding = #0
1684 % Force multi-measure rests to be written as one span
1685 \override MultiMeasureRest #'expand-limit = #3
1688 \override CombineTextScript #'avoid-slur = #'outside
1689 \override DynamicTextSpanner #'style = #'none
1690 \override InstrumentSwitch #'font-size = #-1
1693 \override RestCollision #'positioning-done = #merge-rests-on-positioning
1694 % Auto-Accidentals: Use modern-cautionary style...
1696 % Accidental rules (the rule giving the most accidentals wins!)
1697 % -) Reset accidentals at each barline -> accs not in key sig will always be printed
1698 % -) Same octave accidentals are remembered for two measures -> cancellation
1699 % -) other octave accidentals are remembered for next measure -> cancellation
1700 autoAccidentals = #`(Staff ,(make-accidental-rule 'same-octave 0)
1701 ,(make-accidental-rule 'any-octave 0)
1702 ,(make-accidental-rule 'any-octave 1)
1703 ,(make-accidental-rule 'same-octave 2))
1704 % No auto-cautionaries, we always use autoAccidentals!
1705 % autoCautionaries = #`(Staff ,(make-accidental-rule 'any-octave 0)
1706 % ,(make-accidental-rule 'same-octave 1))
1707 printKeyCancellation = ##t
1708 quotedEventTypes = #'(StreamEvent)
1709 quotedCueEventTypes = #'(
1723 implicitBassFigures = #'(0 100)
1732 ts = #(make-music 'TextScriptEvent 'text "t.s." 'direction UP )
1733 tt = #(make-music 'TextScriptEvent 'text "Tutti" 'direction UP )
1734 solo = #(make-music 'TextScriptEvent 'text "Solo" 'direction UP )
1735 tutti = #(make-music 'TextScriptEvent 'text "Tutti" 'direction UP )
1736 bracketts = #(make-music 'TextScriptEvent 'text "[t.s.]" 'direction UP )
1737 brackettt = #(make-music 'TextScriptEvent 'text "[Tutti]" 'direction UP )
1738 bracketsolo = #(make-music 'TextScriptEvent 'text "[Solo]" 'direction UP )
1740 sottovoce = #(make-music 'TextScriptEvent 'text "sotto voce" 'direction UP )
1742 dashedSlur = -\tweak #'dash-definition #'((0 1 0.4 0.75))(
1743 dashedTie = -\tweak #'dash-definition #'((0 1 0.4 0.75))~
1745 divisi = #(define-music-function (parser location vc1 vc2) (ly:music? ly:music?)
1747 << { \voiceOne $vc1 \oneVoice} \context Voice = "divisi2" { \voiceTwo $vc2 } >>
1751 #(define twoVoice divisi)
1753 #(define-public (bracket-stencils grob)
1754 (let ((lp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "[")))
1755 (rp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "]"))))
1758 bracketify = #(define-music-function (parser loc arg) (ly:music?)
1759 (_i "Tag @var{arg} to be parenthesized.")
1761 \once \override ParenthesesItem #'stencils = #bracket-stencils
1767 #(define-markup-command (hat layout props arg) (markup?)
1768 "Draw a hat above the given string @var{arg}."
1769 (interpret-markup layout props (markup #:combine #:raise 1.5 "^" arg)))
1774 #(let ((m (make-music 'ArticulationEvent
1775 'articulation-type "flageolet")))
1776 (ly:music-set-property! m 'tweaks
1777 (acons 'font-size -2
1778 (ly:music-property m 'tweaks)))
1782 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1783 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1785 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1786 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1788 LicenseCCBYPlain = \markup {Creative Commons BY \with-url #"http://creativecommons.org/licenses/by/3.0/at/" {\translate #'(0 . -0.7) \epsfile #Y #3 #"orchestrallily/cc-by.eps" }}
1789 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" }}
1790 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" }}
1791 LicenseNoRestrictions = \markup{\line {Die Ausgabe darf kopiert und ohne Einschränkungen aufgeführt werden. / May be copied and performed without restriction.}}
1793 \include "sceaux_clef-key.ily"
1796 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1797 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1799 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1802 startUnremovableSection = \set Staff.keepAliveInterfaces =
1803 #'(rhythmic-grob-interface
1806 percent-repeat-item-interface
1807 percent-repeat-interface
1808 stanza-number-interface)
1810 endUnremovableSection = \unset Staff.keepAliveInterfaces
1813 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1814 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1815 %%%%% EDITORIAL ANNOTATIONS
1816 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1817 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1819 #(define-public (editorial-bracket-stencil stil padding widen)
1820 "Add brackets for editorial annoations around STIL, producing a new stencil."
1822 (other-axis (lambda (a) (remainder (+ a 1) 2)))
1823 (ext (interval-widen (ly:stencil-extent stil axis) widen))
1826 (lb (ly:bracket axis ext thick protrusion))
1827 (rb (ly:bracket axis ext thick (- protrusion))))
1828 (set! stil (ly:stencil-combine-at-edge stil (other-axis axis) 1 rb padding))
1830 (ly:stencil-combine-at-edge lb (other-axis axis) 1 stil padding))
1833 editorialHairpin = \once \override Hairpin #'stencil = #(lambda (grob) (editorial-bracket-stencil (ly:hairpin::print grob) 0.2 0.55))
1834 editorialDynamic = \once \override DynamicText #'stencil = #(lambda (grob) (editorial-bracket-stencil (ly:text-interface::print grob) 0.2 0.55))
1835 editorialMarkup = \once \override TextScript #'stencil = #(lambda (grob) (editorial-bracket-stencil (ly:text-interface::print grob) 0.2 0.55))
1837 % videStart = \mark \markup { \hspace #1 \musicglyph #"scripts.coda" \with-dimensions #'(0 . 0) #'(0 . 0) \left-align { vi-} }
1838 videStart = \mark \markup \halign #-2.3 \concat { \hspace #4.5 \musicglyph #"scripts.coda" \left-align { vi- } }
1839 % videEnd = \notemode {
1840 % \once \override Score.RehearsalMark #'break-visibility = #begin-of-line-invisible
1841 % \mark \markup \concat{ \with-dimensions #'(0 . 0) #'(0 . 0) \right-align { -de } \hspace #1 \musicglyph #"scripts.coda" }
1843 videEnd = \notemode {
1844 \once \override Score.RehearsalMark #'break-visibility = #begin-of-line-invisible
1845 \mark \markup \concat{ \right-align { -de } \hspace #1.5 \musicglyph #"scripts.coda" \hspace #4.2 }
1859 % annotate-spacing = ##t
1862 ragged-last-bottom = ##f
1864 top-markup-spacing #'minimum-distance = #5
1865 % top-markup-spacing #'basic-distance = #4
1866 % top-markup-spacing #'padding = #2
1867 top-markup-spacing #'stretchability = #15
1869 top-system-spacing #'minimum-distance = #0
1870 % top-system-spacing #'basic-distance = #3
1871 top-system-spacing #'padding = #2
1872 top-system-spacing #'stretchability = #13
1874 markup-system-spacing #'minimum-distance = #5
1875 % markup-system-spacing #'basic-distance = #4
1876 markup-system-spacing #'padding = #3
1877 markup-system-spacing #'stretchability = #25
1879 system-system-spacing #'minimum-distance = #0
1880 % system-system-spacing #'basic-distance = #5
1881 system-system-spacing #'padding = #2
1882 system-system-spacing #'stretchability = #15
1884 last-bottom-spacing #'basic-distance = #3
1885 % last-bottom-spacing #'basic-distance = #7
1886 last-bottom-spacing #'padding = #4
1887 last-bottom-spacing #'stretchability = #14
1889 % score-markup-spacing #'basic-distance = #5
1890 % score-markup-spacing #'stretchability = #15
1892 % markup-markup-spacing #'basic-distance = #5
1893 % markup-markup-spacing #'stretchability = #30
1897 \context { \PianoStaff
1898 \override StaffGrouper #'staff-staff-spacing #'stretchability = #1.5
1900 \context { \StaffGroup
1901 \override StaffGrouper #'staff-staff-spacing #'stretchability = #2.5
1902 \override SystemStartBracket #'collapse-height = #1
1904 \context { \GrandStaff
1905 \override StaffGrouper #'staff-staff-spacing #'stretchability = #3
1906 \override StaffGrouper #'staffgroup-staff-spacing #'stretchability = #3
1908 \context { \ChoirStaff
1909 \override StaffGrouper #'staff-staff-spacing #'stretchability = #1
1912 \override StaffGrouper #'staff-staff-spacing #'stretchability = #4.9
1915 \override StaffGrouper #'staff-staff-spacing #'stretchability = #5
1921 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1922 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1924 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1925 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1927 % _ does not work as a direction modifier in figured bass
1928 tsdown = #(make-music 'TextScriptEvent 'text "t.s." 'direction DOWN )