1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 1998--2011 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 . (general-music event dynamic-event absolute-dynamic-event))
36 . ((description . "Print an annotation of an output element.")
37 (types . (general-music event annotate-output-event))
41 . ((description . "Call the argument with the current context during
43 (types . (general-music apply-context))
44 (iterator-ctor . ,ly:apply-context-iterator::constructor)
48 . ((description . "Call the argument with all current grobs during
51 Syntax: @code{\\applyOutput #'@var{context} @var{func}}
53 Arguments to @var{func} are 1.@tie{}the grob, 2.@tie{}the originating
54 context, and 3.@tie{}the context where @var{func} is called.")
55 (types . (general-music event apply-output-event))
59 . ((description . "Make an arpeggio on this note.
61 Syntax: @w{@var{note}@code{-\\arpeggio}}")
62 (types . (general-music arpeggio-event event))
65 ;; todo: use articulation-event for slur as well.
66 ;; separate non articulation scripts
68 . ((description . "Add an articulation marking to a note.
70 Syntax: @var{note}@code{x}@code{y}, where @code{x} is a direction
71 (@code{^} for up or @code{_} for down), or LilyPond's choice
72 (no direction specified), and where @code{y} is an articulation
73 (such as @w{@code{-.}}, @w{@code{->}}, @code{\\tenuto}, @code{\\downbow}).
74 See the Notation Reference for details.")
75 (types . (general-music event articulation-event script-event))
79 . ((description . "Used for making voices that switch between
80 piano staves automatically.")
81 (iterator-ctor . ,ly:auto-change-iterator::constructor)
82 (start-callback . ,ly:music-wrapper::start-callback)
83 (length-callback . ,ly:music-wrapper::length-callback)
84 (types . (general-music music-wrapper-music auto-change-instruction))
88 . ((description . "Check whether this music coincides with
89 the start of the measure.")
90 (types . (general-music bar-check))
91 (iterator-ctor . ,ly:bar-check-iterator::constructor)
95 . ((description . "Print a bass-figure text.")
96 (types . (general-music event rhythmic-event bass-figure-event))
100 . ((description . "Start or stop a beam.
102 Syntax for manual control: @code{c8-[ c c-] c8}")
103 (types . (general-music event beam-event span-event))
107 . ((description . "Specify that a note may not auto-beamed.")
108 (types . (general-music event beam-forbid-event))
111 (BreakDynamicSpanEvent
112 . ((description . "End an alignment spanner for dynamics here.")
113 (types . (general-music break-span-event break-dynamic-span-event event))
117 . ((description . "A drop/@/fall/@/doit jazz articulation.")
118 (types . (general-music bend-after-event event))))
121 . ((description . "Create a @q{breath mark} or @q{comma}.
123 Syntax: @var{note}@code{\\breathe}")
125 (types . (general-music event breathing-event))
129 . ((description . "A note that is part of a cluster.")
130 ;; not a note-event, to ensure that Note_heads_engraver doesn't eat it.
131 (types . (general-music cluster-note-event melodic-event
132 rhythmic-event event))
135 (CompletizeExtenderEvent
136 . ((description . "Used internally to signal the end of a lyrics block to
137 ensure extenders are completed correctly when a @code{Lyrics} context ends
138 before its associated @code{Voice} context.")
139 (types . (general-music completize-extender-event event))
143 . ((description . "Change staves in Piano staff.
145 Syntax: @code{\\change Staff = @var{new-id}}")
146 (iterator-ctor . ,ly:change-iterator::constructor)
147 (types . (general-music translator-change-instruction))
151 . ((description . "Interpret the argument music within a
153 (iterator-ctor . ,ly:context-specced-music-iterator::constructor)
154 (length-callback . ,ly:music-wrapper::length-callback)
155 (start-callback . ,ly:music-wrapper::start-callback)
156 (types . (context-specification general-music music-wrapper-music))
160 . ((description . "Begin or end a crescendo.
162 Syntax: @var{note}@code{\\<} @dots{} @var{note}@code{\\!}
164 An alternative syntax is @var{note}@code{\\cr} @dots{}
165 @var{note}@code{\\endcr}.")
166 (types . (general-music span-event span-dynamic-event crescendo-event
171 . ((description . "Begin or end a decrescendo.
173 Syntax: @var{note}@code{\\>} @dots{} @var{note}@code{\\!}
175 An alternative syntax is @var{note}@code{\\decr} @dots{}
176 @var{note}@code{\\enddecr}.")
177 (types . (general-music span-event span-dynamic-event decrescendo-event
182 . ((description . "Used internally to signal double percent repeats.")
183 (types . (general-music event double-percent-event rhythmic-event))
187 . ((description . "Begin or end an episema.")
188 (types . (general-music span-event event episema-event))
192 . ((description . "Atomic music event.")
193 (types . (general-music event))
197 . ((description . "Internally used to group a set of events.")
198 (iterator-ctor . ,ly:event-chord-iterator::constructor)
199 (length-callback . ,ly:music-sequence::maximum-length-callback)
200 (to-relative-callback .
201 ,ly:music-sequence::event-chord-relative-callback)
202 (types . (general-music event-chord simultaneous-music))
206 . ((description . "Extend lyrics.")
207 (types . (general-music extender-event event))
211 . ((description . "Specify what finger to use for this note.")
212 (types . (general-music fingering-event event))
216 . ((description . "Footnote a grob.")
217 (types . (general-music event footnote-event))
221 . ((description . "Start a glissando on this note.")
222 (types . (general-music glissando-event event))
226 . ((description . "Interpret the argument as grace notes.")
227 (start-callback . ,ly:grace-music::start-callback)
228 (length . ,ZERO-MOMENT)
229 (iterator-ctor . ,ly:grace-iterator::constructor)
230 (types . (grace-music music-wrapper-music general-music))
234 . ((description . "Mark a note as harmonic.")
235 (types . (general-music event harmonic-event))
239 . ((description . "A hyphen between lyric syllables.")
240 (types . (general-music hyphen-event event))
244 . ((description . "Change the key signature.
246 Syntax: @code{\\key} @var{name} @var{scale}")
247 (to-relative-callback . ,(lambda (x p) p))
248 (types . (general-music key-change-event event))
252 . ((description . "Place a bookmarking label.")
253 (types . (general-music label-event event))
257 . ((description . "Don't damp this chord.
259 Syntax: @var{note}@code{\\laissezVibrer}")
260 (types . (general-music event laissez-vibrer-event))
264 . ((description . "Start or end a ligature.")
265 (types . (general-music span-event ligature-event event))
269 . ((description . "Allow, forbid or force a line break.")
270 (types . (general-music line-break-event break-event event))
274 . ((description . "Align lyrics to the start of notes.
276 Syntax: @code{\\lyricsto} @var{voicename} @var{lyrics}")
277 (length . ,ZERO-MOMENT)
278 (types . (general-music lyric-combine-music))
279 (iterator-ctor . ,ly:lyric-combine-music-iterator::constructor)
283 . ((description . "A lyric syllable. Must be entered in lyrics mode,
284 i.e., @code{\\lyrics @{ twinkle4 twinkle4 @} }.")
285 (types . (general-music rhythmic-event lyric-event event))
289 . ((description . "Insert a rehearsal mark.
291 Syntax: @code{\\mark} @var{marker}
293 Example: @code{\\mark \"A\"}")
294 (types . (general-music mark-event event))
297 (MultiMeasureRestEvent
298 . ((description . "Used internally by @code{MultiMeasureRestMusic}
300 (types . (general-music event rhythmic-event
301 multi-measure-rest-event))
304 (MultiMeasureRestMusic
305 . ((description . "Rests that may be compressed into Multi rests.
307 Syntax: @code{R2.*4} for 4 measures in 3/4 time.")
308 (iterator-ctor . ,ly:sequential-iterator::constructor)
309 (elements-callback . ,mm-rest-child-list)
310 (types . (general-music multi-measure-rest))
313 (MultiMeasureTextEvent
314 . ((description . "Texts on multi measure rests.
316 Syntax: @code{R-\\markup @{ \\roman \"bla\" @}}
318 Note the explicit font switch.")
319 (types . (general-music event multi-measure-text-event))
323 . ((description . "Generic type for music expressions.")
324 (types . (general-music))
328 . ((description . "A note.")
329 (types . (general-music event note-event rhythmic-event
334 . ((description . "Start or stop grouping brackets.")
335 (types . (general-music event note-grouping-event))
339 . ((description . "Start or stop an ottava bracket.")
340 (iterator-ctor . ,ly:sequential-iterator::constructor)
341 (elements-callback . ,make-ottava-set)
342 (types . (general-music ottava-music))
346 . ((description . "Extend the definition of a graphical object.
348 Syntax: @code{\\override} [ @var{context} @code{.} ]
349 @var{object} @var{property} @code{=} @var{value}")
350 (types . (general-music layout-instruction-event
351 override-property-event))
352 (iterator-ctor . ,ly:push-property-iterator::constructor)
356 . ((description . "Allow, forbid or force a page break.")
357 (types . (general-music break-event page-break-event event))
361 . ((description . "Allow, forbid or force a page turn.")
362 (types . (general-music break-event page-turn-event event))
365 (PartCombineForceEvent
366 . ((description . "Override the part-combiner's strategy.")
367 (types . (general-music part-combine-force-event event))
371 . ((description . "Create an anacrusis or upbeat (partial measure).")
372 (iterator-ctor . ,ly:partial-iterator::constructor)
373 (types . (general-music partial-set))
377 . ((description . "Combine two parts on a staff, either merged or
378 as separate voices.")
379 (length-callback . ,ly:music-sequence::maximum-length-callback)
380 (start-callback . ,ly:music-sequence::minimum-start-callback)
381 (types . (general-music part-combine-music))
382 (iterator-ctor . ,ly:part-combine-iterator::constructor)
386 . ((description . "Used internally to signal percent repeats.")
387 (types . (general-music event percent-event rhythmic-event))
390 (PercentRepeatedMusic
391 . ((description . "Repeats encoded by percents and slashes.")
392 (iterator-ctor . ,ly:percent-repeat-iterator::constructor)
393 (start-callback . ,ly:repeated-music::first-start)
394 (length-callback . ,ly:repeated-music::unfolded-music-length)
395 (types . (general-music repeated-music percent-repeated-music))
399 . ((description . "Within a ligature, mark the previous and the
400 following note to form a pes (if melody goes up) or a flexa (if melody
402 (types . (general-music pes-or-flexa-event event))
406 . ((description . "Start or end phrasing slur.
408 Syntax: @var{note}@code{\\(} and @var{note}@code{\\)}")
410 (types . (general-music span-event event phrasing-slur-event))
414 . ((description . "Set a context property.
416 Syntax: @code{\\set @var{context}.@var{prop} = @var{scheme-val}}")
417 (types . (layout-instruction-event general-music))
418 (iterator-ctor . ,ly:property-iterator::constructor)
422 . ((description . "Restore the default setting for a context
423 property. See @ref{PropertySet}.
425 Syntax: @code{\\unset @var{context}.@var{prop}}")
426 (types . (layout-instruction-event general-music))
427 (iterator-ctor . ,ly:property-unset-iterator::constructor)
431 . ((description . "Quote preprocessed snippets of music.")
432 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
433 (length-callback . ,ly:music-wrapper::length-callback)
434 (start-callback . ,ly:music-wrapper::start-callback)
435 (types . (general-music music-wrapper-music))
439 . ((description . "Check if a pitch is in the correct octave.")
440 (to-relative-callback . ,ly:relative-octave-check::relative-callback)
441 (types . (general-music relative-octave-check))
445 . ((description . "Music that was entered in relative octave notation.")
446 (to-relative-callback . ,ly:relative-octave-music::relative-callback)
447 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
448 (length-callback . ,ly:music-wrapper::length-callback)
449 (start-callback . ,ly:music-wrapper::start-callback)
450 (types . (music-wrapper-music general-music relative-octave-music))
454 . ((description . "A chord repetition")
455 (to-relative-callback . ,ly:music-sequence::repeated-chord-relative-callback)
456 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
457 (start-callback . ,ly:music-wrapper::start-callback)
458 (length-callback . ,ly:music-wrapper::length-callback)
459 (types . (general-music music-wrapper-music))
463 . ((description . "Repeat music in different ways.")
464 (types . (general-music repeated-music))
468 . ((description . "Used internally to signal beat repeats.")
469 (types . (general-music event repeat-slash-event rhythmic-event))
473 . ((description . "Ties for starting a second volta bracket.")
474 (types . (general-music event repeat-tie-event))
478 . ((description . "A Rest.
480 Syntax: @code{r4} for a quarter rest.")
481 (types . (general-music event rhythmic-event rest-event))
485 . ((description . "The opposite of @ref{OverrideProperty}: remove a
486 previously added property from a graphical object definition.")
487 (types . (general-music layout-instruction-event))
488 (iterator-ctor . ,ly:pop-property-iterator::constructor)
492 . ((description . "Add an articulation mark to a note.")
493 (types . (general-music event))
497 . ((description . "Music expressions concatenated.
499 Syntax: @code{\\sequential @{ @dots{} @}} or simply @code{@{ @dots{} @}}")
500 (length-callback . ,ly:music-sequence::cumulative-length-callback)
501 (start-callback . ,ly:music-sequence::first-start-callback)
502 (elements-callback . ,(lambda (m) (ly:music-property m 'elements)))
503 (iterator-ctor . ,ly:sequential-iterator::constructor)
504 (types . (general-music sequential-music))
508 . ((description . "Music playing together.
510 Syntax: @code{\\simultaneous @{ @dots{} @}} or @code{<< @dots{} >>}")
511 (iterator-ctor . ,ly:simultaneous-music-iterator::constructor)
512 (start-callback . ,ly:music-sequence::minimum-start-callback)
513 (length-callback . ,ly:music-sequence::maximum-length-callback)
514 (to-relative-callback .
515 ,ly:music-sequence::simultaneous-relative-callback)
516 (types . (general-music simultaneous-music))
520 . ((description . "Filler that takes up duration, but does not
523 Syntax: @code{s4} for a skip equivalent to a quarter rest.")
524 (types . (general-music event rhythmic-event skip-event))
528 . ((description . "Filler that takes up duration, does not
529 print anything, and also does not create staves or voices implicitly.
531 Syntax: @code{\\skip} @var{duration}")
532 (length-callback . ,ly:music-duration-length)
533 (iterator-ctor . ,ly:simple-music-iterator::constructor)
534 (types . (general-music event rhythmic-event skip-event))
538 . ((description . "Start or end slur.
540 Syntax: @var{note}@code{(} and @var{note}@code{)}")
542 (types . (general-music span-event event slur-event))
546 . ((description . "Print @q{Solo@tie{}1}.")
547 (part-combine-status . solo1)
548 (types . (general-music event part-combine-event solo-one-event))
552 . ((description . "Print @q{Solo@tie{}2}.")
553 (part-combine-status . solo2)
554 (types . (general-music event part-combine-event solo-two-event))
558 . ((description . "Depress or release sostenuto pedal.")
559 (types . (general-music event pedal-event sostenuto-event))
563 . ((description . "Start a new spacing section.")
564 (types . (general-music event spacing-section-event))))
567 . ((description . "Event for anything that is started at a
568 different time than stopped.")
569 (types . (general-music event))
573 . ((description . "Start or stop a staff symbol.")
574 (types . (general-music event span-event staff-span-event))
578 . ((description . "Specify on which string to play this note.
580 Syntax: @code{\\@var{number}}")
581 (types . (general-music string-number-event event))
585 . ((description . "Specify with which finger to pluck a string.
587 Syntax: @code{\\rightHandFinger @var{text}}")
588 (types . (general-music stroke-finger-event event))
592 . ((description . "Depress or release sustain pedal.")
593 (types . (general-music event pedal-event sustain-event))
597 . ((description . "A metronome mark or tempo indication.")
598 (types . (general-music event tempo-change-event))
602 . ((description . "Print text.")
603 (types . (general-music script-event text-script-event event))
607 . ((description . "Start a text spanner, for example, an
609 (types . (general-music span-event event text-span-event))
613 . ((description . "A tie.
615 Syntax: @w{@var{note}@code{-~}}")
616 (types . (general-music tie-event event))
620 . ((description . "Multiply durations, as in tuplets.
622 Syntax: @code{\\times @var{fraction} @var{music}}, e.g.,
623 @code{\\times 2/3 @{ @dots{} @}} for triplets.")
624 (length-callback . ,ly:music-wrapper::length-callback)
625 (start-callback . ,ly:music-wrapper::start-callback)
626 (iterator-ctor . ,ly:tuplet-iterator::constructor)
627 (types . (time-scaled-music music-wrapper-music general-music))
631 . ((description . "Set a new time signature")
632 (iterator-ctor . ,ly:sequential-iterator::constructor)
633 (elements-callback . ,make-time-signature-set)
634 (types . (general-music time-signature-music))
638 . ((description . "Music that has been transposed.")
639 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
640 (start-callback . ,ly:music-wrapper::start-callback)
641 (length-callback . ,ly:music-wrapper::length-callback)
642 (to-relative-callback .
643 ,ly:relative-octave-music::no-relative-callback)
644 (types . (music-wrapper-music general-music transposed-music))
648 . ((description . "Unmeasured tremolo.")
649 (types . (general-music event tremolo-event))
652 (TremoloRepeatedMusic
653 . ((description . "Repeated notes denoted by tremolo beams.")
654 (iterator-ctor . ,ly:chord-tremolo-iterator::constructor)
655 (start-callback . ,ly:repeated-music::first-start)
656 ;; the length of the repeat is handled by shifting the note logs
657 (length-callback . ,ly:repeated-music::folded-music-length)
658 (types . (general-music repeated-music tremolo-repeated-music))
662 . ((description . "Tremolo over two stems.")
663 (types . (general-music event span-event tremolo-span-event))
667 . ((description . "Start a trill spanner.")
668 (types . (general-music span-event event trill-span-event))
672 . ((description . "Used internally to signal where tuplet
673 brackets start and stop.")
674 (types . (tuplet-span-event span-event event general-music))
678 . ((description . "Depress or release una-corda pedal.")
679 (types . (general-music event pedal-event una-corda-event))
682 (UnfoldedRepeatedMusic
683 . ((description . "Repeated music which is fully written
685 (iterator-ctor . ,ly:unfolded-repeat-iterator::constructor)
686 (start-callback . ,ly:repeated-music::first-start)
687 (types . (general-music repeated-music unfolded-repeated-music))
688 (length-callback . ,ly:repeated-music::unfolded-music-length)
692 . ((description . "Print @q{a@tie{}2}.")
693 (part-combine-status . unisono)
694 (types . (general-music event part-combine-event unisono-event))))
697 . ((description . "Music that cannot be converted from relative
698 to absolute notation. For example, transposed music.")
699 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
700 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
701 (length-callback . ,ly:music-wrapper::length-callback)
702 (types . (music-wrapper-music general-music unrelativable-music))
706 . ((description . "Separate polyphonic voices in simultaneous music.
708 Syntax: @code{\\\\}")
709 (types . (separator general-music))
713 . ((description . "Repeats with alternatives placed sequentially.")
714 (iterator-ctor . ,ly:volta-repeat-iterator::constructor)
715 (start-callback . ,ly:repeated-music::first-start)
716 (length-callback . ,ly:repeated-music::volta-music-length)
717 (types . (general-music repeated-music volta-repeated-music))
721 (set! music-descriptions
722 (sort music-descriptions alist<?))
724 (define-public music-name-to-property-table (make-hash-table 59))
727 ;; transport description to an object property.
731 (set-object-property! (car x)
733 (cdr (assq 'description (cdr x))))
735 (set! lst (assoc-set! lst 'name (car x)))
736 (set! lst (assq-remove! lst 'description))
737 (hashq-set! music-name-to-property-table (car x) lst)
741 (define-safe-public (make-music name . music-properties)
742 "Create a music object of given name, and set its properties
743 according to @code{music-properties}, a list of alternating property symbols
745 (make-music 'OverrideProperty
747 'grob-property 'thickness
748 'grob-value (* 2 1.5))"
749 (if (not (symbol? name))
750 (ly:error (_ "symbol expected: ~S") name))
751 (let ((props (hashq-ref music-name-to-property-table name '())))
752 (if (not (pair? props))
753 (ly:error (_ "cannot find music object: ~S") name))
754 (let ((m (ly:make-music props)))
755 (define (set-props mus-props)
756 (if (and (not (null? mus-props))
757 (not (null? (cdr mus-props))))
759 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
760 (set-props (cddr mus-props)))))
761 (set-props music-properties)
764 (define-public (make-repeated-music name)
765 (let* ((repeated-music (assoc-get name '(("volta" . VoltaRepeatedMusic)
766 ("unfold" . UnfoldedRepeatedMusic)
767 ("percent" . PercentRepeatedMusic)
768 ("tremolo" . TremoloRepeatedMusic))))
769 (repeated-music-name (if repeated-music
772 (ly:warning (_ "unknown repeat type `~S'") name)
773 (ly:warning (_ "See define-music-types.scm for supported repeats"))
774 'VoltaRepeatedMusic))))
775 (make-music repeated-music-name)))