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