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 ;; TODO: should link back into user manual.
21 (define-public music-descriptions
24 . ((description . "Create a dynamic mark.
26 Syntax: @var{note}@code{\\x}, where @code{\\x} is a dynamic mark like
27 @code{\\ppp} or @code{\\sfz}. A complete list is in file
28 @file{ly/@/dynamic-scripts-init.ly}.")
29 (types . (general-music event dynamic-event absolute-dynamic-event))
33 . ((description . "Print an annotation of an output element.")
34 (types . (general-music event annotate-output-event))
38 . ((description . "Call the argument with the current context during
40 (types . (general-music apply-context))
41 (iterator-ctor . ,ly:apply-context-iterator::constructor)
45 . ((description . "Call the argument with all current grobs during
48 Syntax: @code{\\applyOutput #'@var{context} @var{func}}
50 Arguments to @var{func} are 1.@tie{}the grob, 2.@tie{}the originating
51 context, and 3.@tie{}the context where @var{func} is called.")
52 (types . (general-music event apply-output-event))
56 . ((description . "Make an arpeggio on this note.
58 Syntax: @var{note}@code{-\\arpeggio}")
59 (types . (general-music arpeggio-event event))
62 ;; todo: use articulation-event for slur as well.
63 ;; separate non articulation scripts
65 . ((description . "Add an articulation marking to a note.
67 Syntax: @var{note}@code{x}@code{y}, where @code{x} is a direction
68 (@code{^} for up or @code{_} for down), or LilyPond's choice
69 (no direction specified), and where @code{y} is an articulation
70 (such as @code{-.}, @code{->}, @code{\\tenuto}, @code{\\downbow}).
71 See the Notation Reference for details.")
72 (types . (general-music event articulation-event script-event))
76 . ((description . "Used for making voices that switch between
77 piano staves automatically.")
78 (iterator-ctor . ,ly:auto-change-iterator::constructor)
79 (start-callback . ,ly:music-wrapper::start-callback)
80 (length-callback . ,ly:music-wrapper::length-callback)
81 (types . (general-music music-wrapper-music auto-change-instruction))
85 . ((description . "Check whether this music coincides with
86 the start of the measure.")
87 (types . (general-music bar-check))
88 (iterator-ctor . ,ly:bar-check-iterator::constructor)
92 . ((description . "Print a bass-figure text.")
93 (types . (general-music event rhythmic-event bass-figure-event))
97 . ((description . "Start or stop a beam.
99 Syntax for manual control: @code{c8-[ c c-] c8}")
100 (types . (general-music event beam-event span-event))
104 . ((description . "Specify that a note may not auto-beamed.")
105 (types . (general-music event beam-forbid-event))
108 (BreakDynamicSpanEvent
109 . ((description . "End an alignment spanner for dynamics here.")
110 (types . (general-music break-span-event break-dynamic-span-event event))
114 . ((description . "A drop/fall/doit jazz articulation.")
115 (types . (general-music bend-after-event event))))
118 . ((description . "Create a @q{breath mark} or @q{comma}.
120 Syntax: @var{note}@code{\\breathe}")
122 (types . (general-music event breathing-event))
126 . ((description . "A note that is part of a cluster.")
127 ;; not a note-event, to ensure that Note_heads_engraver doesn't eat it.
128 (types . (general-music cluster-note-event melodic-event
129 rhythmic-event event))
132 (CompletizeExtenderEvent
133 . ((description . "Used internally to signal the end of a lyrics block to
134 ensure extenders are completed correctly when a @code{Lyrics} context ends
135 before its associated @code{Voice} context.")
136 (types . (general-music completize-extender-event event))
140 . ((description . "Change staves in Piano staff.
142 Syntax: @code{\\change Staff = @var{new-id}}")
143 (iterator-ctor . ,ly:change-iterator::constructor)
144 (types . (general-music translator-change-instruction))
148 . ((description . "Interpret the argument music within a
150 (iterator-ctor . ,ly:context-specced-music-iterator::constructor)
151 (length-callback . ,ly:music-wrapper::length-callback)
152 (start-callback . ,ly:music-wrapper::start-callback)
153 (types . (context-specification general-music music-wrapper-music))
157 . ((description . "Begin or end a crescendo.
159 Syntax: @var{note}@code{\\<} @dots{} @var{note}@code{\\!}
161 An alternative syntax is @var{note}@code{\\cr} @dots{}
162 @var{note}@code{\\endcr}.")
163 (types . (general-music span-event span-dynamic-event crescendo-event
168 . ((description . "Begin or end a decrescendo.
170 Syntax: @var{note}@code{\\>} @dots{} @var{note}@code{\\!}
172 An alternative syntax is @var{note}@code{\\decr} @dots{}
173 @var{note}@code{\\enddecr}.")
174 (types . (general-music span-event span-dynamic-event decrescendo-event
179 . ((description . "Begin or end an episema.")
180 (types . (general-music span-event event episema-event))
184 . ((description . "Atomic music event.")
185 (types . (general-music event))
189 . ((description . "Internally used to group a set of events.")
190 (iterator-ctor . ,ly:event-chord-iterator::constructor)
191 (length-callback . ,ly:music-sequence::maximum-length-callback)
192 (to-relative-callback .
193 ,ly:music-sequence::event-chord-relative-callback)
194 (types . (general-music event-chord simultaneous-music))
198 . ((description . "Extend lyrics.")
199 (types . (general-music extender-event event))
203 . ((description . "Specify what finger to use for this note.")
204 (types . (general-music fingering-event event))
208 . ((description . "Start a glissando on this note.")
209 (types . (general-music glissando-event event))
213 . ((description . "Interpret the argument as grace notes.")
214 (start-callback . ,ly:grace-music::start-callback)
215 (length . ,ZERO-MOMENT)
216 (iterator-ctor . ,ly:grace-iterator::constructor)
217 (types . (grace-music music-wrapper-music general-music))
221 . ((description . "Mark a note as harmonic.")
222 (types . (general-music event harmonic-event))
226 . ((description . "A hyphen between lyric syllables.")
227 (types . (general-music hyphen-event event))
231 . ((description . "Change the key signature.
233 Syntax: @code{\\key} @var{name} @var{scale}")
234 (to-relative-callback . ,(lambda (x p) p))
235 (types . (general-music key-change-event event))
239 . ((description . "Place a bookmarking label.")
240 (types . (general-music label-event event))
244 . ((description . "Don't damp this chord.
246 Syntax: @var{note}@code{\\laissezVibrer}")
247 (types . (general-music event laissez-vibrer-event))
251 . ((description . "Start or end a ligature.")
252 (types . (general-music span-event ligature-event event))
256 . ((description . "Allow, forbid or force a line break.")
257 (types . (general-music line-break-event break-event event))
261 . ((description . "Align lyrics to the start of notes.
263 Syntax: @code{\\lyricsto} @var{voicename} @var{lyrics}")
264 (length . ,ZERO-MOMENT)
265 (types . (general-music lyric-combine-music))
266 (iterator-ctor . ,ly:lyric-combine-music-iterator::constructor)
270 . ((description . "A lyric syllable. Must be entered in lyrics mode,
271 i.e., @code{\\lyrics @{ twinkle4 twinkle4 @} }.")
272 (types . (general-music rhythmic-event lyric-event event))
276 . ((description . "Insert a rehearsal mark.
278 Syntax: @code{\\mark} @var{marker}
280 Example: @code{\\mark \"A\"}")
281 (types . (general-music mark-event event))
284 (MultiMeasureRestEvent
285 . ((description . "Used internally by @code{MultiMeasureRestMusic}
287 (types . (general-music event rhythmic-event
288 multi-measure-rest-event))
291 (MultiMeasureRestMusic
292 . ((description . "Rests that may be compressed into Multi rests.
294 Syntax: @code{R2.*4} for 4 measures in 3/4 time.")
295 (iterator-ctor . ,ly:sequential-iterator::constructor)
296 (elements-callback . ,mm-rest-child-list)
297 (types . (general-music multi-measure-rest))
300 (MultiMeasureTextEvent
301 . ((description . "Texts on multi measure rests.
303 Syntax: @code{R-\\markup @{ \\roman \"bla\" @}}
305 Note the explicit font switch.")
306 (types . (general-music event multi-measure-text-event))
310 . ((description . "Generic type for music expressions.")
311 (types . (general-music))
315 . ((description . "A note.")
316 (types . (general-music event note-event rhythmic-event
321 . ((description . "Start or stop grouping brackets.")
322 (types . (general-music event note-grouping-event))
326 . ((description . "Start or stop an ottava bracket.")
327 (iterator-ctor . ,ly:sequential-iterator::constructor)
328 (elements-callback . ,make-ottava-set)
329 (types . (general-music ottava-music))
333 . ((description . "Extend the definition of a graphical object.
335 Syntax: @code{\\override} [ @var{context} @code{.} ]
336 @var{object} @var{property} @code{=} @var{value}")
337 (types . (general-music layout-instruction-event
338 override-property-event))
339 (iterator-ctor . ,ly:push-property-iterator::constructor)
343 . ((description . "Allow, forbid or force a page break.")
344 (types . (general-music break-event page-break-event event))
348 . ((description . "Allow, forbid or force a page turn.")
349 (types . (general-music break-event page-turn-event event))
352 (PartCombineForceEvent
353 . ((description . "Override the part-combiner's strategy.")
354 (types . (general-music part-combine-force-event event))
358 . ((description . "Create an anacrusis or upbeat (partial measure).")
359 (iterator-ctor . ,ly:partial-iterator::constructor)
360 (types . (general-music partial-set))
364 . ((description . "Combine two parts on a staff, either merged or
365 as separate voices.")
366 (length-callback . ,ly:music-sequence::maximum-length-callback)
367 (start-callback . ,ly:music-sequence::minimum-start-callback)
368 (types . (general-music part-combine-music))
369 (iterator-ctor . ,ly:part-combine-iterator::constructor)
373 . ((description . "Used internally to signal percent repeats.")
374 (types . (general-music event percent-event rhythmic-event))
377 (PercentRepeatedMusic
378 . ((description . "Repeats encoded by percents.")
379 (iterator-ctor . ,ly:percent-repeat-iterator::constructor)
380 (start-callback . ,ly:repeated-music::first-start)
381 (length-callback . ,ly:repeated-music::unfolded-music-length)
382 (types . (general-music repeated-music percent-repeated-music))
386 . ((description . "Within a ligature, mark the previous and the
387 following note to form a pes (if melody goes up) or a flexa (if melody
389 (types . (general-music pes-or-flexa-event event))
393 . ((description . "Start or end phrasing slur.
395 Syntax: @var{note}@code{\\(} and @var{note}@code{\\)}")
396 (types . (general-music span-event event phrasing-slur-event))
400 . ((description . "Set a context property.
402 Syntax: @code{\\set @var{context}.@var{prop} = @var{scheme-val}}")
403 (types . (layout-instruction-event general-music))
404 (iterator-ctor . ,ly:property-iterator::constructor)
408 . ((description . "Restore the default setting for a context
409 property. See @ref{PropertySet}.
411 Syntax: @code{\\unset @var{context}.@var{prop}}")
412 (types . (layout-instruction-event general-music))
413 (iterator-ctor . ,ly:property-unset-iterator::constructor)
417 . ((description . "Quote preprocessed snippets of music.")
418 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
419 (length-callback . ,ly:music-wrapper::length-callback)
420 (start-callback . ,ly:music-wrapper::start-callback)
421 (types . (general-music music-wrapper-music))
425 . ((description . "Check if a pitch is in the correct octave.")
426 (to-relative-callback . ,ly:relative-octave-check::relative-callback)
427 (types . (general-music relative-octave-check))
431 . ((description . "Music that was entered in relative octave notation.")
432 (to-relative-callback . ,ly:relative-octave-music::relative-callback)
433 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
434 (length-callback . ,ly:music-wrapper::length-callback)
435 (start-callback . ,ly:music-wrapper::start-callback)
436 (types . (music-wrapper-music general-music relative-octave-music))
440 . ((description . "A chord repetition")
441 (to-relative-callback . ,ly:music-sequence::repeated-chord-relative-callback)
442 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
443 (start-callback . ,ly:music-wrapper::start-callback)
444 (length-callback . ,ly:music-wrapper::length-callback)
445 (types . (general-music music-wrapper-music))
449 . ((description . "Repeat music in different ways.")
450 (types . (general-music repeated-music))
454 . ((description . "Ties for starting a second volta bracket.")
455 (types . (general-music event repeat-tie-event))
459 . ((description . "A Rest.
461 Syntax: @code{r4} for a quarter rest.")
462 (types . (general-music event rhythmic-event rest-event))
466 . ((description . "The opposite of @ref{OverrideProperty}: remove a
467 previously added property from a graphical object definition.")
468 (types . (general-music layout-instruction-event))
469 (iterator-ctor . ,ly:pop-property-iterator::constructor)
473 . ((description . "Add an articulation mark to a note.")
474 (types . (general-music event))
478 . ((description . "Music expressions concatenated.
480 Syntax: @code{\\sequential @{ @dots{} @}} or simply @code{@{ @dots{} @}}")
481 (length-callback . ,ly:music-sequence::cumulative-length-callback)
482 (start-callback . ,ly:music-sequence::first-start-callback)
483 (elements-callback . ,(lambda (m) (ly:music-property m 'elements)))
484 (iterator-ctor . ,ly:sequential-iterator::constructor)
485 (types . (general-music sequential-music))
489 . ((description . "Music playing together.
491 Syntax: @code{\\simultaneous @{ @dots{} @}} or @code{<< @dots{} >>}")
492 (iterator-ctor . ,ly:simultaneous-music-iterator::constructor)
493 (start-callback . ,ly:music-sequence::minimum-start-callback)
494 (length-callback . ,ly:music-sequence::maximum-length-callback)
495 (to-relative-callback .
496 ,ly:music-sequence::simultaneous-relative-callback)
497 (types . (general-music simultaneous-music))
501 . ((description . "Filler that takes up duration, but does not
504 Syntax: @code{s4} for a skip equivalent to a quarter rest.")
505 (types . (general-music event rhythmic-event skip-event))
509 . ((description . "Filler that takes up duration, does not
510 print anything, and also does not create staves or voices implicitly.
512 Syntax: @code{\\skip} @var{duration}")
513 (length-callback . ,ly:music-duration-length)
514 (iterator-ctor . ,ly:simple-music-iterator::constructor)
515 (types . (general-music event rhythmic-event skip-event))
519 . ((description . "Start or end slur.
521 Syntax: @var{note}@code{(} and @var{note}@code{)}")
522 (types . (general-music span-event event slur-event))
526 . ((description . "Print @q{Solo@tie{}1}.")
527 (part-combine-status . solo1)
528 (types . (general-music event part-combine-event solo-one-event))
532 . ((description . "Print @q{Solo@tie{}2}.")
533 (part-combine-status . solo2)
534 (types . (general-music event part-combine-event solo-two-event))
538 . ((description . "Depress or release sostenuto pedal.")
539 (types . (general-music event pedal-event sostenuto-event))
543 . ((description . "Start a new spacing section.")
544 (types . (general-music event spacing-section-event))))
547 . ((description . "Event for anything that is started at a
548 different time than stopped.")
549 (types . (general-music event))
553 . ((description . "Start or stop a staff symbol.")
554 (types . (general-music event span-event staff-span-event))
558 . ((description . "Specify on which string to play this note.
560 Syntax: @code{\\@var{number}}")
561 (types . (general-music string-number-event event))
565 . ((description . "Specify with which finger to pluck a string.
567 Syntax: @code{\\rightHandFinger @var{text}}")
568 (types . (general-music stroke-finger-event event))
572 . ((description . "Depress or release sustain pedal.")
573 (types . (general-music event pedal-event sustain-event))
577 . ((description . "A metronome mark or tempo indication.")
578 (types . (general-music event tempo-change-event))
582 . ((description . "Print text.")
583 (types . (general-music script-event text-script-event event))
587 . ((description . "Start a text spanner, for example, an
589 (types . (general-music span-event event text-span-event))
593 . ((description . "A tie.
595 Syntax: @var{note}@code{-~}")
596 (types . (general-music tie-event event))
600 . ((description . "Multiply durations, as in tuplets.
602 Syntax: @code{\\times @var{fraction} @var{music}}, e.g.,
603 @code{\\times 2/3 @{ @dots{} @}} for triplets.")
604 (length-callback . ,ly:music-wrapper::length-callback)
605 (start-callback . ,ly:music-wrapper::start-callback)
606 (iterator-ctor . ,ly:tuplet-iterator::constructor)
607 (types . (time-scaled-music music-wrapper-music general-music))
611 . ((description . "Set a new time signature")
612 (iterator-ctor . ,ly:sequential-iterator::constructor)
613 (elements-callback . ,make-time-signature-set)
614 (types . (general-music time-signature-music))
618 . ((description . "Music that has been transposed.")
619 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
620 (start-callback . ,ly:music-wrapper::start-callback)
621 (length-callback . ,ly:music-wrapper::length-callback)
622 (to-relative-callback .
623 ,ly:relative-octave-music::no-relative-callback)
624 (types . (music-wrapper-music general-music transposed-music))
628 . ((description . "Unmeasured tremolo.")
629 (types . (general-music event tremolo-event))
632 (TremoloRepeatedMusic
633 . ((description . "Repeated notes denoted by tremolo beams.")
634 (iterator-ctor . ,ly:chord-tremolo-iterator::constructor)
635 (start-callback . ,ly:repeated-music::first-start)
636 ;; the length of the repeat is handled by shifting the note logs
637 (length-callback . ,ly:repeated-music::folded-music-length)
638 (types . (general-music repeated-music tremolo-repeated-music))
642 . ((description . "Tremolo over two stems.")
643 (types . (general-music event span-event tremolo-span-event))
647 . ((description . "Start a trill spanner.")
648 (types . (general-music span-event event trill-span-event))
652 . ((description . "Used internally to signal where tuplet
653 brackets start and stop.")
654 (types . (tuplet-span-event span-event event general-music))
658 . ((description . "Depress or release una-corda pedal.")
659 (types . (general-music event pedal-event una-corda-event))
662 (UnfoldedRepeatedMusic
663 . ((description . "Repeated music which is fully written
665 (iterator-ctor . ,ly:unfolded-repeat-iterator::constructor)
666 (start-callback . ,ly:repeated-music::first-start)
667 (types . (general-music repeated-music unfolded-repeated-music))
668 (length-callback . ,ly:repeated-music::unfolded-music-length)
672 . ((description . "Print @q{a@tie{}2}.")
673 (part-combine-status . unisono)
674 (types . (general-music event part-combine-event unisono-event))))
677 . ((description . "Music that cannot be converted from relative
678 to absolute notation. For example, transposed music.")
679 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
680 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
681 (length-callback . ,ly:music-wrapper::length-callback)
682 (types . (music-wrapper-music general-music unrelativable-music))
686 . ((description . "Separate polyphonic voices in simultaneous music.
688 Syntax: @code{\\\\}")
689 (types . (separator general-music))
693 . ((description . "Repeats with alternatives placed sequentially.")
694 (iterator-ctor . ,ly:volta-repeat-iterator::constructor)
695 (start-callback . ,ly:repeated-music::first-start)
696 (length-callback . ,ly:repeated-music::volta-music-length)
697 (types . (general-music repeated-music volta-repeated-music))
701 (set! music-descriptions
702 (sort music-descriptions alist<?))
704 (define-public music-name-to-property-table (make-hash-table 59))
707 ;; transport description to an object property.
711 (set-object-property! (car x)
713 (cdr (assq 'description (cdr x))))
715 (set! lst (assoc-set! lst 'name (car x)))
716 (set! lst (assq-remove! lst 'description))
717 (hashq-set! music-name-to-property-table (car x) lst)
721 (define-safe-public (make-music name . music-properties)
722 "Create a music object of given name, and set its properties
723 according to @code{music-properties}, a list of alternating property symbols
725 (make-music 'OverrideProperty
727 'grob-property 'thickness
728 'grob-value (* 2 1.5))"
729 (if (not (symbol? name))
730 (ly:error (_ "symbol expected: ~S") name))
731 (let ((props (hashq-ref music-name-to-property-table name '())))
732 (if (not (pair? props))
733 (ly:error (_ "cannot find music object: ~S") name))
734 (let ((m (ly:make-music props)))
735 (define (set-props mus-props)
736 (if (and (not (null? mus-props))
737 (not (null? (cdr mus-props))))
739 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
740 (set-props (cddr mus-props)))))
741 (set-props music-properties)
744 (define-public (make-repeated-music name)
745 (let* ((repeated-music (assoc-get name '(("volta" . VoltaRepeatedMusic)
746 ("unfold" . UnfoldedRepeatedMusic)
747 ("percent" . PercentRepeatedMusic)
748 ("tremolo" . TremoloRepeatedMusic))))
749 (repeated-music-name (if repeated-music
752 (ly:warning (_ "unknown repeat type `~S'") name)
753 (ly:warning (_ "See define-music-types.scm for supported repeats"))
754 'VoltaRepeatedMusic))))
755 (make-music repeated-music-name)))