Update to "new" (de)cresc text spanner syntax
[orchestrallily.git] / orchestrallily.ly
blobadb4feca1de6fbaddbf9a031399682d3ebdff494
1 \version "2.11.41"
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 % OrchestralLily
5 % ==============
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
13 % Version History:
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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 % Helper functions
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)
40 (let* (
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)))
45 (cond
46 ((defined? fullname) (primitive-eval fullname))
47 ((defined? instrname) (primitive-eval instrname))
48 ((defined? piecename) (primitive-eval piecename))
49 (else '())
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)
59 args)))))
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:orchestral_score_structure '())
90 #(define (oly:set_score_structure struct)
91 (if (list? struct)
92 (set! oly:orchestral_score_structure struct)
93 (ly:warning (_ "oly:set_score_structure needs an association list as argument!"))
97 orchestralScoreStructure = #(define-music-function (parser location structure) (list?)
98 (oly:set_score_structure structure)
99 (make-music 'Music 'void #t)
102 #(define oly:voice_types '())
104 #(define (oly:set_voice_types types)
105 (if (list? types)
106 (set! oly:voice_types types)
107 (ly:warning (_ "oly:set_voice_types needs an association list as argument!"))
111 orchestralVoiceTypes = #(define-music-function (parser location types) (list?)
112 (oly:set_voice_types types)
113 (make-music 'Music 'void #t)
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118 % Automatic staff and group generation
119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
121 % Retrieve all music definitions for the given
122 #(define (oly:get_music_object piece instrument)
123 (namedPieceInstrObject piece instrument "Music")
125 #(define (oly:get_music_objects piece instruments)
126 (filter not-null? (map (lambda (i) (oly:get_music_object piece i)) instruments))
129 % Given a property name and the extensions, either generate the pair to set
130 % the property or an empty list, if no pre-defined variable could be found
131 #(define (oly:generate_property_pair prop piece instr type)
132 (let* ((val (namedPieceInstrObject piece instr type)))
133 (if (not-null? val) (list 'assign prop val) '() )
137 #(define (oly:staff_type type)
138 (cond
139 ((string? type) (string->symbol type))
140 ((symbol? type) type)
141 (else 'Staff)
145 #(define (oly:extractPitch music)
146 (let* (
147 (elems (if (ly:music? music) (ly:music-property music 'elements)))
148 (note (if (pair? elems) (car elems)))
149 (pitch (if (ly:music? note) (ly:music-property note 'pitch)))
151 (if (and (not-null? music) (not (ly:pitch? pitch)))
152 (ly:warning "Unable to interpret as a pitch!")
154 pitch
158 #(define (oly:extractTranspositionPitch piece name)
159 (let* (
160 (trpFromPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeFrom")))
161 (trpToPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeTo")))
163 (if (ly:pitch? trpFromPitch)
164 (if (ly:pitch? trpToPitch)
165 ; Both pitches
166 (ly:pitch-diff trpFromPitch trpToPitch)
167 (ly:pitch-diff trpFromPitch (ly:make-pitch 0 0 0))
169 (if (ly:pitch? trpToPitch)
170 (ly:pitch-diff (ly:make-pitch 0 0 0) trpToPitch)
177 #(define (oly:musiccontent_for_voice parser piece name music additional)
178 (let* ((musiccontent additional))
180 ; Append the settings, key and clef (if defined)
181 (map
182 (lambda (type)
183 (let* ((object (namedPieceInstrObject piece name type)))
184 (if (ly:music? object)
185 (set! musiccontent (append musiccontent (list (ly:music-deep-copy object))))
186 (if (not-null? object) (ly:warning (_ "Wrong type (no ly:music) for ~S for instrument ~S in piece ~S") type name piece))
190 ; TODO: Does the "Tempo" work here???
191 '("Settings" "Key" "Clef" "TimeSignature" ;"Tempo"
195 (if (ly:music? music)
196 (begin
197 (set! musiccontent (make-simultaneous-music (append musiccontent (list music))))
198 ;(ly:message "Generating staff for ~a" name)
199 (let* ((trpPitch (oly:extractTranspositionPitch piece name)))
200 (if (ly:pitch? trpPitch)
201 (set! musiccontent (ly:music-transpose musiccontent trpPitch))
204 musiccontent
206 ; For empty music, return empty
211 #(define (oly:voice_handler_internal parser piece name type music)
212 (let* (
213 (lyrics (namedPieceInstrObject piece name "Lyrics"))
214 (additional '())
217 (if (ly:music? lyrics)
218 (set! additional (list dynamicUp))
219 (if (not-null? lyrics) (ly:warning (_ "Wrong type (no lyrics) for lyrics for instrument ~S in piece ~S") name piece))
222 (if (ly:music? music)
223 (let* ((musiccontent (oly:musiccontent_for_voice parser piece name music additional))
224 (voicename (oly:generate_object_name piece name "Voice" ))
225 (voicetype (oly:staff_type type))
226 (voice (context-spec-music musiccontent voicetype voicename))
227 (staffcont (list voice))
229 ; If we have lyrics, create a lyrics context containing LyricCombineMusic
230 ; and add that as second element to the staff's elements list...
231 (if (ly:music? lyrics)
232 (let* (
233 (lyricsname (oly:generate_object_name piece name "Lyrics" ))
234 (lyricscont (make-music 'LyricCombineMusic 'element lyrics 'associated-context voicename))
236 (set! staffcont (append staffcont
237 (list (context-spec-music lyricscont 'Lyrics lyricsname))))
240 staffcont
242 ; For empty music, return empty
248 #(define (oly:voice_handler parser piece name type)
249 (let* ((music (oly:get_music_object piece name))
251 (oly:voice_handler_internal parser piece name type music)
256 #(define (oly:staff_handler_internal parser piece name type voices)
257 (if (not-null? voices)
258 (let* (
259 (staffname (oly:generate_staff_name piece name))
260 (stafftype (oly:staff_type type))
261 (staff (make-simultaneous-music voices))
262 (propops (oly:staff_handler_properties piece name))
264 (case stafftype
265 ((SimultaneousMusic ParallelMusic) #f)
266 (else (set! staff (context-spec-music staff stafftype staffname)))
268 (if (not-null? propops)
269 (set! (ly:music-property staff 'property-operations) propops)
271 staff
273 ; For empty music, return empty
278 #(define (oly:staff_handler parser piece name type children)
279 (let* ((c (if (not-null? children) children (list name)))
280 (voices (apply append (map (lambda (v) (oly:create_voice parser piece v)) c)) )
282 (if (not-null? voices)
283 (oly:staff_handler_internal parser piece name type voices)
289 #(define (oly:parallel_voices_staff_handler parser piece name type children)
290 (let* (
291 (voices (map (lambda (i) (oly:create_voice parser piece i)) children))
292 ; get the list of non-empty voices and flatten it!
293 (nonemptyvoices (apply append (filter not-null? voices)))
295 (if (not-null? nonemptyvoices)
296 (oly:staff_handler_internal parser piece name "Staff" nonemptyvoices)
302 #(define (oly:part_combined_staff_handler parser piece name type children)
303 (let* ((rawmusic (map (lambda (c) (oly:musiccontent_for_voice parser piece name (oly:get_music_object piece c) '())) children))
304 (music (filter not-null? rawmusic)))
305 (cond
306 ((and (pair? music) (ly:music? (car music)) (not-null? (cdr music)) (ly:music? (cadr music)))
307 ;(ly:message "Part-combine with two music expressions")
308 (oly:staff_handler_internal parser piece name "Staff" (list (make-part-combine-music parser music))))
309 ((null? music)
310 (ly:warning "Part-combine without any music expressions")
311 '())
312 ; exactly one is a music expression, simply use that by joining
313 ((list? music)
314 (ly:message "Part-combine with only one music expressions")
315 (oly:staff_handler_internal parser piece name "Staff" (list (apply append music))))
316 (else
317 ;(ly:message "make_part_combined_staff: ~S ~S ~a" piece instr instruments)
318 '() )
323 % Generate the properties for the staff for piece and instr. Typically, these
324 % are the instrument name and the short instrument name (if defined).
325 % return a (possibly empty) list of all assignments.
326 #(define (oly:staff_handler_properties piece instr)
327 (let* (
328 (mapping '(
329 (instrumentName . "InstrumentName")
330 (shortInstrumentName . "ShortInstrumentName")
331 (midiInstrument . "MidiInstrument")
333 (assignments (map
334 (lambda (pr)
335 (oly:generate_property_pair (car pr) piece instr (cdr pr))
337 mapping))
338 (props (filter not-null? assignments))
340 props
344 % Figured bass is a special case, as it can be voice- or staff-type. When
345 % given as a staff type, simply call the voice handler, instead
347 #(define (oly:figured_bass_staff_handler parser piece name type children)
348 (let* ((c (if (not-null? children) children (list name)))
349 (voice (oly:voice_handler parser piece (car c) type)))
350 (if (pair? voice) (car voice) ())
355 #(define (oly:staff_group_handler parser piece name type children)
356 (let* (
357 (staves (map (lambda (i) (oly:create_staff_or_group parser piece i)) children))
358 (nonemptystaves (filter not-null? staves))
360 (if (not-null? nonemptystaves)
361 (let* (
362 (musicexpr (if (= 1 (length nonemptystaves))
363 (car nonemptystaves)
364 (make-simultaneous-music nonemptystaves)))
365 (groupname (oly:generate_staff_name piece name))
366 (grouptype (oly:staff_type type))
367 (group musicexpr)
368 (propops (oly:staff_handler_properties piece name))
370 (case grouptype
371 ((SimultaneousMusic ParallelMusic) #f)
372 (else (set! group (context-spec-music group grouptype groupname)))
374 (set! (ly:music-property group 'property-operations) propops)
375 group
377 ; Return empty list if no staves are generated
383 #(define (oly:create_voice parser piece name)
384 (let* ( (voice (namedPieceInstrObject piece name "Voice"))
385 (type (assoc-ref oly:voice_types name)) )
386 (if (not-null? voice)
387 ; Explicit voice variable, use that
388 voice
390 (if (not type)
391 ; No entry in structure found => simple voice
392 (oly:voice_handler parser piece name "Voice")
393 ; Entry found in structure => use the handler for the given type
394 (let* (
395 (voicetype (car type))
396 (handler (assoc-ref oly:voice_handlers voicetype))
398 (if handler
399 ((primitive-eval handler) parser piece name voicetype)
400 (begin
401 (ly:warning "No handler found for voice type ~a, using default voice handler" voicetype)
402 (oly:voice_handler parser piece name voicetype)
411 #(define (oly:create_staff_or_group parser piece name)
412 (let* ( (staff (namedPieceInstrObject piece name "Staff"))
413 (type_from_structure (assoc-ref oly:orchestral_score_structure name)) )
414 ;(if (not-null? staff)
415 ; (ly:message "Found staff variable for instrument ~a in piece ~a" instr piece)
416 ; (ly:message "Staff variable for instrument ~a in piece ~a NOT FOUND" instr piece)
418 (if (not-null? staff)
419 ; Explicit staff variable, use that
420 staff
422 (if (not (list? type_from_structure))
423 ; No entry in structure found => simple staff
424 (oly:staff_handler parser piece name "Staff" '())
426 ; Entry found in structure => use the handler for the given type
427 (let* ((type (car type_from_structure))
428 (handler (assoc-ref oly:staff_handlers type))
429 (children (cadr type_from_structure))
431 (if handler
432 ((primitive-eval handler) parser piece name type children)
433 (begin
434 (ly:warning "No handler found for staff type ~a, using default staff handler" type)
435 (oly:staff_handler parser piece name type children)
444 #(define oly:staff_handlers
445 (list
446 ; staff group types
447 '("GrandStaff" . oly:staff_group_handler )
448 '("PianoStaff" . oly:staff_group_handler )
449 '("ChoirStaff" . oly:staff_group_handler )
450 '("StaffGroup" . oly:staff_group_handler )
451 '("InnerChoirStaff" . oly:staff_group_handler )
452 '("InnerStaffGroup" . oly:staff_group_handler )
453 '("ParallelMusic" . oly:staff_group_handler )
454 '("SimultaneousMusic" . oly:staff_group_handler )
455 ; staff types
456 '("Staff" . oly:staff_handler )
457 '("DrumStaff" . oly:staff_handler )
458 '("RhythmicStaff" . oly:staff_handler )
459 '("TabStaff" . oly:staff_handler )
460 '("GregorianTranscriptionStaff" . oly:staff_handler )
461 '("MensuralStaff" . oly:staff_handler )
462 '("VaticanaStaff" . oly:staff_handler )
463 ; staves with multiple voices
464 '("PartCombinedStaff" . oly:part_combined_staff_handler )
465 '("ParallelVoicesStaff" . oly:parallel_voices_staff_handler )
466 ; special cases: Figured bass can be staff or voice type!
467 '("FiguredBass" . oly:figured_bass_staff_handler )
471 #(define oly:voice_handlers
472 (list
473 ; voice types
474 '("Voice" . oly:voice_handler )
475 '("CueVoice" . oly:voice_handler )
476 '("DrumVoice" . oly:voice_handler )
477 '("FiguredBass" . oly:voice_handler )
478 '("GregorianTranscriptionVoice" . oly:voice_handler )
479 '("NoteNames" . oly:voice_handler )
480 '("TabVoice" . oly:voice_handler )
481 '("VaticanaVoice" . oly:voice_handler )
482 ;'("Dynamics" . oly:dynamics_handler )
487 #(define (oly:register_staff_type_handler type func)
488 ; (ly:message "Registering staff handler ~a for type ~a" func type)
489 (set! oly:staff_handlers (assoc-set! oly:staff_handlers type func))
492 #(define (oly:register_voice_type_handler type func)
493 ; (ly:message "Registering voice type handler ~a for type ~a" func type)
494 (set! oly:voice_handlers (assoc-set! oly:voice_handlers type func))
497 % handlers for deprecated API
498 #(oly:register_staff_type_handler 'StaffGroup 'oly:staff_group_handler)
499 #(oly:register_staff_type_handler 'GrandStaff 'oly:staff_group_handler)
500 #(oly:register_staff_type_handler 'PianoStaff 'oly:staff_group_handler)
501 #(oly:register_staff_type_handler 'ChoirStaff 'oly:staff_group_handler)
502 #(oly:register_staff_type_handler 'Staff 'oly:staff_handler )
503 #(oly:register_staff_type_handler 'ParallelMusic 'oly:staff_group_handler)
504 #(oly:register_staff_type_handler 'SimultaneousMusic 'oly:staff_group_handler)
505 #(oly:register_staff_type_handler #t 'oly:part_combined_staff_handler )
506 #(oly:register_staff_type_handler #f 'oly:parallel_voices_staff_handler )
510 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
511 % Automatic score generation
512 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
514 % \setUseBook ##t/##f sets a flag to determine whether the calls to createScore
515 % are from within a book block or not
516 % #(define oly:score_handler collect-scores-for-book)
517 #(define oly:score_handler toplevel-score-handler)
518 #(define oly:music_handler toplevel-music-handler)
519 #(define oly:text_handler toplevel-text-handler)
521 setUseBook = #(define-music-function (parser location usebook) (boolean?)
522 (if usebook
523 (begin
524 (set! oly:score_handler book-score-handler)
525 (set! oly:music_handler book-music-handler)
526 (set! oly:text_handler book-text-handler)
528 (begin
529 (set! oly:score_handler toplevel-score-handler)
530 (set! oly:music_handler toplevel-music-handler)
531 (set! oly:text_handler toplevel-text-handler)
534 (make-music 'Music 'void #t)
538 % Two functions to handle midi-blocks: Either don't set one, or set an empty
539 % one so that MIDI is generated
540 #(define (oly:set_no_midi_block score) '())
541 #(define (oly:set_midi_block score)
542 (let* ((midiblock (if (defined? '$defaultmidi)
543 (ly:output-def-clone $defaultmidi)
544 (ly:make-output-def))))
545 (ly:output-def-set-variable! midiblock 'is-midi #t)
546 (ly:score-add-output-def! score midiblock)
550 % \setCreateMidi ##t/##f sets a flag to determine wheter MIDI output should
551 % be generated
552 #(define oly:apply_score_midi oly:set_no_midi_block)
553 setCreateMIDI = #(define-music-function (parser location createmidi) (boolean?)
554 (if createmidi
555 (set! oly:apply_score_midi oly:set_midi_block)
556 (set! oly:apply_score_midi oly:set_no_midi_block)
558 (make-music 'Music 'void #t)
562 % Two functions to handle layout-blocks: Either don't set one, or set an empty
563 % one so that a PDF is generated
564 #(define (oly:set_no_layout_block score) '())
565 #(define (oly:set_layout_block score)
566 (let* ((layoutblock (if (defined? '$defaultlayout)
567 (ly:output-def-clone $defaultlayout)
568 (ly:make-output-def))))
569 (ly:output-def-set-variable! layoutblock 'is-layout #t)
570 (ly:score-add-output-def! score layoutblock)
574 % \setCreatePDF ##t/##f sets a flag to determine wheter PDF output should
575 % be generated
576 #(define oly:apply_score_layout oly:set_no_layout_block)
577 setCreatePDF = #(define-music-function (parser location createlayout) (boolean?)
578 (if createlayout
579 (set! oly:apply_score_layout oly:set_layout_block)
580 (set! oly:apply_score_layout oly:set_no_layout_block)
582 (make-music 'Music 'void #t)
586 % Set the piece title in a new header block.
587 #(define (oly:set_piece_header score piecename)
588 (if (not-null? piecename)
589 (let* ((header (make-module)))
590 (module-define! header 'piece piecename)
591 (ly:score-set-header! score header)
597 % post-filter functions. By default, no filtering is done. However,
598 % for the *NoCues* function, the cue notes should be killed
599 identity = #(define-music-function (parser location music) (ly:music?) music)
600 cuefilter = #(define-music-function (parser location music) (ly:music?)
601 ((ly:music-function-extract removeWithTag) parser location 'cued ((ly:music-function-extract killCues) parser location music))
605 #(define (oly:create-toc-file layout pages)
606 (let* ((label-table (ly:output-def-lookup layout 'label-page-table))
607 (format-line (lambda (toc-item)
608 (let* ((label (car toc-item))
609 (text (caddr toc-item))
610 (label-page (and (list? label-table)
611 (assoc label label-table)))
612 (page (and label-page (cdr label-page))))
613 (format #f "~a, section, 1, {~a}, ~a" page text label))))
614 (formatted-toc-items (map format-line (toc-items)))
615 (whole-string (string-join formatted-toc-items ",\n"))
616 (output-name (ly:parser-output-name parser))
617 (outfilename (format "~a.toc" output-name))
618 (outfile (open-output-file outfilename)))
619 (if (output-port? outfile)
620 (display whole-string outfile)
621 (ly:warning (_ "Unable to open output file ~a for the TOC information") outfilename))
622 (close-output-port outfile)))
625 #(define-public (oly:add-toc-item parser markup-symbol text)
626 (oly:music_handler parser (add-toc-item! markup-symbol text)))
629 #(define (oly:add-score parser score piecename)
630 (if (not-null? piecename)
631 (oly:add-toc-item parser 'tocItemMarkup piecename))
632 (oly:score_handler parser score)
634 % The helper function to build a score.
635 #(define (oly:createScoreHelper parser location piece children func)
636 (let* (
637 (staves (oly:staff_group_handler parser piece "" "SimultaneousMusic" children))
638 (music (if (not-null? staves)
639 ((ly:music-function-extract func) parser location staves)
642 (score '())
643 (piecename (namedPieceInstrObject piece (car children) "PieceName"))
644 (piecenametacet (namedPieceInstrObject piece (car children) "PieceNameTacet"))
645 (header '())
647 (if (null? music)
648 ; No staves, print tacet
649 (begin
650 (if (not-null? piecenametacet) (set! piecename piecenametacet))
651 (if (not-null? piecename)
652 (oly:add-score parser (list (oly:piece-title-markup piecename)) piecename)
653 (ly:warning (_ "No music and no score title found for part ~a and instrument ~a") piece children)
656 ; we have staves, apply the piecename to the score and add layout/midi blocks if needed
657 (begin
658 (set! score (scorify-music music parser))
659 (oly:set_piece_header score piecename)
660 (oly:apply_score_midi score)
661 (oly:apply_score_layout score)
662 ; Schedule the score for typesetting
663 (oly:add-score parser score piecename)
667 ; This is a void function, the score has been schedulled for typesetting already
668 (make-music 'Music 'void #t)
671 createScore = #(define-music-function (parser location piece children) (string? list?)
672 (oly:createScoreHelper parser location piece children identity)
674 createNoCuesScore = #(define-music-function (parser location piece children) (string? list?)
675 (oly:createScoreHelper parser location piece children cuefilter)
678 createHeadline = #(define-music-function (parser location headline) (string?)
679 (oly:add-toc-item parser 'tocItemMarkup headline)
680 (oly:score_handler parser (list (oly:piece-title-markup headline)))
681 (make-music 'Music 'void #t)
686 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
687 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
688 %%%%% CUE NOTES
689 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
690 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
692 newInstrument = #(define-music-function (parser location instr) (string?)
694 \set Voice.instrumentCueName = #$(string-join (list "+" instr))
697 cueText = #(define-music-function (parser location instr) (string?)
699 \set Voice.instrumentCueName = $instr
703 % generate a cue music section with instrument names
704 % Parameters: \namedCueDuring NameOfQuote CueDirection CueInstrument OriginalInstrument music
705 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
706 % -) CueInstrument and OriginalInstrument are the displayed instrument names
707 % typical call:
708 % \namedCueDuring #"vIQuote" #UP #"V.I" #"Sop." { R1*3 }
709 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
710 % the beginning of the cue notes and "Sop." at the end
711 namedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr cuemusic) (string? number? string? string? ly:music?)
713 \cueDuring #$cuevoice #$direction { \tag #'cued \cueText #$instrcue $cuemusic \tag #'cued \cueText #$instr }
714 % \tag #'uncued $cuemusic
717 namedTransposedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr trans cuemusic) (string? number? string? string? ly:music? ly:music?)
719 \transposedCueDuring #$cuevoice #$direction $trans { \tag #'cued \cueText #$instrcue $cuemusic \tag #'cued \cueText #$instr }
720 % \tag #'uncued $cuemusic
724 % set the cue instrument name and clef
725 setClefCue = #(define-music-function (parser location instr clef)
726 (string? ly:music?)
728 \once \override Staff.Clef #'font-size = #-3 $clef
729 \set Voice.instrumentCueName = $instr
730 #} )
732 % generate a cue music section with instrument names and clef changes
733 % Parameters: \cleffedCueDuring NameOfQuote CueDirection CueInstrument CueClef OriginalInstrument OriginalClef music
734 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
735 % -) CueInstrument and OriginalInstrument are the displayed instrument names
736 % -) CueClef and OriginalClef are the clefs for the the cue notes and the clef of the containing voice
737 % typical call:
738 % \cleffedCueDuring #"vIQuote" #UP #"V.I" #"treble" #"Basso" #"bass" { R1*3 }
739 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
740 % the beginning of the cue notes and "Basso" at the end. The clef is changed to treble at the
741 % beginning of the cue notes and reset to bass at the end
742 cleffedCueDuring = #(define-music-function (parser location cuevoice direction instrcue clefcue instr clefinstr cuemusic)
743 (string? number? string? ly:music? string? ly:music? ly:music?)
745 \cueDuring #$cuevoice #$direction { \tag #'cued \setClefCue #$instrcue $clefcue $cuemusic \tag #'cued \setClefCue #$instr $clefinstr }
746 % \tag #'uncued $cuemusic
753 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
754 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
755 %%%%% DYNAMICS
756 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
757 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
760 dynamicsX = #(define-music-function (parser location offset) (number?)
762 \once \override DynamicText #'X-offset = $offset
763 \once \override DynamicLineSpanner #'Y-offset = #0
766 % Move the dynamic sign inside the staff to a fixed staff-relative position
767 % posY (where 0 means vertically starts at the middle staff line)
768 dynamicsAllInside = #(define-music-function (parser location offsetX posY)
769 (number? number?)
771 % Invalid y-extent -> hidden from skyline calculation and collisions
772 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
773 % move by X offset and to fixed Y-position (use Y-offset of parent!)
774 \once \override DynamicText #'X-offset = $offsetX
775 \once \override DynamicText #'Y-offset =
776 $(lambda (grob)
777 (let* ((head (ly:grob-parent grob Y))
778 (offset (ly:grob-property head 'Y-offset)))
779 (- posY offset (- 0.6))))
780 \once \override DynamicLineSpanner #'Y-offset = $posY
783 dynamicsUpInside = #(define-music-function (parser location offsetX) (number?)
784 ((ly:music-function-extract dynamicsAllInside) parser location offsetX 1.5)
787 dynamicsDownInside = #(define-music-function (parser location offsetX) (number?)
788 ((ly:music-function-extract dynamicsAllInside) parser location offsetX -3.5)
791 hairpinOffset = #(define-music-function (parser location posY) (number?)
793 \once \override DynamicLineSpanner #'Y-offset = $posY
794 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
797 #(define ((line-break-offset before after) grob)
798 (let* ((orig (ly:grob-original grob))
799 ; All siblings if line-broken:
800 (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
801 (if (>= (length siblings) 2)
802 ; We have been line-broken
803 (if (eq? (car (last-pair siblings)) grob)
804 ; Last sibling:
805 (ly:grob-set-property! grob 'Y-offset after)
806 ; Others get the before value:
807 (ly:grob-set-property! grob 'Y-offset before)
813 ffz = #(make-dynamic-script "ffz")
814 pf = #(make-dynamic-script "pf")
815 sempp = #(make-dynamic-script (markup #:line( #:with-dimensions '(0 . 0)
816 '(0 . 0) #:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
817 parenf = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")" )))
818 parenp = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "p" #:normal-text #:italic #:fontsize 2 ")" )))
819 pdolce = #(make-dynamic-script (markup #:line(#:dynamic "p" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
823 cresc = #(make-music 'CrescendoEvent 'span-direction START 'crescendoSpanner 'text 'crescendoText "cresc.")
824 endcresc = #(make-span-event 'CrescendoEvent STOP)
825 dim = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "dim.")
826 enddim = #(make-span-event 'DecrescendoEvent STOP)
827 decresc = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "decresc.")
828 enddecresc = #(make-span-event 'DecrescendoEvent STOP)
830 setCresc = {}
831 setDecresc = {}
832 setDim = {}
834 newOrOldClef = #(define-music-function (parser location new old ) (string? string?)
835 (if (ly:get-option 'old-clefs) #{ \clef $old #} #{ \clef $new #})
840 %%% Thanks to "Gilles THIBAULT" <gilles.thibault@free.fr>, there is a way
841 % to remove also the fermata from R1-\fermataMarkup: By filtering the music
842 % and removing the corresponding events.
843 % Documented as an LSR snippet: http://lsr.dsi.unimi.it/LSR/Item?id=372
844 #(define (filterOneEventsMarkup event)
845 ( let ( (eventname (ly:music-property event 'name)) )
846 (not
847 (or ;; add here event name you do NOT want
848 (eq? eventname 'MultiMeasureTextEvent)
849 (eq? eventname 'AbsoluteDynamicEvent)
850 (eq? eventname 'TextScriptEvent)
851 (eq? eventname 'ArticulationEvent)
852 (eq? eventname 'CrescendoEvent)
853 (eq? eventname 'DecrescendoEvent)
858 filterArticulations = #(define-music-function (parser location music) (ly:music?)
859    (music-filter filterOneEventsMarkup music)
872 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
873 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
874 %%%%% REST COMBINATION
875 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
876 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
880 %% REST COMBINING, TAKEN FROM http://lsr.dsi.unimi.it/LSR/Item?id=336
882 %% Usage:
883 %% \new Staff \with {
884 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
885 %% } << \somevoice \\ \othervoice >>
886 %% or (globally):
887 %% \layout {
888 %% \context {
889 %% \Staff
890 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
891 %% }
892 %% }
894 %% Limitations:
895 %% - only handles two voices
896 %% - does not handle multi-measure/whole-measure rests
898 #(define (rest-score r)
899 (let ((score 0)
900 (yoff (ly:grob-property-data r 'Y-offset))
901 (sp (ly:grob-property-data r 'staff-position)))
902 (if (number? yoff)
903 (set! score (+ score 2))
904 (if (eq? yoff 'calculation-in-progress)
905 (set! score (- score 3))))
906 (and (number? sp)
907 (<= 0 2 sp)
908 (set! score (+ score 2))
909 (set! score (- score (abs (- 1 sp)))))
910 score))
912 #(define (merge-rests-on-positioning grob)
913 (let* ((can-merge #f)
914 (elts (ly:grob-object grob 'elements))
915 (num-elts (and (ly:grob-array? elts)
916 (ly:grob-array-length elts)))
917 (two-voice? (= num-elts 2)))
918 (if two-voice?
919 (let* ((v1-grob (ly:grob-array-ref elts 0))
920 (v2-grob (ly:grob-array-ref elts 1))
921 (v1-rest (ly:grob-object v1-grob 'rest))
922 (v2-rest (ly:grob-object v2-grob 'rest)))
923 (and
924 (ly:grob? v1-rest)
925 (ly:grob? v2-rest)
926 (let* ((v1-duration-log (ly:grob-property v1-rest 'duration-log))
927 (v2-duration-log (ly:grob-property v2-rest 'duration-log))
928 (v1-dot (ly:grob-object v1-rest 'dot))
929 (v2-dot (ly:grob-object v2-rest 'dot))
930 (v1-dot-count (and (ly:grob? v1-dot)
931 (ly:grob-property v1-dot 'dot-count -1)))
932 (v2-dot-count (and (ly:grob? v2-dot)
933 (ly:grob-property v2-dot 'dot-count -1))))
934 (set! can-merge
935 (and
936 (number? v1-duration-log)
937 (number? v2-duration-log)
938 (= v1-duration-log v2-duration-log)
939 (eq? v1-dot-count v2-dot-count)))
940 (if can-merge
941 ;; keep the rest that looks best:
942 (let* ((keep-v1? (>= (rest-score v1-rest)
943 (rest-score v2-rest)))
944 (rest-to-keep (if keep-v1? v1-rest v2-rest))
945 (dot-to-kill (if keep-v1? v2-dot v1-dot)))
946 ;; uncomment if you're curious of which rest was chosen:
947 ;;(ly:grob-set-property! v1-rest 'color green)
948 ;;(ly:grob-set-property! v2-rest 'color blue)
949 (ly:grob-suicide! (if keep-v1? v2-rest v1-rest))
950 (if (ly:grob? dot-to-kill)
951 (ly:grob-suicide! dot-to-kill))
952 (ly:grob-set-property! rest-to-keep 'direction 0)
953 (ly:rest::y-offset-callback rest-to-keep)))))))
954 (if can-merge
956 (ly:rest-collision::calc-positioning-done grob))))
962 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
963 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
964 %%%%% TABLE OF CONTENTS
965 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
966 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
969 contentsTitle = "Inhalt / Contents"
971 \paper {
972 tocTitleMarkup = \markup \fill-line{
973 \null
974 \column {
975 \override #(cons 'line-width (* 7 cm))
976 \line{ \fill-line {\piece-title {\contentsTitle} \null }}
977 \hspace #1
979 \null
981 tocItemMarkup = \markup \fill-line {
982 \null
983 \column {
984 \override #(cons 'line-width (* 7 cm ))
985 \line { \fill-line{\fromproperty #'toc:text \fromproperty #'toc:page }}
987 \null
992 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
993 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
994 %%%%% TITLE PAGE / HEADER
995 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
996 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
998 #(define-markup-command (when-property layout props symbol markp) (symbol? markup?)
999 (if (chain-assoc-get symbol props)
1000 (interpret-markup layout props markp)
1001 (ly:make-stencil '() '(1 . -1) '(1 . -1))))
1003 #(define-markup-command (vspace layout props amount) (number?)
1004 "This produces a invisible object taking vertical space."
1005 (let ((amount (* amount 3.0)))
1006 (if (> amount 0)
1007 (ly:make-stencil "" (cons -1 1) (cons 0 amount))
1008 (ly:make-stencil "" (cons -1 1) (cons amount amount)))))
1012 titlePageMarkup = \markup \abs-fontsize #10 \when-property #'header:title \column {
1013 \vspace #4
1014 \fill-line { \fontsize #8 \fromproperty #'header:composer }
1015 \vspace #1
1016 \fill-line { \fontsize #8 \fromproperty #'header:poet }
1017 \vspace #4
1018 \fill-line { \fontsize #10 \bold \fromproperty #'header:titlepagetitle }
1019 \vspace #1
1020 \fontsize #2 \when-property #'header:titlepagesubtitle {
1021 \fill-line { \fromproperty #'header:titlepagesubtitle }
1022 \vspace #1
1024 \fill-line { \postscript #"-20 0 moveto 40 0 rlineto stroke" }
1025 \vspace #8
1026 \fill-line { \fontsize #5 \fromproperty #'header:ensemble }
1027 \vspace #0.02
1028 \fill-line { \fontsize #2 \fromproperty #'header:instruments }
1029 \vspace #9
1030 \fill-line { \fontsize #5 \fromproperty #'header:date }
1031 \vspace #1
1032 \fill-line { \fontsize #5 \fromproperty #'header:scoretype }
1033 \vspace #8
1034 \fontsize #2 \when-property #'header:enteredby {
1035 \fill-line { "Herausgegeben von: / Edited by:"}
1036 \vspace #0.
1037 \fill-line { \fromproperty #'header:enteredby }
1039 \fill-line {
1040 \when-property #'header:arrangement \column {
1041 \vspace #8
1042 \fill-line { \fontsize #3 \fromproperty #'header:arrangement }
1047 titleHeaderMarkup = \markup {
1048 \override #'(baseline-skip . 3.5)
1049 \column {
1050 \override #'(baseline-skip . 3.5)
1051 \column {
1052 \huge \larger \bold
1053 \fill-line {
1054 \larger \fromproperty #'header:title
1056 \fill-line {
1057 \large \smaller \bold
1058 \larger \fromproperty #'header:subtitle
1060 \fill-line {
1061 \smaller \bold
1062 \fromproperty #'header:subsubtitle
1064 \fill-line {
1065 { \large \bold \fromproperty #'header:instrument }
1067 \fill-line {
1068 \fromproperty #'header:poet
1069 \fromproperty #'header:composer
1071 \fill-line {
1072 \fromproperty #'header:meter
1073 \fromproperty #'header:arranger
1079 titleScoreMarkup = \markup \piece-title \fromproperty #'header:piece
1081 \paper {
1082 scoreTitleMarkup = \titleScoreMarkup
1083 bookTitleMarkup = \titleHeaderMarkup
1088 %%%%%%%%%%%%%% headers and footers %%%%%%%%%%%%%%%%%%%%%%%%%%
1090 #(define (first-score-page layout props arg)
1091 (let* ((label 'first-score-page)
1092 (table (ly:output-def-lookup layout 'label-page-table))
1093 (label-page (and (list? table) (assoc label table)))
1094 (page-number (and label-page (cdr label-page)))
1096 (if (eq? (chain-assoc-get 'page:page-number props -1) page-number)
1097 (interpret-markup layout props arg)
1098 empty-stencil)))
1100 #(define no-header-table '())
1101 thisPageNoHeader = #(define-music-function (parser location) ()
1102 (let* ((label (gensym "header")))
1103 (set! no-header-table (cons label no-header-table))
1104 (make-music 'Music
1105 'page-marker #t
1106 'page-label label)))
1109 % TODO: Use the no-header-table!
1110 #(define (is-header-page layout props arg)
1111 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1113 ;(if (and (> page-number 2) (!= page-number 7))
1114 (if (> page-number 1)
1115 (interpret-markup layout props arg)
1116 empty-stencil)))
1118 #(define no-footer-table '())
1119 thisPageNoFooter = #(define-music-function (parser location) ()
1120 (let* ((label (gensym "footer")))
1121 (set! no-footer-table (cons label no-footer-table))
1122 (make-music 'Music
1123 'page-marker #t
1124 'page-label label)))
1126 % TODO: Use the no-footer-table!
1127 #(define (is-footer-page layout props arg)
1128 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1129 (label 'first-score-page)
1130 (table (ly:output-def-lookup layout 'label-page-table))
1131 (label-page (and (list? table) (assoc label table)))
1132 ;(page-number (and label-page (cdr label-page)))
1134 (if (and (> page-number 3) (!= page-number 7))
1135 (interpret-markup layout props arg)
1136 empty-stencil)))
1139 #(define copyright-footer-table '())
1140 thisPageCopyrightFooter = #(define-music-function (parser location) ()
1141 (let* ((label (gensym "copyrightfooter")))
1142 (set! copyright-footer-table (cons label copyright-footer-table))
1143 (make-music 'Music
1144 'page-marker #t
1145 'page-label label)))
1147 #(define copyright-pg 1)
1148 #(define (set-copyright-page page)
1149 (set! copyright-pg page)
1152 % TODO: Use the copyright-footer-table!
1153 #(define (copyright-page layout props arg)
1154 (if (= (chain-assoc-get 'page:page-number props -1) copyright-pg)
1155 (interpret-markup layout props arg)
1156 empty-stencil))
1159 \paper {
1160 oddHeaderMarkup = \markup \fill-line {
1161 %% force the header to take some space, otherwise the
1162 %% page layout becomes a complete mess.
1164 \on-the-fly #is-header-page \fromproperty #'header:title
1165 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1167 evenHeaderMarkup = \markup \fill-line {
1168 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1169 \on-the-fly #is-header-page \fromproperty #'header:composer
1173 oddFooterMarkup = \markup {
1174 \column {
1175 \fill-line {
1176 %% publisher header field only on title page.
1177 \on-the-fly #first-page \fromproperty #'header:publisher
1179 \fill-line {
1180 %% copyright on the first real score page
1181 \on-the-fly #copyright-page \fromproperty #'header:copyright
1182 \on-the-fly #copyright-page \null
1184 \fill-line {
1185 %% All other pages get the number of the edition centered
1186 \on-the-fly #is-footer-page \fromproperty #'header:scorenumber
1203 % Interpret the given markup with the header fields added to the props.
1204 % This way, one can re-use the same functions (using fromproperty
1205 % #'header:field) in the header block and as top-level markup.
1207 % This function is originally copied from mark-up-title (file scm/titling.scm),
1208 % which is lilypond's internal function to handle the title markups. I needed
1209 % to replace the scopes and manually add the $defaultheader (which is internally
1210 % done in paper-book.cc before calling mark-up-title. Also, I don't extract the
1211 % markup from the header block, but use the given markup.
1213 % I'm not sure if I really need the page properties in props, too... But I
1214 % suppose it does not hurt, either.
1215 #(define-markup-command (markupWithHeader layout props markup) (markup?)
1216 "Interpret the given markup with the header fields added to the props.
1217 This way, one can re-use the same functions (using fromproperty
1218 #'header:field) in the header block and as top-level markup."
1219 (let* (
1220 ; TODO: If we are inside a score, add the score's local header block, too!
1221 ; Currently, I only use the global header block, stored in $defaultheader
1222 (scopes (list $defaultheader))
1223 (alists (map ly:module->alist scopes))
1225 (prefixed-alist
1226 (map (lambda (alist)
1227 (map (lambda (entry)
1228 (cons
1229 (string->symbol (string-append "header:" (symbol->string (car entry))))
1230 (cdr entry)))
1231 alist))
1232 alists))
1233 (props (append prefixed-alist
1234 props
1235 (layout-extract-page-properties layout)))
1237 (interpret-markup layout props markup)
1246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1247 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1248 %%%%% Equally spacing multiple columns (e.g. for translations)
1249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1250 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1252 % Credits: Nicolas Sceaux on the lilypond-user mailinglist
1253 #(define-markup-command (columns layout props args) (markup-list?)
1254 (let ((line-width (/ (chain-assoc-get 'line-width props
1255 (ly:output-def-lookup layout 'line-width))
1256 (max (length args) 1))))
1257 (interpret-markup layout props
1258 (make-line-markup (map (lambda (line)
1259 (markup #:pad-to-box `(0 . ,line-width) '(0 . 0)
1260 #:override `(line-width . ,line-width)
1261 line))
1262 args)))))
1268 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1269 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1270 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1272 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1274 \paper {
1275 % left-margin = 2\cm
1276 % right-margin = 2\cm
1277 % line-width = 17\cm
1278 % bottom-margin = 1\cm
1279 % top-margin = 1\cm
1280 % after-title-space = 0.5\cm
1281 ragged-right = ##f
1282 ragged-last = ##f
1283 ragged-bottom = ##f
1284 ragged-last-bottom = ##f
1286 \layout {
1287 \context {
1288 \ChoirStaff
1289 % If only one non-empty staff in a system exists, still print the backet
1290 \override SystemStartBracket #'collapse-height = #1
1291 \consists "Instrument_name_engraver"
1293 \context {
1294 \StaffGroup
1295 % If only one non-empty staff in a system exists, still print the backet
1296 \override SystemStartBracket #'collapse-height = #1
1297 \consists "Instrument_name_engraver"
1299 \context {
1300 \GrandStaff
1301 \override SystemStartBracket #'collapse-height = #1
1302 \consists "Instrument_name_engraver"
1304 \context {
1305 \PianoStaff
1306 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1308 \context {
1309 \FiguredBass
1310 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1311 \override VerticalAxisGroup #'minimum-Y-extent = #'(0 . 1)
1312 \override VerticalAxisGroup #'padding = #0
1314 \context {
1315 \Score
1316 % Force multi-measure rests to be written as one span
1317 \override MultiMeasureRest #'expand-limit = #3
1318 skipBars = ##t
1319 autoBeaming = ##f
1320 % hairpinToBarline = ##f
1321 \override BarNumber #'break-visibility = #end-of-line-invisible
1322 \override CombineTextScript #'avoid-slur = #'outside
1323 barNumberVisibility = #(every-nth-bar-number-visible 5)
1324 \override DynamicTextSpanner #'dash-period = #-1.0
1325 \override InstrumentSwitch #'font-size = #-1
1327 % Rest collision
1328 \override RestCollision #'positioning-done = #merge-rests-on-positioning
1329 % Auto-Accidentals: Use modern-cautionary style...
1330 extraNatural = ##f
1331 autoAccidentals = #`(Staff ,(make-accidental-rule 'same-octave 0))
1332 autoCautionaries = #`(Staff ,(make-accidental-rule 'any-octave 0)
1333 ,(make-accidental-rule 'same-octave 1))
1334 printKeyCancellation = ##t
1336 \context {
1337 \RemoveEmptyStaffContext
1339 \context {
1340 \Lyrics
1341 \override VerticalAxisGroup #'minimum-Y-extent = #'(0.5 . 0.5)
1347 \layout {
1348 \context {
1349 \type "Engraver_group"
1350 \name Dynamics
1351 % So that \cresc works, for example.
1352 \alias Voice
1353 \consists "Output_property_engraver"
1355 \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
1356 pedalSustainStrings = #'("Ped." "*Ped." "*")
1357 pedalUnaCordaStrings = #'("una corda" "" "tre corde")
1359 \consists "Piano_pedal_engraver"
1360 \consists "Script_engraver"
1361 \consists "Dynamic_engraver"
1362 \consists "Text_engraver"
1364 \override TextScript #'font-size = #2
1365 \override TextScript #'font-shape = #'italic
1366 \override DynamicText #'extra-offset = #'(0 . 2.5)
1367 \override Hairpin #'extra-offset = #'(0 . 2.5)
1369 \consists "Skip_event_swallow_translator"
1371 \consists "Axis_group_engraver"
1373 \context {
1374 \PianoStaff
1375 \accepts Dynamics
1376 % \override VerticalAlignment #'forced-distance = #7