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:parallel_voices_staff_handler parser piece name type children)
374 (voices (map (lambda (i) (oly:create_voice parser piece i)) children))
375 ; get the list of non-empty voices and flatten it!
376 (nonemptyvoices (apply append (filter not-null? voices)))
378 (if (not-null? nonemptyvoices)
379 (oly:staff_handler_internal parser piece name "Staff" nonemptyvoices)
385 #(define (oly:part_combined_staff_handler parser piece name type children)
386 (let* ((rawmusic (map (lambda (c) (oly:musiccontent_for_voice parser piece name (oly:get_music_object piece c) '())) children))
387 (music (filter not-null? rawmusic)))
389 ((and (pair? music) (ly:music? (car music)) (not-null? (cdr music)) (ly:music? (cadr music)))
390 ;(ly:message "Part-combine with two music expressions")
391 (oly:staff_handler_internal parser piece name "Staff" (list (make-part-combine-music parser music))))
393 (ly:warning "Part-combine without any music expressions")
395 ; exactly one is a music expression, simply use that by joining
397 (ly:message "Part-combine with only one music expressions")
398 (oly:staff_handler_internal parser piece name "Staff" (list (apply append music))))
400 ;(ly:message "make_part_combined_staff: ~S ~S ~a" piece instr instruments)
406 % Generate the properties for the staff for piece and instr. Typically, these
407 % are the instrument name and the short instrument name (if defined).
408 % return a (possibly empty) list of all assignments.
409 #(define (oly:staff_handler_properties piece instr)
412 (instrumentName . "InstrumentName")
413 (shortInstrumentName . "ShortInstrumentName")
414 (midiInstrument . "MidiInstrument")
418 (oly:generate_property_pair (car pr) piece instr (cdr pr))
421 (props (filter not-null? assignments))
427 % Figured bass is a special case, as it can be voice- or staff-type. When
428 % given as a staff type, simply call the voice handler, instead
430 #(define (oly:figured_bass_staff_handler parser piece name type children)
431 (let* ((c (if (not-null? children) children (list name)))
432 (voice (oly:voice_handler parser piece (car c) type)))
433 (if (pair? voice) (car voice) ())
438 #(define (oly:staff_group_handler parser piece name type children)
440 (staves (map (lambda (i) (oly:create_staff_or_group parser piece i)) children))
441 (nonemptystaves (filter not-null? staves))
443 (if (not-null? nonemptystaves)
445 (musicexpr (if (= 1 (length nonemptystaves))
447 (make-simultaneous-music nonemptystaves)))
448 (groupname (oly:generate_staff_name piece name))
449 (grouptype (oly:staff_type type))
451 (propops (oly:staff_handler_properties piece name))
454 ((SimultaneousMusic ParallelMusic) #f)
455 (else (set! group (context-spec-music group grouptype groupname)))
458 (set! (ly:music-property group 'property-operations) propops))
461 ; Return empty list if no staves are generated
467 #(define (oly:create_voice parser piece name)
468 (let* ( (voice (namedPieceInstrObject piece name "Voice"))
469 (type (assoc-ref oly:voice_types name)) )
470 (if (not-null? voice)
471 ; Explicit voice variable, use that
475 ; No entry in structure found => simple voice
476 (oly:voice_handler parser piece name "Voice")
477 ; Entry found in structure => use the handler for the given type
479 (voicetype (car type))
480 (handler (assoc-ref oly:voice_handlers voicetype))
483 ((primitive-eval handler) parser piece name voicetype)
485 (ly:warning "No handler found for voice type ~a, using default voice handler" voicetype)
486 (oly:voice_handler parser piece name voicetype)
495 #(define (oly:create_staff_or_group parser piece name)
496 (let* ( (staff (namedPieceInstrObject piece name "Staff"))
497 (type_from_structure (assoc-ref oly:orchestral_score_structure name)) )
498 ;(if (not-null? staff)
499 ; (ly:message "Found staff variable for instrument ~a in piece ~a" instr piece)
500 ; (ly:message "Staff variable for instrument ~a in piece ~a NOT FOUND" instr piece)
502 (if (not-null? staff)
503 ; Explicit staff variable, use that
506 (if (not (list? type_from_structure))
507 ; No entry in structure found => simple staff
508 (oly:staff_handler parser piece name "Staff" '())
510 ; Entry found in structure => use the handler for the given type
511 (let* ((type (car type_from_structure))
512 (handler (assoc-ref oly:staff_handlers type))
513 (children (cadr type_from_structure))
516 ((primitive-eval handler) parser piece name type children)
518 (ly:warning "No handler found for staff type ~a, using default staff handler" type)
519 (oly:staff_handler parser piece name type children)
528 #(define oly:staff_handlers
531 '("GrandStaff" . oly:staff_group_handler )
532 '("PianoStaff" . oly:staff_group_handler )
533 '("ChoirStaff" . oly:staff_group_handler )
534 '("StaffGroup" . oly:staff_group_handler )
535 '("InnerChoirStaff" . oly:staff_group_handler )
536 '("InnerStaffGroup" . oly:staff_group_handler )
537 '("ParallelMusic" . oly:staff_group_handler )
538 '("SimultaneousMusic" . oly:staff_group_handler )
540 '("Staff" . oly:staff_handler )
541 '("DrumStaff" . oly:staff_handler )
542 '("RhythmicStaff" . oly:staff_handler )
543 '("TabStaff" . oly:staff_handler )
544 '("GregorianTranscriptionStaff" . oly:staff_handler )
545 '("MensuralStaff" . oly:staff_handler )
546 '("VaticanaStaff" . oly:staff_handler )
547 ; staves with multiple voices
548 '("PartCombinedStaff" . oly:part_combined_staff_handler )
549 '("ParallelVoicesStaff" . oly:parallel_voices_staff_handler )
550 ; special cases: Figured bass can be staff or voice type!
551 '("FiguredBass" . oly:figured_bass_staff_handler )
555 #(define oly:voice_handlers
558 '("Voice" . oly:voice_handler )
559 '("CueVoice" . oly:voice_handler )
560 '("DrumVoice" . oly:voice_handler )
561 '("FiguredBass" . oly:voice_handler )
562 '("GregorianTranscriptionVoice" . oly:voice_handler )
563 '("NoteNames" . oly:voice_handler )
564 '("TabVoice" . oly:voice_handler )
565 '("VaticanaVoice" . oly:voice_handler )
566 ;'("Dynamics" . oly:dynamics_handler )
571 #(define (oly:register_staff_type_handler type func)
572 ; (ly:message "Registering staff handler ~a for type ~a" func type)
573 (set! oly:staff_handlers (assoc-set! oly:staff_handlers type func))
576 #(define (oly:register_voice_type_handler type func)
577 ; (ly:message "Registering voice type handler ~a for type ~a" func type)
578 (set! oly:voice_handlers (assoc-set! oly:voice_handlers type func))
581 % handlers for deprecated API
582 #(oly:register_staff_type_handler 'StaffGroup 'oly:staff_group_handler)
583 #(oly:register_staff_type_handler 'GrandStaff 'oly:staff_group_handler)
584 #(oly:register_staff_type_handler 'PianoStaff 'oly:staff_group_handler)
585 #(oly:register_staff_type_handler 'ChoirStaff 'oly:staff_group_handler)
586 #(oly:register_staff_type_handler 'Staff 'oly:staff_handler )
587 #(oly:register_staff_type_handler 'ParallelMusic 'oly:staff_group_handler)
588 #(oly:register_staff_type_handler 'SimultaneousMusic 'oly:staff_group_handler)
589 #(oly:register_staff_type_handler #t 'oly:part_combined_staff_handler )
590 #(oly:register_staff_type_handler #f 'oly:parallel_voices_staff_handler )
594 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
595 % Automatic score generation
596 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598 % \setUseBook ##t/##f sets a flag to determine whether the calls to createScore
599 % are from within a book block or not
600 % #(define oly:score_handler collect-scores-for-book)
601 % #(define oly:score_handler toplevel-score-handler)
602 % #(define oly:music_handler toplevel-music-handler)
603 % #(define oly:text_handler toplevel-text-handler)
605 % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
606 #(define-public (add-score parser score)
607 (ly:parser-define! parser 'toplevel-scores
608 (cons score (ly:parser-lookup parser 'toplevel-scores))))
610 #(define-public (add-text parser text)
611 (add-score parser (list text)))
613 #(define-public (add-music parser music)
614 (collect-music-aux (lambda (score)
615 (add-score parser score))
619 #(define-public (toplevel-book-handler parser book)
621 (ly:book-add-score! book score))
622 (reverse! (ly:parser-lookup parser 'toplevel-scores)))
623 (ly:parser-define! parser 'toplevel-scores (list))
624 (print-book-with-defaults parser book))
626 #(define-public (book-score-handler book score)
627 (add-score parser score))
629 #(define-public (book-text-handler book text)
630 (add-text parser text))
632 #(define-public (book-music-handler parser book music)
633 (add-music parser music))
635 #(define oly:score_handler add-score)
636 #(define oly:music_handler add-music)
637 #(define oly:text_handler add-text)
641 setUseBook = #(define-music-function (parser location usebook) (boolean?)
642 (ly:warning "\\setUseBook has been deprecated! Books are now automatically handled without any hacks")
643 (make-music 'Music 'void #t)
647 % Two functions to handle midi-blocks: Either don't set one, or set an empty
648 % one so that MIDI is generated
649 #(define (oly:set_no_midi_block score) '())
650 #(define (oly:set_midi_block score)
651 (let* ((midiblock (if (defined? '$defaultmidi)
652 (ly:output-def-clone $defaultmidi)
653 (ly:make-output-def))))
654 (ly:output-def-set-variable! midiblock 'is-midi #t)
655 (ly:score-add-output-def! score midiblock)
659 % \setCreateMidi ##t/##f sets a flag to determine wheter MIDI output should
661 #(define oly:apply_score_midi oly:set_no_midi_block)
662 setCreateMIDI = #(define-music-function (parser location createmidi) (boolean?)
664 (set! oly:apply_score_midi oly:set_midi_block)
665 (set! oly:apply_score_midi oly:set_no_midi_block)
667 (make-music 'Music 'void #t)
671 % Two functions to handle layout-blocks: Either don't set one, or set an empty
672 % one so that a PDF is generated
673 #(define (oly:set_no_layout_block score) '())
674 #(define (oly:set_layout_block score)
675 (let* ((layoutblock (if (defined? '$defaultlayout)
676 (ly:output-def-clone $defaultlayout)
677 (ly:make-output-def))))
678 (ly:output-def-set-variable! layoutblock 'is-layout #t)
679 (ly:score-add-output-def! score layoutblock)
683 % \setCreatePDF ##t/##f sets a flag to determine wheter PDF output should
685 #(define oly:apply_score_layout oly:set_no_layout_block)
686 setCreatePDF = #(define-music-function (parser location createlayout) (boolean?)
688 (set! oly:apply_score_layout oly:set_layout_block)
689 (set! oly:apply_score_layout oly:set_no_layout_block)
691 (make-music 'Music 'void #t)
695 % Set the piece title in a new header block.
696 #(define (oly:set_piece_header score piecename)
697 (if (not-null? piecename)
698 (let* ((header (make-module)))
699 (module-define! header 'piece piecename)
700 (ly:score-set-header! score header)
706 % post-filter functions. By default, no filtering is done. However,
707 % for the *NoCues* function, the cue notes should be killed
708 identity = #(define-music-function (parser location music) (ly:music?) music)
709 cuefilter = #(define-music-function (parser location music) (ly:music?)
710 ((ly:music-function-extract removeWithTag) parser location 'cued ((ly:music-function-extract killCues) parser location music))
714 #(define (oly:create-toc-file layout pages)
715 (let* ((label-table (ly:output-def-lookup layout 'label-page-table)))
716 (if (not (null? label-table))
717 (let* ((format-line (lambda (toc-item)
718 (let* ((label (car toc-item))
719 (text (caddr toc-item))
720 (label-page (and (list? label-table)
721 (assoc label label-table)))
722 (page (and label-page (cdr label-page))))
723 (format #f "~a, section, 1, {~a}, ~a" page text label))))
724 (formatted-toc-items (map format-line (toc-items)))
725 (whole-string (string-join formatted-toc-items ",\n"))
726 (output-name (ly:parser-output-name parser))
727 (outfilename (format "~a.toc" output-name))
728 (outfile (open-output-file outfilename)))
729 (if (output-port? outfile)
730 (display whole-string outfile)
731 (ly:warning (_ "Unable to open output file ~a for the TOC information") outfilename))
732 (close-output-port outfile)))))
735 #(define-public (oly:add-toc-item parser markup-symbol text)
736 (oly:music_handler parser (add-toc-item! markup-symbol text)))
739 #(define (oly:add-score parser score piecename)
740 (if (not-null? piecename)
741 (oly:add-toc-item parser 'tocItemMarkup piecename))
742 (oly:score_handler parser score)
744 % The helper function to build a score.
745 #(define (oly:createScoreHelper parser location piece children func)
747 (staves (oly:staff_group_handler parser piece "" "SimultaneousMusic" children))
748 (music (if (not-null? staves)
749 ((ly:music-function-extract func) parser location staves)
753 (piecename (namedPieceInstrObject piece (car children) "PieceName"))
754 (piecenametacet (namedPieceInstrObject piece (car children) "PieceNameTacet"))
758 ; No staves, print tacet
760 (if (not-null? piecenametacet) (set! piecename piecenametacet))
761 (if (not-null? piecename)
762 (oly:add-score parser (list (oly:piece-title-markup piecename)) piecename)
763 (ly:warning (_ "No music and no score title found for part ~a and instrument ~a") piece children)
766 ; we have staves, apply the piecename to the score and add layout/midi blocks if needed
768 (set! score (scorify-music music parser))
769 (oly:set_piece_header score piecename)
770 (oly:apply_score_midi score)
771 (oly:apply_score_layout score)
772 ; Schedule the score for typesetting
773 (oly:add-score parser score piecename)
777 ; This is a void function, the score has been schedulled for typesetting already
778 (make-music 'Music 'void #t)
781 createScore = #(define-music-function (parser location piece children) (string? list?)
782 (oly:createScoreHelper parser location piece children identity)
784 createNoCuesScore = #(define-music-function (parser location piece children) (string? list?)
785 (oly:createScoreHelper parser location piece children cuefilter)
788 createHeadline = #(define-music-function (parser location headline) (string?)
789 (oly:add-toc-item parser 'tocItemMarkup headline)
790 (oly:score_handler parser (list (oly:piece-title-markup headline)))
791 (make-music 'Music 'void #t)
796 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
797 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
799 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
802 newInstrument = #(define-music-function (parser location instr) (string?)
804 \set Voice.instrumentCueName = #$(string-join (list "+" instr))
807 cueText = #(define-music-function (parser location instr) (string?)
809 \set Voice.instrumentCueName = $instr
813 % generate a cue music section with instrument names
814 % Parameters: \namedCueDuring NameOfQuote CueDirection CueInstrument OriginalInstrument music
815 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
816 % -) CueInstrument and OriginalInstrument are the displayed instrument names
818 % \namedCueDuring #"vIQuote" #UP #"V.I" #"Sop." { R1*3 }
819 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
820 % the beginning of the cue notes and "Sop." at the end
821 namedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr cuemusic) (string? number? string? string? ly:music?)
823 \cueDuring #$cuevoice #$direction { \tag #'cued \cueText #$instrcue $cuemusic \tag #'cued \cueText #$instr }
824 % \tag #'uncued $cuemusic
827 namedTransposedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr trans cuemusic) (string? number? string? string? ly:music? ly:music?)
829 \transposedCueDuring #$cuevoice #$direction $trans { \tag #'cued \cueText #$instrcue $cuemusic \tag #'cued \cueText #$instr }
830 % \tag #'uncued $cuemusic
834 % set the cue instrument name and clef
835 setClefCue = #(define-music-function (parser location instr clef)
838 \once \override Staff.Clef #'font-size = #-3 $clef
839 \set Voice.instrumentCueName = $instr
842 % generate a cue music section with instrument names and clef changes
843 % Parameters: \cleffedCueDuring NameOfQuote CueDirection CueInstrument CueClef OriginalInstrument OriginalClef music
844 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
845 % -) CueInstrument and OriginalInstrument are the displayed instrument names
846 % -) CueClef and OriginalClef are the clefs for the the cue notes and the clef of the containing voice
848 % \cleffedCueDuring #"vIQuote" #UP #"V.I" #"treble" #"Basso" #"bass" { R1*3 }
849 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
850 % the beginning of the cue notes and "Basso" at the end. The clef is changed to treble at the
851 % beginning of the cue notes and reset to bass at the end
852 cleffedCueDuring = #(define-music-function (parser location cuevoice direction instrcue clefcue instr clefinstr cuemusic)
853 (string? number? string? ly:music? string? ly:music? ly:music?)
855 \cueDuring #$cuevoice #$direction { \tag #'cued \setClefCue #$instrcue $clefcue $cuemusic \tag #'cued \setClefCue #$instr $clefinstr }
856 % \tag #'uncued $cuemusic
863 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
864 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
866 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
867 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
870 dynamicsX = #(define-music-function (parser location offset) (number?)
872 \once \override DynamicText #'X-offset = $offset
873 \once \override DynamicLineSpanner #'Y-offset = #0
876 % Move the dynamic sign inside the staff to a fixed staff-relative position
877 % posY (where 0 means vertically starts at the middle staff line)
878 dynamicsAllInside = #(define-music-function (parser location offsetX posY)
881 % Invalid y-extent -> hidden from skyline calculation and collisions
882 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
883 % move by X offset and to fixed Y-position (use Y-offset of parent!)
884 \once \override DynamicText #'X-offset = $offsetX
885 \once \override DynamicText #'Y-offset =
887 (let* ((head (ly:grob-parent grob Y))
888 (offset (ly:grob-property head 'Y-offset)))
889 (- posY offset (- 0.6))))
890 \once \override DynamicLineSpanner #'Y-offset = $posY
893 dynamicsUpInside = #(define-music-function (parser location offsetX) (number?)
894 ((ly:music-function-extract dynamicsAllInside) parser location offsetX 1.5)
897 dynamicsDownInside = #(define-music-function (parser location offsetX) (number?)
898 ((ly:music-function-extract dynamicsAllInside) parser location offsetX -3.5)
901 hairpinOffset = #(define-music-function (parser location posY) (number?)
903 \once \override DynamicLineSpanner #'Y-offset = $posY
904 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
907 #(define ((line-break-offset before after) grob)
908 (let* ((orig (ly:grob-original grob))
909 ; All siblings if line-broken:
910 (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
911 (if (>= (length siblings) 2)
912 ; We have been line-broken
913 (if (eq? (car (last-pair siblings)) grob)
915 (ly:grob-set-property! grob 'Y-offset after)
916 ; Others get the before value:
917 (ly:grob-set-property! grob 'Y-offset before)
923 ffz = #(make-dynamic-script "ffz")
924 pf = #(make-dynamic-script "pf")
925 sempp = #(make-dynamic-script (markup #:line( #:with-dimensions '(0 . 0)
926 '(0 . 0) #:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
927 parenf = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")" )))
928 parenp = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "p" #:normal-text #:italic #:fontsize 2 ")" )))
929 pdolce = #(make-dynamic-script (markup #:line(#:dynamic "p" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
930 sfpdolce = #(make-dynamic-script (markup #:line(#:dynamic "sfp" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
931 bracketf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text "[" #:dynamic "f" #:normal-text "]"))))
932 bracketp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text "[" #:dynamic "p" #:normal-text "]"))))
936 % cresc = #(make-music 'CrescendoEvent 'span-direction START 'crescendoSpanner 'text 'crescendoText "cresc.")
937 % endcresc = #(make-span-event 'CrescendoEvent STOP)
938 % dim = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "dim.")
939 % enddim = #(make-span-event 'DecrescendoEvent STOP)
940 % decresc = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "decresc.")
941 % enddecresc = #(make-span-event 'DecrescendoEvent STOP)
946 cresc = #(make-music 'CrescendoEvent 'span-direction START
947 'span-type 'text 'span-text "cresc.")
948 dim = #(make-music 'DecrescendoEvent 'span-direction START
949 'span-type 'text 'span-text "dim.")
950 decresc = #(make-music 'DecrescendoEvent 'span-direction START
951 'span-type 'text 'span-text "decresc.")
953 newOrOldClef = #(define-music-function (parser location new old ) (string? string?)
954 (if (ly:get-option 'old-clefs) #{ \clef $old #} #{ \clef $new #})
959 %%% Thanks to "Gilles THIBAULT" <gilles.thibault@free.fr>, there is a way
960 % to remove also the fermata from R1-\fermataMarkup: By filtering the music
961 % and removing the corresponding events.
962 % Documented as an LSR snippet: http://lsr.dsi.unimi.it/LSR/Item?id=372
963 #(define (filterOneEventsMarkup event)
964 ( let ( (eventname (ly:music-property event 'name)) )
966 (or ;; add here event name you do NOT want
967 (eq? eventname 'MultiMeasureTextEvent)
968 (eq? eventname 'AbsoluteDynamicEvent)
969 (eq? eventname 'TextScriptEvent)
970 (eq? eventname 'ArticulationEvent)
971 (eq? eventname 'CrescendoEvent)
972 (eq? eventname 'DecrescendoEvent)
977 filterArticulations = #(define-music-function (parser location music) (ly:music?)
978 Â Â (music-filter filterOneEventsMarkup music)
985 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
986 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
988 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
989 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
993 rit = \markup {\italic "rit."}
994 pocorit = \markup {\italic "poco rit."}
995 ppmosso = \markup {\italic "poco più mosso"}
996 dolce = \markup {\italic "dolce."}
997 pizz = \markup {\italic "pizz."}
998 arco = \markup {\italic "arco"}
999 perd = \markup {\italic "perdend."}
1004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1006 %%%%% REST COMBINATION
1007 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1012 %% REST COMBINING, TAKEN FROM http://lsr.dsi.unimi.it/LSR/Item?id=336
1015 %% \new Staff \with {
1016 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1017 %% } << \somevoice \\ \othervoice >>
1022 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1027 %% - only handles two voices
1028 %% - does not handle multi-measure/whole-measure rests
1030 #(define (rest-score r)
1032 (yoff (ly:grob-property-data r 'Y-offset))
1033 (sp (ly:grob-property-data r 'staff-position)))
1035 (set! score (+ score 2))
1036 (if (eq? yoff 'calculation-in-progress)
1037 (set! score (- score 3))))
1040 (set! score (+ score 2))
1041 (set! score (- score (abs (- 1 sp)))))
1044 #(define (merge-rests-on-positioning grob)
1045 (let* ((can-merge #f)
1046 (elts (ly:grob-object grob 'elements))
1047 (num-elts (and (ly:grob-array? elts)
1048 (ly:grob-array-length elts)))
1049 (two-voice? (= num-elts 2)))
1051 (let* ((v1-grob (ly:grob-array-ref elts 0))
1052 (v2-grob (ly:grob-array-ref elts 1))
1053 (v1-rest (ly:grob-object v1-grob 'rest))
1054 (v2-rest (ly:grob-object v2-grob 'rest)))
1058 (let* ((v1-duration-log (ly:grob-property v1-rest 'duration-log))
1059 (v2-duration-log (ly:grob-property v2-rest 'duration-log))
1060 (v1-dot (ly:grob-object v1-rest 'dot))
1061 (v2-dot (ly:grob-object v2-rest 'dot))
1062 (v1-dot-count (and (ly:grob? v1-dot)
1063 (ly:grob-property v1-dot 'dot-count -1)))
1064 (v2-dot-count (and (ly:grob? v2-dot)
1065 (ly:grob-property v2-dot 'dot-count -1))))
1068 (number? v1-duration-log)
1069 (number? v2-duration-log)
1070 (= v1-duration-log v2-duration-log)
1071 (eq? v1-dot-count v2-dot-count)))
1073 ;; keep the rest that looks best:
1074 (let* ((keep-v1? (>= (rest-score v1-rest)
1075 (rest-score v2-rest)))
1076 (rest-to-keep (if keep-v1? v1-rest v2-rest))
1077 (dot-to-kill (if keep-v1? v2-dot v1-dot)))
1078 ;; uncomment if you're curious of which rest was chosen:
1079 ;;(ly:grob-set-property! v1-rest 'color green)
1080 ;;(ly:grob-set-property! v2-rest 'color blue)
1081 (ly:grob-suicide! (if keep-v1? v2-rest v1-rest))
1082 (if (ly:grob? dot-to-kill)
1083 (ly:grob-suicide! dot-to-kill))
1084 (ly:grob-set-property! rest-to-keep 'direction 0)
1085 (ly:rest::y-offset-callback rest-to-keep)))))))
1088 (ly:rest-collision::calc-positioning-done grob))))
1094 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1095 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1096 %%%%% TABLE OF CONTENTS
1097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1098 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1101 contentsTitle = "Inhalt / Contents"
1104 tocTitleMarkup = \markup \fill-line{
1107 \override #(cons 'line-width (* 7 cm))
1108 \line{ \fill-line {\piece-title {\contentsTitle} \null }}
1113 tocItemMarkup = \markup \fill-line {
1116 \override #(cons 'line-width (* 7 cm ))
1117 \line { \fill-line{\fromproperty #'toc:text \fromproperty #'toc:page }}
1124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1126 %%%%% TITLE PAGE / HEADER
1127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1130 #(define-markup-command (when-property layout props symbol markp) (symbol? markup?)
1131 (if (chain-assoc-get symbol props)
1132 (interpret-markup layout props markp)
1133 (ly:make-stencil '() '(1 . -1) '(1 . -1))))
1135 #(define-markup-command (vspace layout props amount) (number?)
1136 "This produces a invisible object taking vertical space."
1137 (let ((amount (* amount 3.0)))
1139 (ly:make-stencil "" (cons -1 1) (cons 0 amount))
1140 (ly:make-stencil "" (cons -1 1) (cons amount amount)))))
1144 titlePageMarkup = \markup \abs-fontsize #10 \when-property #'header:title \column {
1146 \fill-line { \fontsize #8 \fromproperty #'header:composer }
1148 \fill-line { \fontsize #8 \fromproperty #'header:poet }
1150 \fill-line { \fontsize #10 \bold \fromproperty #'header:titlepagetitle }
1152 \fontsize #2 \when-property #'header:titlepagesubtitle {
1153 \fill-line { \fromproperty #'header:titlepagesubtitle }
1156 \fill-line { \postscript #"-20 0 moveto 40 0 rlineto stroke" }
1158 \fill-line { \fontsize #5 \fromproperty #'header:ensemble }
1160 \fill-line { \fontsize #2 \fromproperty #'header:instruments }
1162 \fill-line { \fontsize #5 \fromproperty #'header:date }
1164 \fill-line { \fontsize #5 \fromproperty #'header:scoretype }
1166 \fontsize #2 \when-property #'header:enteredby {
1167 \fill-line { "Herausgegeben von: / Edited by:"}
1169 \fill-line { \fromproperty #'header:enteredby }
1172 \when-property #'header:arrangement \column {
1174 \fill-line { \fontsize #3 \fromproperty #'header:arrangement }
1179 titleHeaderMarkup = \markup {
1180 \override #'(baseline-skip . 3.5)
1182 \override #'(baseline-skip . 3.5)
1186 \larger \fromproperty #'header:title
1189 \large \smaller \bold
1190 \larger \fromproperty #'header:subtitle
1194 \fromproperty #'header:subsubtitle
1197 { \large \bold \fromproperty #'header:instrument }
1200 \fromproperty #'header:poet
1201 \fromproperty #'header:composer
1204 \fromproperty #'header:meter
1205 \fromproperty #'header:arranger
1211 titleScoreMarkup = \markup \piece-title \fromproperty #'header:piece
1214 scoreTitleMarkup = \titleScoreMarkup
1215 bookTitleMarkup = \titleHeaderMarkup
1220 %%%%%%%%%%%%%% headers and footers %%%%%%%%%%%%%%%%%%%%%%%%%%
1222 #(define (first-score-page layout props arg)
1223 (let* ((label 'first-score-page)
1224 (table (ly:output-def-lookup layout 'label-page-table))
1225 (label-page (and (list? table) (assoc label table)))
1226 (page-number (and label-page (cdr label-page)))
1228 (if (eq? (chain-assoc-get 'page:page-number props -1) page-number)
1229 (interpret-markup layout props arg)
1232 #(define no-header-table '())
1233 thisPageNoHeader = #(define-music-function (parser location) ()
1234 (let* ((label (gensym "header")))
1235 (set! no-header-table (cons label no-header-table))
1238 'page-label label)))
1241 % TODO: Use the no-header-table!
1242 #(define (is-header-page layout props arg)
1243 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1245 ;(if (and (> page-number 2) (!= page-number 7))
1246 (if (> page-number 1)
1247 (interpret-markup layout props arg)
1250 #(define no-footer-table '())
1251 thisPageNoFooter = #(define-music-function (parser location) ()
1252 (let* ((label (gensym "footer")))
1253 (set! no-footer-table (cons label no-footer-table))
1256 'page-label label)))
1258 % TODO: Use the no-footer-table!
1259 #(define (is-footer-page layout props arg)
1260 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1261 (label 'first-score-page)
1262 (table (ly:output-def-lookup layout 'label-page-table))
1263 (label-page (and (list? table) (assoc label table)))
1264 ;(page-number (and label-page (cdr label-page)))
1266 (if (and (> page-number 1))
1267 (interpret-markup layout props arg)
1271 #(define copyright-footer-table '())
1272 thisPageCopyrightFooter = #(define-music-function (parser location) ()
1273 (let* ((label (gensym "copyrightfooter")))
1274 (set! copyright-footer-table (cons label copyright-footer-table))
1277 'page-label label)))
1279 #(define copyright-pg 1)
1280 #(define (set-copyright-page page)
1281 (set! copyright-pg page)
1284 % TODO: Use the copyright-footer-table!
1285 #(define (copyright-page layout props arg)
1286 (if (= (chain-assoc-get 'page:page-number props -1) copyright-pg)
1287 (interpret-markup layout props arg)
1292 oddHeaderMarkup = \markup \fill-line {
1293 %% force the header to take some space, otherwise the
1294 %% page layout becomes a complete mess.
1296 \on-the-fly #is-header-page \fromproperty #'header:title
1297 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1299 evenHeaderMarkup = \markup \fill-line {
1300 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1301 \on-the-fly #is-header-page \fromproperty #'header:composer
1305 oddFooterMarkup = \markup {
1308 %% publisher header field only on title page.
1309 \on-the-fly #first-page \fromproperty #'header:publisher
1312 %% copyright on the first real score page
1313 \on-the-fly #copyright-page \fromproperty #'header:copyright
1314 \on-the-fly #copyright-page \null
1317 %% All other pages get the number of the edition centered
1318 \on-the-fly #is-footer-page \fromproperty #'header:scorenumber
1335 % Interpret the given markup with the header fields added to the props.
1336 % This way, one can re-use the same functions (using fromproperty
1337 % #'header:field) in the header block and as top-level markup.
1339 % This function is originally copied from mark-up-title (file scm/titling.scm),
1340 % which is lilypond's internal function to handle the title markups. I needed
1341 % to replace the scopes and manually add the $defaultheader (which is internally
1342 % done in paper-book.cc before calling mark-up-title. Also, I don't extract the
1343 % markup from the header block, but use the given markup.
1345 % I'm not sure if I really need the page properties in props, too... But I
1346 % suppose it does not hurt, either.
1347 #(define-markup-command (markupWithHeader layout props markup) (markup?)
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 ; TODO: If we are inside a score, add the score's local header block, too!
1353 ; Currently, I only use the global header block, stored in $defaultheader
1354 (scopes (list $defaultheader))
1355 (alists (map ly:module->alist scopes))
1358 (map (lambda (alist)
1359 (map (lambda (entry)
1361 (string->symbol (string-append "header:" (symbol->string (car entry))))
1365 (props (append prefixed-alist
1367 (layout-extract-page-properties layout)))
1369 (interpret-markup layout props markup)
1378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1379 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1380 %%%%% Equally spacing multiple columns (e.g. for translations)
1381 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1384 % Credits: Nicolas Sceaux on the lilypond-user mailinglist
1385 #(define-markup-command (columns layout props args) (markup-list?)
1386 (let ((line-width (/ (chain-assoc-get 'line-width props
1387 (ly:output-def-lookup layout 'line-width))
1388 (max (length args) 1))))
1389 (interpret-markup layout props
1390 (make-line-markup (map (lambda (line)
1391 (markup #:pad-to-box `(0 . ,line-width) '(0 . 0)
1392 #:override `(line-width . ,line-width)
1398 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1399 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1400 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1401 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1402 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1405 startSlashedGraceMusic = {
1406 \override Stem #'stroke-style = #"grace"
1409 stopSlashedGraceMusic = {
1410 \revert Stem #'stroke-style
1414 #(def-grace-function startSlashedGraceMusic stopSlashedGraceMusic
1415 (_i "Create slashed graces (slashes through stems, but no slur)from the following music expression"))
1418 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1419 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1420 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1421 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1422 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1426 right-margin = 1.5\cm
1427 line-width = 17.5\cm
1428 % bottom-margin = 1.5\cm
1429 % top-margin = 1.5\cm
1430 % after-title-space = 0.5\cm
1434 ragged-last-bottom = ##f
1439 % If only one non-empty staff in a system exists, still print the backet
1440 \override SystemStartBracket #'collapse-height = #1
1441 \consists "Instrument_name_engraver"
1445 % If only one non-empty staff in a system exists, still print the backet
1446 \override SystemStartBracket #'collapse-height = #1
1447 \consists "Instrument_name_engraver"
1451 \override SystemStartBracket #'collapse-height = #1
1452 \consists "Instrument_name_engraver"
1456 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1460 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1461 \override VerticalAxisGroup #'minimum-Y-extent = #'(0 . 1)
1462 \override VerticalAxisGroup #'padding = #0
1466 % Force multi-measure rests to be written as one span
1467 \override MultiMeasureRest #'expand-limit = #3
1470 % hairpinToBarline = ##f
1471 \override BarNumber #'break-visibility = #end-of-line-invisible
1472 \override BarNumber #'self-alignment-X = #0
1473 \override CombineTextScript #'avoid-slur = #'outside
1474 barNumberVisibility = #(every-nth-bar-number-visible 5)
1475 \override DynamicTextSpanner #'dash-period = #-1.0
1476 \override InstrumentSwitch #'font-size = #-1
1479 \override RestCollision #'positioning-done = #merge-rests-on-positioning
1480 % Auto-Accidentals: Use modern-cautionary style...
1482 autoAccidentals = #`(Staff ,(make-accidental-rule 'same-octave 0)
1483 ,(make-accidental-rule 'any-octave 0)
1484 ,(make-accidental-rule 'same-octave 1))
1485 % autoCautionaries = #`(Staff ,(make-accidental-rule 'any-octave 0)
1486 % ,(make-accidental-rule 'same-octave 1))
1487 printKeyCancellation = ##t
1490 \RemoveEmptyStaffContext
1494 \override VerticalAxisGroup #'minimum-Y-extent = #'(0.5 . 0.5)
1498 \override VerticalAxisGroup #'minimum-Y-extent = #'(-1. . 3)
1499 quotedEventTypes = #'(StreamEvent)
1500 ignoreFiguredBassRest = ##f
1501 implicitBassFigures = #'(0 100)
1509 \type "Engraver_group"
1511 % So that \cresc works, for example.
1513 \consists "Output_property_engraver"
1515 \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
1516 pedalSustainStrings = #'("Ped." "*Ped." "*")
1517 pedalUnaCordaStrings = #'("una corda" "" "tre corde")
1519 \consists "Piano_pedal_engraver"
1520 \consists "Script_engraver"
1521 \consists "Dynamic_engraver"
1522 \consists "Text_engraver"
1524 \override TextScript #'font-size = #2
1525 \override TextScript #'font-shape = #'italic
1526 \override DynamicText #'extra-offset = #'(0 . 2.5)
1527 \override Hairpin #'extra-offset = #'(0 . 2.5)
1529 \consists "Skip_event_swallow_translator"
1531 \consists "Axis_group_engraver"
1536 % \override VerticalAlignment #'forced-distance = #7
1541 bracketts = ^\markup{"[Solo]"}
1542 brackettt = ^\markup{"[Tutti]"}
1543 ts = ^\markup{"t.s."}
1544 tt = ^\markup{"Tutti"}
1545 solo = ^\markup{"Solo"}
1546 tutti = ^\markup{"Tutti"}
1548 dashedSlur = -\tweak #'dash-definition #'((0 1 0.4 0.75))(
1549 dashedTie = -\tweak #'dash-definition #'((0 1 0.4 0.75))~
1551 divisi = #(define-music-function (parser location vc1 vc2) (ly:music? ly:music?)
1553 << { \voiceOne $vc1 \oneVoice} \new Voice = "divisi2" { \voiceTwo $vc2 } >>
1557 #(define-public (bracket-stencils grob)
1558 (let ((lp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "[")))
1559 (rp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "]"))))
1562 bracketify = #(define-music-function (parser loc arg) (ly:music?)
1563 (_i "Tag @var{arg} to be parenthesized.")
1565 \once \override ParenthesesItem #'stencils = #bracket-stencils
1571 #(define-markup-command (hat layout props arg) (markup?)
1572 "Draw a hat above the given string @var{arg}."
1573 (interpret-markup layout props (markup #:combine #:raise 1.5 "^" arg)))