1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 1998--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
4 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; LilyPond is free software: you can redistribute it and/or modify
7 ;;;; it under the terms of the GNU General Public License as published by
8 ;;;; the Free Software Foundation, either version 3 of the License, or
9 ;;;; (at your option) any later version.
11 ;;;; LilyPond is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;;; GNU General Public License for more details.
16 ;;;; You should have received a copy of the GNU General Public License
17 ;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
19 ;; for define-safe-public when byte-compiling using Guile V2
20 (use-modules (scm safe-utility-defs))
22 ;; TODO: should link back into user manual.
24 (define-public music-descriptions
27 . ((description . "Create a dynamic mark.
29 Syntax: @var{note}@code{\\x}, where @code{\\x} is a dynamic mark like
30 @code{\\ppp} or @code{\\sfz}. A complete list is in file
31 @file{ly/@/dynamic-scripts-init.ly}.")
32 (types . (post-event event dynamic-event absolute-dynamic-event))
36 . ((description . "Create an alternative event.")
37 (types . (event alternative-event))
41 . ((description . "Print an annotation of an output element.")
42 (types . (event annotate-output-event post-event))
46 . ((description . "Call the argument with the current context during
48 (types . (apply-context))
49 (iterator-ctor . ,ly:apply-context-iterator::constructor)
53 . ((description . "Call the argument with all current grobs during
56 Syntax: @code{\\applyOutput #'@var{context} @var{func}}
58 Arguments to @var{func} are 1.@tie{}the grob, 2.@tie{}the originating
59 context, and 3.@tie{}the context where @var{func} is called.")
60 (types . (event apply-output-event))
64 . ((description . "Make an arpeggio on this note.
66 Syntax: @w{@var{note}@code{-\\arpeggio}}")
67 (types . (post-event arpeggio-event event))
70 ;; todo: use articulation-event for slur as well.
71 ;; separate non articulation scripts
73 . ((description . "Add an articulation marking to a note.
75 Syntax: @var{note}@code{x}@code{y}, where @code{x} is a direction\
76 \n(@code{^} for up or @code{_} for down), or LilyPond's choice\
77 \n(no direction specified), and where @code{y} is an articulation\
78 \n(such as @w{@code{-.}}, @w{@code{->}}, @code{\\tenuto}, @code{\\downbow}).
79 See the Notation Reference for details.")
80 (types . (post-event event articulation-event script-event))
84 . ((description . "Used for making voices that switch between
85 piano staves automatically.")
86 (iterator-ctor . ,ly:auto-change-iterator::constructor)
87 (start-callback . ,ly:music-wrapper::start-callback)
88 (length-callback . ,ly:music-wrapper::length-callback)
89 (types . (music-wrapper-music auto-change-instruction))
93 . ((description . "Check whether this music coincides with
94 the start of the measure.")
96 (iterator-ctor . ,ly:bar-check-iterator::constructor)
100 . ((description . "Print a bass-figure text.")
101 (types . (event rhythmic-event bass-figure-event))
105 . ((description . "Start or stop a beam.
107 Syntax for manual control: @code{c8-[ c c-] c8}")
108 (types . (post-event event beam-event span-event))
112 . ((description . "Specify that a note may not auto-beamed.")
113 (types . (post-event event beam-forbid-event))
116 (BreakDynamicSpanEvent
117 . ((description . "End an alignment spanner for dynamics here.")
118 (types . (post-event break-span-event break-dynamic-span-event event))
122 . ((description . "A drop/@/fall/@/doit jazz articulation.")
123 (types . (post-event bend-after-event event))))
126 . ((description . "Create a @q{breath mark} or @q{comma}.
128 Syntax: @var{note}@code{\\breathe}")
130 (types . (event breathing-event))
131 (midi-length . ,breathe::midi-length)))
134 . ((description . "A note that is part of a cluster.")
135 ;; not a note-event, to ensure that Note_heads_engraver doesn't eat it.
136 (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
137 (types . (cluster-note-event melodic-event rhythmic-event event))
140 (CompletizeExtenderEvent
141 . ((description . "Used internally to signal the end of a lyrics block to
142 ensure extenders are completed correctly when a @code{Lyrics} context ends
143 before its associated @code{Voice} context.")
144 (types . (completize-extender-event event))
148 . ((description . "Change staves in Piano staff.
150 Syntax: @code{\\change Staff = @var{new-id}}")
151 (iterator-ctor . ,ly:change-iterator::constructor)
152 (types . (translator-change-instruction))
156 . ((description . "Interpret the argument music within a
158 (iterator-ctor . ,ly:context-specced-music-iterator::constructor)
159 (length-callback . ,ly:music-wrapper::length-callback)
160 (start-callback . ,ly:music-wrapper::start-callback)
161 (types . (context-specification music-wrapper-music))
165 . ((description . "Begin or end a crescendo.
167 Syntax: @var{note}@code{\\<} @dots{} @var{note}@code{\\!}
169 An alternative syntax is @var{note}@code{\\cr} @dots{}
170 @var{note}@code{\\endcr}.")
171 (types . (post-event span-event span-dynamic-event crescendo-event
176 . ((description . "Begin or end a decrescendo.
178 Syntax: @var{note}@code{\\>} @dots{} @var{note}@code{\\!}
180 An alternative syntax is @var{note}@code{\\decr} @dots{}
181 @var{note}@code{\\enddecr}.")
182 (types . (post-event span-event span-dynamic-event decrescendo-event
187 . ((description . "Used internally to signal double percent repeats.")
188 (types . (event double-percent-event rhythmic-event))
192 . ((description . "Begin or end an episema.")
193 (types . (post-event span-event event episema-event))
197 . ((description . "Atomic music event.")
202 . ((description . "Explicitly entered chords.
204 When iterated, @code{elements} are converted to events at the current
205 timestep, followed by any @code{articulations}. Per-chord postevents
206 attached by the parser just follow any rhythmic events in
207 @code{elements} instead of utilizing @code{articulations}.
209 An unexpanded chord repetition @samp{q} is recognizable by having its
210 duration stored in @code{duration}.")
211 (iterator-ctor . ,ly:event-chord-iterator::constructor)
212 (length-callback . ,ly:music-sequence::event-chord-length-callback)
213 (to-relative-callback .
214 ,ly:music-sequence::event-chord-relative-callback)
215 (types . (event-chord simultaneous-music))
219 . ((description . "Extend lyrics.")
220 (types . (post-event extender-event event))
224 . ((description . "Specify what finger to use for this note.")
225 (types . (post-event fingering-event event))
229 . ((description . "Footnote a grob.")
230 (types . (event footnote-event))
234 . ((description . "Start a glissando on this note.")
235 (types . (post-event glissando-event event))
239 . ((description . "Interpret the argument as grace notes.")
240 (start-callback . ,ly:grace-music::start-callback)
241 (length . ,ZERO-MOMENT)
242 (iterator-ctor . ,ly:grace-iterator::constructor)
243 (types . (grace-music music-wrapper-music))
247 . ((description . "Mark a note as harmonic.")
248 (types . (post-event event harmonic-event))
252 . ((description . "A hyphen between lyric syllables.")
253 (types . (post-event hyphen-event event))
257 . ((description . "Change the key signature.
259 Syntax: @code{\\key} @var{name} @var{scale}")
260 (to-relative-callback . ,(lambda (x p) p))
261 (types . (key-change-event event))
265 . ((description . "Place a bookmarking label.")
266 (types . (label-event event))
270 . ((description . "Don't damp this chord.
272 Syntax: @var{note}@code{\\laissezVibrer}")
273 (types . (post-event event laissez-vibrer-event))
277 . ((description . "Start or end a ligature.")
278 (types . (span-event ligature-event event))
282 . ((description . "Allow, forbid or force a line break.")
283 (types . (line-break-event break-event event))
287 . ((description . "Align lyrics to the start of notes.
289 Syntax: @code{\\lyricsto} @var{voicename} @var{lyrics}")
290 (length . ,ZERO-MOMENT)
291 (types . (lyric-combine-music))
292 (iterator-ctor . ,ly:lyric-combine-music-iterator::constructor)
296 . ((description . "A lyric syllable. Must be entered in lyrics mode,
297 i.e., @code{\\lyrics @{ twinkle4 twinkle4 @} }.")
298 (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
299 (types . (rhythmic-event lyric-event event))
303 . ((description . "Insert a rehearsal mark.
305 Syntax: @code{\\mark} @var{marker}
307 Example: @code{\\mark \"A\"}")
308 (types . (mark-event event))
312 . ((description . "Used to signal the start and end of a measure count.")
313 (types . (measure-counter-event span-event event))
316 (MultiMeasureRestEvent
317 . ((description . "Used internally by @code{MultiMeasureRestMusic}
319 (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
320 (types . (event rhythmic-event multi-measure-rest-event))
323 (MultiMeasureRestMusic
324 . ((description . "Rests that may be compressed into Multi rests.
326 Syntax: @code{R2.*4} for 4 measures in 3/4 time.")
327 (iterator-ctor . ,ly:sequential-iterator::constructor)
328 (elements-callback . ,mm-rest-child-list)
329 (types . (multi-measure-rest))
332 (MultiMeasureTextEvent
333 . ((description . "Texts on multi measure rests.
335 Syntax: @code{R-\\markup @{ \\roman \"bla\" @}}
337 Note the explicit font switch.")
338 (types . (post-event event multi-measure-text-event))
342 . ((description . "Generic type for music expressions.")
347 . ((description . "A note.
349 Outside of chords, any events in @code{articulations} with a listener
350 are broadcast like chord articulations, the others are retained.
352 For iteration inside of chords, @xref{EventChord}.")
353 (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
354 (types . (event note-event rhythmic-event melodic-event))
358 . ((description . "Start or stop grouping brackets.")
359 (types . (post-event event note-grouping-event))
363 . ((description . "Start or stop an ottava bracket.")
364 (iterator-ctor . ,ly:sequential-iterator::constructor)
365 (elements-callback . ,make-ottava-set)
366 (types . (ottava-music))
370 . ((description . "Extend the definition of a graphical object.
372 Syntax: @code{\\override} [ @var{context} @code{.} ]
373 @var{object} @var{property} @code{=} @var{value}")
374 (types . (layout-instruction-event override-property-event))
375 (iterator-ctor . ,ly:push-property-iterator::constructor)
376 (untransposable . #t)
380 . ((description . "Allow, forbid or force a page break.")
381 (types . (break-event page-break-event event))
385 . ((description . "Allow, forbid or force a page turn.")
386 (types . (break-event page-turn-event event))
389 (PartCombineForceEvent
390 . ((description . "Override the part-combiner's strategy.")
391 (types . (part-combine-force-event event))
395 . ((description . "Create an anacrusis or upbeat (partial measure).")
396 (iterator-ctor . ,ly:partial-iterator::constructor)
397 ;; The length-callback is kind of cheesy since 'elements is
398 ;; empty. We just use that in order to get a zero length
399 ;; for the overall timing in spite of having a non-zero
401 (length-callback . ,ly:music-sequence::cumulative-length-callback)
402 (types . (partial-set))
406 . ((description . "Combine two parts on a staff, either merged or
407 as separate voices.")
408 (length-callback . ,ly:music-sequence::maximum-length-callback)
409 (start-callback . ,ly:music-sequence::minimum-start-callback)
410 (types . (part-combine-music))
411 (iterator-ctor . ,ly:part-combine-iterator::constructor)
414 (PartCombinePartMusic
415 . ((description . "A part to be combined with other parts on a staff.")
416 (length-callback . ,ly:music-wrapper::length-callback)
417 (start-callback . ,ly:music-wrapper::start-callback)
418 (iterator-ctor . ,ly:part-combine-part-iterator::constructor)
419 (types . (part-combine-part-music music-wrapper-music))
423 . ((description . "Used internally to signal percent repeats.")
424 (types . (event percent-event rhythmic-event))
427 (PercentRepeatedMusic
428 . ((description . "Repeats encoded by percents and slashes.")
429 (iterator-ctor . ,ly:percent-repeat-iterator::constructor)
430 (start-callback . ,ly:repeated-music::first-start)
431 (length-callback . ,ly:repeated-music::unfolded-music-length)
432 (types . (repeated-music percent-repeated-music))
436 . ((description . "Within a ligature, mark the previous and the
437 following note to form a pes (if melody goes up) or a flexa (if melody
439 (types . (pes-or-flexa-event event))
443 . ((description . "Start or end phrasing slur.
445 Syntax: @var{note}@code{\\(} and @var{note}@code{\\)}")
447 (types . (post-event span-event event phrasing-slur-event))
451 . ((description . "Container for several postevents.
453 This can be used to package several events into a single one. Should not be seen outside of the parser.")
454 (types . (post-event post-event-wrapper))))
457 . ((description . "Set a context property.
459 Syntax: @code{\\set @var{context}.@var{prop} = @var{scheme-val}}")
460 (types . (layout-instruction-event))
461 (iterator-ctor . ,ly:property-iterator::constructor)
462 (untransposable . #t)
466 . ((description . "Restore the default setting for a context
467 property. See @ref{PropertySet}.
469 Syntax: @code{\\unset @var{context}.@var{prop}}")
470 (types . (layout-instruction-event))
471 (iterator-ctor . ,ly:property-unset-iterator::constructor)
475 . ((description . "Quote preprocessed snippets of music.")
476 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
477 (length-callback . ,ly:music-wrapper::length-callback)
478 (start-callback . ,ly:music-wrapper::start-callback)
479 (types . (music-wrapper-music))
483 . ((description . "Check if a pitch is in the correct octave.")
484 (to-relative-callback . ,ly:relative-octave-check::relative-callback)
485 (types . (relative-octave-check))
489 . ((description . "Music in which the assignment of octaves is complete.")
490 (to-relative-callback . ,ly:relative-octave-music::relative-callback)
491 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
492 (length-callback . ,ly:music-wrapper::length-callback)
493 (start-callback . ,ly:music-wrapper::start-callback)
494 (types . (music-wrapper-music relative-octave-music))
498 . ((description . "Repeat music in different ways.")
499 (types . (repeated-music))
503 . ((description . "Used internally to signal beat repeats.")
504 (types . (event repeat-slash-event rhythmic-event))
508 . ((description . "Ties for starting a second volta bracket.")
509 (types . (post-event event repeat-tie-event))
513 . ((description . "A Rest.
515 Syntax: @code{r4} for a quarter rest.")
516 (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
517 (types . (event rhythmic-event rest-event))
521 . ((description . "The opposite of @ref{OverrideProperty}: remove a
522 previously added property from a graphical object definition.")
523 (types . (layout-instruction-event))
524 (iterator-ctor . ,ly:pop-property-iterator::constructor)
528 . ((description . "Add an articulation mark to a note.")
533 . ((description . "Music expressions concatenated.
535 Syntax: @code{\\sequential @{ @dots{} @}} or simply @code{@{ @dots{} @}}")
536 (length-callback . ,ly:music-sequence::cumulative-length-callback)
537 (start-callback . ,ly:music-sequence::first-start-callback)
538 (elements-callback . ,(lambda (m) (ly:music-property m 'elements)))
539 (iterator-ctor . ,ly:sequential-iterator::constructor)
540 (types . (sequential-music))
544 . ((description . "Music playing together.
546 Syntax: @code{\\simultaneous @{ @dots{} @}} or @code{<< @dots{} >>}")
547 (iterator-ctor . ,ly:simultaneous-music-iterator::constructor)
548 (start-callback . ,ly:music-sequence::minimum-start-callback)
549 (length-callback . ,ly:music-sequence::maximum-length-callback)
550 (to-relative-callback .
551 ,ly:music-sequence::simultaneous-relative-callback)
552 (types . (simultaneous-music))
556 . ((description . "Filler that takes up duration, but does not
559 Syntax: @code{s4} for a skip equivalent to a quarter rest.")
560 (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
561 (types . (event rhythmic-event skip-event))
565 . ((description . "Filler that takes up duration, does not
566 print anything, and also does not create staves or voices implicitly.
568 Syntax: @code{\\skip} @var{duration}")
569 (length-callback . ,ly:music-duration-length)
570 (iterator-ctor . ,ly:simple-music-iterator::constructor)
571 (types . (event skip-event))
575 . ((description . "Start or end slur.
577 Syntax: @var{note}@code{(} and @var{note}@code{)}")
579 (types . (post-event span-event event slur-event))
583 . ((description . "Print @q{Solo@tie{}1}.")
584 (part-combine-status . solo1)
585 (types . (event part-combine-event solo-one-event))
589 . ((description . "Print @q{Solo@tie{}2}.")
590 (part-combine-status . solo2)
591 (types . (event part-combine-event solo-two-event))
595 . ((description . "Depress or release sostenuto pedal.")
596 (types . (post-event event pedal-event sostenuto-event))
600 . ((description . "Start a new spacing section.")
601 (types . (event spacing-section-event))))
604 . ((description . "Event for anything that is started at a
605 different time than stopped.")
610 . ((description . "Start or stop a staff symbol.")
611 (types . (event span-event staff-span-event))
615 . ((description . "Specify on which string to play this note.
617 Syntax: @code{\\@var{number}}")
618 (types . (post-event string-number-event event))
622 . ((description . "Specify with which finger to pluck a string.
624 Syntax: @code{\\rightHandFinger @var{text}}")
625 (types . (post-event stroke-finger-event event))
629 . ((description . "Depress or release sustain pedal.")
630 (types . (post-event event pedal-event sustain-event))
634 . ((description . "A metronome mark or tempo indication.")
635 (types . (event tempo-change-event))
639 . ((description . "Print text.")
640 (types . (post-event script-event text-script-event event))
644 . ((description . "Start a text spanner, for example, an
646 (types . (post-event span-event event text-span-event))
650 . ((description . "A tie.
652 Syntax: @w{@var{note}@code{-~}}")
653 (types . (post-event tie-event event))
657 . ((description . "Multiply durations, as in tuplets.
659 Syntax: @code{\\times @var{fraction} @var{music}}, e.g.,
660 @code{\\times 2/3 @{ @dots{} @}} for triplets.")
661 (length-callback . ,ly:music-wrapper::length-callback)
662 (start-callback . ,ly:music-wrapper::start-callback)
663 (iterator-ctor . ,ly:tuplet-iterator::constructor)
664 (types . (time-scaled-music music-wrapper-music))
668 . ((description . "Set a new time signature")
669 (iterator-ctor . ,ly:sequential-iterator::constructor)
670 (elements-callback . ,make-time-signature-set)
671 (types . (time-signature-music))
675 . ((description . "An event created when setting a new time signature")
676 (types . (event time-signature-event))
680 . ((description . "Music that has been transposed.")
681 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
682 (start-callback . ,ly:music-wrapper::start-callback)
683 (length-callback . ,ly:music-wrapper::length-callback)
684 (to-relative-callback .
685 ,ly:relative-octave-music::no-relative-callback)
686 (types . (music-wrapper-music transposed-music))
690 . ((description . "Unmeasured tremolo.")
691 (types . (post-event event tremolo-event))
694 (TremoloRepeatedMusic
695 . ((description . "Repeated notes denoted by tremolo beams.")
696 (iterator-ctor . ,ly:chord-tremolo-iterator::constructor)
697 (start-callback . ,ly:repeated-music::first-start)
698 (length-callback . ,ly:repeated-music::unfolded-music-length)
699 (types . (repeated-music tremolo-repeated-music))
703 . ((description . "Tremolo over two stems.")
704 (types . (event span-event tremolo-span-event))
708 . ((description . "Start a trill spanner.")
709 (types . (post-event span-event event trill-span-event))
713 . ((description . "Used internally to signal where tuplet
714 brackets start and stop.")
715 (types . (tuplet-span-event span-event event post-event))
719 . ((description . "Depress or release una-corda pedal.")
720 (types . (post-event event pedal-event una-corda-event))
723 (UnfoldedRepeatedMusic
724 . ((description . "Repeated music which is fully written (and
726 (iterator-ctor . ,ly:sequential-iterator::constructor)
727 (elements-callback . ,make-unfolded-set)
728 (start-callback . ,ly:repeated-music::first-start)
729 (types . (repeated-music unfolded-repeated-music))
730 (length-callback . ,ly:repeated-music::unfolded-music-length)
734 . ((description . "Print @q{a@tie{}2}.")
735 (part-combine-status . unisono)
736 (types . (event part-combine-event unisono-event))))
739 . ((description . "Music that cannot be converted from relative
740 to absolute notation. For example, transposed music.")
741 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
742 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
743 (length-callback . ,ly:music-wrapper::length-callback)
744 (start-callback . ,ly:music-wrapper::start-callback)
745 (types . (music-wrapper-music unrelativable-music))
749 . ((description . "Separate polyphonic voices in simultaneous music.
751 Syntax: @code{\\\\}")
752 (types . (separator))
756 . ((description . "Repeats with alternatives placed sequentially.")
757 (iterator-ctor . ,ly:volta-repeat-iterator::constructor)
758 (elements-callback . ,make-volta-set)
759 (start-callback . ,ly:repeated-music::first-start)
760 (length-callback . ,ly:repeated-music::volta-music-length)
761 (types . (repeated-music volta-repeated-music))
765 (set! music-descriptions
766 (sort music-descriptions alist<?))
768 (define-public music-name-to-property-table (make-hash-table 59))
771 ;; transport description to an object property.
775 (set-object-property! (car x)
777 (cdr (assq 'description (cdr x))))
779 (set! lst (assoc-set! lst 'name (car x)))
780 (set! lst (assq-remove! lst 'description))
781 (hashq-set! music-name-to-property-table (car x) lst)
785 (define-safe-public (make-music name . music-properties)
786 "Create a music object of given name, and set its properties
787 according to @code{music-properties}, a list of alternating property symbols
790 (make-music 'OverrideProperty
792 'grob-property 'thickness
793 'grob-value (* 2 1.5))
795 Instead of a successive symbol and value, an entry in the list may
796 also be an alist or a music object in which case its elements,
797 respectively its @emph{mutable} property list (properties not inherent
798 to the type of the music object) will get taken.
800 The argument list will be interpreted left-to-right, so later entries
801 override earlier ones."
802 (if (not (symbol? name))
803 (ly:error (_ "symbol expected: ~S") name))
804 (let ((props (hashq-ref music-name-to-property-table name '())))
805 (if (not (pair? props))
806 (ly:error (_ "cannot find music object: ~S") name))
807 (let ((m (ly:make-music props)))
808 (define (alist-set-props lst)
809 (for-each (lambda (e)
810 (set! (ly:music-property m (car e)) (cdr e)))
812 (define (set-props mus-props)
813 (if (pair? mus-props)
814 (let ((e (car mus-props))
815 (mus-props (cdr mus-props)))
817 (set! (ly:music-property m e) (car mus-props))
818 (set-props (cdr mus-props)))
820 (alist-set-props (ly:music-mutable-properties e))
821 (set-props mus-props))
824 (set-props mus-props))
826 (ly:error (_ "bad make-music argument: ~S") e))))))
827 (set-props music-properties)