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 ("Continuo" "ParallelVoicesStaff" ("BCFb" "BC" "FiguredBass"))
143 ("RealizedContinuo" "PianoStaff" ("BCRealization" "Continuo"))
144 ("BassGroup" "StaffGroup" ("Continuo"))
146 ("P" "PianoStaff" ("PI" "PII"))
147 ("O" "PianoStaff" ("OI" "OII"))
148 ("OI" "ParallelVoicesStaff" ("OIa" "OIb"))
149 ("OII" "ParallelVoicesStaff" ("OIIa" "OIIb"))
150 ("Organ" "SimultaneousMusic" ("OGroup" "RealizedContinuo"))
151 ;("BassGroup" "ParallelVoicesStaff" ("Organ" "O" "BC" "VceB"))
154 ("FullScore" "SimultaneousMusic" ("Wd" "Br" "Perc" "Str" "SoloChoirScore" "O" "RealizedContinuo"))
155 ("LongScore" "SimultaneousMusic" ("WdLong" "BrLong" "Perc" "Str" "SoloChoirScore" "O" "RealizedContinuo"))
156 ("OriginalScore" "SimultaneousMusic" ("BrLong" "WdLong" "Perc" "Str" "SoloChoirScore" "O" "BassGroup"))
159 ;("Piano" "SimultaneousMusic" ("Organ"))
160 ("OrganScore" "SimultaneousMusic" ("ChoralScore" "O"))
161 ("VocalScore" "SimultaneousMusic" ("ChoralScore" "P"))
162 ("Particell" "SimultaneousMusic" ("ChoralScore" "BassGroup"))
164 ; Full scores: Orchestral score and long score including organ
165 ("ChStrQ" "SimultaneousMusic" ("Str" "Ch" "VceB"))
167 #(define oly:orchestral_score_structure oly:fullOrchestraScoreStructure)
169 #(define (oly:set_score_structure struct)
171 (set! oly:orchestral_score_structure struct)
172 (ly:warning (_ "oly:set_score_structure needs an association list as argument!"))
176 #(define (oly:modify_score_structure entry)
178 (set! oly:orchestral_score_structure (assoc-set! oly:orchestral_score_structure (car entry) (cdr entry)))
179 (ly:warning (_ "oly:modify_score_structure expects a list (\"key\" \"type\" '(children)) as argument!"))))
181 #(define (oly:remove_from_score_structure entry)
183 (map oly:remove_from_score_structure entry)
184 (set! oly:orchestral_score_structure (assoc-remove! oly:orchestral_score_structure entry))))
186 orchestralScoreStructure = #(define-music-function (parser location structure) (list?)
187 (oly:set_score_structure structure)
188 (make-music 'Music 'void #t)
191 #(define oly:voice_types '())
193 #(define (oly:set_voice_types types)
195 (set! oly:voice_types types)
196 (ly:warning (_ "oly:set_voice_types needs an association list as argument!"))
200 orchestralVoiceTypes = #(define-music-function (parser location types) (list?)
201 (oly:set_voice_types types)
202 (make-music 'Music 'void #t)
206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
207 % Automatic staff and group generation
208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
210 % Retrieve all music definitions for the given
211 #(define (oly:get_music_object piece instrument)
212 (namedPieceInstrObject piece instrument "Music")
214 #(define (oly:get_music_objects piece instruments)
215 (filter not-null? (map (lambda (i) (oly:get_music_object piece i)) instruments))
218 % Given a property name and the extensions, either generate the pair to set
219 % the property or an empty list, if no pre-defined variable could be found
220 #(define (oly:generate_property_pair prop piece instr type)
221 (let* ((val (namedPieceInstrObject piece instr type)))
222 (if (not-null? val) (list 'assign prop val) '() )
226 #(define (oly:staff_type type)
228 ((string? type) (string->symbol type))
229 ((symbol? type) type)
234 #(define (oly:extractPitch music)
236 (elems (if (ly:music? music) (ly:music-property music 'elements)))
237 (note (if (pair? elems) (car elems)))
238 (pitch (if (ly:music? note) (ly:music-property note 'pitch)))
240 (if (and (not-null? music) (not (ly:pitch? pitch)))
241 (ly:warning "Unable to interpret as a pitch!")
247 #(define (oly:extractTranspositionPitch piece name)
249 (trpFromPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeFrom")))
250 (trpToPitch (oly:extractPitch (namedPieceInstrObject piece name "TransposeTo")))
252 (if (ly:pitch? trpFromPitch)
253 (if (ly:pitch? trpToPitch)
255 (ly:pitch-diff trpFromPitch trpToPitch)
256 (ly:pitch-diff trpFromPitch (ly:make-pitch 0 0 0))
258 (if (ly:pitch? trpToPitch)
259 (ly:pitch-diff (ly:make-pitch 0 0 0) trpToPitch)
266 #(define (oly:musiccontent_for_voice parser piece name music additional)
267 (let* ((musiccontent additional))
269 ; Append the settings, key and clef (if defined)
272 (let* ((object (namedPieceInstrObject piece name type)))
273 (if (ly:music? object)
274 (set! musiccontent (append musiccontent (list (ly:music-deep-copy object))))
275 (if (not-null? object) (ly:warning (_ "Wrong type (no ly:music) for ~S for instrument ~S in piece ~S") type name piece))
279 ; TODO: Does the "Tempo" work here???
280 '("Settings" "Key" "Clef" "TimeSignature" ;"Tempo"
284 (if (ly:music? music)
286 (set! musiccontent (make-simultaneous-music (append musiccontent (list music))))
287 ;(ly:message "Generating staff for ~a" name)
288 (let* ((trpPitch (oly:extractTranspositionPitch piece name)))
289 (if (ly:pitch? trpPitch)
290 (set! musiccontent (ly:music-transpose musiccontent trpPitch))
295 ; For empty music, return empty
301 #(define (oly:lyrics_create_single_context parser piece name voicename lyricsid)
302 ; If we have lyrics, create a lyrics context containing LyricCombineMusic
303 ; and add that as second element to the staff's elements list...
304 (let* ((id (string-append "Lyrics" lyricsid))
305 (lyrics (namedPieceInstrObject piece name id)))
306 (if (ly:music? lyrics)
307 (context-spec-music (make-music 'LyricCombineMusic
309 'associated-context voicename)
310 'Lyrics (oly:generate_object_name piece name id))
315 #(define (oly:lyrics_create_contexts parser piece name voicename)
318 (oly:lyrics_create_single_context parser piece name voicename str))
319 (list "" "I" "II" "III" "IV" "V" "VI"))))
321 #(define (oly:voice_handler_internal parser piece name type music)
322 (if (ly:music? music)
324 (voicename (oly:generate_object_name piece name "Voice" ))
325 (lyrics (oly:lyrics_create_contexts parser piece name voicename))
326 (additional (if (not-null? lyrics) (list dynamicUp) '()))
327 (musiccontent (oly:musiccontent_for_voice parser piece name music additional))
328 (voicetype (oly:staff_type type))
329 (voice (context-spec-music musiccontent voicetype voicename))
333 ; For empty music, return empty
338 #(define (oly:voice_handler parser piece name type)
339 (oly:voice_handler_internal parser piece name type (oly:get_music_object piece name)))
342 #(define (oly:staff_handler_internal parser piece name type voices)
343 (if (not-null? voices)
345 (staffname (oly:generate_staff_name piece name))
346 (stafftype (oly:staff_type type))
347 (staff (make-simultaneous-music voices))
348 (propops (oly:staff_handler_properties piece name))
351 ((SimultaneousMusic ParallelMusic) #f)
352 (else (set! staff (context-spec-music staff stafftype staffname)))
354 (if (not-null? propops)
355 (set! (ly:music-property staff 'property-operations) propops)
359 ; For empty music, return empty
364 #(define (oly:staff_handler parser piece name type children)
365 (let* ((c (if (not-null? children) children (list name)))
366 (voices (apply append (map (lambda (v) (oly:create_voice parser piece v)) c)) )
368 (if (not-null? voices)
369 (oly:staff_handler_internal parser piece name type voices)
375 #(define (oly:devnull_handler parser piece name type children)
376 (oly:voice_handler parser piece name type)
379 #(define (oly:parallel_voices_staff_handler parser piece name type children)
381 (voices (map (lambda (i) (oly:create_voice parser piece i)) children))
382 ; get the list of non-empty voices and flatten it!
383 (nonemptyvoices (apply append (filter not-null? voices)))
385 (if (not-null? nonemptyvoices)
386 (oly:staff_handler_internal parser piece name "Staff" nonemptyvoices)
392 #(define (oly:part_combined_staff_handler parser piece name type children)
393 (let* ((rawmusic (map (lambda (c) (oly:musiccontent_for_voice parser piece name (oly:get_music_object piece c) '())) children))
394 (music (filter not-null? rawmusic)))
396 ((and (pair? music) (ly:music? (car music)) (not-null? (cdr music)) (ly:music? (cadr music)))
397 ;(ly:message "Part-combine with two music expressions")
398 (oly:staff_handler_internal parser piece name "Staff" (list (make-part-combine-music parser music))))
400 ;;(ly:warning "Part-combine without any music expressions")
402 ; exactly one is a music expression, simply use that by joining
404 ;;(ly:message "Part-combine with only one music expressions")
405 (oly:staff_handler_internal parser piece name "Staff" (list (apply append music))))
407 ;(ly:message "make_part_combined_staff: ~S ~S ~a" piece instr instruments)
413 % Generate the properties for the staff for piece and instr. Typically, these
414 % are the instrument name and the short instrument name (if defined).
415 % return a (possibly empty) list of all assignments.
416 #(define (oly:staff_handler_properties piece instr)
419 (instrumentName . "InstrumentName")
420 (shortInstrumentName . "ShortInstrumentName")
421 (midiInstrument . "MidiInstrument")
425 (oly:generate_property_pair (car pr) piece instr (cdr pr))
428 (props (filter not-null? assignments))
434 % Figured bass is a special case, as it can be voice- or staff-type. When
435 % given as a staff type, simply call the voice handler, instead
437 #(define (oly:figured_bass_staff_handler parser piece name type children)
438 (let* ((c (if (not-null? children) children (list name)))
439 (voice (oly:voice_handler parser piece (car c) type)))
440 (if (pair? voice) (car voice) ())
444 #(define (flatten lst)
445 (define (f remaining result)
447 ((null? remaining) result)
448 ((pair? (car remaining)) (f (cdr remaining) (f (car remaining) result)))
449 (else (f (cdr remaining) (cons (car remaining) result)))))
450 (reverse! (f lst '())))
452 #(define (oly:staff_group_handler parser piece name type children)
454 (staves (flatten (map (lambda (i) (oly:create_staff_or_group parser piece i)) children)))
455 (nonemptystaves (filter not-null? staves))
457 (if (not-null? nonemptystaves)
459 (musicexpr (if (= 1 (length nonemptystaves))
461 (make-simultaneous-music nonemptystaves)))
462 (groupname (oly:generate_staff_name piece name))
463 (grouptype (oly:staff_type type))
465 (propops (oly:staff_handler_properties piece name))
468 ((SimultaneousMusic ParallelMusic) #f)
469 (else (set! group (context-spec-music group grouptype groupname)))
472 (set! (ly:music-property group 'property-operations) propops))
475 ; Return empty list if no staves are generated
481 #(define (oly:create_voice parser piece name)
482 (let* ( (voice (namedPieceInstrObject piece name "Voice"))
483 (type (assoc-ref oly:voice_types name)) )
484 (if (not-null? voice)
485 ; Explicit voice variable, use that
489 ; No entry in structure found => simple voice
490 (oly:voice_handler parser piece name "Voice")
491 ; Entry found in structure => use the handler for the given type
493 (voicetype (car type))
494 (handler (assoc-ref oly:voice_handlers voicetype))
497 ((primitive-eval handler) parser piece name voicetype)
499 (ly:warning "No handler found for voice type ~a, using default voice handler" voicetype)
500 (oly:voice_handler parser piece name voicetype)
509 #(define (oly:create_staff_or_group parser piece name)
510 (let* ( (staff (namedPieceInstrObject piece name "Staff"))
511 (type_from_structure (assoc-ref oly:orchestral_score_structure name)) )
512 ;(if (not-null? staff)
513 ; (ly:message "Found staff variable for instrument ~a in piece ~a" instr piece)
514 ; (ly:message "Staff variable for instrument ~a in piece ~a NOT FOUND" instr piece)
516 (if (not-null? staff)
517 ; Explicit staff variable, use that
520 (if (not (list? type_from_structure))
521 ; No entry in structure found => simple staff
522 (oly:staff_handler parser piece name "Staff" '())
524 ; Entry found in structure => use the handler for the given type
525 (let* ((type (car type_from_structure))
526 (handler (assoc-ref oly:staff_handlers type))
527 (children (cadr type_from_structure))
530 ((primitive-eval handler) parser piece name type children)
532 (ly:warning "No handler found for staff type ~a, using default staff handler" type)
533 (oly:staff_handler parser piece name type children)
542 #(define oly:staff_handlers
545 '("GrandStaff" . oly:staff_group_handler )
546 '("PianoStaff" . oly:staff_group_handler )
547 '("ChoirStaff" . oly:staff_group_handler )
548 '("StaffGroup" . oly:staff_group_handler )
549 '("InnerChoirStaff" . oly:staff_group_handler )
550 '("InnerStaffGroup" . oly:staff_group_handler )
551 '("ParallelMusic" . oly:staff_group_handler )
552 '("SimultaneousMusic" . oly:staff_group_handler )
554 '("Staff" . oly:staff_handler )
555 '("DrumStaff" . oly:staff_handler )
556 '("RhythmicStaff" . oly:staff_handler )
557 '("TabStaff" . oly:staff_handler )
558 '("GregorianTranscriptionStaff" . oly:staff_handler )
559 '("MensuralStaff" . oly:staff_handler )
560 '("VaticanaStaff" . oly:staff_handler )
561 ; staves with multiple voices
562 '("PartCombinedStaff" . oly:part_combined_staff_handler )
563 '("ParallelVoicesStaff" . oly:parallel_voices_staff_handler )
564 ; special cases: Figured bass can be staff or voice type!
565 '("FiguredBass" . oly:figured_bass_staff_handler )
566 ; Devnull is like a staff, only that it doesn't craete output
567 '("Devnull" . oly:devnull_handler )
571 #(define oly:voice_handlers
574 '("Voice" . oly:voice_handler )
575 '("CueVoice" . oly:voice_handler )
576 '("DrumVoice" . oly:voice_handler )
577 '("FiguredBass" . oly:voice_handler )
578 '("GregorianTranscriptionVoice" . oly:voice_handler )
579 '("NoteNames" . oly:voice_handler )
580 '("TabVoice" . oly:voice_handler )
581 '("VaticanaVoice" . oly:voice_handler )
582 ;'("Dynamics" . oly:dynamics_handler )
587 #(define (oly:register_staff_type_handler type func)
588 ; (ly:message "Registering staff handler ~a for type ~a" func type)
589 (set! oly:staff_handlers (assoc-set! oly:staff_handlers type func))
592 #(define (oly:register_voice_type_handler type func)
593 ; (ly:message "Registering voice type handler ~a for type ~a" func type)
594 (set! oly:voice_handlers (assoc-set! oly:voice_handlers type func))
597 % handlers for deprecated API
598 #(oly:register_staff_type_handler 'StaffGroup 'oly:staff_group_handler)
599 #(oly:register_staff_type_handler 'GrandStaff 'oly:staff_group_handler)
600 #(oly:register_staff_type_handler 'PianoStaff 'oly:staff_group_handler)
601 #(oly:register_staff_type_handler 'ChoirStaff 'oly:staff_group_handler)
602 #(oly:register_staff_type_handler 'Staff 'oly:staff_handler )
603 #(oly:register_staff_type_handler 'ParallelMusic 'oly:staff_group_handler)
604 #(oly:register_staff_type_handler 'SimultaneousMusic 'oly:staff_group_handler)
605 #(oly:register_staff_type_handler #t 'oly:part_combined_staff_handler )
606 #(oly:register_staff_type_handler #f 'oly:parallel_voices_staff_handler )
610 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
611 % Automatic score generation
612 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
614 #(define oly:score_handler add-score)
615 #(define oly:music_handler add-music)
616 #(define oly:text_handler add-text)
620 setUseBook = #(define-music-function (parser location usebook) (boolean?)
621 (ly:warning "\\setUseBook has been deprecated! Books are now automatically handled without any hacks")
622 (make-music 'Music 'void #t)
626 % Two functions to handle midi-blocks: Either don't set one, or set an empty
627 % one so that MIDI is generated
628 #(define (oly:set_no_midi_block score) '())
629 #(define (oly:set_midi_block score)
630 (let* ((midiblock (if (defined? '$defaultmidi)
631 (ly:output-def-clone $defaultmidi)
632 (ly:make-output-def))))
633 (ly:output-def-set-variable! midiblock 'is-midi #t)
634 (ly:score-add-output-def! score midiblock)
638 % \setCreateMidi ##t/##f sets a flag to determine wheter MIDI output should
640 #(define oly:apply_score_midi oly:set_no_midi_block)
641 setCreateMIDI = #(define-music-function (parser location createmidi) (boolean?)
643 (set! oly:apply_score_midi oly:set_midi_block)
644 (set! oly:apply_score_midi oly:set_no_midi_block)
646 (make-music 'Music 'void #t)
650 % Two functions to handle layout-blocks: Either don't set one, or set an empty
651 % one so that a PDF is generated
652 #(define (oly:set_no_layout_block score) '())
653 #(define (oly:set_layout_block score)
654 (let* ((layoutblock (if (defined? '$defaultlayout)
655 (ly:output-def-clone $defaultlayout)
656 (ly:make-output-def))))
657 (ly:output-def-set-variable! layoutblock 'is-layout #t)
658 (ly:score-add-output-def! score layoutblock)
662 % \setCreatePDF ##t/##f sets a flag to determine wheter PDF output should
664 #(define oly:apply_score_layout oly:set_no_layout_block)
665 setCreatePDF = #(define-music-function (parser location createlayout) (boolean?)
667 (set! oly:apply_score_layout oly:set_layout_block)
668 (set! oly:apply_score_layout oly:set_no_layout_block)
670 (make-music 'Music 'void #t)
674 % Set the piece title in a new header block.
675 #(define (oly:set_piece_header score piecename)
676 (if (not-null? piecename)
677 (let* ((header (make-module)))
678 (module-define! header 'piece piecename)
679 (ly:score-set-header! score header)
685 % post-filter functions. By default, no filtering is done. However,
686 % for the *NoCues* function, the cue notes should be killed
687 identity = #(define-music-function (parser location music) (ly:music?) music)
688 cuefilter = #(define-music-function (parser location music) (ly:music?)
689 ((ly:music-function-extract removeWithTag) parser location 'cued ((ly:music-function-extract killCues) parser location music))
693 #(define (oly:create-toc-file layout pages)
694 (let* ((label-table (ly:output-def-lookup layout 'label-page-table)))
695 (if (not (null? label-table))
696 (let* ((format-line (lambda (toc-item)
697 (let* ((label (car toc-item))
698 (text (caddr toc-item))
699 (label-page (and (list? label-table)
700 (assoc label label-table)))
701 (page (and label-page (cdr label-page))))
702 (format #f "~a, section, 1, {~a}, ~a" page text label))))
703 (formatted-toc-items (map format-line (toc-items)))
704 (whole-string (string-join formatted-toc-items ",\n"))
705 (output-name (ly:parser-output-name parser))
706 (outfilename (format "~a.toc" output-name))
707 (outfile (open-output-file outfilename)))
708 (if (output-port? outfile)
709 (display whole-string outfile)
710 (ly:warning (_ "Unable to open output file ~a for the TOC information") outfilename))
711 (close-output-port outfile)))))
714 #(define-public (oly:add-toc-item parser markup-symbol text)
715 (oly:music_handler parser (add-toc-item! markup-symbol text)))
718 #(define (oly:add-score parser score piecename)
719 (if (not-null? piecename)
720 (oly:add-toc-item parser 'tocItemMarkup piecename))
721 (oly:score_handler parser score)
723 % The helper function to build a score.
724 #(define (oly:createScoreHelper parser location piece children func)
726 (staves (oly:staff_group_handler parser piece "" "SimultaneousMusic" children))
727 (music (if (not-null? staves)
728 ((ly:music-function-extract func) parser location staves)
732 (piecename (namedPieceInstrObject piece (car children) "PieceName"))
733 (piecenametacet (namedPieceInstrObject piece (car children) "PieceNameTacet"))
737 ; No staves, print tacet
739 (if (not-null? piecenametacet) (set! piecename piecenametacet))
740 (if (not-null? piecename)
741 (oly:add-score parser (list (oly:piece-title-markup piecename)) piecename)
742 (ly:warning (_ "No music and no score title found for part ~a and instrument ~a") piece children)
745 ; we have staves, apply the piecename to the score and add layout/midi blocks if needed
747 (set! score (scorify-music music parser))
748 (oly:set_piece_header score piecename)
749 (oly:apply_score_midi score)
750 (oly:apply_score_layout score)
751 ; Schedule the score for typesetting
752 (oly:add-score parser score piecename)
756 ; This is a void function, the score has been schedulled for typesetting already
757 (make-music 'Music 'void #t)
760 createScore = #(define-music-function (parser location piece children) (string? list?)
761 (oly:createScoreHelper parser location piece children identity)
763 createNoCuesScore = #(define-music-function (parser location piece children) (string? list?)
764 (oly:createScoreHelper parser location piece children cuefilter)
767 createHeadline = #(define-music-function (parser location headline) (string?)
768 (oly:add-toc-item parser 'tocItemMarkup headline)
769 (oly:score_handler parser (list (oly:piece-title-markup headline)))
770 (make-music 'Music 'void #t)
775 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
776 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
778 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
779 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
781 newInstrument = #(define-music-function (parser location instr) (string?)
783 \set Voice.instrumentCueName = #$(string-join (list "+" instr))
786 cueText = #(define-music-function (parser location instr) (string?)
788 \set Voice.instrumentCueName = $instr
792 clearCueText = #(define-music-function (parser location) ()
794 \unset Voice.instrumentCueName
798 insertCueText = #(define-music-function (parser location instr) (string?)
799 (if (string-null? instr)
800 #{ \tag #'cued \clearCueText #}
801 #{ \tag #'cued \cueText #$instr #}
804 % generate a cue music section with instrument names
805 % Parameters: \namedCueDuring NameOfQuote CueDirection CueInstrument OriginalInstrument music
806 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
807 % -) CueInstrument and OriginalInstrument are the displayed instrument names
809 % \namedCueDuring #"vIQuote" #UP #"V.I" #"Sop." { R1*3 }
810 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
811 % the beginning of the cue notes and "Sop." at the end
812 namedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr cuemusic) (string? number? string? string? ly:music?)
814 \cueDuring #$cuevoice #$direction {
815 \insertCueText #$instrcue
817 \insertCueText #$instr
821 namedTransposedCueDuring = #(define-music-function (parser location cuevoice direction instrcue instr trans cuemusic) (string? number? string? string? ly:music? ly:music?)
823 \transposedCueDuring #$cuevoice #$direction $trans {
824 \insertCueText #$instrcue
826 \insertCueText #$instr
831 % set the cue instrument name and clef
832 setClefCue = #(define-music-function (parser location instr clef)
835 \once \override Staff.Clef #'font-size = #-3 $clef
836 \insertCueText $instr
839 % generate a cue music section with instrument names and clef changes
840 % Parameters: \cleffedCueDuring NameOfQuote CueDirection CueInstrument CueClef OriginalInstrument OriginalClef music
841 % -) NameOfQuote CueDirection music are the parameters for \cueDuring
842 % -) CueInstrument and OriginalInstrument are the displayed instrument names
843 % -) CueClef and OriginalClef are the clefs for the the cue notes and the clef of the containing voice
845 % \cleffedCueDuring #"vIQuote" #UP #"V.I" #"treble" #"Basso" #"bass" { R1*3 }
846 % This adds the notes from vIQuote (defined via \addQuote) to three measures, prints "V.I" at
847 % the beginning of the cue notes and "Basso" at the end. The clef is changed to treble at the
848 % beginning of the cue notes and reset to bass at the end
849 cleffedCueDuring = #(define-music-function (parser location cuevoice direction instrcue clefcue instr clefinstr cuemusic)
850 (string? number? string? ly:music? string? ly:music? ly:music?)
852 \cueDuring #$cuevoice #$direction {
853 \tag #'cued \setClefCue #$instrcue $clefcue
855 \tag #'cued \setClefCue #$instr $clefinstr
863 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
864 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
866 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
867 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
870 dynamicsX = #(define-music-function (parser location offset) (number?)
872 \once \override DynamicText #'X-offset = $offset
873 \once \override DynamicLineSpanner #'Y-offset = #0
876 % Move the dynamic sign inside the staff to a fixed staff-relative position
877 % posY (where 0 means vertically starts at the middle staff line)
878 dynamicsAllInside = #(define-music-function (parser location offsetX posY)
881 % Invalid y-extent -> hidden from skyline calculation and collisions
882 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
883 % move by X offset and to fixed Y-position (use Y-offset of parent!)
884 \once \override DynamicText #'X-offset = $offsetX
885 \once \override DynamicText #'Y-offset =
887 (let* ((head (ly:grob-parent grob Y))
888 (offset (ly:grob-property head 'Y-offset)))
889 (- posY offset (- 0.6))))
890 \once \override DynamicLineSpanner #'Y-offset = $posY
893 dynamicsUpInside = #(define-music-function (parser location offsetX) (number?)
894 ((ly:music-function-extract dynamicsAllInside) parser location offsetX 1.5)
897 dynamicsDownInside = #(define-music-function (parser location offsetX) (number?)
898 ((ly:music-function-extract dynamicsAllInside) parser location offsetX -3.5)
901 hairpinOffset = #(define-music-function (parser location posY) (number?)
903 \once \override DynamicLineSpanner #'Y-offset = $posY
904 \once \override DynamicLineSpanner #'Y-extent = #(cons +0 -0.01)
907 #(define ((line-break-offset before after) grob)
908 (let* ((orig (ly:grob-original grob))
909 ; All siblings if line-broken:
910 (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '() )))
911 (if (>= (length siblings) 2)
912 ; We have been line-broken
913 (if (eq? (car (last-pair siblings)) grob)
915 (ly:grob-set-property! grob 'Y-offset after)
916 ; Others get the before value:
917 (ly:grob-set-property! grob 'Y-offset before)
923 ffz = #(make-dynamic-script "ffz")
924 pf = #(make-dynamic-script "pf")
925 sempp = #(make-dynamic-script (markup #:line( #:with-dimensions '(0 . 0)
926 '(0 . 0) #:right-align #:normal-text #:italic "sempre" #:dynamic "pp")))
927 parenf = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "f" #:normal-text #:italic #:fontsize 2 ")" )))
928 parenp = #(make-dynamic-script (markup #:line(#:normal-text #:italic #:fontsize 2 "(" #:dynamic "p" #:normal-text #:italic #:fontsize 2 ")" )))
929 pdolce = #(make-dynamic-script (markup #:line(#:dynamic "p" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
930 sfpdolce = #(make-dynamic-script (markup #:line(#:dynamic "sfp" #:with-dimensions '(0 . 0) '(0 . 0) #:normal-text #:italic "dolce" )))
931 bracketf = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 3 "[" #:dynamic "f" #:hspace 0.1 #:normal-text #:fontsize 3 "]"))))
932 bracketp = #(make-dynamic-script (markup #:line(#:concat(#:normal-text #:fontsize 2 "[" #:hspace 0.2 #:dynamic "p" #:normal-text #:fontsize 2 "]"))))
936 % cresc = #(make-music 'CrescendoEvent 'span-direction START 'crescendoSpanner 'text 'crescendoText "cresc.")
937 % endcresc = #(make-span-event 'CrescendoEvent STOP)
938 % dim = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "dim.")
939 % enddim = #(make-span-event 'DecrescendoEvent STOP)
940 % decresc = #(make-music 'DecrescendoEvent 'span-direction START 'decrescendoSpanner 'text 'decrescendoText "decresc.")
941 % enddecresc = #(make-span-event 'DecrescendoEvent STOP)
946 cresc = #(make-music 'CrescendoEvent 'span-direction START
947 'span-type 'text 'span-text "cresc.")
948 dim = #(make-music 'DecrescendoEvent 'span-direction START
949 'span-type 'text 'span-text "dim.")
950 decresc = #(make-music 'DecrescendoEvent 'span-direction START
951 'span-type 'text 'span-text "decresc.")
953 newOrOldClef = #(define-music-function (parser location new old ) (string? string?)
954 (if (ly:get-option 'old-clefs) #{ \clef $old #} #{ \clef $new #})
959 %%% Thanks to "Gilles THIBAULT" <gilles.thibault@free.fr>, there is a way
960 % to remove also the fermata from R1-\fermataMarkup: By filtering the music
961 % and removing the corresponding events.
962 % Documented as an LSR snippet: http://lsr.dsi.unimi.it/LSR/Item?id=372
963 #(define (filterOneEventsMarkup event)
964 ( let ( (eventname (ly:music-property event 'name)) )
966 (or ;; add here event name you do NOT want
967 (eq? eventname 'MultiMeasureTextEvent)
968 (eq? eventname 'AbsoluteDynamicEvent)
969 (eq? eventname 'TextScriptEvent)
970 (eq? eventname 'ArticulationEvent)
971 (eq? eventname 'CrescendoEvent)
972 (eq? eventname 'DecrescendoEvent)
977 filterArticulations = #(define-music-function (parser location music) (ly:music?)
978 (music-filter filterOneEventsMarkup music)
985 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
986 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
988 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
989 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
993 rit = \markup {\italic "rit."}
994 pocorit = \markup {\italic "poco rit."}
995 ppmosso = \markup {\italic "poco più mosso"}
996 dolce = \markup {\italic "dolce"}
997 pizz = \markup {\italic "pizz."}
998 arco = \markup {\italic "arco"}
999 perd = \markup {\italic "perdend."}
1004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1005 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1006 %%%%% REST COMBINATION
1007 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1012 %% REST COMBINING, TAKEN FROM http://lsr.dsi.unimi.it/LSR/Item?id=336
1015 %% \new Staff \with {
1016 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1017 %% } << \somevoice \\ \othervoice >>
1022 %% \override RestCollision #'positioning-done = #merge-rests-on-positioning
1027 %% - only handles two voices
1028 %% - does not handle multi-measure/whole-measure rests
1030 #(define (rest-score r)
1032 (yoff (ly:grob-property-data r 'Y-offset))
1033 (sp (ly:grob-property-data r 'staff-position)))
1035 (set! score (+ score 2))
1036 (if (eq? yoff 'calculation-in-progress)
1037 (set! score (- score 3))))
1040 (set! score (+ score 2))
1041 (set! score (- score (abs (- 1 sp)))))
1044 #(define (merge-rests-on-positioning grob)
1045 (let* ((can-merge #f)
1046 (elts (ly:grob-object grob 'elements))
1047 (num-elts (and (ly:grob-array? elts)
1048 (ly:grob-array-length elts)))
1049 (two-voice? (= num-elts 2)))
1051 (let* ((v1-grob (ly:grob-array-ref elts 0))
1052 (v2-grob (ly:grob-array-ref elts 1))
1053 (v1-rest (ly:grob-object v1-grob 'rest))
1054 (v2-rest (ly:grob-object v2-grob 'rest)))
1058 (let* ((v1-duration-log (ly:grob-property v1-rest 'duration-log))
1059 (v2-duration-log (ly:grob-property v2-rest 'duration-log))
1060 (v1-dot (ly:grob-object v1-rest 'dot))
1061 (v2-dot (ly:grob-object v2-rest 'dot))
1062 (v1-dot-count (and (ly:grob? v1-dot)
1063 (ly:grob-property v1-dot 'dot-count -1)))
1064 (v2-dot-count (and (ly:grob? v2-dot)
1065 (ly:grob-property v2-dot 'dot-count -1))))
1068 (number? v1-duration-log)
1069 (number? v2-duration-log)
1070 (= v1-duration-log v2-duration-log)
1071 (eq? v1-dot-count v2-dot-count)))
1073 ;; keep the rest that looks best:
1074 (let* ((keep-v1? (>= (rest-score v1-rest)
1075 (rest-score v2-rest)))
1076 (rest-to-keep (if keep-v1? v1-rest v2-rest))
1077 (dot-to-kill (if keep-v1? v2-dot v1-dot)))
1078 ;; uncomment if you're curious of which rest was chosen:
1079 ;;(ly:grob-set-property! v1-rest 'color green)
1080 ;;(ly:grob-set-property! v2-rest 'color blue)
1081 (ly:grob-suicide! (if keep-v1? v2-rest v1-rest))
1082 (if (ly:grob? dot-to-kill)
1083 (ly:grob-suicide! dot-to-kill))
1084 (ly:grob-set-property! rest-to-keep 'direction 0)
1085 (ly:rest::y-offset-callback rest-to-keep)))))))
1088 (ly:rest-collision::calc-positioning-done grob))))
1094 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1095 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1096 %%%%% TABLE OF CONTENTS
1097 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1098 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1101 contentsTitle = "Inhalt / Contents"
1104 tocTitleMarkup = \markup \fill-line{
1107 \override #(cons 'line-width (* 7 cm))
1108 \line{ \fill-line {\piece-title {\contentsTitle} \null }}
1113 tocItemMarkup = \markup \fill-line {
1116 \override #(cons 'line-width (* 7 cm ))
1117 \line { \fill-line{\fromproperty #'toc:text \fromproperty #'toc:page }}
1124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1126 %%%%% TITLE PAGE / HEADER
1127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1130 #(define-markup-command (when-property layout props symbol markp) (symbol? markup?)
1131 (if (chain-assoc-get symbol props)
1132 (interpret-markup layout props markp)
1133 (ly:make-stencil '() '(1 . -1) '(1 . -1))))
1135 #(define-markup-command (vspace layout props amount) (number?)
1136 "This produces a invisible object taking vertical space."
1137 (let ((amount (* amount 3.0)))
1139 (ly:make-stencil "" (cons -1 1) (cons 0 amount))
1140 (ly:make-stencil "" (cons -1 1) (cons amount amount)))))
1144 titlePageMarkup = \markup \abs-fontsize #10 \when-property #'header:title \column {
1146 \fill-line { \fontsize #8 \fromproperty #'header:composer }
1148 \fill-line { \fontsize #8 \fromproperty #'header:poet }
1150 \fill-line { \fontsize #10 \bold \fromproperty #'header:titlepagetitle }
1152 \fontsize #2 \when-property #'header:titlepagesubtitle {
1153 \fill-line { \fromproperty #'header:titlepagesubtitle }
1156 \fill-line { \postscript #"-20 0 moveto 40 0 rlineto stroke" }
1158 \fill-line { \fontsize #5 \fromproperty #'header:ensemble }
1160 \fill-line { \fontsize #2 \fromproperty #'header:instruments }
1162 \fill-line { \fontsize #5 \fromproperty #'header:date }
1164 \fill-line { \fontsize #5 \fromproperty #'header:scoretype }
1166 \fontsize #2 \when-property #'header:enteredby {
1167 \fill-line { "Herausgegeben von: / Edited by:"}
1169 \fill-line { \fromproperty #'header:enteredby }
1172 \when-property #'header:arrangement \column {
1174 \fill-line { \fontsize #3 \fromproperty #'header:arrangement }
1179 titleHeaderMarkup = \markup {
1180 \override #'(baseline-skip . 3.5)
1183 \fromproperty #'header:logo
1185 \huge \larger \bold \larger \fromproperty #'header:title
1186 \large \smaller \bold \larger \fromproperty #'header:subtitle
1187 \smaller \bold \fromproperty #'header:subsubtitle
1189 \bold \when-property #'header:instrument \rounded-box \fromproperty #'header:instrument
1192 \with-dimensions #'( 0 . 0) #'( 0 . 1 ) \null
1196 % { \large \bold \fromproperty #'header:instrument }
1199 \fromproperty #'header:poet
1200 \fromproperty #'header:composer
1203 \fromproperty #'header:meter
1204 \fromproperty #'header:arranger
1209 titleScoreMarkup = \markup \piece-title \fromproperty #'header:piece
1212 scoreTitleMarkup = \titleScoreMarkup
1213 bookTitleMarkup = \titleHeaderMarkup
1218 %%%%%%%%%%%%%% headers and footers %%%%%%%%%%%%%%%%%%%%%%%%%%
1220 #(define (first-score-page layout props arg)
1221 (let* ((label 'first-score-page)
1222 (table (ly:output-def-lookup layout 'label-page-table))
1223 (label-page (and (list? table) (assoc label table)))
1224 (page-number (and label-page (cdr label-page)))
1226 (if (eq? (chain-assoc-get 'page:page-number props -1) page-number)
1227 (interpret-markup layout props arg)
1230 #(define no-header-table '())
1231 thisPageNoHeader = #(define-music-function (parser location) ()
1232 (let* ((label (gensym "header")))
1233 (set! no-header-table (cons label no-header-table))
1236 'page-label label)))
1239 % TODO: Use the no-header-table!
1240 #(define (is-header-page layout props arg)
1241 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1243 ;(if (and (> page-number 2) (!= page-number 7))
1244 (if (> page-number 1)
1245 (interpret-markup layout props arg)
1248 #(define no-footer-table '())
1249 thisPageNoFooter = #(define-music-function (parser location) ()
1250 (let* ((label (gensym "footer")))
1251 (set! no-footer-table (cons label no-footer-table))
1254 'page-label label)))
1256 % TODO: Use the no-footer-table!
1257 #(define (is-footer-page layout props arg)
1258 (let* ((page-number (chain-assoc-get 'page:page-number props -1))
1259 (label 'first-score-page)
1260 (table (ly:output-def-lookup layout 'label-page-table))
1261 (label-page (and (list? table) (assoc label table)))
1262 ;(page-number (and label-page (cdr label-page)))
1264 (if (and (> page-number 1))
1265 (interpret-markup layout props arg)
1269 #(define copyright-footer-table '())
1270 thisPageCopyrightFooter = #(define-music-function (parser location) ()
1271 (let* ((label (gensym "copyrightfooter")))
1272 (set! copyright-footer-table (cons label copyright-footer-table))
1275 'page-label label)))
1277 #(define copyright-pg 1)
1278 #(define (set-copyright-page page)
1279 (set! copyright-pg page)
1282 % TODO: Use the copyright-footer-table!
1283 #(define (copyright-page layout props arg)
1284 (if (= (chain-assoc-get 'page:page-number props -1) copyright-pg)
1285 (interpret-markup layout props arg)
1290 oddHeaderMarkup = \markup \fill-line {
1291 %% force the header to take some space, otherwise the
1292 %% page layout becomes a complete mess.
1294 \on-the-fly #is-header-page \fromproperty #'header:title
1295 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1297 evenHeaderMarkup = \markup \fill-line {
1298 \on-the-fly #is-header-page \fromproperty #'page:page-number-string
1299 \on-the-fly #is-header-page \fromproperty #'header:composer
1303 oddFooterMarkup = \markup {
1306 %% publisher header field only on title page.
1307 \on-the-fly #first-page \fromproperty #'header:publisher
1310 %% copyright on the first real score page
1311 \on-the-fly #copyright-page \fromproperty #'header:copyright
1312 \on-the-fly #copyright-page \null
1315 %% All other pages get the number of the edition centered
1316 \on-the-fly #is-footer-page \fromproperty #'header:scorenumber
1333 % Interpret the given markup with the header fields added to the props.
1334 % This way, one can re-use the same functions (using fromproperty
1335 % #'header:field) in the header block and as top-level markup.
1337 % This function is originally copied from mark-up-title (file scm/titling.scm),
1338 % which is lilypond's internal function to handle the title markups. I needed
1339 % to replace the scopes and manually add the $defaultheader (which is internally
1340 % done in paper-book.cc before calling mark-up-title. Also, I don't extract the
1341 % markup from the header block, but use the given markup.
1343 % I'm not sure if I really need the page properties in props, too... But I
1344 % suppose it does not hurt, either.
1345 #(define-markup-command (markupWithHeader layout props markup) (markup?)
1346 "Interpret the given markup with the header fields added to the props.
1347 This way, one can re-use the same functions (using fromproperty
1348 #'header:field) in the header block and as top-level markup."
1350 ; TODO: If we are inside a score, add the score's local header block, too!
1351 ; Currently, I only use the global header block, stored in $defaultheader
1352 (scopes (list $defaultheader))
1353 (alists (map ly:module->alist scopes))
1356 (map (lambda (alist)
1357 (map (lambda (entry)
1359 (string->symbol (string-append "header:" (symbol->string (car entry))))
1363 (props (append prefixed-alist
1365 (layout-extract-page-properties layout)))
1367 (interpret-markup layout props markup)
1376 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1377 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1378 %%%%% Equally spacing multiple columns (e.g. for translations)
1379 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1380 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1382 % Credits: Nicolas Sceaux on the lilypond-user mailinglist
1383 #(define-markup-command (columns layout props args) (markup-list?)
1384 (let ((line-width (/ (chain-assoc-get 'line-width props
1385 (ly:output-def-lookup layout 'line-width))
1386 (max (length args) 1))))
1387 (interpret-markup layout props
1388 (make-line-markup (map (lambda (line)
1389 (markup #:pad-to-box `(0 . ,line-width) '(0 . 0)
1390 #:override `(line-width . ,line-width)
1396 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1397 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1398 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1399 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1400 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1403 startSlashedGraceMusic = {
1404 \override Stem #'stroke-style = #"grace"
1407 stopSlashedGraceMusic = {
1408 \revert Stem #'stroke-style
1412 #(def-grace-function startSlashedGraceMusic stopSlashedGraceMusic
1413 (_i "Create slashed graces (slashes through stems, but no slur)from the following music expression"))
1416 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1417 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1418 %%%%% SCORE (HEADER / LAYOUT) SETTINGS
1419 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1424 right-margin = 1.5\cm
1425 line-width = 17.5\cm
1426 % bottom-margin = 1.5\cm
1428 % after-title-space = 0.5\cm
1432 ragged-last-bottom = ##f
1437 % If only one non-empty staff in a system exists, still print the backet
1438 \override SystemStartBracket #'collapse-height = #1
1439 \consists "Instrument_name_engraver"
1443 % If only one non-empty staff in a system exists, still print the backet
1444 \override SystemStartBracket #'collapse-height = #1
1445 \consists "Instrument_name_engraver"
1449 \override SystemStartBracket #'collapse-height = #1
1450 \consists "Instrument_name_engraver"
1454 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1458 % \override VerticalAxisGroup #'keep-fixed-while-stretching = ##t
1459 \override VerticalAxisGroup #'minimum-Y-extent = #'(0 . 1)
1460 \override VerticalAxisGroup #'padding = #0
1464 % Force multi-measure rests to be written as one span
1465 \override MultiMeasureRest #'expand-limit = #3
1468 % hairpinToBarline = ##f
1469 \override BarNumber #'break-visibility = #end-of-line-invisible
1470 \override BarNumber #'self-alignment-X = #0
1471 \override CombineTextScript #'avoid-slur = #'outside
1472 barNumberVisibility = #(every-nth-bar-number-visible 5)
1473 \override DynamicTextSpanner #'dash-period = #-1.0
1474 \override InstrumentSwitch #'font-size = #-1
1477 \override RestCollision #'positioning-done = #merge-rests-on-positioning
1478 % Auto-Accidentals: Use modern-cautionary style...
1480 autoAccidentals = #`(Staff ,(make-accidental-rule 'same-octave 0)
1481 ,(make-accidental-rule 'any-octave 0)
1482 ,(make-accidental-rule 'same-octave 1))
1483 % autoCautionaries = #`(Staff ,(make-accidental-rule 'any-octave 0)
1484 % ,(make-accidental-rule 'same-octave 1))
1485 printKeyCancellation = ##t
1486 quotedEventTypes = #'(StreamEvent)
1487 implicitBassFigures = #'(0 100)
1490 \RemoveEmptyStaffContext
1494 \override VerticalAxisGroup #'minimum-Y-extent = #'(0.5 . 0.5)
1498 \override VerticalAxisGroup #'minimum-Y-extent = #'(-1. . 3)
1499 ignoreFiguredBassRest = ##f
1507 \type "Engraver_group"
1509 % So that \cresc works, for example.
1511 \consists "Output_property_engraver"
1513 \override VerticalAxisGroup #'minimum-Y-extent = #'(-1 . 1)
1514 pedalSustainStrings = #'("Ped." "*Ped." "*")
1515 pedalUnaCordaStrings = #'("una corda" "" "tre corde")
1517 \consists "Piano_pedal_engraver"
1518 \consists "Script_engraver"
1519 \consists "Dynamic_engraver"
1520 \consists "Text_engraver"
1522 \override TextScript #'font-size = #2
1523 \override TextScript #'font-shape = #'italic
1524 \override DynamicText #'extra-offset = #'(0 . 2.5)
1525 \override Hairpin #'extra-offset = #'(0 . 2.5)
1527 \consists "Skip_event_swallow_translator"
1529 \consists "Axis_group_engraver"
1534 % \override VerticalAlignment #'forced-distance = #7
1539 bracketts = ^\markup{"[Solo]"}
1540 brackettt = ^\markup{"[Tutti]"}
1541 ts = ^\markup{"t.s."}
1542 tt = ^\markup{"Tutti"}
1543 solo = ^\markup{"Solo"}
1544 bracketsolo = ^\markup{"[Solo]"}
1545 tutti = ^\markup{"Tutti"}
1547 dashedSlur = -\tweak #'dash-definition #'((0 1 0.4 0.75))(
1548 dashedTie = -\tweak #'dash-definition #'((0 1 0.4 0.75))~
1550 divisi = #(define-music-function (parser location vc1 vc2) (ly:music? ly:music?)
1552 << { \voiceOne $vc1 \oneVoice} \new Voice = "divisi2" { \voiceTwo $vc2 } >>
1556 #(define-public (bracket-stencils grob)
1557 (let ((lp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "[")))
1558 (rp (grob-interpret-markup grob (markup #:fontsize 3.5 #:translate (cons -0.3 -0.5) "]"))))
1561 bracketify = #(define-music-function (parser loc arg) (ly:music?)
1562 (_i "Tag @var{arg} to be parenthesized.")
1564 \once \override ParenthesesItem #'stencils = #bracket-stencils
1570 #(define-markup-command (hat layout props arg) (markup?)
1571 "Draw a hat above the given string @var{arg}."
1572 (interpret-markup layout props (markup #:combine #:raise 1.5 "^" arg)))
1577 #(let ((m (make-music 'ArticulationEvent
1578 'articulation-type "flageolet")))
1579 (ly:music-set-property! m 'tweaks
1580 (acons 'font-size -2
1581 (ly:music-property m 'tweaks)))
1585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1588 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1589 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1591 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" }}
1592 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" }}
1593 LicenseNoRestrictions = \markup{\line {Die Ausgabe darf kopiert und ohne Einschränkungen aufgeführt werden. / May be copied and performed without restriction.}}