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:dynamics_handler parser piece name type children)
552 (oly:voice_handler parser piece name type)
556 #(define oly:staff_handlers
559 '("GrandStaff" . oly:staff_group_handler )
560 '("PianoStaff" . oly:staff_group_handler )
561 '("ChoirStaff" . oly:staff_group_handler )
562 '("StaffGroup" . oly:staff_group_handler )
563 '("InnerChoirStaff" . oly:staff_group_handler )
564 '("InnerStaffGroup" . oly:staff_group_handler )
565 '("ParallelMusic" . oly:staff_group_handler )
566 '("SimultaneousMusic" . oly:staff_group_handler )
568 '("Staff" . oly:staff_handler )
569 '("DrumStaff" . oly:staff_handler )
570 '("RhythmicStaff" . oly:staff_handler )
571 '("TabStaff" . oly:staff_handler )
572 '("GregorianTranscriptionStaff" . oly:staff_handler )
573 '("MensuralStaff" . oly:staff_handler )
574 '("VaticanaStaff" . oly:staff_handler )
575 ; staves with multiple voices
576 '("PartCombinedStaff" . oly:part_combined_staff_handler )
577 '("ParallelVoicesStaff" . oly:parallel_voices_staff_handler )
578 ; special cases: Figured bass can be staff or voice type!
579 '("FiguredBass" . oly:figured_bass_staff_handler )
580 ; Devnull is like a staff, only that it doesn't craete output
581 '("Devnull" . oly:devnull_handler )
582 '("Dynamics" . oly:dynamics_handler )
586 #(define oly:voice_handlers
589 '("Voice" . oly:voice_handler )
590 '("CueVoice" . oly:voice_handler )
591 '("DrumVoice" . oly:voice_handler )
592 '("FiguredBass" . oly:voice_handler )
593 '("GregorianTranscriptionVoice" . oly:voice_handler )
594 '("NoteNames" . oly:voice_handler )
595 '("TabVoice" . oly:voice_handler )
596 '("VaticanaVoice" . oly:voice_handler )
601 #(define (oly:register_staff_type_handler type func)
602 ; (ly:message "Registering staff handler ~a for type ~a" func type)
603 (set! oly:staff_handlers (assoc-set! oly:staff_handlers type func))
606 #(define (oly:register_voice_type_handler type func)
607 ; (ly:message "Registering voice type handler ~a for type ~a" func type)
608 (set! oly:voice_handlers (assoc-set! oly:voice_handlers type func))
611 % handlers for deprecated API
612 #(oly:register_staff_type_handler 'StaffGroup 'oly:staff_group_handler)
613 #(oly:register_staff_type_handler 'GrandStaff 'oly:staff_group_handler)
614 #(oly:register_staff_type_handler 'PianoStaff 'oly:staff_group_handler)
615 #(oly:register_staff_type_handler 'ChoirStaff 'oly:staff_group_handler)
616 #(oly:register_staff_type_handler 'Staff 'oly:staff_handler )
617 #(oly:register_staff_type_handler 'ParallelMusic 'oly:staff_group_handler)
618 #(oly:register_staff_type_handler 'SimultaneousMusic 'oly:staff_group_handler)
619 #(oly:register_staff_type_handler #t 'oly:part_combined_staff_handler )
620 #(oly:register_staff_type_handler #f 'oly:parallel_voices_staff_handler )
624 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
625 % Automatic score generation
626 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
628 #(define oly:score_handler add-score)
629 #(define oly:music_handler add-music)
630 #(define oly:text_handler add-text)
634 setUseBook = #(define-music-function (parser location usebook) (boolean?)
635 (ly:warning "\\setUseBook has been deprecated! Books are now automatically handled without any hacks")
636 (make-music 'Music 'void #t)
640 % Two functions to handle midi-blocks: Either don't set one, or set an empty
641 % one so that MIDI is generated
642 #(define (oly:set_no_midi_block score) '())
643 #(define (oly:set_midi_block score)
644 (let* ((midiblock (if (defined? '$defaultmidi)
645 (ly:output-def-clone $defaultmidi)
646 (ly:make-output-def))))
647 (ly:output-def-set-variable! midiblock 'is-midi #t)
648 (ly:score-add-output-def! score midiblock)
652 % \setCreateMidi ##t/##f sets a flag to determine wheter MIDI output should
654 #(define oly:apply_score_midi oly:set_no_midi_block)
655 setCreateMIDI = #(define-music-function (parser location createmidi) (boolean?)
657 (set! oly:apply_score_midi oly:set_midi_block)
658 (set! oly:apply_score_midi oly:set_no_midi_block)
660 (make-music 'Music 'void #t)
664 % Two functions to handle layout-blocks: Either don't set one, or set an empty
665 % one so that a PDF is generated
666 #(define (oly:set_no_layout_block score) '())
667 #(define (oly:set_layout_block score)
668 (let* ((layoutblock (if (defined? '$defaultlayout)
669 (ly:output-def-clone $defaultlayout)
670 (ly:make-output-def))))
671 (ly:output-def-set-variable! layoutblock 'is-layout #t)
672 (ly:score-add-output-def! score layoutblock)
676 % \setCreatePDF ##t/##f sets a flag to determine wheter PDF output should
678 #(define oly:apply_score_layout oly:set_no_layout_block)
679 setCreatePDF = #(define-music-function (parser location createlayout) (boolean?)
681 (set! oly:apply_score_layout oly:set_layout_block)
682 (set! oly:apply_score_layout oly:set_no_layout_block)
684 (make-music 'Music 'void #t)
688 % Set the piece title in a new header block.
689 #(define (oly:set_piece_header score piecename)
690 (if (not-null? piecename)
691 (let* ((header (make-module)))
692 (module-define! header 'piece piecename)
693 (ly:score-set-header! score header)
699 % post-filter functions. By default, no filtering is done. However,
700 % for the *NoCues* function, the cue notes should be killed
701 identity = #(define-music-function (parser location music) (ly:music?) music)
702 cuefilter = #(define-music-function (parser location music) (ly:music?)
703 ((ly:music-function-extract removeWithTag) parser location 'cued ((ly:music-function-extract killCues) parser location music))
707 #(define (oly:create-toc-file layout pages)
708 (let* ((label-table (ly:output-def-lookup layout 'label-page-table)))
709 (if (not (null? label-table))
710 (let* ((format-line (lambda (toc-item)
711 (let* ((label (car toc-item))
712 (text (caddr toc-item))
713 (label-page (and (list? label-table)
714 (assoc label label-table)))
715 (page (and label-page (cdr label-page))))
716 (format #f "~a, section, 1, {~a}, ~a" page text label))))
717 (formatted-toc-items (map format-line (toc-items)))
718 (whole-string (string-join formatted-toc-items ",\n"))
719 (output-name (ly:parser-output-name parser))
720 (outfilename (format "~a.toc" output-name))
721 (outfile (open-output-file outfilename)))
722 (if (output-port? outfile)
723 (display whole-string outfile)
724 (ly:warning (_ "Unable to open output file ~a for the TOC information") outfilename))
725 (close-output-port outfile)))))
728 #(define-public (oly:add-toc-item parser markup-symbol text)
729 (oly:music_handler parser (add-toc-item! markup-symbol text)))
732 #(define (oly:add-score parser score piecename)
733 (if (not-null? piecename)
734 (oly:add-toc-item parser 'tocItemMarkup piecename))
735 (oly:score_handler parser score)
737 % The helper function to build a score.
738 #(define (oly:createScoreHelper parser location piece children func)
740 (staves (oly:staff_group_handler parser piece "" "SimultaneousMusic" children))
741 (music (if (not-null? staves)
742 ((ly:music-function-extract func) parser location staves)
746 (piecename (namedPieceInstrObject piece (car children) "PieceName"))
747 (piecenametacet (namedPieceInstrObject piece (car children) "PieceNameTacet"))
751 ; No staves, print tacet
753 (if (not-null? piecenametacet) (set! piecename piecenametacet))
754 (if (not-null? piecename)
755 (oly:add-score parser (list (oly:piece-title-markup piecename)) piecename)
756 (ly:warning (_ "No music and no score title found for part ~a and instrument ~a") piece children)
759 ; we have staves, apply the piecename to the score and add layout/midi blocks if needed
761 (set! score (scorify-music music parser))
762 (oly:set_piece_header score piecename)
763 (oly:apply_score_midi score)
764 (oly:apply_score_layout score)
765 ; Schedule the score for typesetting
766 (oly:add-score parser score piecename)
770 ; This is a void function, the score has been schedulled for typesetting already
771 (make-music 'Music 'void #t)
774 createScore = #(define-music-function (parser location piece children) (string? list?)
775 (oly:createScoreHelper parser location piece children identity)
777 createNoCuesScore = #(define-music-function (parser location piece children) (string? list?)
778 (oly:createScoreHelper parser location piece children cuefilter)
781 createHeadline = #(define-music-function (parser location headline) (string?)
782 (oly:add-toc-item parser 'tocItemMarkup headline)
783 (oly:score_handler parser (list (oly:piece-title-markup headline)))
784 (make-music 'Music 'void #t)
789 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
790 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
792 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
793 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
795 newInstrument = #(define-music-function (parser location instr) (string?)
797 \set Voice.instrumentCueName = #$(string-join (list "+" instr))
800 cueText = #(define-music-function (parser location instr) (string?)
802 \set Voice.instrumentCueName = $instr
806 clearCueText = #(define-music-function (parser location) ()
808 \unset Voice.instrumentCueName
812 insertCueText = #(define-music-function (parser location instr) (string?)
813 (if (string-null? instr)
814 #{ \tag #'cued \clearCueText #}
815 #{ \tag #'cued \cueText #$instr #}
818 % generate a cue music section with instrument names
819 % Parameters: \namedCueDuring NameOfQuote CueDirection CueInstrument OriginalInstrument music
820 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
821 % -) CueInstrument and OriginalInstrument are the displayed instrument names
823 % \namedCueDuring #"vIQuote" #UP #"V.I" #"Sop." { R1*3 }
824 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
825 % the beginning of the cue notes and "Sop." at the end
826 namedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr cuemusic) (string? number? string? string? ly:music?)
828 \cueDuring #$cuevoice #$direction {
829 \insertCueText #$instrcue
831 \insertCueText #$instr
835 namedTransposedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr trans cuemusic) (string? number? string? string? ly:music? ly:music?)
837 \transposedCueDuring #$cuevoice #$direction $trans {
838 \insertCueText #$instrcue
840 \insertCueText #$instr
845 % set the cue instrument name and clef
846 setClefCue = #(define-music-function (parser location instr clef)
849 \once \override Staff.Clef #'font-size = #-3 $clef
850 \insertCueText $instr
853 % generate a cue music section with instrument names and clef changes
854 % Parameters: \cleffedCueDuring NameOfQuote CueDirection CueInstrument CueClef OriginalInstrument OriginalClef music
855 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
856 % -) CueInstrument and OriginalInstrument are the displayed instrument names
857 % -) CueClef and OriginalClef are the clefs for the the cue notes and the clef of the containing voice
859 % \cleffedCueDuring #"vIQuote" #UP #"V.I" #"treble" #"Basso" #"bass" { R1*3 }
860 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
861 % the beginning of the cue notes and "Basso" at the end. The clef is changed to treble at the
862 % beginning of the cue notes and reset to bass at the end
863 cleffedCueDuring = #(define-music-function (parser location cuevoice direction instrcue clefcue instr clefinstr cuemusic)
864 (string? number? string? ly:music? string? ly:music? ly:music?)
866 \cueDuring #$cuevoice #$direction {
867 \tag #'cued \setClefCue #$instrcue $clefcue
869 \tag #'cued \setClefCue #$instr $clefinstr
877 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
878 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
880 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
881 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
884 dynamicsX = #(define-music-function (parser location offset) (number?)
886 \once \override DynamicText #'X-offset = $offset
887 \once \override DynamicLineSpanner #'Y-offset = #0
890 % Move the dynamic sign inside the staff to a fixed staff-relative position
891 % posY (where 0 means vertically starts at the middle staff line)
892 dynamicsAllInside = #(define-music-function (parser location offsetX posY)
895 % Invalid y-extent -> hidden from skyline calculation and collisions
896 % \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
897 \once \override DynamicLineSpanner #'Y-extent = $(lambda (grob)
898 (let* ((ext (ly:axis-group-interface::height grob))
899 (dir (ly:grob-property grob 'direction)))
901 (cons (- (cdr ext) 0.1) (cdr ext))
902 (cons (car ext) (+ (car ext) 0.1)))))
903 % move by X offset and to fixed Y-position (use Y-offset of parent!)
904 \once \override DynamicText #'X-offset = $offsetX
905 \once \override DynamicText #'Y-offset =
907 (let* ((head (ly:grob-parent grob Y))
908 (offset (ly:grob-property head 'Y-offset)))
909 (- posY offset (- 0.6))))
910 \once \override DynamicLineSpanner #'Y-offset = $posY
913 dynamicsUpInside = #(define-music-function (parser location offsetX) (number?)
914 ((ly:music-function-extract dynamicsAllInside) parser location offsetX 1.5)
917 dynamicsDownInside = #(define-music-function (parser location offsetX) (number?)
918 ((ly:music-function-extract dynamicsAllInside) parser location offsetX -3.5)
921 hairpinOffset = #(define-music-function (parser location posY) (number?)
923 \once \override DynamicLineSpanner #'Y-offset = $posY
924 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
927 #(define ((line-break-offset before after) grob)
928 (let* ((orig (ly:grob-original grob))
929 ; All siblings if line-broken:
930 (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
931 (if (>= (length siblings) 2)
932 ; We have been line-broken
933 (if (eq? (car (last-pair siblings)) grob)
935 (ly:grob-set-property! grob 'Y-offset after)
936 ; Others get the before value:
937 (ly:grob-set-property! grob 'Y-offset before)
943 ffz = #(make-dynamic-script "ffz")
944 pf = #(make-dynamic-script "pf")
945 sempp = #(make-dynamic-script (markup #:line( #:with-dimensions '(0 . 0)
946 '(0 . 0) #:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
947 parenf = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")" )))
948 parenp = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "p" #:normal-text #:italic #:fontsize 2 ")" )))
949 pdolce = #(make-dynamic-script (markup #:line(#:dynamic "p" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
950 sfpdolce = #(make-dynamic-script (markup #:line(#:dynamic "sfp" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
951 bracketf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 3 "[" #:dynamic "f" #:hspace 0.1 #:normal-text #:fontsize 3 "]"))))
952 bracketp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 2 "[" #:hspace 0.2 #:dynamic "p" #:normal-text #:fontsize 2 "]"))))
956 % cresc = #(make-music 'CrescendoEvent 'span-direction START 'crescendoSpanner 'text 'crescendoText "cresc.")
957 % endcresc = #(make-span-event 'CrescendoEvent STOP)
958 % dim = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "dim.")
959 % enddim = #(make-span-event 'DecrescendoEvent STOP)
960 % decresc = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "decresc.")
961 % enddecresc = #(make-span-event 'DecrescendoEvent STOP)
966 cresc = #(make-music 'CrescendoEvent 'span-direction START
967 'span-type 'text 'span-text "cresc.")
968 dim = #(make-music 'DecrescendoEvent 'span-direction START
969 'span-type 'text 'span-text "dim.")
970 decresc = #(make-music 'DecrescendoEvent 'span-direction START
971 'span-type 'text 'span-text "decresc.")
973 newOrOldClef = #(define-music-function (parser location new old ) (string? string?)
974 (if (ly:get-option 'old-clefs) #{ \clef $old #} #{ \clef $new #})
979 %%% Thanks to "Gilles THIBAULT" <gilles.thibault@free.fr>, there is a way
980 % to remove also the fermata from R1-\fermataMarkup: By filtering the music
981 % and removing the corresponding events.
982 % Documented as an LSR snippet: http://lsr.dsi.unimi.it/LSR/Item?id=372
983 #(define (filterOneEventsMarkup event)
984 ( let ( (eventname (ly:music-property event 'name)) )
986 (or ;; add here event name you do NOT want
987 (eq? eventname 'MultiMeasureTextEvent)
988 (eq? eventname 'AbsoluteDynamicEvent)
989 (eq? eventname 'TextScriptEvent)
990 (eq? eventname 'ArticulationEvent)
991 (eq? eventname 'CrescendoEvent)
992 (eq? eventname 'DecrescendoEvent)
997 filterArticulations = #(define-music-function (parser location music) (ly:music?)
998 (music-filter filterOneEventsMarkup music)
1005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1007 %%%%% Tempo markings
1008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1013 rit = \markup {\italic "rit."}
1014 pocorit = \markup {\italic "poco rit."}
1015 ppmosso = \markup {\italic "poco più mosso"}
1016 dolce = \markup {\italic "dolce"}
1017 pizz = \markup {\italic "pizz."}
1018 arco = \markup {\italic "arco"}
1019 perd = \markup {\italic "perdend."}
1024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1026 %%%%% REST COMBINATION
1027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1032 %% REST COMBINING, TAKEN FROM http://lsr.dsi.unimi.it/LSR/Item?id=336
1035 %% \new Staff \with {
1036 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1037 %% } << \somevoice \\ \othervoice >>
1042 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1047 %% - only handles two voices
1048 %% - does not handle multi-measure/whole-measure rests
1050 #(define (rest-score r)
1052 (yoff (ly:grob-property-data r 'Y-offset))
1053 (sp (ly:grob-property-data r 'staff-position)))
1055 (set! score (+ score 2))
1056 (if (eq? yoff 'calculation-in-progress)
1057 (set! score (- score 3))))
1060 (set! score (+ score 2))
1061 (set! score (- score (abs (- 1 sp)))))
1064 #(define (merge-rests-on-positioning grob)
1065 (let* ((can-merge #f)
1066 (elts (ly:grob-object grob 'elements))
1067 (num-elts (and (ly:grob-array? elts)
1068 (ly:grob-array-length elts)))
1069 (two-voice? (= num-elts 2)))
1071 (let* ((v1-grob (ly:grob-array-ref elts 0))
1072 (v2-grob (ly:grob-array-ref elts 1))
1073 (v1-rest (ly:grob-object v1-grob 'rest))
1074 (v2-rest (ly:grob-object v2-grob 'rest)))
1078 (let* ((v1-duration-log (ly:grob-property v1-rest 'duration-log))
1079 (v2-duration-log (ly:grob-property v2-rest 'duration-log))
1080 (v1-dot (ly:grob-object v1-rest 'dot))
1081 (v2-dot (ly:grob-object v2-rest 'dot))
1082 (v1-dot-count (and (ly:grob? v1-dot)
1083 (ly:grob-property v1-dot 'dot-count -1)))
1084 (v2-dot-count (and (ly:grob? v2-dot)
1085 (ly:grob-property v2-dot 'dot-count -1))))
1088 (number? v1-duration-log)
1089 (number? v2-duration-log)
1090 (= v1-duration-log v2-duration-log)
1091 (eq? v1-dot-count v2-dot-count)))
1093 ;; keep the rest that looks best:
1094 (let* ((keep-v1? (>= (rest-score v1-rest)
1095 (rest-score v2-rest)))
1096 (rest-to-keep (if keep-v1? v1-rest v2-rest))
1097 (dot-to-kill (if keep-v1? v2-dot v1-dot)))
1098 ;; uncomment if you're curious of which rest was chosen:
1099 ;;(ly:grob-set-property! v1-rest 'color green)
1100 ;;(ly:grob-set-property! v2-rest 'color blue)
1101 (ly:grob-suicide! (if keep-v1? v2-rest v1-rest))
1102 (if (ly:grob? dot-to-kill)
1103 (ly:grob-suicide! dot-to-kill))
1104 (ly:grob-set-property! rest-to-keep 'direction 0)
1105 (ly:rest::y-offset-callback rest-to-keep)))))))
1108 (ly:rest-collision::calc-positioning-done grob))))
1114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1116 %%%%% TABLE OF CONTENTS
1117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1121 contentsTitle = "Inhalt / Contents"
1124 tocTitleMarkup = \markup \fill-line{
1127 \override #(cons 'line-width (* 7 cm))
1128 \line{ \fill-line {\piece-title {\contentsTitle} \null }}
1133 tocItemMarkup = \markup \fill-line {
1136 \override #(cons 'line-width (* 7 cm ))
1137 \line { \fill-line{\fromproperty #'toc:text \fromproperty #'toc:page }}
1144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1146 %%%%% TITLE PAGE / HEADER
1147 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1148 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1150 #(define-markup-command (when-property layout props symbol markp) (symbol? markup?)
1151 (if (chain-assoc-get symbol props)
1152 (interpret-markup layout props markp)
1153 (ly:make-stencil '() '(1 . -1) '(1 . -1))))
1155 #(define-markup-command (vspace layout props amount) (number?)
1156 "This produces a invisible object taking vertical space."
1157 (let ((amount (* amount 3.0)))
1159 (ly:make-stencil "" (cons -1 1) (cons 0 amount))
1160 (ly:make-stencil "" (cons -1 1) (cons amount amount)))))
1164 titlePageMarkup = \markup \abs-fontsize #10 \when-property #'header:title \column {
1166 \fill-line { \fontsize #8 \fromproperty #'header:composer }
1168 \fill-line { \fontsize #8 \fromproperty #'header:poet }
1170 \fill-line { \fontsize #10 \bold \fromproperty #'header:titlepagetitle }
1172 \fontsize #2 \when-property #'header:titlepagesubtitle {
1173 \fill-line { \fromproperty #'header:titlepagesubtitle }
1176 \fill-line { \postscript #"-20 0 moveto 40 0 rlineto stroke" }
1178 \fill-line { \fontsize #5 \fromproperty #'header:ensemble }
1180 \fill-line { \fontsize #2 \fromproperty #'header:instruments }
1182 \fill-line { \fontsize #5 \fromproperty #'header:date }
1184 \fill-line { \fontsize #5 \fromproperty #'header:scoretype }
1186 \fontsize #2 \when-property #'header:enteredby {
1187 \fill-line { "Herausgegeben von: / Edited by:"}
1189 \fill-line { \fromproperty #'header:enteredby }
1192 \when-property #'header:arrangement \column {
1194 \fill-line { \fontsize #3 \fromproperty #'header:arrangement }
1199 titleHeaderMarkup = \markup {
1200 \override #'(baseline-skip . 3.5)
1203 \fromproperty #'header:logo
1205 \huge \larger \bold \larger \fromproperty #'header:title
1206 \large \smaller \bold \larger \fromproperty #'header:subtitle
1207 \smaller \bold \fromproperty #'header:subsubtitle
1209 \bold \when-property #'header:instrument \rounded-box \fromproperty #'header:instrument
1212 \with-dimensions #'( 0 . 0) #'( 0 . 1 ) \null
1216 % { \large \bold \fromproperty #'header:instrument }
1219 \fromproperty #'header:poet
1220 \fromproperty #'header:composer
1223 \fromproperty #'header:meter
1224 \fromproperty #'header:arranger
1229 titleScoreMarkup = \markup \piece-title \fromproperty #'header:piece
1232 scoreTitleMarkup = \titleScoreMarkup
1233 bookTitleMarkup = \titleHeaderMarkup
1238 %%%%%%%%%%%%%% headers and footers %%%%%%%%%%%%%%%%%%%%%%%%%%
1240 #(define (first-score-page layout props arg)
1241 (let* ((label 'first-score-page)
1242 (table (ly:output-def-lookup layout 'label-page-table))
1243 (label-page (and (list? table) (assoc label table)))
1244 (page-number (and label-page (cdr label-page)))
1246 (if (eq? (chain-assoc-get 'page:page-number props -1) page-number)
1247 (interpret-markup layout props arg)
1250 #(define no-header-table '())
1251 thisPageNoHeader = #(define-music-function (parser location) ()
1252 (let* ((label (gensym "header")))
1253 (set! no-header-table (cons label no-header-table))
1256 'page-label label)))
1259 % TODO: Use the no-header-table!
1260 #(define (is-header-page layout props arg)
1261 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1263 ;(if (and (> page-number 2) (!= page-number 7))
1264 (if (> page-number 1)
1265 (interpret-markup layout props arg)
1268 #(define no-footer-table '())
1269 thisPageNoFooter = #(define-music-function (parser location) ()
1270 (let* ((label (gensym "footer")))
1271 (set! no-footer-table (cons label no-footer-table))
1274 'page-label label)))
1276 % TODO: Use the no-footer-table!
1277 #(define (is-footer-page layout props arg)
1278 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1279 (label 'first-score-page)
1280 (table (ly:output-def-lookup layout 'label-page-table))
1281 (label-page (and (list? table) (assoc label table)))
1282 ;(page-number (and label-page (cdr label-page)))
1284 (if (and (> page-number 1))
1285 (interpret-markup layout props arg)
1289 #(define copyright-footer-table '())
1290 thisPageCopyrightFooter = #(define-music-function (parser location) ()
1291 (let* ((label (gensym "copyrightfooter")))
1292 (set! copyright-footer-table (cons label copyright-footer-table))
1295 'page-label label)))
1297 #(define copyright-pg 1)
1298 #(define (set-copyright-page page)
1299 (set! copyright-pg page)
1302 % TODO: Use the copyright-footer-table!
1303 #(define (copyright-page layout props arg)
1304 (if (= (chain-assoc-get 'page:page-number props -1) copyright-pg)
1305 (interpret-markup layout props arg)
1310 oddHeaderMarkup = \markup \fill-line {
1311 %% force the header to take some space, otherwise the
1312 %% page layout becomes a complete mess.
1314 \on-the-fly #is-header-page \fromproperty #'header:title
1315 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1317 evenHeaderMarkup = \markup \fill-line {
1318 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1319 \on-the-fly #is-header-page \fromproperty #'header:composer
1323 oddFooterMarkup = \markup {
1326 %% publisher header field only on title page.
1327 \on-the-fly #first-page \fromproperty #'header:publisher
1330 %% copyright on the first real score page
1331 \on-the-fly #copyright-page \fromproperty #'header:copyright
1332 \on-the-fly #copyright-page \null
1335 %% All other pages get the number of the edition centered
1336 \on-the-fly #is-footer-page \fromproperty #'header:scorenumber
1353 % Interpret the given markup with the header fields added to the props.
1354 % This way, one can re-use the same functions (using fromproperty
1355 % #'header:field) in the header block and as top-level markup.
1357 % This function is originally copied from mark-up-title (file scm/titling.scm),
1358 % which is lilypond's internal function to handle the title markups. I needed
1359 % to replace the scopes and manually add the $defaultheader (which is internally
1360 % done in paper-book.cc before calling mark-up-title. Also, I don't extract the
1361 % markup from the header block, but use the given markup.
1363 % I'm not sure if I really need the page properties in props, too... But I
1364 % suppose it does not hurt, either.
1365 #(define-markup-command (markupWithHeader layout props markup) (markup?)
1366 "Interpret the given markup with the header fields added to the props.
1367 This way, one can re-use the same functions (using fromproperty
1368 #'header:field) in the header block and as top-level markup."
1370 ; TODO: If we are inside a score, add the score's local header block, too!
1371 ; Currently, I only use the global header block, stored in $defaultheader
1372 (scopes (list $defaultheader))
1373 (alists (map ly:module->alist scopes))
1376 (map (lambda (alist)
1377 (map (lambda (entry)
1379 (string->symbol (string-append "header:" (symbol->string (car entry))))
1383 (props (append prefixed-alist
1385 (layout-extract-page-properties layout)))
1387 (interpret-markup layout props markup)
1396 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1398 %%%%% Equally spacing multiple columns (e.g. for translations)
1399 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1400 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1402 % Credits: Nicolas Sceaux on the lilypond-user mailinglist
1403 #(define-markup-command (columns layout props args) (markup-list?)
1404 (let ((line-width (/ (chain-assoc-get 'line-width props
1405 (ly:output-def-lookup layout 'line-width))
1406 (max (length args) 1))))
1407 (interpret-markup layout props
1408 (make-line-markup (map (lambda (line)
1409 (markup #:pad-to-box `(0 . ,line-width) '(0 . 0)
1410 #:override `(line-width . ,line-width)
1416 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1418 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1419 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1423 startSlashedGraceMusic = {
1424 \override Stem #'stroke-style = #"grace"
1427 stopSlashedGraceMusic = {
1428 \revert Stem #'stroke-style
1432 #(def-grace-function startSlashedGraceMusic stopSlashedGraceMusic
1433 (_i "Create slashed graces (slashes through stems, but no slur)from the following music expression"))
1436 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1437 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1438 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1439 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1440 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1444 right-margin = 1.5\cm
1445 line-width = 17.5\cm
1446 % bottom-margin = 1.5\cm
1448 % after-title-space = 0.5\cm
1452 ragged-last-bottom = ##f
1457 % If only one non-empty staff in a system exists, still print the backet
1458 \override SystemStartBracket #'collapse-height = #1
1459 \consists "Instrument_name_engraver"
1463 % If only one non-empty staff in a system exists, still print the backet
1464 \override SystemStartBracket #'collapse-height = #1
1465 \consists "Instrument_name_engraver"
1469 \override SystemStartBracket #'collapse-height = #1
1470 \consists "Instrument_name_engraver"
1474 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1475 \override VerticalAxisGroup #'minimum-Y-extent = #'(0 . 1)
1476 \override VerticalAxisGroup #'padding = #0
1480 % Force multi-measure rests to be written as one span
1481 \override MultiMeasureRest #'expand-limit = #3
1484 % hairpinToBarline = ##f
1485 \override BarNumber #'break-visibility = #end-of-line-invisible
1486 \override BarNumber #'self-alignment-X = #0
1487 \override CombineTextScript #'avoid-slur = #'outside
1488 barNumberVisibility = #(every-nth-bar-number-visible 5)
1489 \override DynamicTextSpanner #'dash-period = #-1.0
1490 \override InstrumentSwitch #'font-size = #-1
1493 \override RestCollision #'positioning-done = #merge-rests-on-positioning
1494 % Auto-Accidentals: Use modern-cautionary style...
1496 autoAccidentals = #`(Staff ,(make-accidental-rule 'same-octave 0)
1497 ,(make-accidental-rule 'any-octave 0)
1498 ,(make-accidental-rule 'same-octave 1))
1499 % autoCautionaries = #`(Staff ,(make-accidental-rule 'any-octave 0)
1500 % ,(make-accidental-rule 'same-octave 1))
1501 printKeyCancellation = ##t
1502 quotedEventTypes = #'(StreamEvent)
1503 implicitBassFigures = #'(0 100)
1506 \RemoveEmptyStaffContext
1510 ignoreFiguredBassRest = ##f
1515 bracketts = ^\markup{"[Solo]"}
1516 brackettt = ^\markup{"[Tutti]"}
1517 ts = ^\markup{"t.s."}
1518 tt = ^\markup{"Tutti"}
1519 solo = ^\markup{"Solo"}
1520 bracketsolo = ^\markup{"[Solo]"}
1521 tutti = ^\markup{"Tutti"}
1523 dashedSlur = -\tweak #'dash-definition #'((0 1 0.4 0.75))(
1524 dashedTie = -\tweak #'dash-definition #'((0 1 0.4 0.75))~
1526 divisi = #(define-music-function (parser location vc1 vc2) (ly:music? ly:music?)
1528 << { \voiceOne $vc1 \oneVoice} \new Voice = "divisi2" { \voiceTwo $vc2 } >>
1532 #(define twoVoice divisi)
1534 #(define-public (bracket-stencils grob)
1535 (let ((lp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "[")))
1536 (rp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "]"))))
1539 bracketify = #(define-music-function (parser loc arg) (ly:music?)
1540 (_i "Tag @var{arg} to be parenthesized.")
1542 \once \override ParenthesesItem #'stencils = #bracket-stencils
1548 #(define-markup-command (hat layout props arg) (markup?)
1549 "Draw a hat above the given string @var{arg}."
1550 (interpret-markup layout props (markup #:combine #:raise 1.5 "^" arg)))
1555 #(let ((m (make-music 'ArticulationEvent
1556 'articulation-type "flageolet")))
1557 (ly:music-set-property! m 'tweaks
1558 (acons 'font-size -2
1559 (ly:music-property m 'tweaks)))
1563 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1564 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1566 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1567 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1569 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" }}
1570 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" }}
1571 LicenseNoRestrictions = \markup{\line {Die Ausgabe darf kopiert und ohne Einschränkungen aufgeführt werden. / May be copied and performed without restriction.}}
1573 \include "sceaux_clef-key.ily"
1576 startUnremovableSection = \set Staff.keepAliveInterfaces =
1577 #'(rhythmic-grob-interface
1580 percent-repeat-item-interface
1581 percent-repeat-interface
1582 stanza-number-interface)
1584 endUnremovableSection = \unset Staff.keepAliveInterfaces