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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 % Use relative include pathes!
27 #(ly:set-option 'relative-includes #t)
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%% SCORE STRUCTURE AND AUTOMATIC GENERATION
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 % Helper function to filter all non-null entries
44 #(define (not-null? x) (not (null? x)))
46 % Helper function to extract a given variable, built from [Piece][Instrument]Identifier
47 #(define (namedPieceInstrObject piece instr name)
49 (fullname (string->symbol (string-append piece instr name)))
50 (instrname (string->symbol (string-append instr name)))
51 (piecename (string->symbol (string-append piece name)))
52 (fallback (string->symbol name))
55 ((defined? fullname) (primitive-eval fullname))
56 ((defined? instrname) (primitive-eval instrname))
57 ((defined? piecename) (primitive-eval piecename))
58 ((defined? fallback) (primitive-eval fallback))
64 %% Print text as a justified paragraph, taken from the lilypond Notation Reference
65 #(define-markup-list-command (paragraph layout props args) (markup-list?)
66 (let ((indent (chain-assoc-get 'par-indent props 2)))
67 (interpret-markup-list layout props
68 (make-justified-lines-markup-list (cons (make-hspace-markup indent)
71 conditionalBreak = #(define-music-function (parser location) ()
72 #{ \tag #'instrumental-score \pageBreak #}
75 #(define (oly:piece-title-markup title) (markup #:column (#:line (#:fontsize #'3 #:bold title))) )
77 #(define-markup-command (piece-title layout props title) (markup?)
78 (interpret-markup layout props (oly:piece-title-markup title))
81 #(define (oly:generate_object_name piece instr obj )
82 (if (and (string? piece) (string? instr) (string? obj))
83 (string-append piece instr obj)
87 #(define (oly:generate_staff_name piece instr) (oly:generate_object_name piece instr "St"))
89 #(define (set-context-property context property value)
90 (set! (ly:music-property context property) value)
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 % Score structure and voice types
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98 #(define oly:LiedScoreStructure '(
99 ("SoloScore" "SimultaneousMusic" ("Singstimme"))
100 ("Pfe" "PianoStaff" ("PfeI" "PfeII"))
101 ;("PfeI" "ParallelVoicesStaff" ("OIa" "OIb"))
102 ;("PfeII" "ParallelVoicesStaff" ("OIIa" "OIIb"))
103 ("FullScore" "SimultaneousMusic" ("Singstimme" "Pfe"))
104 ("VocalScore" "SimultaneousMusic" ("Singstimme" "Pfe"))
107 #(define oly:fullOrchestraScoreStructure '(
108 ; Part-combined staves for full score
109 ("Fl" "PartCombinedStaff" ("FlI" "FlII"))
110 ("Ob" "PartCombinedStaff" ("ObI" "ObII"))
111 ("Cl" "PartCombinedStaff" ("ClI" "ClII"))
112 ("Fag" "PartCombinedStaff" ("FagI" "FagII"))
113 ("Wd" "StaffGroup" ("Fl" "Ob" "Cl" "Fag" "CFag"))
115 ("Cor" "PartCombinedStaff" ("CorI" "CorII"))
116 ("Trb" "PartCombinedStaff" ("TrbI" "TrbII"))
117 ("Tbe" "PartCombinedStaff" ("TbeI" "TbeII"))
118 ("Br" "StaffGroup" ("Cor" "Trb" "Tbe" "Tba"))
120 ; long score; no part-combined staves, but GrandStaves instead
121 ("FlLong" "GrandStaff" ("FlI" "FlII"))
122 ("ObLong" "GrandStaff" ("ObI" "ObII"))
123 ("ClLong" "GrandStaff" ("ClI" "ClII"))
124 ("FagLong" "GrandStaff" ("FagI" "FagII"))
125 ("WdLong" "StaffGroup" ("FlLong" "ObLong" "ClLong" "FagLong" "CFag"))
127 ("CorLong" "GrandStaff" ("CorI" "CorII"))
128 ("TrbLong" "GrandStaff" ("TrbI" "TrbII"))
129 ("TbeLong" "GrandStaff" ("TbeI" "TbeII" "TbeIII"))
130 ("BrLong" "StaffGroup" ("CorLong" "TrbLong" "TbeLong" "Tba"))
133 ("Perc" "StaffGroup" ("Tim"))
135 ; Strings, they are the same in long and short full score
136 ("V" "GrandStaff" ("VI" "VII"))
137 ("Str" "StaffGroup" ("V" "Va"))
138 ("VceB" "StaffGroup" ("Vc" "Cb" "VcB"))
139 ("FullStr" "StaffGroup" ("V" "Va" "Vc" "Cb" "VcB"))
142 ("Solo" "SimultaneousMusic" ("SSolo" "ASolo" "TSolo" "BSolo"))
143 ("Ch" "ChoirStaff" ("S" "A" "T" "B"))
144 ("ChoralScore" "SimultaneousMusic" ("Ch"))
145 ("SoloScore" "SimultaneousMusic" ("Solo"))
146 ("SoloChoirScore" "SimultaneousMusic" ("Solo" "Ch"))
148 ; Organ score (inkl. Figured bass)
149 ("BCFb" "FiguredBass" ())
150 ("FiguredBass" "FiguredBass" ())
151 ;("Organ" "SimultaneousMusic" ("BCFb" "O"))
152 ("Continuo" "ParallelVoicesStaff" ("BCFb" "BC" "FiguredBass"))
153 ("RealizedContinuo" "PianoStaff" ("BCRealization" "Continuo"))
154 ("BassGroup" "StaffGroup" ("Continuo"))
156 ("P" "PianoStaff" ("PI" "PII"))
157 ("O" "PianoStaff" ("OI" "OII"))
158 ("OI" "ParallelVoicesStaff" ("OIa" "OIb"))
159 ("OII" "ParallelVoicesStaff" ("OIIa" "OIIb"))
160 ("Organ" "SimultaneousMusic" ("OGroup" "RealizedContinuo"))
161 ;("BassGroup" "ParallelVoicesStaff" ("Organ" "O" "BC" "VceB"))
164 ("FullScore" "SimultaneousMusic" ("Wd" "Br" "Perc" "Str" "SoloChoirScore" "O" "RealizedContinuo"))
165 ("LongScore" "SimultaneousMusic" ("WdLong" "BrLong" "Perc" "Str" "SoloChoirScore" "O" "RealizedContinuo"))
166 ("OriginalScore" "SimultaneousMusic" ("BrLong" "WdLong" "Perc" "Str" "SoloChoirScore" "O" "BassGroup"))
169 ;("Piano" "SimultaneousMusic" ("Organ"))
170 ("OrganScore" "SimultaneousMusic" ("ChoralScore" "O"))
171 ("VocalScore" "SimultaneousMusic" ("ChoralScore" "P"))
172 ("Particell" "SimultaneousMusic" ("ChoralScore" "BassGroup"))
174 ; Full scores: Orchestral score and long score including organ
175 ("ChStrQ" "SimultaneousMusic" ("Str" "Ch" "VceB"))
177 #(define oly:orchestral_score_structure oly:fullOrchestraScoreStructure)
179 #(define (oly:set_score_structure struct)
181 (set! oly:orchestral_score_structure struct)
182 (ly:warning (_ "oly:set_score_structure needs an association list as argument!"))
186 #(define (oly:modify_score_structure entry)
188 (set! oly:orchestral_score_structure (assoc-set! oly:orchestral_score_structure (car entry) (cdr entry)))
189 (ly:warning (_ "oly:modify_score_structure expects a list (\"key\" \"type\" '(children)) as argument!"))))
191 #(define (oly:remove_from_score_structure entry)
193 (map oly:remove_from_score_structure entry)
194 (set! oly:orchestral_score_structure (assoc-remove! oly:orchestral_score_structure entry))))
196 orchestralScoreStructure = #(define-music-function (parser location structure) (list?)
197 (oly:set_score_structure structure)
198 (make-music 'Music 'void #t)
201 #(define oly:voice_types '())
203 #(define (oly:set_voice_types types)
205 (set! oly:voice_types types)
206 (ly:warning (_ "oly:set_voice_types needs an association list as argument!"))
210 orchestralVoiceTypes = #(define-music-function (parser location types) (list?)
211 (oly:set_voice_types types)
212 (make-music 'Music 'void #t)
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
217 % Automatic staff and group generation
218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220 % Retrieve all music definitions for the given
221 #(define (oly:get_music_object piece instrument)
222 (namedPieceInstrObject piece instrument "Music")
224 #(define (oly:get_music_objects piece instruments)
225 (filter not-null? (map (lambda (i) (oly:get_music_object piece i)) instruments))
228 % Given a property name and the extensions, either generate the pair to set
229 % the property or an empty list, if no pre-defined variable could be found
230 #(define (oly:generate_property_pair prop piece instr type)
231 (let* ((val (namedPieceInstrObject piece instr type)))
232 (if (not-null? val) (list 'assign prop val) '() )
236 #(define (oly:staff_type type)
238 ((string? type) (string->symbol type))
239 ((symbol? type) type)
244 #(define (oly:extractPitch music)
246 (elems (if (ly:music? music) (ly:music-property music 'elements)))
247 (note (if (pair? elems) (car elems)))
248 (pitch (if (ly:music? note) (ly:music-property note 'pitch)))
250 (if (and (not-null? music) (not (ly:pitch? pitch)))
251 (ly:warning "Unable to interpret as a pitch!")
257 #(define (oly:extractTranspositionPitch piece name)
259 (trpFromPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeFrom")))
260 (trpToPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeTo")))
262 (if (ly:pitch? trpFromPitch)
263 (if (ly:pitch? trpToPitch)
265 (ly:pitch-diff trpFromPitch trpToPitch)
266 (ly:pitch-diff trpFromPitch (ly:make-pitch 0 0 0))
268 (if (ly:pitch? trpToPitch)
269 (ly:pitch-diff (ly:make-pitch 0 0 0) trpToPitch)
276 #(define (oly:musiccontent_for_voice parser piece name music additional)
277 (let* ((musiccontent additional))
279 ; Append the settings, key and clef (if defined)
282 (let* ((object (namedPieceInstrObject piece name type)))
283 (if (ly:music? object)
284 (set! musiccontent (append musiccontent (list (ly:music-deep-copy object))))
285 (if (not-null? object) (ly:warning (_ "Wrong type (no ly:music) for ~S for instrument ~S in piece ~S") type name piece))
289 ; TODO: Does the "Tempo" work here???
290 '("Settings" "Key" "Clef" "TimeSignature" "ExtraSettings";"Tempo"
294 (if (ly:music? music)
296 (set! musiccontent (make-simultaneous-music (append musiccontent (list music))))
297 ;(ly:message "Generating staff for ~a" name)
298 (let* ((trpPitch (oly:extractTranspositionPitch piece name)))
299 (if (ly:pitch? trpPitch)
300 (set! musiccontent (ly:music-transpose musiccontent trpPitch))
305 ; For empty music, return empty
311 #(define (oly:lyrics_create_single_context parser piece name voicename lyricsid)
312 ; If we have lyrics, create a lyrics context containing LyricCombineMusic
313 ; and add that as second element to the staff's elements list...
314 (let* ((id (string-append "Lyrics" lyricsid))
315 (lyrics (namedPieceInstrObject piece name id)))
316 (if (ly:music? lyrics)
317 (context-spec-music (make-music 'LyricCombineMusic
319 'associated-context voicename)
320 'Lyrics (oly:generate_object_name piece name id))
325 #(define (oly:lyrics_create_contexts parser piece name voicename)
328 (oly:lyrics_create_single_context parser piece name voicename str))
329 (list "" "I" "II" "III" "IV" "V" "VI"))))
331 #(define (oly:voice_handler_internal parser piece name type music)
332 (if (ly:music? music)
334 (voicename (oly:generate_object_name piece name "Voice" ))
335 (lyrics (oly:lyrics_create_contexts parser piece name voicename))
336 (additional (if (not-null? lyrics) (list dynamicUp) '()))
337 (musiccontent (oly:musiccontent_for_voice parser piece name music additional))
338 (voicetype (oly:staff_type type))
339 (voice (context-spec-music musiccontent voicetype voicename))
343 ; For empty music, return empty
348 #(define (oly:voice_handler parser piece name type)
349 (oly:voice_handler_internal parser piece name type (oly:get_music_object piece name)))
351 #(define (oly:staff_handler_internal parser piece name type voices)
352 (if (not-null? voices)
354 (staffname (oly:generate_staff_name piece name))
355 (stafftype (oly:staff_type type))
356 (staff (make-simultaneous-music voices))
357 (propops (oly:staff_handler_properties piece name))
360 ((SimultaneousMusic ParallelMusic) #f)
361 (else (set! staff (context-spec-music staff stafftype staffname)))
363 (if (not-null? propops)
364 (set! (ly:music-property staff 'property-operations) propops)
368 ; For empty music, return empty
373 #(define (oly:staff_handler parser piece name type children)
374 (let* ((c (if (not-null? children) children (list name)))
375 (voices (apply append (map (lambda (v) (oly:create_voice parser piece v)) c)) )
377 (if (not-null? voices)
378 (oly:staff_handler_internal parser piece name type voices)
384 #(define (oly:devnull_handler parser piece name type children)
385 (oly:voice_handler parser piece name type)
388 #(define (oly:parallel_voices_staff_handler parser piece name type children)
390 (voices (map (lambda (i) (oly:create_voice parser piece i)) children))
391 ; get the list of non-empty voices and flatten it!
392 (nonemptyvoices (apply append (filter not-null? voices)))
394 (if (not-null? nonemptyvoices)
395 (oly:staff_handler_internal parser piece name "Staff" nonemptyvoices)
401 #(define (oly:part_combined_staff_handler parser piece name type children)
402 (let* ((rawmusic (map (lambda (c) (oly:musiccontent_for_voice parser piece name (oly:get_music_object piece c) '())) children))
403 (music (filter not-null? rawmusic)))
405 ((and (pair? music) (ly:music? (car music)) (not-null? (cdr music)) (ly:music? (cadr music)))
406 ;(ly:message "Part-combine with two music expressions")
407 (oly:staff_handler_internal parser piece name "Staff" (list (make-part-combine-music parser music))))
409 ;;(ly:warning "Part-combine without any music expressions")
411 ; exactly one is a music expression, simply use that by joining
413 ;;(ly:message "Part-combine with only one music expressions")
414 (oly:staff_handler_internal parser piece name "Staff" (list (apply append music))))
416 ;(ly:message "make_part_combined_staff: ~S ~S ~a" piece instr instruments)
422 % Generate the properties for the staff for piece and instr. Typically, these
423 % are the instrument name and the short instrument name (if defined).
424 % return a (possibly empty) list of all assignments.
425 #(define (oly:staff_handler_properties piece instr)
428 (instrumentName . "InstrumentName")
429 (shortInstrumentName . "ShortInstrumentName")
430 (midiInstrument . "MidiInstrument")
434 (oly:generate_property_pair (car pr) piece instr (cdr pr))
437 (props (filter not-null? assignments))
443 % Figured bass is a special case, as it can be voice- or staff-type. When
444 % given as a staff type, simply call the voice handler, instead
446 #(define (oly:figured_bass_staff_handler parser piece name type children)
447 (let* ((c (if (not-null? children) children (list name)))
448 (voice (oly:voice_handler parser piece (car c) type)))
449 (if (pair? voice) (car voice) ())
453 #(define (flatten lst)
454 (define (f remaining result)
456 ((null? remaining) result)
457 ((pair? (car remaining)) (f (cdr remaining) (f (car remaining) result)))
458 (else (f (cdr remaining) (cons (car remaining) result)))))
459 (reverse! (f lst '())))
461 #(define (oly:staff_group_handler parser piece name type children)
463 (staves (flatten (map (lambda (i) (oly:create_staff_or_group parser piece i)) children)))
464 (nonemptystaves (filter not-null? staves))
466 (if (not-null? nonemptystaves)
468 (musicexpr (if (= 1 (length nonemptystaves))
470 (make-simultaneous-music nonemptystaves)))
471 (groupname (oly:generate_staff_name piece name))
472 (grouptype (oly:staff_type type))
474 (propops (oly:staff_handler_properties piece name))
477 ((SimultaneousMusic ParallelMusic) #f)
478 (else (set! group (context-spec-music group grouptype groupname)))
481 (set! (ly:music-property group 'property-operations) propops))
484 ; Return empty list if no staves are generated
490 #(define (oly:create_voice parser piece name)
491 (let* ( (voice (namedPieceInstrObject piece name "Voice"))
492 (type (assoc-ref oly:voice_types name)) )
493 (if (not-null? voice)
494 ; Explicit voice variable, use that
498 ; No entry in structure found => simple voice
499 (oly:voice_handler parser piece name "Voice")
500 ; Entry found in structure => use the handler for the given type
502 (voicetype (car type))
503 (handler (assoc-ref oly:voice_handlers voicetype))
506 ((primitive-eval handler) parser piece name voicetype)
508 (ly:warning "No handler found for voice type ~a, using default voice handler" voicetype)
509 (oly:voice_handler parser piece name voicetype)
518 #(define (oly:create_staff_or_group parser piece name)
519 (let* ( (staff (namedPieceInstrObject piece name "Staff"))
520 (type_from_structure (assoc-ref oly:orchestral_score_structure name)) )
521 ;(if (not-null? staff)
522 ; (ly:message "Found staff variable for instrument ~a in piece ~a" instr piece)
523 ; (ly:message "Staff variable for instrument ~a in piece ~a NOT FOUND" instr piece)
525 (if (not-null? staff)
526 ; Explicit staff variable, use that
529 (if (not (list? type_from_structure))
530 ; No entry in structure found => simple staff
531 (oly:staff_handler parser piece name "Staff" '())
533 ; Entry found in structure => use the handler for the given type
534 (let* ((type (car type_from_structure))
535 (handler (assoc-ref oly:staff_handlers type))
536 (children (cadr type_from_structure))
539 ((primitive-eval handler) parser piece name type children)
541 (ly:warning "No handler found for staff type ~a, using default staff handler" type)
542 (oly:staff_handler parser piece name type children)
551 #(define oly:staff_handlers
554 '("GrandStaff" . oly:staff_group_handler )
555 '("PianoStaff" . oly:staff_group_handler )
556 '("ChoirStaff" . oly:staff_group_handler )
557 '("StaffGroup" . oly:staff_group_handler )
558 '("InnerChoirStaff" . oly:staff_group_handler )
559 '("InnerStaffGroup" . oly:staff_group_handler )
560 '("ParallelMusic" . oly:staff_group_handler )
561 '("SimultaneousMusic" . oly:staff_group_handler )
563 '("Staff" . oly:staff_handler )
564 '("DrumStaff" . oly:staff_handler )
565 '("RhythmicStaff" . oly:staff_handler )
566 '("TabStaff" . oly:staff_handler )
567 '("GregorianTranscriptionStaff" . oly:staff_handler )
568 '("MensuralStaff" . oly:staff_handler )
569 '("VaticanaStaff" . oly:staff_handler )
570 ; staves with multiple voices
571 '("PartCombinedStaff" . oly:part_combined_staff_handler )
572 '("ParallelVoicesStaff" . oly:parallel_voices_staff_handler )
573 ; special cases: Figured bass can be staff or voice type!
574 '("FiguredBass" . oly:figured_bass_staff_handler )
575 ; Devnull is like a staff, only that it doesn't craete output
576 '("Devnull" . oly:devnull_handler )
580 #(define oly:voice_handlers
583 '("Voice" . oly:voice_handler )
584 '("CueVoice" . oly:voice_handler )
585 '("DrumVoice" . oly:voice_handler )
586 '("FiguredBass" . oly:voice_handler )
587 '("GregorianTranscriptionVoice" . oly:voice_handler )
588 '("NoteNames" . oly:voice_handler )
589 '("TabVoice" . oly:voice_handler )
590 '("VaticanaVoice" . oly:voice_handler )
591 ;'("Dynamics" . oly:dynamics_handler )
596 #(define (oly:register_staff_type_handler type func)
597 ; (ly:message "Registering staff handler ~a for type ~a" func type)
598 (set! oly:staff_handlers (assoc-set! oly:staff_handlers type func))
601 #(define (oly:register_voice_type_handler type func)
602 ; (ly:message "Registering voice type handler ~a for type ~a" func type)
603 (set! oly:voice_handlers (assoc-set! oly:voice_handlers type func))
606 % handlers for deprecated API
607 #(oly:register_staff_type_handler 'StaffGroup 'oly:staff_group_handler)
608 #(oly:register_staff_type_handler 'GrandStaff 'oly:staff_group_handler)
609 #(oly:register_staff_type_handler 'PianoStaff 'oly:staff_group_handler)
610 #(oly:register_staff_type_handler 'ChoirStaff 'oly:staff_group_handler)
611 #(oly:register_staff_type_handler 'Staff 'oly:staff_handler )
612 #(oly:register_staff_type_handler 'ParallelMusic 'oly:staff_group_handler)
613 #(oly:register_staff_type_handler 'SimultaneousMusic 'oly:staff_group_handler)
614 #(oly:register_staff_type_handler #t 'oly:part_combined_staff_handler )
615 #(oly:register_staff_type_handler #f 'oly:parallel_voices_staff_handler )
619 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
620 % Automatic score generation
621 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
623 #(define oly:score_handler add-score)
624 #(define oly:music_handler add-music)
625 #(define oly:text_handler add-text)
629 setUseBook = #(define-music-function (parser location usebook) (boolean?)
630 (ly:warning "\\setUseBook has been deprecated! Books are now automatically handled without any hacks")
631 (make-music 'Music 'void #t)
635 % Two functions to handle midi-blocks: Either don't set one, or set an empty
636 % one so that MIDI is generated
637 #(define (oly:set_no_midi_block score) '())
638 #(define (oly:set_midi_block score)
639 (let* ((midiblock (if (defined? '$defaultmidi)
640 (ly:output-def-clone $defaultmidi)
641 (ly:make-output-def))))
642 (ly:output-def-set-variable! midiblock 'is-midi #t)
643 (ly:score-add-output-def! score midiblock)
647 % \setCreateMidi ##t/##f sets a flag to determine wheter MIDI output should
649 #(define oly:apply_score_midi oly:set_no_midi_block)
650 setCreateMIDI = #(define-music-function (parser location createmidi) (boolean?)
652 (set! oly:apply_score_midi oly:set_midi_block)
653 (set! oly:apply_score_midi oly:set_no_midi_block)
655 (make-music 'Music 'void #t)
659 % Two functions to handle layout-blocks: Either don't set one, or set an empty
660 % one so that a PDF is generated
661 #(define (oly:set_no_layout_block score) '())
662 #(define (oly:set_layout_block score)
663 (let* ((layoutblock (if (defined? '$defaultlayout)
664 (ly:output-def-clone $defaultlayout)
665 (ly:make-output-def))))
666 (ly:output-def-set-variable! layoutblock 'is-layout #t)
667 (ly:score-add-output-def! score layoutblock)
671 % \setCreatePDF ##t/##f sets a flag to determine wheter PDF output should
673 #(define oly:apply_score_layout oly:set_no_layout_block)
674 setCreatePDF = #(define-music-function (parser location createlayout) (boolean?)
676 (set! oly:apply_score_layout oly:set_layout_block)
677 (set! oly:apply_score_layout oly:set_no_layout_block)
679 (make-music 'Music 'void #t)
683 % Set the piece title in a new header block.
684 #(define (oly:set_piece_header score piecename)
685 (if (not-null? piecename)
686 (let* ((header (make-module)))
687 (module-define! header 'piece piecename)
688 (ly:score-set-header! score header)
694 % post-filter functions. By default, no filtering is done. However,
695 % for the *NoCues* function, the cue notes should be killed
696 identity = #(define-music-function (parser location music) (ly:music?) music)
697 cuefilter = #(define-music-function (parser location music) (ly:music?)
698 ((ly:music-function-extract removeWithTag) parser location 'cued ((ly:music-function-extract killCues) parser location music))
702 #(define (oly:create-toc-file layout pages)
703 (let* ((label-table (ly:output-def-lookup layout 'label-page-table)))
704 (if (not (null? label-table))
705 (let* ((format-line (lambda (toc-item)
706 (let* ((label (car toc-item))
707 (text (caddr toc-item))
708 (label-page (and (list? label-table)
709 (assoc label label-table)))
710 (page (and label-page (cdr label-page))))
711 (format #f "~a, section, 1, {~a}, ~a" page text label))))
712 (formatted-toc-items (map format-line (toc-items)))
713 (whole-string (string-join formatted-toc-items ",\n"))
714 (output-name (ly:parser-output-name parser))
715 (outfilename (format "~a.toc" output-name))
716 (outfile (open-output-file outfilename)))
717 (if (output-port? outfile)
718 (display whole-string outfile)
719 (ly:warning (_ "Unable to open output file ~a for the TOC information") outfilename))
720 (close-output-port outfile)))))
723 #(define-public (oly:add-toc-item parser markup-symbol text)
724 (oly:music_handler parser (add-toc-item! markup-symbol text)))
727 #(define (oly:add-score parser score piecename)
728 (if (not-null? piecename)
729 (oly:add-toc-item parser 'tocItemMarkup piecename))
730 (oly:score_handler parser score)
732 % The helper function to build a score.
733 #(define (oly:createScoreHelper parser location piece children func)
735 (staves (oly:staff_group_handler parser piece "" "SimultaneousMusic" children))
736 (music (if (not-null? staves)
737 ((ly:music-function-extract func) parser location staves)
741 (piecename (namedPieceInstrObject piece (car children) "PieceName"))
742 (piecenametacet (namedPieceInstrObject piece (car children) "PieceNameTacet"))
746 ; No staves, print tacet
748 (if (not-null? piecenametacet) (set! piecename piecenametacet))
749 (if (not-null? piecename)
750 (oly:add-score parser (list (oly:piece-title-markup piecename)) piecename)
751 (ly:warning (_ "No music and no score title found for part ~a and instrument ~a") piece children)
754 ; we have staves, apply the piecename to the score and add layout/midi blocks if needed
756 (set! score (scorify-music music parser))
757 (oly:set_piece_header score piecename)
758 (oly:apply_score_midi score)
759 (oly:apply_score_layout score)
760 ; Schedule the score for typesetting
761 (oly:add-score parser score piecename)
765 ; This is a void function, the score has been schedulled for typesetting already
766 (make-music 'Music 'void #t)
769 createScore = #(define-music-function (parser location piece children) (string? list?)
770 (oly:createScoreHelper parser location piece children identity)
772 createNoCuesScore = #(define-music-function (parser location piece children) (string? list?)
773 (oly:createScoreHelper parser location piece children cuefilter)
776 createHeadline = #(define-music-function (parser location headline) (string?)
777 (oly:add-toc-item parser 'tocItemMarkup headline)
778 (oly:score_handler parser (list (oly:piece-title-markup headline)))
779 (make-music 'Music 'void #t)
784 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
785 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
787 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
788 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
790 newInstrument = #(define-music-function (parser location instr) (string?)
792 \set Voice.instrumentCueName = #$(string-join (list "+" instr))
795 cueText = #(define-music-function (parser location instr) (string?)
797 \set Voice.instrumentCueName = $instr
801 clearCueText = #(define-music-function (parser location) ()
803 \unset Voice.instrumentCueName
807 insertCueText = #(define-music-function (parser location instr) (string?)
808 (if (string-null? instr)
809 #{ \tag #'cued \clearCueText #}
810 #{ \tag #'cued \cueText #$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 {
824 \insertCueText #$instrcue
826 \insertCueText #$instr
830 namedTransposedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr trans cuemusic) (string? number? string? string? ly:music? ly:music?)
832 \transposedCueDuring #$cuevoice #$direction $trans {
833 \insertCueText #$instrcue
835 \insertCueText #$instr
840 % set the cue instrument name and clef
841 setClefCue = #(define-music-function (parser location instr clef)
844 \once \override Staff.Clef #'font-size = #-3 $clef
845 \insertCueText $instr
848 % generate a cue music section with instrument names and clef changes
849 % Parameters: \cleffedCueDuring NameOfQuote CueDirection CueInstrument CueClef OriginalInstrument OriginalClef music
850 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
851 % -) CueInstrument and OriginalInstrument are the displayed instrument names
852 % -) CueClef and OriginalClef are the clefs for the the cue notes and the clef of the containing voice
854 % \cleffedCueDuring #"vIQuote" #UP #"V.I" #"treble" #"Basso" #"bass" { R1*3 }
855 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
856 % the beginning of the cue notes and "Basso" at the end. The clef is changed to treble at the
857 % beginning of the cue notes and reset to bass at the end
858 cleffedCueDuring = #(define-music-function (parser location cuevoice direction instrcue clefcue instr clefinstr cuemusic)
859 (string? number? string? ly:music? string? ly:music? ly:music?)
861 \cueDuring #$cuevoice #$direction {
862 \tag #'cued \setClefCue #$instrcue $clefcue
864 \tag #'cued \setClefCue #$instr $clefinstr
872 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
873 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
875 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
876 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
879 dynamicsX = #(define-music-function (parser location offset) (number?)
881 \once \override DynamicText #'X-offset = $offset
882 \once \override DynamicLineSpanner #'Y-offset = #0
885 % Move the dynamic sign inside the staff to a fixed staff-relative position
886 % posY (where 0 means vertically starts at the middle staff line)
887 dynamicsAllInside = #(define-music-function (parser location offsetX posY)
890 % Invalid y-extent -> hidden from skyline calculation and collisions
891 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
892 % move by X offset and to fixed Y-position (use Y-offset of parent!)
893 \once \override DynamicText #'X-offset = $offsetX
894 \once \override DynamicText #'Y-offset =
896 (let* ((head (ly:grob-parent grob Y))
897 (offset (ly:grob-property head 'Y-offset)))
898 (- posY offset (- 0.6))))
899 \once \override DynamicLineSpanner #'Y-offset = $posY
902 dynamicsUpInside = #(define-music-function (parser location offsetX) (number?)
903 ((ly:music-function-extract dynamicsAllInside) parser location offsetX 1.5)
906 dynamicsDownInside = #(define-music-function (parser location offsetX) (number?)
907 ((ly:music-function-extract dynamicsAllInside) parser location offsetX -3.5)
910 hairpinOffset = #(define-music-function (parser location posY) (number?)
912 \once \override DynamicLineSpanner #'Y-offset = $posY
913 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
916 #(define ((line-break-offset before after) grob)
917 (let* ((orig (ly:grob-original grob))
918 ; All siblings if line-broken:
919 (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
920 (if (>= (length siblings) 2)
921 ; We have been line-broken
922 (if (eq? (car (last-pair siblings)) grob)
924 (ly:grob-set-property! grob 'Y-offset after)
925 ; Others get the before value:
926 (ly:grob-set-property! grob 'Y-offset before)
932 ffz = #(make-dynamic-script "ffz")
933 pf = #(make-dynamic-script "pf")
934 sempp = #(make-dynamic-script (markup #:line( #:with-dimensions '(0 . 0)
935 '(0 . 0) #:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
936 parenf = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")" )))
937 parenp = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "p" #:normal-text #:italic #:fontsize 2 ")" )))
938 pdolce = #(make-dynamic-script (markup #:line(#:dynamic "p" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
939 sfpdolce = #(make-dynamic-script (markup #:line(#:dynamic "sfp" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
940 bracketf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 3 "[" #:dynamic "f" #:hspace 0.1 #:normal-text #:fontsize 3 "]"))))
941 bracketp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 2 "[" #:hspace 0.2 #:dynamic "p" #:normal-text #:fontsize 2 "]"))))
945 % cresc = #(make-music 'CrescendoEvent 'span-direction START 'crescendoSpanner 'text 'crescendoText "cresc.")
946 % endcresc = #(make-span-event 'CrescendoEvent STOP)
947 % dim = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "dim.")
948 % enddim = #(make-span-event 'DecrescendoEvent STOP)
949 % decresc = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "decresc.")
950 % enddecresc = #(make-span-event 'DecrescendoEvent STOP)
955 cresc = #(make-music 'CrescendoEvent 'span-direction START
956 'span-type 'text 'span-text "cresc.")
957 dim = #(make-music 'DecrescendoEvent 'span-direction START
958 'span-type 'text 'span-text "dim.")
959 decresc = #(make-music 'DecrescendoEvent 'span-direction START
960 'span-type 'text 'span-text "decresc.")
962 newOrOldClef = #(define-music-function (parser location new old ) (string? string?)
963 (if (ly:get-option 'old-clefs) #{ \clef $old #} #{ \clef $new #})
968 %%% Thanks to "Gilles THIBAULT" <gilles.thibault@free.fr>, there is a way
969 % to remove also the fermata from R1-\fermataMarkup: By filtering the music
970 % and removing the corresponding events.
971 % Documented as an LSR snippet: http://lsr.dsi.unimi.it/LSR/Item?id=372
972 #(define (filterOneEventsMarkup event)
973 ( let ( (eventname (ly:music-property event 'name)) )
975 (or ;; add here event name you do NOT want
976 (eq? eventname 'MultiMeasureTextEvent)
977 (eq? eventname 'AbsoluteDynamicEvent)
978 (eq? eventname 'TextScriptEvent)
979 (eq? eventname 'ArticulationEvent)
980 (eq? eventname 'CrescendoEvent)
981 (eq? eventname 'DecrescendoEvent)
986 filterArticulations = #(define-music-function (parser location music) (ly:music?)
987 (music-filter filterOneEventsMarkup music)
994 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
995 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
997 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
998 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1002 rit = \markup {\italic "rit."}
1003 pocorit = \markup {\italic "poco rit."}
1004 ppmosso = \markup {\italic "poco più mosso"}
1005 dolce = \markup {\italic "dolce"}
1006 pizz = \markup {\italic "pizz."}
1007 arco = \markup {\italic "arco"}
1008 perd = \markup {\italic "perdend."}
1013 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1014 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1015 %%%%% REST COMBINATION
1016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1017 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1021 %% REST COMBINING, TAKEN FROM http://lsr.dsi.unimi.it/LSR/Item?id=336
1024 %% \new Staff \with {
1025 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1026 %% } << \somevoice \\ \othervoice >>
1031 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1036 %% - only handles two voices
1037 %% - does not handle multi-measure/whole-measure rests
1039 #(define (rest-score r)
1041 (yoff (ly:grob-property-data r 'Y-offset))
1042 (sp (ly:grob-property-data r 'staff-position)))
1044 (set! score (+ score 2))
1045 (if (eq? yoff 'calculation-in-progress)
1046 (set! score (- score 3))))
1049 (set! score (+ score 2))
1050 (set! score (- score (abs (- 1 sp)))))
1053 #(define (merge-rests-on-positioning grob)
1054 (let* ((can-merge #f)
1055 (elts (ly:grob-object grob 'elements))
1056 (num-elts (and (ly:grob-array? elts)
1057 (ly:grob-array-length elts)))
1058 (two-voice? (= num-elts 2)))
1060 (let* ((v1-grob (ly:grob-array-ref elts 0))
1061 (v2-grob (ly:grob-array-ref elts 1))
1062 (v1-rest (ly:grob-object v1-grob 'rest))
1063 (v2-rest (ly:grob-object v2-grob 'rest)))
1067 (let* ((v1-duration-log (ly:grob-property v1-rest 'duration-log))
1068 (v2-duration-log (ly:grob-property v2-rest 'duration-log))
1069 (v1-dot (ly:grob-object v1-rest 'dot))
1070 (v2-dot (ly:grob-object v2-rest 'dot))
1071 (v1-dot-count (and (ly:grob? v1-dot)
1072 (ly:grob-property v1-dot 'dot-count -1)))
1073 (v2-dot-count (and (ly:grob? v2-dot)
1074 (ly:grob-property v2-dot 'dot-count -1))))
1077 (number? v1-duration-log)
1078 (number? v2-duration-log)
1079 (= v1-duration-log v2-duration-log)
1080 (eq? v1-dot-count v2-dot-count)))
1082 ;; keep the rest that looks best:
1083 (let* ((keep-v1? (>= (rest-score v1-rest)
1084 (rest-score v2-rest)))
1085 (rest-to-keep (if keep-v1? v1-rest v2-rest))
1086 (dot-to-kill (if keep-v1? v2-dot v1-dot)))
1087 ;; uncomment if you're curious of which rest was chosen:
1088 ;;(ly:grob-set-property! v1-rest 'color green)
1089 ;;(ly:grob-set-property! v2-rest 'color blue)
1090 (ly:grob-suicide! (if keep-v1? v2-rest v1-rest))
1091 (if (ly:grob? dot-to-kill)
1092 (ly:grob-suicide! dot-to-kill))
1093 (ly:grob-set-property! rest-to-keep 'direction 0)
1094 (ly:rest::y-offset-callback rest-to-keep)))))))
1097 (ly:rest-collision::calc-positioning-done grob))))
1103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1105 %%%%% TABLE OF CONTENTS
1106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1110 contentsTitle = "Inhalt / Contents"
1113 tocTitleMarkup = \markup \fill-line{
1116 \override #(cons 'line-width (* 7 cm))
1117 \line{ \fill-line {\piece-title {\contentsTitle} \null }}
1122 tocItemMarkup = \markup \fill-line {
1125 \override #(cons 'line-width (* 7 cm ))
1126 \line { \fill-line{\fromproperty #'toc:text \fromproperty #'toc:page }}
1133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1135 %%%%% TITLE PAGE / HEADER
1136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1139 #(define-markup-command (when-property layout props symbol markp) (symbol? markup?)
1140 (if (chain-assoc-get symbol props)
1141 (interpret-markup layout props markp)
1142 (ly:make-stencil '() '(1 . -1) '(1 . -1))))
1144 #(define-markup-command (vspace layout props amount) (number?)
1145 "This produces a invisible object taking vertical space."
1146 (let ((amount (* amount 3.0)))
1148 (ly:make-stencil "" (cons -1 1) (cons 0 amount))
1149 (ly:make-stencil "" (cons -1 1) (cons amount amount)))))
1153 titlePageMarkup = \markup \abs-fontsize #10 \when-property #'header:title \column {
1155 \fill-line { \fontsize #8 \fromproperty #'header:composer }
1157 \fill-line { \fontsize #8 \fromproperty #'header:poet }
1159 \fill-line { \fontsize #10 \bold \fromproperty #'header:titlepagetitle }
1161 \fontsize #2 \when-property #'header:titlepagesubtitle {
1162 \fill-line { \fromproperty #'header:titlepagesubtitle }
1165 \fill-line { \postscript #"-20 0 moveto 40 0 rlineto stroke" }
1167 \fill-line { \fontsize #5 \fromproperty #'header:ensemble }
1169 \fill-line { \fontsize #2 \fromproperty #'header:instruments }
1171 \fill-line { \fontsize #5 \fromproperty #'header:date }
1173 \fill-line { \fontsize #5 \fromproperty #'header:scoretype }
1175 \fontsize #2 \when-property #'header:enteredby {
1176 \fill-line { "Herausgegeben von: / Edited by:"}
1178 \fill-line { \fromproperty #'header:enteredby }
1181 \when-property #'header:arrangement \column {
1183 \fill-line { \fontsize #3 \fromproperty #'header:arrangement }
1188 titleHeaderMarkup = \markup {
1189 \override #'(baseline-skip . 3.5)
1192 \fromproperty #'header:logo
1194 \huge \larger \bold \larger \fromproperty #'header:title
1195 \large \smaller \bold \larger \fromproperty #'header:subtitle
1196 \smaller \bold \fromproperty #'header:subsubtitle
1198 \bold \when-property #'header:instrument \rounded-box \fromproperty #'header:instrument
1201 \with-dimensions #'( 0 . 0) #'( 0 . 1 ) \null
1205 % { \large \bold \fromproperty #'header:instrument }
1208 \fromproperty #'header:poet
1209 \fromproperty #'header:composer
1212 \fromproperty #'header:meter
1213 \fromproperty #'header:arranger
1218 titleScoreMarkup = \markup \piece-title \fromproperty #'header:piece
1221 scoreTitleMarkup = \titleScoreMarkup
1222 bookTitleMarkup = \titleHeaderMarkup
1227 %%%%%%%%%%%%%% headers and footers %%%%%%%%%%%%%%%%%%%%%%%%%%
1229 #(define (first-score-page layout props arg)
1230 (let* ((label 'first-score-page)
1231 (table (ly:output-def-lookup layout 'label-page-table))
1232 (label-page (and (list? table) (assoc label table)))
1233 (page-number (and label-page (cdr label-page)))
1235 (if (eq? (chain-assoc-get 'page:page-number props -1) page-number)
1236 (interpret-markup layout props arg)
1239 #(define no-header-table '())
1240 thisPageNoHeader = #(define-music-function (parser location) ()
1241 (let* ((label (gensym "header")))
1242 (set! no-header-table (cons label no-header-table))
1245 'page-label label)))
1248 % TODO: Use the no-header-table!
1249 #(define (is-header-page layout props arg)
1250 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1252 ;(if (and (> page-number 2) (!= page-number 7))
1253 (if (> page-number 1)
1254 (interpret-markup layout props arg)
1257 #(define no-footer-table '())
1258 thisPageNoFooter = #(define-music-function (parser location) ()
1259 (let* ((label (gensym "footer")))
1260 (set! no-footer-table (cons label no-footer-table))
1263 'page-label label)))
1265 % TODO: Use the no-footer-table!
1266 #(define (is-footer-page layout props arg)
1267 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1268 (label 'first-score-page)
1269 (table (ly:output-def-lookup layout 'label-page-table))
1270 (label-page (and (list? table) (assoc label table)))
1271 ;(page-number (and label-page (cdr label-page)))
1273 (if (and (> page-number 1))
1274 (interpret-markup layout props arg)
1278 #(define copyright-footer-table '())
1279 thisPageCopyrightFooter = #(define-music-function (parser location) ()
1280 (let* ((label (gensym "copyrightfooter")))
1281 (set! copyright-footer-table (cons label copyright-footer-table))
1284 'page-label label)))
1286 #(define copyright-pg 1)
1287 #(define (set-copyright-page page)
1288 (set! copyright-pg page)
1291 % TODO: Use the copyright-footer-table!
1292 #(define (copyright-page layout props arg)
1293 (if (= (chain-assoc-get 'page:page-number props -1) copyright-pg)
1294 (interpret-markup layout props arg)
1299 oddHeaderMarkup = \markup \fill-line {
1300 %% force the header to take some space, otherwise the
1301 %% page layout becomes a complete mess.
1303 \on-the-fly #is-header-page \fromproperty #'header:title
1304 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1306 evenHeaderMarkup = \markup \fill-line {
1307 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1308 \on-the-fly #is-header-page \fromproperty #'header:composer
1312 oddFooterMarkup = \markup {
1315 %% publisher header field only on title page.
1316 \on-the-fly #first-page \fromproperty #'header:publisher
1319 %% copyright on the first real score page
1320 \on-the-fly #copyright-page \fromproperty #'header:copyright
1321 \on-the-fly #copyright-page \null
1324 %% All other pages get the number of the edition centered
1325 \on-the-fly #is-footer-page \fromproperty #'header:scorenumber
1342 % Interpret the given markup with the header fields added to the props.
1343 % This way, one can re-use the same functions (using fromproperty
1344 % #'header:field) in the header block and as top-level markup.
1346 % This function is originally copied from mark-up-title (file scm/titling.scm),
1347 % which is lilypond's internal function to handle the title markups. I needed
1348 % to replace the scopes and manually add the $defaultheader (which is internally
1349 % done in paper-book.cc before calling mark-up-title. Also, I don't extract the
1350 % markup from the header block, but use the given markup.
1352 % I'm not sure if I really need the page properties in props, too... But I
1353 % suppose it does not hurt, either.
1354 #(define-markup-command (markupWithHeader layout props markup) (markup?)
1355 "Interpret the given markup with the header fields added to the props.
1356 This way, one can re-use the same functions (using fromproperty
1357 #'header:field) in the header block and as top-level markup."
1359 ; TODO: If we are inside a score, add the score's local header block, too!
1360 ; Currently, I only use the global header block, stored in $defaultheader
1361 (scopes (list $defaultheader))
1362 (alists (map ly:module->alist scopes))
1365 (map (lambda (alist)
1366 (map (lambda (entry)
1368 (string->symbol (string-append "header:" (symbol->string (car entry))))
1372 (props (append prefixed-alist
1374 (layout-extract-page-properties layout)))
1376 (interpret-markup layout props markup)
1385 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1386 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1387 %%%%% Equally spacing multiple columns (e.g. for translations)
1388 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1389 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1391 % Credits: Nicolas Sceaux on the lilypond-user mailinglist
1392 #(define-markup-command (columns layout props args) (markup-list?)
1393 (let ((line-width (/ (chain-assoc-get 'line-width props
1394 (ly:output-def-lookup layout 'line-width))
1395 (max (length args) 1))))
1396 (interpret-markup layout props
1397 (make-line-markup (map (lambda (line)
1398 (markup #:pad-to-box `(0 . ,line-width) '(0 . 0)
1399 #:override `(line-width . ,line-width)
1405 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1407 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1408 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1409 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1412 startSlashedGraceMusic = {
1413 \override Stem #'stroke-style = #"grace"
1416 stopSlashedGraceMusic = {
1417 \revert Stem #'stroke-style
1421 #(def-grace-function startSlashedGraceMusic stopSlashedGraceMusic
1422 (_i "Create slashed graces (slashes through stems, but no slur)from the following music expression"))
1425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1426 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1427 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1428 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1429 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1433 right-margin = 1.5\cm
1434 line-width = 17.5\cm
1435 % bottom-margin = 1.5\cm
1437 % after-title-space = 0.5\cm
1441 ragged-last-bottom = ##f
1446 % If only one non-empty staff in a system exists, still print the backet
1447 \override SystemStartBracket #'collapse-height = #1
1448 \consists "Instrument_name_engraver"
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 \override SystemStartBracket #'collapse-height = #1
1459 \consists "Instrument_name_engraver"
1463 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1467 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1468 \override VerticalAxisGroup #'minimum-Y-extent = #'(0 . 1)
1469 \override VerticalAxisGroup #'padding = #0
1473 % Force multi-measure rests to be written as one span
1474 \override MultiMeasureRest #'expand-limit = #3
1477 % hairpinToBarline = ##f
1478 \override BarNumber #'break-visibility = #end-of-line-invisible
1479 \override BarNumber #'self-alignment-X = #0
1480 \override CombineTextScript #'avoid-slur = #'outside
1481 barNumberVisibility = #(every-nth-bar-number-visible 5)
1482 \override DynamicTextSpanner #'dash-period = #-1.0
1483 \override InstrumentSwitch #'font-size = #-1
1486 \override RestCollision #'positioning-done = #merge-rests-on-positioning
1487 % Auto-Accidentals: Use modern-cautionary style...
1489 autoAccidentals = #`(Staff ,(make-accidental-rule 'same-octave 0)
1490 ,(make-accidental-rule 'any-octave 0)
1491 ,(make-accidental-rule 'same-octave 1))
1492 % autoCautionaries = #`(Staff ,(make-accidental-rule 'any-octave 0)
1493 % ,(make-accidental-rule 'same-octave 1))
1494 printKeyCancellation = ##t
1495 quotedEventTypes = #'(StreamEvent)
1496 implicitBassFigures = #'(0 100)
1499 \RemoveEmptyStaffContext
1503 % \override VerticalAxisGroup #'minimum-Y-extent = #'(0.5 . 0.5)
1507 % \override VerticalAxisGroup #'minimum-Y-extent = #'(-1. . 3)
1508 ignoreFiguredBassRest = ##f
1516 \type "Engraver_group"
1518 % So that \cresc works, for example.
1520 \consists "Output_property_engraver"
1522 \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
1523 pedalSustainStrings = #'("Ped." "*Ped." "*")
1524 pedalUnaCordaStrings = #'("una corda" "" "tre corde")
1526 \consists "Piano_pedal_engraver"
1527 \consists "Script_engraver"
1528 \consists "Dynamic_engraver"
1529 \consists "Text_engraver"
1531 \override TextScript #'font-size = #2
1532 \override TextScript #'font-shape = #'italic
1533 \override DynamicText #'extra-offset = #'(0 . 2.5)
1534 \override Hairpin #'extra-offset = #'(0 . 2.5)
1536 \consists "Skip_event_swallow_translator"
1538 \consists "Axis_group_engraver"
1543 % \override VerticalAlignment #'forced-distance = #7
1548 bracketts = ^\markup{"[Solo]"}
1549 brackettt = ^\markup{"[Tutti]"}
1550 ts = ^\markup{"t.s."}
1551 tt = ^\markup{"Tutti"}
1552 solo = ^\markup{"Solo"}
1553 bracketsolo = ^\markup{"[Solo]"}
1554 tutti = ^\markup{"Tutti"}
1556 dashedSlur = -\tweak #'dash-definition #'((0 1 0.4 0.75))(
1557 dashedTie = -\tweak #'dash-definition #'((0 1 0.4 0.75))~
1559 divisi = #(define-music-function (parser location vc1 vc2) (ly:music? ly:music?)
1561 << { \voiceOne $vc1 \oneVoice} \new Voice = "divisi2" { \voiceTwo $vc2 } >>
1565 #(define twoVoice divisi)
1567 #(define-public (bracket-stencils grob)
1568 (let ((lp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "[")))
1569 (rp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "]"))))
1572 bracketify = #(define-music-function (parser loc arg) (ly:music?)
1573 (_i "Tag @var{arg} to be parenthesized.")
1575 \once \override ParenthesesItem #'stencils = #bracket-stencils
1581 #(define-markup-command (hat layout props arg) (markup?)
1582 "Draw a hat above the given string @var{arg}."
1583 (interpret-markup layout props (markup #:combine #:raise 1.5 "^" arg)))
1588 #(let ((m (make-music 'ArticulationEvent
1589 'articulation-type "flageolet")))
1590 (ly:music-set-property! m 'tweaks
1591 (acons 'font-size -2
1592 (ly:music-property m 'tweaks)))
1596 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1599 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1600 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1602 LicenseCCBY = \markup {Lizensiert unter / Licensed under: Creative Commons BY \with-url #"http://creativecommons.org/licenses/by/3.0/at/" {\translate #'(0 . -0.7) \epsfile #Y #3 #"orchestrallily/cc-by.eps" }}
1603 LicenseCCBYNC = \markup {Lizensiert unter / Licensed under: Creative Commons BY-NC \with-url #"http://creativecommons.org/licenses/by-nc/3.0/at/" {\translate #'(0 . -0.7) \epsfile #Y #3 #"orchestrallily/cc-by-nc.eps" }}
1604 LicenseNoRestrictions = \markup{\line {Die Ausgabe darf kopiert und ohne Einschränkungen aufgeführt werden. / May be copied and performed without restriction.}}
1606 \include "sceaux_clef-key.ily"
1609 startUnremovableSection = \set Staff.keepAliveInterfaces =
1610 #'(rhythmic-grob-interface
1613 percent-repeat-item-interface
1614 percent-repeat-interface
1615 stanza-number-interface)
1617 endUnremovableSection = \unset Staff.keepAliveInterfaces