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: GPL v3.0, http://www.gnu.org/licenses/gpl.html
14 % 0.01 (2008-03-02): Initial Version
15 % 0.02 (2008-03-06): Added basic MIDI support (*MidiInstrument and \setCreateMIDI)
16 % 0.03 (2008-07-xx): General staff/voice types, title pages, etc.
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19 #(use-modules (ice-9 match))
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24 %%%%% SCORE STRUCTURE AND AUTOMATIC GENERATION
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 % Helper function to filter all non-null entries
36 #(define (not-null? x) (not (null? x)))
38 % Helper function to extract a given variable, built from [Piece][Instrument]Identifier
39 #(define (namedPieceInstrObject piece instr name)
41 (fullname (string->symbol (string-append piece instr name)))
42 (instrname (string->symbol (string-append instr name)))
43 (piecename (string->symbol (string-append piece name)))
46 ((defined? fullname) (primitive-eval fullname))
47 ((defined? instrname) (primitive-eval instrname))
48 ((defined? piecename) (primitive-eval piecename))
54 %% Print text as a justified paragraph, taken from the lilypond Notation Reference
55 #(define-markup-list-command (paragraph layout props args) (markup-list?)
56 (let ((indent (chain-assoc-get 'par-indent props 2)))
57 (interpret-markup-list layout props
58 (make-justified-lines-markup-list (cons (make-hspace-markup indent)
61 conditionalBreak = #(define-music-function (parser location) ()
62 #{ \tag #'instrumental-score \pageBreak #}
65 #(define (oly:piece-title-markup title) (markup #:column (#:line (#:fontsize #'3 #:bold title))) )
67 #(define-markup-command (piece-title layout props title) (markup?)
68 (interpret-markup layout props (oly:piece-title-markup title))
71 #(define (oly:generate_object_name piece instr obj )
72 (if (and (string? piece) (string? instr) (string? obj))
73 (string-append piece instr obj)
77 #(define (oly:generate_staff_name piece instr) (oly:generate_object_name piece instr "St"))
79 #(define (set-context-property context property value)
80 (set! (ly:music-property context property) value)
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 % Score structure and voice types
86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 #(define oly:LiedScoreStructure '(
89 ("SoloScore" "SimultaneousMusic" ("Singstimme"))
90 ("Pfe" "PianoStaff" ("PfeI" "PfeII"))
91 ;("PfeI" "ParallelVoicesStaff" ("OIa" "OIb"))
92 ;("PfeII" "ParallelVoicesStaff" ("OIIa" "OIIb"))
93 ("FullScore" "SimultaneousMusic" ("Singstimme" "Pfe"))
94 ("VocalScore" "SimultaneousMusic" ("Singstimme" "Pfe"))
97 #(define oly:fullOrchestraScoreStructure '(
98 ; Part-combined staves for full score
99 ("Fl" "PartCombinedStaff" ("FlI" "FlII"))
100 ("Ob" "PartCombinedStaff" ("ObI" "ObII"))
101 ("Cl" "PartCombinedStaff" ("ClI" "ClII"))
102 ("Fag" "PartCombinedStaff" ("FagI" "FagII"))
103 ("Wd" "StaffGroup" ("Fl" "Ob" "Cl" "Fag" "CFag"))
105 ("Cor" "PartCombinedStaff" ("CorI" "CorII"))
106 ("Trb" "PartCombinedStaff" ("TrbI" "TrbII"))
107 ("Tbe" "PartCombinedStaff" ("TbeI" "TbeII"))
108 ("Br" "StaffGroup" ("Cor" "Trb" "Tbe" "Tba"))
110 ; long score; no part-combined staves, but GrandStaves instead
111 ("FlLong" "GrandStaff" ("FlI" "FlII"))
112 ("ObLong" "GrandStaff" ("ObI" "ObII"))
113 ("ClLong" "GrandStaff" ("ClI" "ClII"))
114 ("FagLong" "GrandStaff" ("FagI" "FagII"))
115 ("WdLong" "StaffGroup" ("FlLong" "ObLong" "ClLong" "FagLong" "CFag"))
117 ("CorLong" "GrandStaff" ("CorI" "CorII"))
118 ("TrbLong" "GrandStaff" ("TrbI" "TrbII"))
119 ("TbeLong" "GrandStaff" ("TbeI" "TbeII" "TbeIII"))
120 ("BrLong" "StaffGroup" ("CorLong" "TrbLong" "TbeLong" "Tba"))
123 ("Perc" "StaffGroup" ("Tim"))
125 ; Strings, they are the same in long and short full score
126 ("V" "GrandStaff" ("VI" "VII"))
127 ("Str" "StaffGroup" ("V" "Va"))
128 ("VceB" "StaffGroup" ("Vc" "Cb" "VcB"))
129 ("FullStr" "StaffGroup" ("V" "Va" "Vc" "Cb" "VcB"))
132 ("Solo" "SimultaneousMusic" ("SSolo" "ASolo" "TSolo" "BSolo"))
133 ("Ch" "ChoirStaff" ("S" "A" "T" "B"))
134 ("ChoralScore" "SimultaneousMusic" ("Ch"))
135 ("SoloScore" "SimultaneousMusic" ("Solo"))
136 ("SoloChoirScore" "SimultaneousMusic" ("Solo" "Ch"))
138 ; Organ score (inkl. Figured bass)
139 ("BCFb" "FiguredBass" ())
140 ("FiguredBass" "FiguredBass" ())
141 ;("Organ" "SimultaneousMusic" ("BCFb" "O"))
142 ("Organ" "ParallelVoicesStaff" ("BCFb" "BC" "FiguredBass"))
143 ("Continuo" "ParallelVoicesStaff" ("BCFb" "BC" "FiguredBass"))
145 ("O" "PianoStaff" ("OI" "OII"))
146 ("OI" "ParallelVoicesStaff" ("OIa" "OIb"))
147 ("OII" "ParallelVoicesStaff" ("OIIa" "OIIb"))
148 ;("BassGroup" "ParallelVoicesStaff" ("Organ" "O" "BC" "VceB"))
149 ("BassGroup" "StaffGroup" ("O" "Continuo"))
152 ("FullScore" "SimultaneousMusic" ("Wd" "Br" "Perc" "Str" "SoloChoirScore" "BassGroup"))
153 ("LongScore" "SimultaneousMusic" ("WdLong" "BrLong" "Perc" "Str" "SoloChoirScore" "BassGroup"))
156 ;("Piano" "SimultaneousMusic" ("Organ"))
157 ("OrganScore" "SimultaneousMusic" ("ChoralScore" "O"))
158 ("VocalScore" "SimultaneousMusic" ("ChoralScore" "Piano"))
159 ("Particell" "SimultaneousMusic" ("ChoralScore" "Continuo"))
161 ; Full scores: Orchestral score and long score including organ
162 ("ChStrQ" "SimultaneousMusic" ("Str" "Ch" "VceB"))
164 #(define oly:orchestral_score_structure oly:fullOrchestraScoreStructure)
166 #(define (oly:set_score_structure struct)
168 (set! oly:orchestral_score_structure struct)
169 (ly:warning (_ "oly:set_score_structure needs an association list as argument!"))
173 #(define (oly:modify_score_structure entry)
175 (set! oly:orchestral_score_structure (assoc-set! oly:orchestral_score_structure (car entry) (cdr entry)))
176 (ly:warning (_ "oly:modify_score_structure expects a list (\"key\" \"type\" '(children)) as argument!"))))
178 #(define (oly:remove_from_score_structure entry)
180 (map oly:remove_from_score_structure entry)
181 (set! oly:orchestral_score_structure (assoc-remove! oly:orchestral_score_structure entry))))
183 orchestralScoreStructure = #(define-music-function (parser location structure) (list?)
184 (oly:set_score_structure structure)
185 (make-music 'Music 'void #t)
188 #(define oly:voice_types '())
190 #(define (oly:set_voice_types types)
192 (set! oly:voice_types types)
193 (ly:warning (_ "oly:set_voice_types needs an association list as argument!"))
197 orchestralVoiceTypes = #(define-music-function (parser location types) (list?)
198 (oly:set_voice_types types)
199 (make-music 'Music 'void #t)
203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204 % Automatic staff and group generation
205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
207 % Retrieve all music definitions for the given
208 #(define (oly:get_music_object piece instrument)
209 (namedPieceInstrObject piece instrument "Music")
211 #(define (oly:get_music_objects piece instruments)
212 (filter not-null? (map (lambda (i) (oly:get_music_object piece i)) instruments))
215 % Given a property name and the extensions, either generate the pair to set
216 % the property or an empty list, if no pre-defined variable could be found
217 #(define (oly:generate_property_pair prop piece instr type)
218 (let* ((val (namedPieceInstrObject piece instr type)))
219 (if (not-null? val) (list 'assign prop val) '() )
223 #(define (oly:staff_type type)
225 ((string? type) (string->symbol type))
226 ((symbol? type) type)
231 #(define (oly:extractPitch music)
233 (elems (if (ly:music? music) (ly:music-property music 'elements)))
234 (note (if (pair? elems) (car elems)))
235 (pitch (if (ly:music? note) (ly:music-property note 'pitch)))
237 (if (and (not-null? music) (not (ly:pitch? pitch)))
238 (ly:warning "Unable to interpret as a pitch!")
244 #(define (oly:extractTranspositionPitch piece name)
246 (trpFromPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeFrom")))
247 (trpToPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeTo")))
249 (if (ly:pitch? trpFromPitch)
250 (if (ly:pitch? trpToPitch)
252 (ly:pitch-diff trpFromPitch trpToPitch)
253 (ly:pitch-diff trpFromPitch (ly:make-pitch 0 0 0))
255 (if (ly:pitch? trpToPitch)
256 (ly:pitch-diff (ly:make-pitch 0 0 0) trpToPitch)
263 #(define (oly:musiccontent_for_voice parser piece name music additional)
264 (let* ((musiccontent additional))
266 ; Append the settings, key and clef (if defined)
269 (let* ((object (namedPieceInstrObject piece name type)))
270 (if (ly:music? object)
271 (set! musiccontent (append musiccontent (list (ly:music-deep-copy object))))
272 (if (not-null? object) (ly:warning (_ "Wrong type (no ly:music) for ~S for instrument ~S in piece ~S") type name piece))
276 ; TODO: Does the "Tempo" work here???
277 '("Settings" "Key" "Clef" "TimeSignature" ;"Tempo"
281 (if (ly:music? music)
283 (set! musiccontent (make-simultaneous-music (append musiccontent (list music))))
284 ;(ly:message "Generating staff for ~a" name)
285 (let* ((trpPitch (oly:extractTranspositionPitch piece name)))
286 (if (ly:pitch? trpPitch)
287 (set! musiccontent (ly:music-transpose musiccontent trpPitch))
292 ; For empty music, return empty
298 #(define (oly:lyrics_create_single_context parser piece name voicename lyricsid)
299 ; If we have lyrics, create a lyrics context containing LyricCombineMusic
300 ; and add that as second element to the staff's elements list...
301 (let* ((id (string-append "Lyrics" lyricsid))
302 (lyrics (namedPieceInstrObject piece name id)))
303 (if (ly:music? lyrics)
304 (context-spec-music (make-music 'LyricCombineMusic
306 'associated-context voicename)
307 'Lyrics (oly:generate_object_name piece name id))
312 #(define (oly:lyrics_create_contexts parser piece name voicename)
315 (oly:lyrics_create_single_context parser piece name voicename str))
316 (list "" "I" "II" "III" "IV" "V" "VI"))))
318 #(define (oly:voice_handler_internal parser piece name type music)
319 (if (ly:music? music)
321 (voicename (oly:generate_object_name piece name "Voice" ))
322 (lyrics (oly:lyrics_create_contexts parser piece name voicename))
323 (additional (if (not-null? lyrics) (list dynamicUp) '()))
324 (musiccontent (oly:musiccontent_for_voice parser piece name music additional))
325 (voicetype (oly:staff_type type))
326 (voice (context-spec-music musiccontent voicetype voicename))
330 ; For empty music, return empty
335 #(define (oly:voice_handler parser piece name type)
336 (oly:voice_handler_internal parser piece name type (oly:get_music_object piece name)))
339 #(define (oly:staff_handler_internal parser piece name type voices)
340 (if (not-null? voices)
342 (staffname (oly:generate_staff_name piece name))
343 (stafftype (oly:staff_type type))
344 (staff (make-simultaneous-music voices))
345 (propops (oly:staff_handler_properties piece name))
348 ((SimultaneousMusic ParallelMusic) #f)
349 (else (set! staff (context-spec-music staff stafftype staffname)))
351 (if (not-null? propops)
352 (set! (ly:music-property staff 'property-operations) propops)
356 ; For empty music, return empty
361 #(define (oly:staff_handler parser piece name type children)
362 (let* ((c (if (not-null? children) children (list name)))
363 (voices (apply append (map (lambda (v) (oly:create_voice parser piece v)) c)) )
365 (if (not-null? voices)
366 (oly:staff_handler_internal parser piece name type voices)
372 #(define (oly:devnull_handler parser piece name type children)
373 (oly:voice_handler parser piece name type)
376 #(define (oly:parallel_voices_staff_handler parser piece name type children)
378 (voices (map (lambda (i) (oly:create_voice parser piece i)) children))
379 ; get the list of non-empty voices and flatten it!
380 (nonemptyvoices (apply append (filter not-null? voices)))
382 (if (not-null? nonemptyvoices)
383 (oly:staff_handler_internal parser piece name "Staff" nonemptyvoices)
389 #(define (oly:part_combined_staff_handler parser piece name type children)
390 (let* ((rawmusic (map (lambda (c) (oly:musiccontent_for_voice parser piece name (oly:get_music_object piece c) '())) children))
391 (music (filter not-null? rawmusic)))
393 ((and (pair? music) (ly:music? (car music)) (not-null? (cdr music)) (ly:music? (cadr music)))
394 ;(ly:message "Part-combine with two music expressions")
395 (oly:staff_handler_internal parser piece name "Staff" (list (make-part-combine-music parser music))))
397 (ly:warning "Part-combine without any music expressions")
399 ; exactly one is a music expression, simply use that by joining
401 (ly:message "Part-combine with only one music expressions")
402 (oly:staff_handler_internal parser piece name "Staff" (list (apply append music))))
404 ;(ly:message "make_part_combined_staff: ~S ~S ~a" piece instr instruments)
410 % Generate the properties for the staff for piece and instr. Typically, these
411 % are the instrument name and the short instrument name (if defined).
412 % return a (possibly empty) list of all assignments.
413 #(define (oly:staff_handler_properties piece instr)
416 (instrumentName . "InstrumentName")
417 (shortInstrumentName . "ShortInstrumentName")
418 (midiInstrument . "MidiInstrument")
422 (oly:generate_property_pair (car pr) piece instr (cdr pr))
425 (props (filter not-null? assignments))
431 % Figured bass is a special case, as it can be voice- or staff-type. When
432 % given as a staff type, simply call the voice handler, instead
434 #(define (oly:figured_bass_staff_handler parser piece name type children)
435 (let* ((c (if (not-null? children) children (list name)))
436 (voice (oly:voice_handler parser piece (car c) type)))
437 (if (pair? voice) (car voice) ())
441 #(define (flatten lst)
442 (define (f remaining result)
444 ((null? remaining) result)
445 ((pair? (car remaining)) (f (cdr remaining) (f (car remaining) result)))
446 (else (f (cdr remaining) (cons (car remaining) result)))))
447 (reverse! (f lst '())))
449 #(define (oly:staff_group_handler parser piece name type children)
451 (staves (flatten (map (lambda (i) (oly:create_staff_or_group parser piece i)) children)))
452 (nonemptystaves (filter not-null? staves))
454 (if (not-null? nonemptystaves)
456 (musicexpr (if (= 1 (length nonemptystaves))
458 (make-simultaneous-music nonemptystaves)))
459 (groupname (oly:generate_staff_name piece name))
460 (grouptype (oly:staff_type type))
462 (propops (oly:staff_handler_properties piece name))
465 ((SimultaneousMusic ParallelMusic) #f)
466 (else (set! group (context-spec-music group grouptype groupname)))
469 (set! (ly:music-property group 'property-operations) propops))
472 ; Return empty list if no staves are generated
478 #(define (oly:create_voice parser piece name)
479 (let* ( (voice (namedPieceInstrObject piece name "Voice"))
480 (type (assoc-ref oly:voice_types name)) )
481 (if (not-null? voice)
482 ; Explicit voice variable, use that
486 ; No entry in structure found => simple voice
487 (oly:voice_handler parser piece name "Voice")
488 ; Entry found in structure => use the handler for the given type
490 (voicetype (car type))
491 (handler (assoc-ref oly:voice_handlers voicetype))
494 ((primitive-eval handler) parser piece name voicetype)
496 (ly:warning "No handler found for voice type ~a, using default voice handler" voicetype)
497 (oly:voice_handler parser piece name voicetype)
506 #(define (oly:create_staff_or_group parser piece name)
507 (let* ( (staff (namedPieceInstrObject piece name "Staff"))
508 (type_from_structure (assoc-ref oly:orchestral_score_structure name)) )
509 ;(if (not-null? staff)
510 ; (ly:message "Found staff variable for instrument ~a in piece ~a" instr piece)
511 ; (ly:message "Staff variable for instrument ~a in piece ~a NOT FOUND" instr piece)
513 (if (not-null? staff)
514 ; Explicit staff variable, use that
517 (if (not (list? type_from_structure))
518 ; No entry in structure found => simple staff
519 (oly:staff_handler parser piece name "Staff" '())
521 ; Entry found in structure => use the handler for the given type
522 (let* ((type (car type_from_structure))
523 (handler (assoc-ref oly:staff_handlers type))
524 (children (cadr type_from_structure))
527 ((primitive-eval handler) parser piece name type children)
529 (ly:warning "No handler found for staff type ~a, using default staff handler" type)
530 (oly:staff_handler parser piece name type children)
539 #(define oly:staff_handlers
542 '("GrandStaff" . oly:staff_group_handler )
543 '("PianoStaff" . oly:staff_group_handler )
544 '("ChoirStaff" . oly:staff_group_handler )
545 '("StaffGroup" . oly:staff_group_handler )
546 '("InnerChoirStaff" . oly:staff_group_handler )
547 '("InnerStaffGroup" . oly:staff_group_handler )
548 '("ParallelMusic" . oly:staff_group_handler )
549 '("SimultaneousMusic" . oly:staff_group_handler )
551 '("Staff" . oly:staff_handler )
552 '("DrumStaff" . oly:staff_handler )
553 '("RhythmicStaff" . oly:staff_handler )
554 '("TabStaff" . oly:staff_handler )
555 '("GregorianTranscriptionStaff" . oly:staff_handler )
556 '("MensuralStaff" . oly:staff_handler )
557 '("VaticanaStaff" . oly:staff_handler )
558 ; staves with multiple voices
559 '("PartCombinedStaff" . oly:part_combined_staff_handler )
560 '("ParallelVoicesStaff" . oly:parallel_voices_staff_handler )
561 ; special cases: Figured bass can be staff or voice type!
562 '("FiguredBass" . oly:figured_bass_staff_handler )
563 ; Devnull is like a staff, only that it doesn't craete output
564 '("Devnull" . oly:devnull_handler )
568 #(define oly:voice_handlers
571 '("Voice" . oly:voice_handler )
572 '("CueVoice" . oly:voice_handler )
573 '("DrumVoice" . oly:voice_handler )
574 '("FiguredBass" . oly:voice_handler )
575 '("GregorianTranscriptionVoice" . oly:voice_handler )
576 '("NoteNames" . oly:voice_handler )
577 '("TabVoice" . oly:voice_handler )
578 '("VaticanaVoice" . oly:voice_handler )
579 ;'("Dynamics" . oly:dynamics_handler )
584 #(define (oly:register_staff_type_handler type func)
585 ; (ly:message "Registering staff handler ~a for type ~a" func type)
586 (set! oly:staff_handlers (assoc-set! oly:staff_handlers type func))
589 #(define (oly:register_voice_type_handler type func)
590 ; (ly:message "Registering voice type handler ~a for type ~a" func type)
591 (set! oly:voice_handlers (assoc-set! oly:voice_handlers type func))
594 % handlers for deprecated API
595 #(oly:register_staff_type_handler 'StaffGroup 'oly:staff_group_handler)
596 #(oly:register_staff_type_handler 'GrandStaff 'oly:staff_group_handler)
597 #(oly:register_staff_type_handler 'PianoStaff 'oly:staff_group_handler)
598 #(oly:register_staff_type_handler 'ChoirStaff 'oly:staff_group_handler)
599 #(oly:register_staff_type_handler 'Staff 'oly:staff_handler )
600 #(oly:register_staff_type_handler 'ParallelMusic 'oly:staff_group_handler)
601 #(oly:register_staff_type_handler 'SimultaneousMusic 'oly:staff_group_handler)
602 #(oly:register_staff_type_handler #t 'oly:part_combined_staff_handler )
603 #(oly:register_staff_type_handler #f 'oly:parallel_voices_staff_handler )
607 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
608 % Automatic score generation
609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
611 % \setUseBook ##t/##f sets a flag to determine whether the calls to createScore
612 % are from within a book block or not
613 % #(define oly:score_handler collect-scores-for-book)
614 % #(define oly:score_handler toplevel-score-handler)
615 % #(define oly:music_handler toplevel-music-handler)
616 % #(define oly:text_handler toplevel-text-handler)
618 % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
619 #(define-public (add-score parser score)
620 (ly:parser-define! parser 'toplevel-scores
621 (cons score (ly:parser-lookup parser 'toplevel-scores))))
623 #(define-public (add-text parser text)
624 (add-score parser (list text)))
626 #(define-public (add-music parser music)
627 (collect-music-aux (lambda (score)
628 (add-score parser score))
632 #(define-public (toplevel-book-handler parser book)
634 (ly:book-add-score! book score))
635 (reverse! (ly:parser-lookup parser 'toplevel-scores)))
636 (ly:parser-define! parser 'toplevel-scores (list))
637 (print-book-with-defaults parser book))
639 #(define-public (book-score-handler book score)
640 (add-score parser score))
642 #(define-public (book-text-handler book text)
643 (add-text parser text))
645 #(define-public (book-music-handler parser book music)
646 (add-music parser music))
648 #(define oly:score_handler add-score)
649 #(define oly:music_handler add-music)
650 #(define oly:text_handler add-text)
654 setUseBook = #(define-music-function (parser location usebook) (boolean?)
655 (ly:warning "\\setUseBook has been deprecated! Books are now automatically handled without any hacks")
656 (make-music 'Music 'void #t)
660 % Two functions to handle midi-blocks: Either don't set one, or set an empty
661 % one so that MIDI is generated
662 #(define (oly:set_no_midi_block score) '())
663 #(define (oly:set_midi_block score)
664 (let* ((midiblock (if (defined? '$defaultmidi)
665 (ly:output-def-clone $defaultmidi)
666 (ly:make-output-def))))
667 (ly:output-def-set-variable! midiblock 'is-midi #t)
668 (ly:score-add-output-def! score midiblock)
672 % \setCreateMidi ##t/##f sets a flag to determine wheter MIDI output should
674 #(define oly:apply_score_midi oly:set_no_midi_block)
675 setCreateMIDI = #(define-music-function (parser location createmidi) (boolean?)
677 (set! oly:apply_score_midi oly:set_midi_block)
678 (set! oly:apply_score_midi oly:set_no_midi_block)
680 (make-music 'Music 'void #t)
684 % Two functions to handle layout-blocks: Either don't set one, or set an empty
685 % one so that a PDF is generated
686 #(define (oly:set_no_layout_block score) '())
687 #(define (oly:set_layout_block score)
688 (let* ((layoutblock (if (defined? '$defaultlayout)
689 (ly:output-def-clone $defaultlayout)
690 (ly:make-output-def))))
691 (ly:output-def-set-variable! layoutblock 'is-layout #t)
692 (ly:score-add-output-def! score layoutblock)
696 % \setCreatePDF ##t/##f sets a flag to determine wheter PDF output should
698 #(define oly:apply_score_layout oly:set_no_layout_block)
699 setCreatePDF = #(define-music-function (parser location createlayout) (boolean?)
701 (set! oly:apply_score_layout oly:set_layout_block)
702 (set! oly:apply_score_layout oly:set_no_layout_block)
704 (make-music 'Music 'void #t)
708 % Set the piece title in a new header block.
709 #(define (oly:set_piece_header score piecename)
710 (if (not-null? piecename)
711 (let* ((header (make-module)))
712 (module-define! header 'piece piecename)
713 (ly:score-set-header! score header)
719 % post-filter functions. By default, no filtering is done. However,
720 % for the *NoCues* function, the cue notes should be killed
721 identity = #(define-music-function (parser location music) (ly:music?) music)
722 cuefilter = #(define-music-function (parser location music) (ly:music?)
723 ((ly:music-function-extract removeWithTag) parser location 'cued ((ly:music-function-extract killCues) parser location music))
727 #(define (oly:create-toc-file layout pages)
728 (let* ((label-table (ly:output-def-lookup layout 'label-page-table)))
729 (if (not (null? label-table))
730 (let* ((format-line (lambda (toc-item)
731 (let* ((label (car toc-item))
732 (text (caddr toc-item))
733 (label-page (and (list? label-table)
734 (assoc label label-table)))
735 (page (and label-page (cdr label-page))))
736 (format #f "~a, section, 1, {~a}, ~a" page text label))))
737 (formatted-toc-items (map format-line (toc-items)))
738 (whole-string (string-join formatted-toc-items ",\n"))
739 (output-name (ly:parser-output-name parser))
740 (outfilename (format "~a.toc" output-name))
741 (outfile (open-output-file outfilename)))
742 (if (output-port? outfile)
743 (display whole-string outfile)
744 (ly:warning (_ "Unable to open output file ~a for the TOC information") outfilename))
745 (close-output-port outfile)))))
748 #(define-public (oly:add-toc-item parser markup-symbol text)
749 (oly:music_handler parser (add-toc-item! markup-symbol text)))
752 #(define (oly:add-score parser score piecename)
753 (if (not-null? piecename)
754 (oly:add-toc-item parser 'tocItemMarkup piecename))
755 (oly:score_handler parser score)
757 % The helper function to build a score.
758 #(define (oly:createScoreHelper parser location piece children func)
760 (staves (oly:staff_group_handler parser piece "" "SimultaneousMusic" children))
761 (music (if (not-null? staves)
762 ((ly:music-function-extract func) parser location staves)
766 (piecename (namedPieceInstrObject piece (car children) "PieceName"))
767 (piecenametacet (namedPieceInstrObject piece (car children) "PieceNameTacet"))
771 ; No staves, print tacet
773 (if (not-null? piecenametacet) (set! piecename piecenametacet))
774 (if (not-null? piecename)
775 (oly:add-score parser (list (oly:piece-title-markup piecename)) piecename)
776 (ly:warning (_ "No music and no score title found for part ~a and instrument ~a") piece children)
779 ; we have staves, apply the piecename to the score and add layout/midi blocks if needed
781 (set! score (scorify-music music parser))
782 (oly:set_piece_header score piecename)
783 (oly:apply_score_midi score)
784 (oly:apply_score_layout score)
785 ; Schedule the score for typesetting
786 (oly:add-score parser score piecename)
790 ; This is a void function, the score has been schedulled for typesetting already
791 (make-music 'Music 'void #t)
794 createScore = #(define-music-function (parser location piece children) (string? list?)
795 (oly:createScoreHelper parser location piece children identity)
797 createNoCuesScore = #(define-music-function (parser location piece children) (string? list?)
798 (oly:createScoreHelper parser location piece children cuefilter)
801 createHeadline = #(define-music-function (parser location headline) (string?)
802 (oly:add-toc-item parser 'tocItemMarkup headline)
803 (oly:score_handler parser (list (oly:piece-title-markup headline)))
804 (make-music 'Music 'void #t)
809 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
810 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
812 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
813 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
815 newInstrument = #(define-music-function (parser location instr) (string?)
817 \set Voice.instrumentCueName = #$(string-join (list "+" instr))
820 cueText = #(define-music-function (parser location instr) (string?)
822 \set Voice.instrumentCueName = $instr
826 % generate a cue music section with instrument names
827 % Parameters: \namedCueDuring NameOfQuote CueDirection CueInstrument OriginalInstrument music
828 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
829 % -) CueInstrument and OriginalInstrument are the displayed instrument names
831 % \namedCueDuring #"vIQuote" #UP #"V.I" #"Sop." { R1*3 }
832 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
833 % the beginning of the cue notes and "Sop." at the end
834 namedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr cuemusic) (string? number? string? string? ly:music?)
836 \cueDuring #$cuevoice #$direction { \tag #'cued \cueText #$instrcue $cuemusic \tag #'cued \cueText #$instr }
837 % \tag #'uncued $cuemusic
840 namedTransposedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr trans cuemusic) (string? number? string? string? ly:music? ly:music?)
842 \transposedCueDuring #$cuevoice #$direction $trans { \tag #'cued \cueText #$instrcue $cuemusic \tag #'cued \cueText #$instr }
843 % \tag #'uncued $cuemusic
847 % set the cue instrument name and clef
848 setClefCue = #(define-music-function (parser location instr clef)
851 \once \override Staff.Clef #'font-size = #-3 $clef
852 \set Voice.instrumentCueName = $instr
855 % generate a cue music section with instrument names and clef changes
856 % Parameters: \cleffedCueDuring NameOfQuote CueDirection CueInstrument CueClef OriginalInstrument OriginalClef music
857 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
858 % -) CueInstrument and OriginalInstrument are the displayed instrument names
859 % -) CueClef and OriginalClef are the clefs for the the cue notes and the clef of the containing voice
861 % \cleffedCueDuring #"vIQuote" #UP #"V.I" #"treble" #"Basso" #"bass" { R1*3 }
862 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
863 % the beginning of the cue notes and "Basso" at the end. The clef is changed to treble at the
864 % beginning of the cue notes and reset to bass at the end
865 cleffedCueDuring = #(define-music-function (parser location cuevoice direction instrcue clefcue instr clefinstr cuemusic)
866 (string? number? string? ly:music? string? ly:music? ly:music?)
868 \cueDuring #$cuevoice #$direction { \tag #'cued \setClefCue #$instrcue $clefcue $cuemusic \tag #'cued \setClefCue #$instr $clefinstr }
869 % \tag #'uncued $cuemusic
876 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
877 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
879 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
880 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
883 dynamicsX = #(define-music-function (parser location offset) (number?)
885 \once \override DynamicText #'X-offset = $offset
886 \once \override DynamicLineSpanner #'Y-offset = #0
889 % Move the dynamic sign inside the staff to a fixed staff-relative position
890 % posY (where 0 means vertically starts at the middle staff line)
891 dynamicsAllInside = #(define-music-function (parser location offsetX posY)
894 % Invalid y-extent -> hidden from skyline calculation and collisions
895 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
896 % move by X offset and to fixed Y-position (use Y-offset of parent!)
897 \once \override DynamicText #'X-offset = $offsetX
898 \once \override DynamicText #'Y-offset =
900 (let* ((head (ly:grob-parent grob Y))
901 (offset (ly:grob-property head 'Y-offset)))
902 (- posY offset (- 0.6))))
903 \once \override DynamicLineSpanner #'Y-offset = $posY
906 dynamicsUpInside = #(define-music-function (parser location offsetX) (number?)
907 ((ly:music-function-extract dynamicsAllInside) parser location offsetX 1.5)
910 dynamicsDownInside = #(define-music-function (parser location offsetX) (number?)
911 ((ly:music-function-extract dynamicsAllInside) parser location offsetX -3.5)
914 hairpinOffset = #(define-music-function (parser location posY) (number?)
916 \once \override DynamicLineSpanner #'Y-offset = $posY
917 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
920 #(define ((line-break-offset before after) grob)
921 (let* ((orig (ly:grob-original grob))
922 ; All siblings if line-broken:
923 (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
924 (if (>= (length siblings) 2)
925 ; We have been line-broken
926 (if (eq? (car (last-pair siblings)) grob)
928 (ly:grob-set-property! grob 'Y-offset after)
929 ; Others get the before value:
930 (ly:grob-set-property! grob 'Y-offset before)
936 ffz = #(make-dynamic-script "ffz")
937 pf = #(make-dynamic-script "pf")
938 sempp = #(make-dynamic-script (markup #:line( #:with-dimensions '(0 . 0)
939 '(0 . 0) #:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
940 parenf = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")" )))
941 parenp = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "p" #:normal-text #:italic #:fontsize 2 ")" )))
942 pdolce = #(make-dynamic-script (markup #:line(#:dynamic "p" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
943 sfpdolce = #(make-dynamic-script (markup #:line(#:dynamic "sfp" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
944 bracketf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text "[" #:dynamic "f" #:normal-text "]"))))
945 bracketp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text "[" #:dynamic "p" #:normal-text "]"))))
949 % cresc = #(make-music 'CrescendoEvent 'span-direction START 'crescendoSpanner 'text 'crescendoText "cresc.")
950 % endcresc = #(make-span-event 'CrescendoEvent STOP)
951 % dim = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "dim.")
952 % enddim = #(make-span-event 'DecrescendoEvent STOP)
953 % decresc = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "decresc.")
954 % enddecresc = #(make-span-event 'DecrescendoEvent STOP)
959 cresc = #(make-music 'CrescendoEvent 'span-direction START
960 'span-type 'text 'span-text "cresc.")
961 dim = #(make-music 'DecrescendoEvent 'span-direction START
962 'span-type 'text 'span-text "dim.")
963 decresc = #(make-music 'DecrescendoEvent 'span-direction START
964 'span-type 'text 'span-text "decresc.")
966 newOrOldClef = #(define-music-function (parser location new old ) (string? string?)
967 (if (ly:get-option 'old-clefs) #{ \clef $old #} #{ \clef $new #})
972 %%% Thanks to "Gilles THIBAULT" <gilles.thibault@free.fr>, there is a way
973 % to remove also the fermata from R1-\fermataMarkup: By filtering the music
974 % and removing the corresponding events.
975 % Documented as an LSR snippet: http://lsr.dsi.unimi.it/LSR/Item?id=372
976 #(define (filterOneEventsMarkup event)
977 ( let ( (eventname (ly:music-property event 'name)) )
979 (or ;; add here event name you do NOT want
980 (eq? eventname 'MultiMeasureTextEvent)
981 (eq? eventname 'AbsoluteDynamicEvent)
982 (eq? eventname 'TextScriptEvent)
983 (eq? eventname 'ArticulationEvent)
984 (eq? eventname 'CrescendoEvent)
985 (eq? eventname 'DecrescendoEvent)
990 filterArticulations = #(define-music-function (parser location music) (ly:music?)
991 Â Â (music-filter filterOneEventsMarkup music)
998 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
999 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1000 %%%%% Tempo markings
1001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1006 rit = \markup {\italic "rit."}
1007 pocorit = \markup {\italic "poco rit."}
1008 ppmosso = \markup {\italic "poco più mosso"}
1009 dolce = \markup {\italic "dolce."}
1010 pizz = \markup {\italic "pizz."}
1011 arco = \markup {\italic "arco"}
1012 perd = \markup {\italic "perdend."}
1017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1019 %%%%% REST COMBINATION
1020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1025 %% REST COMBINING, TAKEN FROM http://lsr.dsi.unimi.it/LSR/Item?id=336
1028 %% \new Staff \with {
1029 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1030 %% } << \somevoice \\ \othervoice >>
1035 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1040 %% - only handles two voices
1041 %% - does not handle multi-measure/whole-measure rests
1043 #(define (rest-score r)
1045 (yoff (ly:grob-property-data r 'Y-offset))
1046 (sp (ly:grob-property-data r 'staff-position)))
1048 (set! score (+ score 2))
1049 (if (eq? yoff 'calculation-in-progress)
1050 (set! score (- score 3))))
1053 (set! score (+ score 2))
1054 (set! score (- score (abs (- 1 sp)))))
1057 #(define (merge-rests-on-positioning grob)
1058 (let* ((can-merge #f)
1059 (elts (ly:grob-object grob 'elements))
1060 (num-elts (and (ly:grob-array? elts)
1061 (ly:grob-array-length elts)))
1062 (two-voice? (= num-elts 2)))
1064 (let* ((v1-grob (ly:grob-array-ref elts 0))
1065 (v2-grob (ly:grob-array-ref elts 1))
1066 (v1-rest (ly:grob-object v1-grob 'rest))
1067 (v2-rest (ly:grob-object v2-grob 'rest)))
1071 (let* ((v1-duration-log (ly:grob-property v1-rest 'duration-log))
1072 (v2-duration-log (ly:grob-property v2-rest 'duration-log))
1073 (v1-dot (ly:grob-object v1-rest 'dot))
1074 (v2-dot (ly:grob-object v2-rest 'dot))
1075 (v1-dot-count (and (ly:grob? v1-dot)
1076 (ly:grob-property v1-dot 'dot-count -1)))
1077 (v2-dot-count (and (ly:grob? v2-dot)
1078 (ly:grob-property v2-dot 'dot-count -1))))
1081 (number? v1-duration-log)
1082 (number? v2-duration-log)
1083 (= v1-duration-log v2-duration-log)
1084 (eq? v1-dot-count v2-dot-count)))
1086 ;; keep the rest that looks best:
1087 (let* ((keep-v1? (>= (rest-score v1-rest)
1088 (rest-score v2-rest)))
1089 (rest-to-keep (if keep-v1? v1-rest v2-rest))
1090 (dot-to-kill (if keep-v1? v2-dot v1-dot)))
1091 ;; uncomment if you're curious of which rest was chosen:
1092 ;;(ly:grob-set-property! v1-rest 'color green)
1093 ;;(ly:grob-set-property! v2-rest 'color blue)
1094 (ly:grob-suicide! (if keep-v1? v2-rest v1-rest))
1095 (if (ly:grob? dot-to-kill)
1096 (ly:grob-suicide! dot-to-kill))
1097 (ly:grob-set-property! rest-to-keep 'direction 0)
1098 (ly:rest::y-offset-callback rest-to-keep)))))))
1101 (ly:rest-collision::calc-positioning-done grob))))
1107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1109 %%%%% TABLE OF CONTENTS
1110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1114 contentsTitle = "Inhalt / Contents"
1117 tocTitleMarkup = \markup \fill-line{
1120 \override #(cons 'line-width (* 7 cm))
1121 \line{ \fill-line {\piece-title {\contentsTitle} \null }}
1126 tocItemMarkup = \markup \fill-line {
1129 \override #(cons 'line-width (* 7 cm ))
1130 \line { \fill-line{\fromproperty #'toc:text \fromproperty #'toc:page }}
1137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1139 %%%%% TITLE PAGE / HEADER
1140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1143 #(define-markup-command (when-property layout props symbol markp) (symbol? markup?)
1144 (if (chain-assoc-get symbol props)
1145 (interpret-markup layout props markp)
1146 (ly:make-stencil '() '(1 . -1) '(1 . -1))))
1148 #(define-markup-command (vspace layout props amount) (number?)
1149 "This produces a invisible object taking vertical space."
1150 (let ((amount (* amount 3.0)))
1152 (ly:make-stencil "" (cons -1 1) (cons 0 amount))
1153 (ly:make-stencil "" (cons -1 1) (cons amount amount)))))
1157 titlePageMarkup = \markup \abs-fontsize #10 \when-property #'header:title \column {
1159 \fill-line { \fontsize #8 \fromproperty #'header:composer }
1161 \fill-line { \fontsize #8 \fromproperty #'header:poet }
1163 \fill-line { \fontsize #10 \bold \fromproperty #'header:titlepagetitle }
1165 \fontsize #2 \when-property #'header:titlepagesubtitle {
1166 \fill-line { \fromproperty #'header:titlepagesubtitle }
1169 \fill-line { \postscript #"-20 0 moveto 40 0 rlineto stroke" }
1171 \fill-line { \fontsize #5 \fromproperty #'header:ensemble }
1173 \fill-line { \fontsize #2 \fromproperty #'header:instruments }
1175 \fill-line { \fontsize #5 \fromproperty #'header:date }
1177 \fill-line { \fontsize #5 \fromproperty #'header:scoretype }
1179 \fontsize #2 \when-property #'header:enteredby {
1180 \fill-line { "Herausgegeben von: / Edited by:"}
1182 \fill-line { \fromproperty #'header:enteredby }
1185 \when-property #'header:arrangement \column {
1187 \fill-line { \fontsize #3 \fromproperty #'header:arrangement }
1192 titleHeaderMarkup = \markup {
1193 \override #'(baseline-skip . 3.5)
1195 \override #'(baseline-skip . 3.5)
1199 \larger \fromproperty #'header:title
1202 \large \smaller \bold
1203 \larger \fromproperty #'header:subtitle
1207 \fromproperty #'header:subsubtitle
1210 { \large \bold \fromproperty #'header:instrument }
1213 \fromproperty #'header:poet
1214 \fromproperty #'header:composer
1217 \fromproperty #'header:meter
1218 \fromproperty #'header:arranger
1224 titleScoreMarkup = \markup \piece-title \fromproperty #'header:piece
1227 scoreTitleMarkup = \titleScoreMarkup
1228 bookTitleMarkup = \titleHeaderMarkup
1233 %%%%%%%%%%%%%% headers and footers %%%%%%%%%%%%%%%%%%%%%%%%%%
1235 #(define (first-score-page layout props arg)
1236 (let* ((label 'first-score-page)
1237 (table (ly:output-def-lookup layout 'label-page-table))
1238 (label-page (and (list? table) (assoc label table)))
1239 (page-number (and label-page (cdr label-page)))
1241 (if (eq? (chain-assoc-get 'page:page-number props -1) page-number)
1242 (interpret-markup layout props arg)
1245 #(define no-header-table '())
1246 thisPageNoHeader = #(define-music-function (parser location) ()
1247 (let* ((label (gensym "header")))
1248 (set! no-header-table (cons label no-header-table))
1251 'page-label label)))
1254 % TODO: Use the no-header-table!
1255 #(define (is-header-page layout props arg)
1256 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1258 ;(if (and (> page-number 2) (!= page-number 7))
1259 (if (> page-number 1)
1260 (interpret-markup layout props arg)
1263 #(define no-footer-table '())
1264 thisPageNoFooter = #(define-music-function (parser location) ()
1265 (let* ((label (gensym "footer")))
1266 (set! no-footer-table (cons label no-footer-table))
1269 'page-label label)))
1271 % TODO: Use the no-footer-table!
1272 #(define (is-footer-page layout props arg)
1273 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1274 (label 'first-score-page)
1275 (table (ly:output-def-lookup layout 'label-page-table))
1276 (label-page (and (list? table) (assoc label table)))
1277 ;(page-number (and label-page (cdr label-page)))
1279 (if (and (> page-number 1))
1280 (interpret-markup layout props arg)
1284 #(define copyright-footer-table '())
1285 thisPageCopyrightFooter = #(define-music-function (parser location) ()
1286 (let* ((label (gensym "copyrightfooter")))
1287 (set! copyright-footer-table (cons label copyright-footer-table))
1290 'page-label label)))
1292 #(define copyright-pg 1)
1293 #(define (set-copyright-page page)
1294 (set! copyright-pg page)
1297 % TODO: Use the copyright-footer-table!
1298 #(define (copyright-page layout props arg)
1299 (if (= (chain-assoc-get 'page:page-number props -1) copyright-pg)
1300 (interpret-markup layout props arg)
1305 oddHeaderMarkup = \markup \fill-line {
1306 %% force the header to take some space, otherwise the
1307 %% page layout becomes a complete mess.
1309 \on-the-fly #is-header-page \fromproperty #'header:title
1310 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1312 evenHeaderMarkup = \markup \fill-line {
1313 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1314 \on-the-fly #is-header-page \fromproperty #'header:composer
1318 oddFooterMarkup = \markup {
1321 %% publisher header field only on title page.
1322 \on-the-fly #first-page \fromproperty #'header:publisher
1325 %% copyright on the first real score page
1326 \on-the-fly #copyright-page \fromproperty #'header:copyright
1327 \on-the-fly #copyright-page \null
1330 %% All other pages get the number of the edition centered
1331 \on-the-fly #is-footer-page \fromproperty #'header:scorenumber
1348 % Interpret the given markup with the header fields added to the props.
1349 % This way, one can re-use the same functions (using fromproperty
1350 % #'header:field) in the header block and as top-level markup.
1352 % This function is originally copied from mark-up-title (file scm/titling.scm),
1353 % which is lilypond's internal function to handle the title markups. I needed
1354 % to replace the scopes and manually add the $defaultheader (which is internally
1355 % done in paper-book.cc before calling mark-up-title. Also, I don't extract the
1356 % markup from the header block, but use the given markup.
1358 % I'm not sure if I really need the page properties in props, too... But I
1359 % suppose it does not hurt, either.
1360 #(define-markup-command (markupWithHeader layout props markup) (markup?)
1361 "Interpret the given markup with the header fields added to the props.
1362 This way, one can re-use the same functions (using fromproperty
1363 #'header:field) in the header block and as top-level markup."
1365 ; TODO: If we are inside a score, add the score's local header block, too!
1366 ; Currently, I only use the global header block, stored in $defaultheader
1367 (scopes (list $defaultheader))
1368 (alists (map ly:module->alist scopes))
1371 (map (lambda (alist)
1372 (map (lambda (entry)
1374 (string->symbol (string-append "header:" (symbol->string (car entry))))
1378 (props (append prefixed-alist
1380 (layout-extract-page-properties layout)))
1382 (interpret-markup layout props markup)
1391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1392 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1393 %%%%% Equally spacing multiple columns (e.g. for translations)
1394 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1395 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1397 % Credits: Nicolas Sceaux on the lilypond-user mailinglist
1398 #(define-markup-command (columns layout props args) (markup-list?)
1399 (let ((line-width (/ (chain-assoc-get 'line-width props
1400 (ly:output-def-lookup layout 'line-width))
1401 (max (length args) 1))))
1402 (interpret-markup layout props
1403 (make-line-markup (map (lambda (line)
1404 (markup #:pad-to-box `(0 . ,line-width) '(0 . 0)
1405 #:override `(line-width . ,line-width)
1411 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1412 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1413 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1414 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1415 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1418 startSlashedGraceMusic = {
1419 \override Stem #'stroke-style = #"grace"
1422 stopSlashedGraceMusic = {
1423 \revert Stem #'stroke-style
1427 #(def-grace-function startSlashedGraceMusic stopSlashedGraceMusic
1428 (_i "Create slashed graces (slashes through stems, but no slur)from the following music expression"))
1431 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1432 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1433 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1434 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1435 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1439 right-margin = 1.5\cm
1440 line-width = 17.5\cm
1441 % bottom-margin = 1.5\cm
1442 % top-margin = 1.5\cm
1443 % after-title-space = 0.5\cm
1447 ragged-last-bottom = ##f
1452 % If only one non-empty staff in a system exists, still print the backet
1453 \override SystemStartBracket #'collapse-height = #1
1454 \consists "Instrument_name_engraver"
1458 % If only one non-empty staff in a system exists, still print the backet
1459 \override SystemStartBracket #'collapse-height = #1
1460 \consists "Instrument_name_engraver"
1464 \override SystemStartBracket #'collapse-height = #1
1465 \consists "Instrument_name_engraver"
1469 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1473 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1474 \override VerticalAxisGroup #'minimum-Y-extent = #'(0 . 1)
1475 \override VerticalAxisGroup #'padding = #0
1479 % Force multi-measure rests to be written as one span
1480 \override MultiMeasureRest #'expand-limit = #3
1483 % hairpinToBarline = ##f
1484 \override BarNumber #'break-visibility = #end-of-line-invisible
1485 \override BarNumber #'self-alignment-X = #0
1486 \override CombineTextScript #'avoid-slur = #'outside
1487 barNumberVisibility = #(every-nth-bar-number-visible 5)
1488 \override DynamicTextSpanner #'dash-period = #-1.0
1489 \override InstrumentSwitch #'font-size = #-1
1492 \override RestCollision #'positioning-done = #merge-rests-on-positioning
1493 % Auto-Accidentals: Use modern-cautionary style...
1495 autoAccidentals = #`(Staff ,(make-accidental-rule 'same-octave 0)
1496 ,(make-accidental-rule 'any-octave 0)
1497 ,(make-accidental-rule 'same-octave 1))
1498 % autoCautionaries = #`(Staff ,(make-accidental-rule 'any-octave 0)
1499 % ,(make-accidental-rule 'same-octave 1))
1500 printKeyCancellation = ##t
1503 \RemoveEmptyStaffContext
1507 \override VerticalAxisGroup #'minimum-Y-extent = #'(0.5 . 0.5)
1511 \override VerticalAxisGroup #'minimum-Y-extent = #'(-1. . 3)
1512 quotedEventTypes = #'(StreamEvent)
1513 ignoreFiguredBassRest = ##f
1514 implicitBassFigures = #'(0 100)
1522 \type "Engraver_group"
1524 % So that \cresc works, for example.
1526 \consists "Output_property_engraver"
1528 \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
1529 pedalSustainStrings = #'("Ped." "*Ped." "*")
1530 pedalUnaCordaStrings = #'("una corda" "" "tre corde")
1532 \consists "Piano_pedal_engraver"
1533 \consists "Script_engraver"
1534 \consists "Dynamic_engraver"
1535 \consists "Text_engraver"
1537 \override TextScript #'font-size = #2
1538 \override TextScript #'font-shape = #'italic
1539 \override DynamicText #'extra-offset = #'(0 . 2.5)
1540 \override Hairpin #'extra-offset = #'(0 . 2.5)
1542 \consists "Skip_event_swallow_translator"
1544 \consists "Axis_group_engraver"
1549 % \override VerticalAlignment #'forced-distance = #7
1554 bracketts = ^\markup{"[Solo]"}
1555 brackettt = ^\markup{"[Tutti]"}
1556 ts = ^\markup{"t.s."}
1557 tt = ^\markup{"Tutti"}
1558 solo = ^\markup{"Solo"}
1559 tutti = ^\markup{"Tutti"}
1561 dashedSlur = -\tweak #'dash-definition #'((0 1 0.4 0.75))(
1562 dashedTie = -\tweak #'dash-definition #'((0 1 0.4 0.75))~
1564 divisi = #(define-music-function (parser location vc1 vc2) (ly:music? ly:music?)
1566 << { \voiceOne $vc1 \oneVoice} \new Voice = "divisi2" { \voiceTwo $vc2 } >>
1570 #(define-public (bracket-stencils grob)
1571 (let ((lp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "[")))
1572 (rp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "]"))))
1575 bracketify = #(define-music-function (parser loc arg) (ly:music?)
1576 (_i "Tag @var{arg} to be parenthesized.")
1578 \once \override ParenthesesItem #'stencils = #bracket-stencils
1584 #(define-markup-command (hat layout props arg) (markup?)
1585 "Draw a hat above the given string @var{arg}."
1586 (interpret-markup layout props (markup #:combine #:raise 1.5 "^" arg)))