3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % Desciption: Lilypond package to make writing large orchestral scores easier.
7 % Documentation: http://wiki.kainhofer.com/lilypond/orchestrallily
8 % Version: 0.02, 2008-03-06
9 % Author: Reinhold Kainhofer, reinhold@kainhofer.com
10 % Copyright: (C) 2008 by Reinhold Kainhofer
11 % License: GPL v3.0, http://www.gnu.org/licenses/gpl.html
14 % 0.01 (2008-03-02): Initial Version
15 % 0.02 (2008-03-06): Added basic MIDI support (*MidiInstrument and \setCreateMIDI)
16 % 0.03 (2008-07-xx): General staff/voice types, title pages, etc.
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19 #(use-modules (ice-9 match))
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
23 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24 %%%%% SCORE STRUCTURE AND AUTOMATIC GENERATION
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 % Helper function to filter all non-null entries
36 #(define (not-null? x) (not (null? x)))
38 % Helper function to extract a given variable, built from [Piece][Instrument]Identifier
39 #(define (namedPieceInstrObject piece instr name)
41 (fullname (string->symbol (string-append piece instr name)))
42 (instrname (string->symbol (string-append instr name)))
43 (piecename (string->symbol (string-append piece name)))
46 ((defined? fullname) (primitive-eval fullname))
47 ((defined? instrname) (primitive-eval instrname))
48 ((defined? piecename) (primitive-eval piecename))
54 %% Print text as a justified paragraph, taken from the lilypond Notation Reference
55 #(define-markup-list-command (paragraph layout props args) (markup-list?)
56 (let ((indent (chain-assoc-get 'par-indent props 2)))
57 (interpret-markup-list layout props
58 (make-justified-lines-markup-list (cons (make-hspace-markup indent)
61 conditionalBreak = #(define-music-function (parser location) ()
62 #{ \tag #'instrumental-score \pageBreak #}
65 #(define (oly:piece-title-markup title) (markup #:column (#:line (#:fontsize #'3 #:bold title))) )
67 #(define-markup-command (piece-title layout props title) (markup?)
68 (interpret-markup layout props (oly:piece-title-markup title))
71 #(define (oly:generate_object_name piece instr obj )
72 (if (and (string? piece) (string? instr) (string? obj))
73 (string-append piece instr obj)
77 #(define (oly:generate_staff_name piece instr) (oly:generate_object_name piece instr "St"))
79 #(define (set-context-property context property value)
80 (set! (ly:music-property context property) value)
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 % Score structure and voice types
86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 #(define oly:LiedScoreStructure '(
89 ("SoloScore" "SimultaneousMusic" ("Singstimme"))
90 ("Pfe" "PianoStaff" ("PfeI" "PfeII"))
91 ;("PfeI" "ParallelVoicesStaff" ("OIa" "OIb"))
92 ;("PfeII" "ParallelVoicesStaff" ("OIIa" "OIIb"))
93 ("FullScore" "SimultaneousMusic" ("Singstimme" "Pfe"))
94 ("VocalScore" "SimultaneousMusic" ("Singstimme" "Pfe"))
97 #(define oly:fullOrchestraScoreStructure '(
98 ; Part-combined staves for full score
99 ("Fl" "PartCombinedStaff" ("FlI" "FlII"))
100 ("Ob" "PartCombinedStaff" ("ObI" "ObII"))
101 ("Cl" "PartCombinedStaff" ("ClI" "ClII"))
102 ("Fag" "PartCombinedStaff" ("FagI" "FagII"))
103 ("Wd" "StaffGroup" ("Fl" "Ob" "Cl" "Fag" "CFag"))
105 ("Cor" "PartCombinedStaff" ("CorI" "CorII"))
106 ("Trb" "PartCombinedStaff" ("TrbI" "TrbII"))
107 ("Tbe" "PartCombinedStaff" ("TbeI" "TbeII"))
108 ("Br" "StaffGroup" ("Cor" "Trb" "Tbe" "Tba"))
110 ; long score; no part-combined staves, but GrandStaves instead
111 ("FlLong" "GrandStaff" ("FlI" "FlII"))
112 ("ObLong" "GrandStaff" ("ObI" "ObII"))
113 ("ClLong" "GrandStaff" ("ClI" "ClII"))
114 ("FagLong" "GrandStaff" ("FagI" "FagII"))
115 ("WdLong" "StaffGroup" ("FlLong" "ObLong" "ClLong" "FagLong" "CFag"))
117 ("CorLong" "GrandStaff" ("CorI" "CorII"))
118 ("TrbLong" "GrandStaff" ("TrbI" "TrbII"))
119 ("TbeLong" "GrandStaff" ("TbeI" "TbeII" "TbeIII"))
120 ("BrLong" "StaffGroup" ("CorLong" "TrbLong" "TbeLong" "Tba"))
123 ("Perc" "StaffGroup" ("Tim"))
125 ; Strings, they are the same in long and short full score
126 ("V" "GrandStaff" ("VI" "VII"))
127 ("Str" "StaffGroup" ("V" "Va"))
128 ("VceB" "StaffGroup" ("Vc" "Cb" "VcB"))
129 ("FullStr" "StaffGroup" ("V" "Va" "Vc" "Cb" "VcB"))
132 ("Solo" "SimultaneousMusic" ("SSolo" "ASolo" "TSolo" "BSolo"))
133 ("Ch" "ChoirStaff" ("S" "A" "T" "B"))
134 ("ChoralScore" "SimultaneousMusic" ("Ch"))
135 ("SoloScore" "SimultaneousMusic" ("Solo"))
136 ("SoloChoirScore" "SimultaneousMusic" ("Solo" "Ch"))
138 ; Organ score (inkl. Figured bass)
139 ("BCFb" "FiguredBass" ())
140 ("FiguredBass" "FiguredBass" ())
141 ;("Organ" "SimultaneousMusic" ("BCFb" "O"))
142 ("Organ" "ParallelVoicesStaff" ("BCFb" "BC" "FiguredBass"))
143 ("Continuo" "ParallelVoicesStaff" ("BCFb" "BC" "FiguredBass"))
145 ("Pfe" "PianoStaff" ("PfeI" "PfeII"))
146 ("O" "PianoStaff" ("OI" "OII"))
147 ("OI" "ParallelVoicesStaff" ("OIa" "OIb"))
148 ("OII" "ParallelVoicesStaff" ("OIIa" "OIIb"))
149 ;("BassGroup" "ParallelVoicesStaff" ("Organ" "O" "BC" "VceB"))
150 ("BassGroup" "StaffGroup" ("O" "Continuo"))
153 ("FullScore" "SimultaneousMusic" ("Wd" "Br" "Perc" "Str" "SoloChoirScore" "BassGroup"))
154 ("LongScore" "SimultaneousMusic" ("WdLong" "BrLong" "Perc" "Str" "SoloChoirScore" "BassGroup"))
155 ("OriginalScore" "SimultaneousMusic" ("BrLong" "WdLong" "Perc" "Str" "SoloChoirScore" "BassGroup"))
158 ;("Piano" "SimultaneousMusic" ("Organ"))
159 ("OrganScore" "SimultaneousMusic" ("ChoralScore" "O"))
160 ("VocalScore" "SimultaneousMusic" ("ChoralScore" "Piano"))
161 ("Particell" "SimultaneousMusic" ("ChoralScore" "Continuo"))
163 ; Full scores: Orchestral score and long score including organ
164 ("ChStrQ" "SimultaneousMusic" ("Str" "Ch" "VceB"))
166 #(define oly:orchestral_score_structure oly:fullOrchestraScoreStructure)
168 #(define (oly:set_score_structure struct)
170 (set! oly:orchestral_score_structure struct)
171 (ly:warning (_ "oly:set_score_structure needs an association list as argument!"))
175 #(define (oly:modify_score_structure entry)
177 (set! oly:orchestral_score_structure (assoc-set! oly:orchestral_score_structure (car entry) (cdr entry)))
178 (ly:warning (_ "oly:modify_score_structure expects a list (\"key\" \"type\" '(children)) as argument!"))))
180 #(define (oly:remove_from_score_structure entry)
182 (map oly:remove_from_score_structure entry)
183 (set! oly:orchestral_score_structure (assoc-remove! oly:orchestral_score_structure entry))))
185 orchestralScoreStructure = #(define-music-function (parser location structure) (list?)
186 (oly:set_score_structure structure)
187 (make-music 'Music 'void #t)
190 #(define oly:voice_types '())
192 #(define (oly:set_voice_types types)
194 (set! oly:voice_types types)
195 (ly:warning (_ "oly:set_voice_types needs an association list as argument!"))
199 orchestralVoiceTypes = #(define-music-function (parser location types) (list?)
200 (oly:set_voice_types types)
201 (make-music 'Music 'void #t)
205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 % Automatic staff and group generation
207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
209 % Retrieve all music definitions for the given
210 #(define (oly:get_music_object piece instrument)
211 (namedPieceInstrObject piece instrument "Music")
213 #(define (oly:get_music_objects piece instruments)
214 (filter not-null? (map (lambda (i) (oly:get_music_object piece i)) instruments))
217 % Given a property name and the extensions, either generate the pair to set
218 % the property or an empty list, if no pre-defined variable could be found
219 #(define (oly:generate_property_pair prop piece instr type)
220 (let* ((val (namedPieceInstrObject piece instr type)))
221 (if (not-null? val) (list 'assign prop val) '() )
225 #(define (oly:staff_type type)
227 ((string? type) (string->symbol type))
228 ((symbol? type) type)
233 #(define (oly:extractPitch music)
235 (elems (if (ly:music? music) (ly:music-property music 'elements)))
236 (note (if (pair? elems) (car elems)))
237 (pitch (if (ly:music? note) (ly:music-property note 'pitch)))
239 (if (and (not-null? music) (not (ly:pitch? pitch)))
240 (ly:warning "Unable to interpret as a pitch!")
246 #(define (oly:extractTranspositionPitch piece name)
248 (trpFromPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeFrom")))
249 (trpToPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeTo")))
251 (if (ly:pitch? trpFromPitch)
252 (if (ly:pitch? trpToPitch)
254 (ly:pitch-diff trpFromPitch trpToPitch)
255 (ly:pitch-diff trpFromPitch (ly:make-pitch 0 0 0))
257 (if (ly:pitch? trpToPitch)
258 (ly:pitch-diff (ly:make-pitch 0 0 0) trpToPitch)
265 #(define (oly:musiccontent_for_voice parser piece name music additional)
266 (let* ((musiccontent additional))
268 ; Append the settings, key and clef (if defined)
271 (let* ((object (namedPieceInstrObject piece name type)))
272 (if (ly:music? object)
273 (set! musiccontent (append musiccontent (list (ly:music-deep-copy object))))
274 (if (not-null? object) (ly:warning (_ "Wrong type (no ly:music) for ~S for instrument ~S in piece ~S") type name piece))
278 ; TODO: Does the "Tempo" work here???
279 '("Settings" "Key" "Clef" "TimeSignature" ;"Tempo"
283 (if (ly:music? music)
285 (set! musiccontent (make-simultaneous-music (append musiccontent (list music))))
286 ;(ly:message "Generating staff for ~a" name)
287 (let* ((trpPitch (oly:extractTranspositionPitch piece name)))
288 (if (ly:pitch? trpPitch)
289 (set! musiccontent (ly:music-transpose musiccontent trpPitch))
294 ; For empty music, return empty
300 #(define (oly:lyrics_create_single_context parser piece name voicename lyricsid)
301 ; If we have lyrics, create a lyrics context containing LyricCombineMusic
302 ; and add that as second element to the staff's elements list...
303 (let* ((id (string-append "Lyrics" lyricsid))
304 (lyrics (namedPieceInstrObject piece name id)))
305 (if (ly:music? lyrics)
306 (context-spec-music (make-music 'LyricCombineMusic
308 'associated-context voicename)
309 'Lyrics (oly:generate_object_name piece name id))
314 #(define (oly:lyrics_create_contexts parser piece name voicename)
317 (oly:lyrics_create_single_context parser piece name voicename str))
318 (list "" "I" "II" "III" "IV" "V" "VI"))))
320 #(define (oly:voice_handler_internal parser piece name type music)
321 (if (ly:music? music)
323 (voicename (oly:generate_object_name piece name "Voice" ))
324 (lyrics (oly:lyrics_create_contexts parser piece name voicename))
325 (additional (if (not-null? lyrics) (list dynamicUp) '()))
326 (musiccontent (oly:musiccontent_for_voice parser piece name music additional))
327 (voicetype (oly:staff_type type))
328 (voice (context-spec-music musiccontent voicetype voicename))
332 ; For empty music, return empty
337 #(define (oly:voice_handler parser piece name type)
338 (oly:voice_handler_internal parser piece name type (oly:get_music_object piece name)))
341 #(define (oly:staff_handler_internal parser piece name type voices)
342 (if (not-null? voices)
344 (staffname (oly:generate_staff_name piece name))
345 (stafftype (oly:staff_type type))
346 (staff (make-simultaneous-music voices))
347 (propops (oly:staff_handler_properties piece name))
350 ((SimultaneousMusic ParallelMusic) #f)
351 (else (set! staff (context-spec-music staff stafftype staffname)))
353 (if (not-null? propops)
354 (set! (ly:music-property staff 'property-operations) propops)
358 ; For empty music, return empty
363 #(define (oly:staff_handler parser piece name type children)
364 (let* ((c (if (not-null? children) children (list name)))
365 (voices (apply append (map (lambda (v) (oly:create_voice parser piece v)) c)) )
367 (if (not-null? voices)
368 (oly:staff_handler_internal parser piece name type voices)
374 #(define (oly:devnull_handler parser piece name type children)
375 (oly:voice_handler parser piece name type)
378 #(define (oly:parallel_voices_staff_handler parser piece name type children)
380 (voices (map (lambda (i) (oly:create_voice parser piece i)) children))
381 ; get the list of non-empty voices and flatten it!
382 (nonemptyvoices (apply append (filter not-null? voices)))
384 (if (not-null? nonemptyvoices)
385 (oly:staff_handler_internal parser piece name "Staff" nonemptyvoices)
391 #(define (oly:part_combined_staff_handler parser piece name type children)
392 (let* ((rawmusic (map (lambda (c) (oly:musiccontent_for_voice parser piece name (oly:get_music_object piece c) '())) children))
393 (music (filter not-null? rawmusic)))
395 ((and (pair? music) (ly:music? (car music)) (not-null? (cdr music)) (ly:music? (cadr music)))
396 ;(ly:message "Part-combine with two music expressions")
397 (oly:staff_handler_internal parser piece name "Staff" (list (make-part-combine-music parser music))))
399 ;;(ly:warning "Part-combine without any music expressions")
401 ; exactly one is a music expression, simply use that by joining
403 ;;(ly:message "Part-combine with only one music expressions")
404 (oly:staff_handler_internal parser piece name "Staff" (list (apply append music))))
406 ;(ly:message "make_part_combined_staff: ~S ~S ~a" piece instr instruments)
412 % Generate the properties for the staff for piece and instr. Typically, these
413 % are the instrument name and the short instrument name (if defined).
414 % return a (possibly empty) list of all assignments.
415 #(define (oly:staff_handler_properties piece instr)
418 (instrumentName . "InstrumentName")
419 (shortInstrumentName . "ShortInstrumentName")
420 (midiInstrument . "MidiInstrument")
424 (oly:generate_property_pair (car pr) piece instr (cdr pr))
427 (props (filter not-null? assignments))
433 % Figured bass is a special case, as it can be voice- or staff-type. When
434 % given as a staff type, simply call the voice handler, instead
436 #(define (oly:figured_bass_staff_handler parser piece name type children)
437 (let* ((c (if (not-null? children) children (list name)))
438 (voice (oly:voice_handler parser piece (car c) type)))
439 (if (pair? voice) (car voice) ())
443 #(define (flatten lst)
444 (define (f remaining result)
446 ((null? remaining) result)
447 ((pair? (car remaining)) (f (cdr remaining) (f (car remaining) result)))
448 (else (f (cdr remaining) (cons (car remaining) result)))))
449 (reverse! (f lst '())))
451 #(define (oly:staff_group_handler parser piece name type children)
453 (staves (flatten (map (lambda (i) (oly:create_staff_or_group parser piece i)) children)))
454 (nonemptystaves (filter not-null? staves))
456 (if (not-null? nonemptystaves)
458 (musicexpr (if (= 1 (length nonemptystaves))
460 (make-simultaneous-music nonemptystaves)))
461 (groupname (oly:generate_staff_name piece name))
462 (grouptype (oly:staff_type type))
464 (propops (oly:staff_handler_properties piece name))
467 ((SimultaneousMusic ParallelMusic) #f)
468 (else (set! group (context-spec-music group grouptype groupname)))
471 (set! (ly:music-property group 'property-operations) propops))
474 ; Return empty list if no staves are generated
480 #(define (oly:create_voice parser piece name)
481 (let* ( (voice (namedPieceInstrObject piece name "Voice"))
482 (type (assoc-ref oly:voice_types name)) )
483 (if (not-null? voice)
484 ; Explicit voice variable, use that
488 ; No entry in structure found => simple voice
489 (oly:voice_handler parser piece name "Voice")
490 ; Entry found in structure => use the handler for the given type
492 (voicetype (car type))
493 (handler (assoc-ref oly:voice_handlers voicetype))
496 ((primitive-eval handler) parser piece name voicetype)
498 (ly:warning "No handler found for voice type ~a, using default voice handler" voicetype)
499 (oly:voice_handler parser piece name voicetype)
508 #(define (oly:create_staff_or_group parser piece name)
509 (let* ( (staff (namedPieceInstrObject piece name "Staff"))
510 (type_from_structure (assoc-ref oly:orchestral_score_structure name)) )
511 ;(if (not-null? staff)
512 ; (ly:message "Found staff variable for instrument ~a in piece ~a" instr piece)
513 ; (ly:message "Staff variable for instrument ~a in piece ~a NOT FOUND" instr piece)
515 (if (not-null? staff)
516 ; Explicit staff variable, use that
519 (if (not (list? type_from_structure))
520 ; No entry in structure found => simple staff
521 (oly:staff_handler parser piece name "Staff" '())
523 ; Entry found in structure => use the handler for the given type
524 (let* ((type (car type_from_structure))
525 (handler (assoc-ref oly:staff_handlers type))
526 (children (cadr type_from_structure))
529 ((primitive-eval handler) parser piece name type children)
531 (ly:warning "No handler found for staff type ~a, using default staff handler" type)
532 (oly:staff_handler parser piece name type children)
541 #(define oly:staff_handlers
544 '("GrandStaff" . oly:staff_group_handler )
545 '("PianoStaff" . oly:staff_group_handler )
546 '("ChoirStaff" . oly:staff_group_handler )
547 '("StaffGroup" . oly:staff_group_handler )
548 '("InnerChoirStaff" . oly:staff_group_handler )
549 '("InnerStaffGroup" . oly:staff_group_handler )
550 '("ParallelMusic" . oly:staff_group_handler )
551 '("SimultaneousMusic" . oly:staff_group_handler )
553 '("Staff" . oly:staff_handler )
554 '("DrumStaff" . oly:staff_handler )
555 '("RhythmicStaff" . oly:staff_handler )
556 '("TabStaff" . oly:staff_handler )
557 '("GregorianTranscriptionStaff" . oly:staff_handler )
558 '("MensuralStaff" . oly:staff_handler )
559 '("VaticanaStaff" . oly:staff_handler )
560 ; staves with multiple voices
561 '("PartCombinedStaff" . oly:part_combined_staff_handler )
562 '("ParallelVoicesStaff" . oly:parallel_voices_staff_handler )
563 ; special cases: Figured bass can be staff or voice type!
564 '("FiguredBass" . oly:figured_bass_staff_handler )
565 ; Devnull is like a staff, only that it doesn't craete output
566 '("Devnull" . oly:devnull_handler )
570 #(define oly:voice_handlers
573 '("Voice" . oly:voice_handler )
574 '("CueVoice" . oly:voice_handler )
575 '("DrumVoice" . oly:voice_handler )
576 '("FiguredBass" . oly:voice_handler )
577 '("GregorianTranscriptionVoice" . oly:voice_handler )
578 '("NoteNames" . oly:voice_handler )
579 '("TabVoice" . oly:voice_handler )
580 '("VaticanaVoice" . oly:voice_handler )
581 ;'("Dynamics" . oly:dynamics_handler )
586 #(define (oly:register_staff_type_handler type func)
587 ; (ly:message "Registering staff handler ~a for type ~a" func type)
588 (set! oly:staff_handlers (assoc-set! oly:staff_handlers type func))
591 #(define (oly:register_voice_type_handler type func)
592 ; (ly:message "Registering voice type handler ~a for type ~a" func type)
593 (set! oly:voice_handlers (assoc-set! oly:voice_handlers type func))
596 % handlers for deprecated API
597 #(oly:register_staff_type_handler 'StaffGroup 'oly:staff_group_handler)
598 #(oly:register_staff_type_handler 'GrandStaff 'oly:staff_group_handler)
599 #(oly:register_staff_type_handler 'PianoStaff 'oly:staff_group_handler)
600 #(oly:register_staff_type_handler 'ChoirStaff 'oly:staff_group_handler)
601 #(oly:register_staff_type_handler 'Staff 'oly:staff_handler )
602 #(oly:register_staff_type_handler 'ParallelMusic 'oly:staff_group_handler)
603 #(oly:register_staff_type_handler 'SimultaneousMusic 'oly:staff_group_handler)
604 #(oly:register_staff_type_handler #t 'oly:part_combined_staff_handler )
605 #(oly:register_staff_type_handler #f 'oly:parallel_voices_staff_handler )
609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
610 % Automatic score generation
611 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
613 #(define oly:score_handler add-score)
614 #(define oly:music_handler add-music)
615 #(define oly:text_handler add-text)
619 setUseBook = #(define-music-function (parser location usebook) (boolean?)
620 (ly:warning "\\setUseBook has been deprecated! Books are now automatically handled without any hacks")
621 (make-music 'Music 'void #t)
625 % Two functions to handle midi-blocks: Either don't set one, or set an empty
626 % one so that MIDI is generated
627 #(define (oly:set_no_midi_block score) '())
628 #(define (oly:set_midi_block score)
629 (let* ((midiblock (if (defined? '$defaultmidi)
630 (ly:output-def-clone $defaultmidi)
631 (ly:make-output-def))))
632 (ly:output-def-set-variable! midiblock 'is-midi #t)
633 (ly:score-add-output-def! score midiblock)
637 % \setCreateMidi ##t/##f sets a flag to determine wheter MIDI output should
639 #(define oly:apply_score_midi oly:set_no_midi_block)
640 setCreateMIDI = #(define-music-function (parser location createmidi) (boolean?)
642 (set! oly:apply_score_midi oly:set_midi_block)
643 (set! oly:apply_score_midi oly:set_no_midi_block)
645 (make-music 'Music 'void #t)
649 % Two functions to handle layout-blocks: Either don't set one, or set an empty
650 % one so that a PDF is generated
651 #(define (oly:set_no_layout_block score) '())
652 #(define (oly:set_layout_block score)
653 (let* ((layoutblock (if (defined? '$defaultlayout)
654 (ly:output-def-clone $defaultlayout)
655 (ly:make-output-def))))
656 (ly:output-def-set-variable! layoutblock 'is-layout #t)
657 (ly:score-add-output-def! score layoutblock)
661 % \setCreatePDF ##t/##f sets a flag to determine wheter PDF output should
663 #(define oly:apply_score_layout oly:set_no_layout_block)
664 setCreatePDF = #(define-music-function (parser location createlayout) (boolean?)
666 (set! oly:apply_score_layout oly:set_layout_block)
667 (set! oly:apply_score_layout oly:set_no_layout_block)
669 (make-music 'Music 'void #t)
673 % Set the piece title in a new header block.
674 #(define (oly:set_piece_header score piecename)
675 (if (not-null? piecename)
676 (let* ((header (make-module)))
677 (module-define! header 'piece piecename)
678 (ly:score-set-header! score header)
684 % post-filter functions. By default, no filtering is done. However,
685 % for the *NoCues* function, the cue notes should be killed
686 identity = #(define-music-function (parser location music) (ly:music?) music)
687 cuefilter = #(define-music-function (parser location music) (ly:music?)
688 ((ly:music-function-extract removeWithTag) parser location 'cued ((ly:music-function-extract killCues) parser location music))
692 #(define (oly:create-toc-file layout pages)
693 (let* ((label-table (ly:output-def-lookup layout 'label-page-table)))
694 (if (not (null? label-table))
695 (let* ((format-line (lambda (toc-item)
696 (let* ((label (car toc-item))
697 (text (caddr toc-item))
698 (label-page (and (list? label-table)
699 (assoc label label-table)))
700 (page (and label-page (cdr label-page))))
701 (format #f "~a, section, 1, {~a}, ~a" page text label))))
702 (formatted-toc-items (map format-line (toc-items)))
703 (whole-string (string-join formatted-toc-items ",\n"))
704 (output-name (ly:parser-output-name parser))
705 (outfilename (format "~a.toc" output-name))
706 (outfile (open-output-file outfilename)))
707 (if (output-port? outfile)
708 (display whole-string outfile)
709 (ly:warning (_ "Unable to open output file ~a for the TOC information") outfilename))
710 (close-output-port outfile)))))
713 #(define-public (oly:add-toc-item parser markup-symbol text)
714 (oly:music_handler parser (add-toc-item! markup-symbol text)))
717 #(define (oly:add-score parser score piecename)
718 (if (not-null? piecename)
719 (oly:add-toc-item parser 'tocItemMarkup piecename))
720 (oly:score_handler parser score)
722 % The helper function to build a score.
723 #(define (oly:createScoreHelper parser location piece children func)
725 (staves (oly:staff_group_handler parser piece "" "SimultaneousMusic" children))
726 (music (if (not-null? staves)
727 ((ly:music-function-extract func) parser location staves)
731 (piecename (namedPieceInstrObject piece (car children) "PieceName"))
732 (piecenametacet (namedPieceInstrObject piece (car children) "PieceNameTacet"))
736 ; No staves, print tacet
738 (if (not-null? piecenametacet) (set! piecename piecenametacet))
739 (if (not-null? piecename)
740 (oly:add-score parser (list (oly:piece-title-markup piecename)) piecename)
741 (ly:warning (_ "No music and no score title found for part ~a and instrument ~a") piece children)
744 ; we have staves, apply the piecename to the score and add layout/midi blocks if needed
746 (set! score (scorify-music music parser))
747 (oly:set_piece_header score piecename)
748 (oly:apply_score_midi score)
749 (oly:apply_score_layout score)
750 ; Schedule the score for typesetting
751 (oly:add-score parser score piecename)
755 ; This is a void function, the score has been schedulled for typesetting already
756 (make-music 'Music 'void #t)
759 createScore = #(define-music-function (parser location piece children) (string? list?)
760 (oly:createScoreHelper parser location piece children identity)
762 createNoCuesScore = #(define-music-function (parser location piece children) (string? list?)
763 (oly:createScoreHelper parser location piece children cuefilter)
766 createHeadline = #(define-music-function (parser location headline) (string?)
767 (oly:add-toc-item parser 'tocItemMarkup headline)
768 (oly:score_handler parser (list (oly:piece-title-markup headline)))
769 (make-music 'Music 'void #t)
774 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
775 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
777 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
778 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
780 newInstrument = #(define-music-function (parser location instr) (string?)
782 \set Voice.instrumentCueName = #$(string-join (list "+" instr))
785 cueText = #(define-music-function (parser location instr) (string?)
787 \set Voice.instrumentCueName = $instr
791 clearCueText = #(define-music-function (parser location) ()
793 \unset Voice.instrumentCueName
797 insertCueText = #(define-music-function (parser location instr) (string?)
798 (if (string-null? instr)
799 #{ \tag #'cued \clearCueText #}
800 #{ \tag #'cued \cueText #$instr #}
803 % generate a cue music section with instrument names
804 % Parameters: \namedCueDuring NameOfQuote CueDirection CueInstrument OriginalInstrument music
805 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
806 % -) CueInstrument and OriginalInstrument are the displayed instrument names
808 % \namedCueDuring #"vIQuote" #UP #"V.I" #"Sop." { R1*3 }
809 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
810 % the beginning of the cue notes and "Sop." at the end
811 namedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr cuemusic) (string? number? string? string? ly:music?)
813 \cueDuring #$cuevoice #$direction {
814 \insertCueText #$instrcue
816 \insertCueText #$instr
820 namedTransposedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr trans cuemusic) (string? number? string? string? ly:music? ly:music?)
822 \transposedCueDuring #$cuevoice #$direction $trans {
823 \insertCueText #$instrcue
825 \insertCueText #$instr
830 % set the cue instrument name and clef
831 setClefCue = #(define-music-function (parser location instr clef)
834 \once \override Staff.Clef #'font-size = #-3 $clef
835 \insertCueText $instr
838 % generate a cue music section with instrument names and clef changes
839 % Parameters: \cleffedCueDuring NameOfQuote CueDirection CueInstrument CueClef OriginalInstrument OriginalClef music
840 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
841 % -) CueInstrument and OriginalInstrument are the displayed instrument names
842 % -) CueClef and OriginalClef are the clefs for the the cue notes and the clef of the containing voice
844 % \cleffedCueDuring #"vIQuote" #UP #"V.I" #"treble" #"Basso" #"bass" { R1*3 }
845 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
846 % the beginning of the cue notes and "Basso" at the end. The clef is changed to treble at the
847 % beginning of the cue notes and reset to bass at the end
848 cleffedCueDuring = #(define-music-function (parser location cuevoice direction instrcue clefcue instr clefinstr cuemusic)
849 (string? number? string? ly:music? string? ly:music? ly:music?)
851 \cueDuring #$cuevoice #$direction {
852 \tag #'cued \setClefCue #$instrcue $clefcue
854 \tag #'cued \setClefCue #$instr $clefinstr
862 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
863 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
865 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
866 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
869 dynamicsX = #(define-music-function (parser location offset) (number?)
871 \once \override DynamicText #'X-offset = $offset
872 \once \override DynamicLineSpanner #'Y-offset = #0
875 % Move the dynamic sign inside the staff to a fixed staff-relative position
876 % posY (where 0 means vertically starts at the middle staff line)
877 dynamicsAllInside = #(define-music-function (parser location offsetX posY)
880 % Invalid y-extent -> hidden from skyline calculation and collisions
881 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
882 % move by X offset and to fixed Y-position (use Y-offset of parent!)
883 \once \override DynamicText #'X-offset = $offsetX
884 \once \override DynamicText #'Y-offset =
886 (let* ((head (ly:grob-parent grob Y))
887 (offset (ly:grob-property head 'Y-offset)))
888 (- posY offset (- 0.6))))
889 \once \override DynamicLineSpanner #'Y-offset = $posY
892 dynamicsUpInside = #(define-music-function (parser location offsetX) (number?)
893 ((ly:music-function-extract dynamicsAllInside) parser location offsetX 1.5)
896 dynamicsDownInside = #(define-music-function (parser location offsetX) (number?)
897 ((ly:music-function-extract dynamicsAllInside) parser location offsetX -3.5)
900 hairpinOffset = #(define-music-function (parser location posY) (number?)
902 \once \override DynamicLineSpanner #'Y-offset = $posY
903 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
906 #(define ((line-break-offset before after) grob)
907 (let* ((orig (ly:grob-original grob))
908 ; All siblings if line-broken:
909 (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
910 (if (>= (length siblings) 2)
911 ; We have been line-broken
912 (if (eq? (car (last-pair siblings)) grob)
914 (ly:grob-set-property! grob 'Y-offset after)
915 ; Others get the before value:
916 (ly:grob-set-property! grob 'Y-offset before)
922 ffz = #(make-dynamic-script "ffz")
923 pf = #(make-dynamic-script "pf")
924 sempp = #(make-dynamic-script (markup #:line( #:with-dimensions '(0 . 0)
925 '(0 . 0) #:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
926 parenf = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")" )))
927 parenp = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "p" #:normal-text #:italic #:fontsize 2 ")" )))
928 pdolce = #(make-dynamic-script (markup #:line(#:dynamic "p" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
929 sfpdolce = #(make-dynamic-script (markup #:line(#:dynamic "sfp" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
930 bracketf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 3 "[" #:dynamic "f" #:hspace 0.1 #:normal-text #:fontsize 3 "]"))))
931 bracketp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 2 "[" #:hspace 0.2 #:dynamic "p" #:normal-text #:fontsize 2 "]"))))
935 % cresc = #(make-music 'CrescendoEvent 'span-direction START 'crescendoSpanner 'text 'crescendoText "cresc.")
936 % endcresc = #(make-span-event 'CrescendoEvent STOP)
937 % dim = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "dim.")
938 % enddim = #(make-span-event 'DecrescendoEvent STOP)
939 % decresc = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "decresc.")
940 % enddecresc = #(make-span-event 'DecrescendoEvent STOP)
945 cresc = #(make-music 'CrescendoEvent 'span-direction START
946 'span-type 'text 'span-text "cresc.")
947 dim = #(make-music 'DecrescendoEvent 'span-direction START
948 'span-type 'text 'span-text "dim.")
949 decresc = #(make-music 'DecrescendoEvent 'span-direction START
950 'span-type 'text 'span-text "decresc.")
952 newOrOldClef = #(define-music-function (parser location new old ) (string? string?)
953 (if (ly:get-option 'old-clefs) #{ \clef $old #} #{ \clef $new #})
958 %%% Thanks to "Gilles THIBAULT" <gilles.thibault@free.fr>, there is a way
959 % to remove also the fermata from R1-\fermataMarkup: By filtering the music
960 % and removing the corresponding events.
961 % Documented as an LSR snippet: http://lsr.dsi.unimi.it/LSR/Item?id=372
962 #(define (filterOneEventsMarkup event)
963 ( let ( (eventname (ly:music-property event 'name)) )
965 (or ;; add here event name you do NOT want
966 (eq? eventname 'MultiMeasureTextEvent)
967 (eq? eventname 'AbsoluteDynamicEvent)
968 (eq? eventname 'TextScriptEvent)
969 (eq? eventname 'ArticulationEvent)
970 (eq? eventname 'CrescendoEvent)
971 (eq? eventname 'DecrescendoEvent)
976 filterArticulations = #(define-music-function (parser location music) (ly:music?)
977 (music-filter filterOneEventsMarkup music)
984 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
985 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
987 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
988 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
992 rit = \markup {\italic "rit."}
993 pocorit = \markup {\italic "poco rit."}
994 ppmosso = \markup {\italic "poco più mosso"}
995 dolce = \markup {\italic "dolce"}
996 pizz = \markup {\italic "pizz."}
997 arco = \markup {\italic "arco"}
998 perd = \markup {\italic "perdend."}
1003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1005 %%%%% REST COMBINATION
1006 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1007 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1011 %% REST COMBINING, TAKEN FROM http://lsr.dsi.unimi.it/LSR/Item?id=336
1014 %% \new Staff \with {
1015 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1016 %% } << \somevoice \\ \othervoice >>
1021 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1026 %% - only handles two voices
1027 %% - does not handle multi-measure/whole-measure rests
1029 #(define (rest-score r)
1031 (yoff (ly:grob-property-data r 'Y-offset))
1032 (sp (ly:grob-property-data r 'staff-position)))
1034 (set! score (+ score 2))
1035 (if (eq? yoff 'calculation-in-progress)
1036 (set! score (- score 3))))
1039 (set! score (+ score 2))
1040 (set! score (- score (abs (- 1 sp)))))
1043 #(define (merge-rests-on-positioning grob)
1044 (let* ((can-merge #f)
1045 (elts (ly:grob-object grob 'elements))
1046 (num-elts (and (ly:grob-array? elts)
1047 (ly:grob-array-length elts)))
1048 (two-voice? (= num-elts 2)))
1050 (let* ((v1-grob (ly:grob-array-ref elts 0))
1051 (v2-grob (ly:grob-array-ref elts 1))
1052 (v1-rest (ly:grob-object v1-grob 'rest))
1053 (v2-rest (ly:grob-object v2-grob 'rest)))
1057 (let* ((v1-duration-log (ly:grob-property v1-rest 'duration-log))
1058 (v2-duration-log (ly:grob-property v2-rest 'duration-log))
1059 (v1-dot (ly:grob-object v1-rest 'dot))
1060 (v2-dot (ly:grob-object v2-rest 'dot))
1061 (v1-dot-count (and (ly:grob? v1-dot)
1062 (ly:grob-property v1-dot 'dot-count -1)))
1063 (v2-dot-count (and (ly:grob? v2-dot)
1064 (ly:grob-property v2-dot 'dot-count -1))))
1067 (number? v1-duration-log)
1068 (number? v2-duration-log)
1069 (= v1-duration-log v2-duration-log)
1070 (eq? v1-dot-count v2-dot-count)))
1072 ;; keep the rest that looks best:
1073 (let* ((keep-v1? (>= (rest-score v1-rest)
1074 (rest-score v2-rest)))
1075 (rest-to-keep (if keep-v1? v1-rest v2-rest))
1076 (dot-to-kill (if keep-v1? v2-dot v1-dot)))
1077 ;; uncomment if you're curious of which rest was chosen:
1078 ;;(ly:grob-set-property! v1-rest 'color green)
1079 ;;(ly:grob-set-property! v2-rest 'color blue)
1080 (ly:grob-suicide! (if keep-v1? v2-rest v1-rest))
1081 (if (ly:grob? dot-to-kill)
1082 (ly:grob-suicide! dot-to-kill))
1083 (ly:grob-set-property! rest-to-keep 'direction 0)
1084 (ly:rest::y-offset-callback rest-to-keep)))))))
1087 (ly:rest-collision::calc-positioning-done grob))))
1093 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1094 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1095 %%%%% TABLE OF CONTENTS
1096 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1100 contentsTitle = "Inhalt / Contents"
1103 tocTitleMarkup = \markup \fill-line{
1106 \override #(cons 'line-width (* 7 cm))
1107 \line{ \fill-line {\piece-title {\contentsTitle} \null }}
1112 tocItemMarkup = \markup \fill-line {
1115 \override #(cons 'line-width (* 7 cm ))
1116 \line { \fill-line{\fromproperty #'toc:text \fromproperty #'toc:page }}
1123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1125 %%%%% TITLE PAGE / HEADER
1126 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1129 #(define-markup-command (when-property layout props symbol markp) (symbol? markup?)
1130 (if (chain-assoc-get symbol props)
1131 (interpret-markup layout props markp)
1132 (ly:make-stencil '() '(1 . -1) '(1 . -1))))
1134 #(define-markup-command (vspace layout props amount) (number?)
1135 "This produces a invisible object taking vertical space."
1136 (let ((amount (* amount 3.0)))
1138 (ly:make-stencil "" (cons -1 1) (cons 0 amount))
1139 (ly:make-stencil "" (cons -1 1) (cons amount amount)))))
1143 titlePageMarkup = \markup \abs-fontsize #10 \when-property #'header:title \column {
1145 \fill-line { \fontsize #8 \fromproperty #'header:composer }
1147 \fill-line { \fontsize #8 \fromproperty #'header:poet }
1149 \fill-line { \fontsize #10 \bold \fromproperty #'header:titlepagetitle }
1151 \fontsize #2 \when-property #'header:titlepagesubtitle {
1152 \fill-line { \fromproperty #'header:titlepagesubtitle }
1155 \fill-line { \postscript #"-20 0 moveto 40 0 rlineto stroke" }
1157 \fill-line { \fontsize #5 \fromproperty #'header:ensemble }
1159 \fill-line { \fontsize #2 \fromproperty #'header:instruments }
1161 \fill-line { \fontsize #5 \fromproperty #'header:date }
1163 \fill-line { \fontsize #5 \fromproperty #'header:scoretype }
1165 \fontsize #2 \when-property #'header:enteredby {
1166 \fill-line { "Herausgegeben von: / Edited by:"}
1168 \fill-line { \fromproperty #'header:enteredby }
1171 \when-property #'header:arrangement \column {
1173 \fill-line { \fontsize #3 \fromproperty #'header:arrangement }
1178 titleHeaderMarkup = \markup {
1179 \override #'(baseline-skip . 3.5)
1182 \fromproperty #'header:logo
1184 \huge \larger \bold \larger \fromproperty #'header:title
1185 \large \smaller \bold \larger \fromproperty #'header:subtitle
1186 \smaller \bold \fromproperty #'header:subsubtitle
1188 \bold \when-property #'header:instrument \rounded-box \fromproperty #'header:instrument
1191 \with-dimensions #'( 0 . 0) #'( 0 . 1 ) \null
1195 % { \large \bold \fromproperty #'header:instrument }
1198 \fromproperty #'header:poet
1199 \fromproperty #'header:composer
1202 \fromproperty #'header:meter
1203 \fromproperty #'header:arranger
1208 titleScoreMarkup = \markup \piece-title \fromproperty #'header:piece
1211 scoreTitleMarkup = \titleScoreMarkup
1212 bookTitleMarkup = \titleHeaderMarkup
1217 %%%%%%%%%%%%%% headers and footers %%%%%%%%%%%%%%%%%%%%%%%%%%
1219 #(define (first-score-page layout props arg)
1220 (let* ((label 'first-score-page)
1221 (table (ly:output-def-lookup layout 'label-page-table))
1222 (label-page (and (list? table) (assoc label table)))
1223 (page-number (and label-page (cdr label-page)))
1225 (if (eq? (chain-assoc-get 'page:page-number props -1) page-number)
1226 (interpret-markup layout props arg)
1229 #(define no-header-table '())
1230 thisPageNoHeader = #(define-music-function (parser location) ()
1231 (let* ((label (gensym "header")))
1232 (set! no-header-table (cons label no-header-table))
1235 'page-label label)))
1238 % TODO: Use the no-header-table!
1239 #(define (is-header-page layout props arg)
1240 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1242 ;(if (and (> page-number 2) (!= page-number 7))
1243 (if (> page-number 1)
1244 (interpret-markup layout props arg)
1247 #(define no-footer-table '())
1248 thisPageNoFooter = #(define-music-function (parser location) ()
1249 (let* ((label (gensym "footer")))
1250 (set! no-footer-table (cons label no-footer-table))
1253 'page-label label)))
1255 % TODO: Use the no-footer-table!
1256 #(define (is-footer-page layout props arg)
1257 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1258 (label 'first-score-page)
1259 (table (ly:output-def-lookup layout 'label-page-table))
1260 (label-page (and (list? table) (assoc label table)))
1261 ;(page-number (and label-page (cdr label-page)))
1263 (if (and (> page-number 1))
1264 (interpret-markup layout props arg)
1268 #(define copyright-footer-table '())
1269 thisPageCopyrightFooter = #(define-music-function (parser location) ()
1270 (let* ((label (gensym "copyrightfooter")))
1271 (set! copyright-footer-table (cons label copyright-footer-table))
1274 'page-label label)))
1276 #(define copyright-pg 1)
1277 #(define (set-copyright-page page)
1278 (set! copyright-pg page)
1281 % TODO: Use the copyright-footer-table!
1282 #(define (copyright-page layout props arg)
1283 (if (= (chain-assoc-get 'page:page-number props -1) copyright-pg)
1284 (interpret-markup layout props arg)
1289 oddHeaderMarkup = \markup \fill-line {
1290 %% force the header to take some space, otherwise the
1291 %% page layout becomes a complete mess.
1293 \on-the-fly #is-header-page \fromproperty #'header:title
1294 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1296 evenHeaderMarkup = \markup \fill-line {
1297 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1298 \on-the-fly #is-header-page \fromproperty #'header:composer
1302 oddFooterMarkup = \markup {
1305 %% publisher header field only on title page.
1306 \on-the-fly #first-page \fromproperty #'header:publisher
1309 %% copyright on the first real score page
1310 \on-the-fly #copyright-page \fromproperty #'header:copyright
1311 \on-the-fly #copyright-page \null
1314 %% All other pages get the number of the edition centered
1315 \on-the-fly #is-footer-page \fromproperty #'header:scorenumber
1332 % Interpret the given markup with the header fields added to the props.
1333 % This way, one can re-use the same functions (using fromproperty
1334 % #'header:field) in the header block and as top-level markup.
1336 % This function is originally copied from mark-up-title (file scm/titling.scm),
1337 % which is lilypond's internal function to handle the title markups. I needed
1338 % to replace the scopes and manually add the $defaultheader (which is internally
1339 % done in paper-book.cc before calling mark-up-title. Also, I don't extract the
1340 % markup from the header block, but use the given markup.
1342 % I'm not sure if I really need the page properties in props, too... But I
1343 % suppose it does not hurt, either.
1344 #(define-markup-command (markupWithHeader layout props markup) (markup?)
1345 "Interpret the given markup with the header fields added to the props.
1346 This way, one can re-use the same functions (using fromproperty
1347 #'header:field) in the header block and as top-level markup."
1349 ; TODO: If we are inside a score, add the score's local header block, too!
1350 ; Currently, I only use the global header block, stored in $defaultheader
1351 (scopes (list $defaultheader))
1352 (alists (map ly:module->alist scopes))
1355 (map (lambda (alist)
1356 (map (lambda (entry)
1358 (string->symbol (string-append "header:" (symbol->string (car entry))))
1362 (props (append prefixed-alist
1364 (layout-extract-page-properties layout)))
1366 (interpret-markup layout props markup)
1375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1376 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1377 %%%%% Equally spacing multiple columns (e.g. for translations)
1378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1379 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1381 % Credits: Nicolas Sceaux on the lilypond-user mailinglist
1382 #(define-markup-command (columns layout props args) (markup-list?)
1383 (let ((line-width (/ (chain-assoc-get 'line-width props
1384 (ly:output-def-lookup layout 'line-width))
1385 (max (length args) 1))))
1386 (interpret-markup layout props
1387 (make-line-markup (map (lambda (line)
1388 (markup #:pad-to-box `(0 . ,line-width) '(0 . 0)
1389 #:override `(line-width . ,line-width)
1395 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1396 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1397 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1398 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1399 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1402 startSlashedGraceMusic = {
1403 \override Stem #'stroke-style = #"grace"
1406 stopSlashedGraceMusic = {
1407 \revert Stem #'stroke-style
1411 #(def-grace-function startSlashedGraceMusic stopSlashedGraceMusic
1412 (_i "Create slashed graces (slashes through stems, but no slur)from the following music expression"))
1415 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1416 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1417 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1418 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1419 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1423 right-margin = 1.5\cm
1424 line-width = 17.5\cm
1425 % bottom-margin = 1.5\cm
1427 % after-title-space = 0.5\cm
1431 ragged-last-bottom = ##f
1436 % If only one non-empty staff in a system exists, still print the backet
1437 \override SystemStartBracket #'collapse-height = #1
1438 \consists "Instrument_name_engraver"
1442 % If only one non-empty staff in a system exists, still print the backet
1443 \override SystemStartBracket #'collapse-height = #1
1444 \consists "Instrument_name_engraver"
1448 \override SystemStartBracket #'collapse-height = #1
1449 \consists "Instrument_name_engraver"
1453 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1457 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1458 \override VerticalAxisGroup #'minimum-Y-extent = #'(0 . 1)
1459 \override VerticalAxisGroup #'padding = #0
1463 % Force multi-measure rests to be written as one span
1464 \override MultiMeasureRest #'expand-limit = #3
1467 % hairpinToBarline = ##f
1468 \override BarNumber #'break-visibility = #end-of-line-invisible
1469 \override BarNumber #'self-alignment-X = #0
1470 \override CombineTextScript #'avoid-slur = #'outside
1471 barNumberVisibility = #(every-nth-bar-number-visible 5)
1472 \override DynamicTextSpanner #'dash-period = #-1.0
1473 \override InstrumentSwitch #'font-size = #-1
1476 \override RestCollision #'positioning-done = #merge-rests-on-positioning
1477 % Auto-Accidentals: Use modern-cautionary style...
1479 autoAccidentals = #`(Staff ,(make-accidental-rule 'same-octave 0)
1480 ,(make-accidental-rule 'any-octave 0)
1481 ,(make-accidental-rule 'same-octave 1))
1482 % autoCautionaries = #`(Staff ,(make-accidental-rule 'any-octave 0)
1483 % ,(make-accidental-rule 'same-octave 1))
1484 printKeyCancellation = ##t
1485 quotedEventTypes = #'(StreamEvent)
1486 implicitBassFigures = #'(0 100)
1489 \RemoveEmptyStaffContext
1493 \override VerticalAxisGroup #'minimum-Y-extent = #'(0.5 . 0.5)
1497 \override VerticalAxisGroup #'minimum-Y-extent = #'(-1. . 3)
1498 ignoreFiguredBassRest = ##f
1506 \type "Engraver_group"
1508 % So that \cresc works, for example.
1510 \consists "Output_property_engraver"
1512 \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
1513 pedalSustainStrings = #'("Ped." "*Ped." "*")
1514 pedalUnaCordaStrings = #'("una corda" "" "tre corde")
1516 \consists "Piano_pedal_engraver"
1517 \consists "Script_engraver"
1518 \consists "Dynamic_engraver"
1519 \consists "Text_engraver"
1521 \override TextScript #'font-size = #2
1522 \override TextScript #'font-shape = #'italic
1523 \override DynamicText #'extra-offset = #'(0 . 2.5)
1524 \override Hairpin #'extra-offset = #'(0 . 2.5)
1526 \consists "Skip_event_swallow_translator"
1528 \consists "Axis_group_engraver"
1533 % \override VerticalAlignment #'forced-distance = #7
1538 bracketts = ^\markup{"[Solo]"}
1539 brackettt = ^\markup{"[Tutti]"}
1540 ts = ^\markup{"t.s."}
1541 tt = ^\markup{"Tutti"}
1542 solo = ^\markup{"Solo"}
1543 bracketsolo = ^\markup{"[Solo]"}
1544 tutti = ^\markup{"Tutti"}
1546 dashedSlur = -\tweak #'dash-definition #'((0 1 0.4 0.75))(
1547 dashedTie = -\tweak #'dash-definition #'((0 1 0.4 0.75))~
1549 divisi = #(define-music-function (parser location vc1 vc2) (ly:music? ly:music?)
1551 << { \voiceOne $vc1 \oneVoice} \new Voice = "divisi2" { \voiceTwo $vc2 } >>
1555 #(define-public (bracket-stencils grob)
1556 (let ((lp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "[")))
1557 (rp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "]"))))
1560 bracketify = #(define-music-function (parser loc arg) (ly:music?)
1561 (_i "Tag @var{arg} to be parenthesized.")
1563 \once \override ParenthesesItem #'stencils = #bracket-stencils
1569 #(define-markup-command (hat layout props arg) (markup?)
1570 "Draw a hat above the given string @var{arg}."
1571 (interpret-markup layout props (markup #:combine #:raise 1.5 "^" arg)))
1576 #(let ((m (make-music 'ArticulationEvent
1577 'articulation-type "flageolet")))
1578 (ly:music-set-property! m 'tweaks
1579 (acons 'font-size -2
1580 (ly:music-property m 'tweaks)))
1584 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1587 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1588 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1590 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" }}
1591 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" }}
1592 LicenseNoRestrictions = \markup{\line {Die Ausgabe darf kopiert und ohne Einschränkungen aufgeführt werden. / May be copied and performed without restriction.}}