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 . (general-music post-event event dynamic-event absolute-dynamic-event))
36 . ((description . "Create an alternative event.")
37 (types . (general-music event alternative-event))
41 . ((description . "Print an annotation of an output element.")
42 (types . (general-music event annotate-output-event post-event))
46 . ((description . "Call the argument with the current context during
48 (types . (general-music 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 . (general-music event apply-output-event))
64 . ((description . "Make an arpeggio on this note.
66 Syntax: @w{@var{note}@code{-\\arpeggio}}")
67 (types . (general-music 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 . (general-music 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 . (general-music music-wrapper-music auto-change-instruction))
93 . ((description . "Check whether this music coincides with
94 the start of the measure.")
95 (types . (general-music bar-check))
96 (iterator-ctor . ,ly:bar-check-iterator::constructor)
100 . ((description . "Print a bass-figure text.")
101 (types . (general-music 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 . (general-music post-event event beam-event span-event))
112 . ((description . "Specify that a note may not auto-beamed.")
113 (types . (general-music post-event event beam-forbid-event))
116 (BreakDynamicSpanEvent
117 . ((description . "End an alignment spanner for dynamics here.")
118 (types . (general-music post-event break-span-event break-dynamic-span-event event))
122 . ((description . "A drop/@/fall/@/doit jazz articulation.")
123 (types . (general-music post-event bend-after-event event))))
126 . ((description . "Create a @q{breath mark} or @q{comma}.
128 Syntax: @var{note}@code{\\breathe}")
130 (types . (general-music 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 . (general-music cluster-note-event melodic-event
138 rhythmic-event event))
141 (CompletizeExtenderEvent
142 . ((description . "Used internally to signal the end of a lyrics block to
143 ensure extenders are completed correctly when a @code{Lyrics} context ends
144 before its associated @code{Voice} context.")
145 (types . (general-music completize-extender-event event))
149 . ((description . "Change staves in Piano staff.
151 Syntax: @code{\\change Staff = @var{new-id}}")
152 (iterator-ctor . ,ly:change-iterator::constructor)
153 (types . (general-music translator-change-instruction))
157 . ((description . "Interpret the argument music within a
159 (iterator-ctor . ,ly:context-specced-music-iterator::constructor)
160 (length-callback . ,ly:music-wrapper::length-callback)
161 (start-callback . ,ly:music-wrapper::start-callback)
162 (types . (context-specification general-music music-wrapper-music))
166 . ((description . "Begin or end a crescendo.
168 Syntax: @var{note}@code{\\<} @dots{} @var{note}@code{\\!}
170 An alternative syntax is @var{note}@code{\\cr} @dots{}
171 @var{note}@code{\\endcr}.")
172 (types . (general-music post-event span-event span-dynamic-event crescendo-event
177 . ((description . "Begin or end a decrescendo.
179 Syntax: @var{note}@code{\\>} @dots{} @var{note}@code{\\!}
181 An alternative syntax is @var{note}@code{\\decr} @dots{}
182 @var{note}@code{\\enddecr}.")
183 (types . (general-music post-event span-event span-dynamic-event decrescendo-event
188 . ((description . "Used internally to signal double percent repeats.")
189 (types . (general-music event double-percent-event rhythmic-event))
193 . ((description . "Begin or end an episema.")
194 (types . (general-music post-event span-event event episema-event))
198 . ((description . "Atomic music event.")
199 (types . (general-music event))
203 . ((description . "Explicitly entered chords.
205 When iterated, @code{elements} are converted to events at the current
206 timestep, followed by any @code{articulations}. Per-chord postevents
207 attached by the parser just follow any rhythmic events in
208 @code{elements} instead of utilizing @code{articulations}.
210 An unexpanded chord repetition @samp{q} is recognizable by having its
211 duration stored in @code{duration}.")
212 (iterator-ctor . ,ly:event-chord-iterator::constructor)
213 (length-callback . ,ly:music-sequence::event-chord-length-callback)
214 (to-relative-callback .
215 ,ly:music-sequence::event-chord-relative-callback)
216 (types . (general-music event-chord simultaneous-music))
220 . ((description . "Extend lyrics.")
221 (types . (general-music post-event extender-event event))
225 . ((description . "Specify what finger to use for this note.")
226 (types . (general-music post-event fingering-event event))
230 . ((description . "Footnote a grob.")
231 (types . (general-music event footnote-event))
235 . ((description . "Start a glissando on this note.")
236 (types . (general-music post-event glissando-event event))
240 . ((description . "Interpret the argument as grace notes.")
241 (start-callback . ,ly:grace-music::start-callback)
242 (length . ,ZERO-MOMENT)
243 (iterator-ctor . ,ly:grace-iterator::constructor)
244 (types . (grace-music music-wrapper-music general-music))
248 . ((description . "Mark a note as harmonic.")
249 (types . (general-music post-event event harmonic-event))
253 . ((description . "A hyphen between lyric syllables.")
254 (types . (general-music post-event hyphen-event event))
258 . ((description . "Change the key signature.
260 Syntax: @code{\\key} @var{name} @var{scale}")
261 (to-relative-callback . ,(lambda (x p) p))
262 (types . (general-music key-change-event event))
266 . ((description . "Place a bookmarking label.")
267 (types . (general-music label-event event))
271 . ((description . "Don't damp this chord.
273 Syntax: @var{note}@code{\\laissezVibrer}")
274 (types . (general-music post-event event laissez-vibrer-event))
278 . ((description . "Start or end a ligature.")
279 (types . (general-music span-event ligature-event event))
283 . ((description . "Allow, forbid or force a line break.")
284 (types . (general-music line-break-event break-event event))
288 . ((description . "Align lyrics to the start of notes.
290 Syntax: @code{\\lyricsto} @var{voicename} @var{lyrics}")
291 (length . ,ZERO-MOMENT)
292 (types . (general-music lyric-combine-music))
293 (iterator-ctor . ,ly:lyric-combine-music-iterator::constructor)
297 . ((description . "A lyric syllable. Must be entered in lyrics mode,
298 i.e., @code{\\lyrics @{ twinkle4 twinkle4 @} }.")
299 (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
300 (types . (general-music rhythmic-event lyric-event event))
304 . ((description . "Insert a rehearsal mark.
306 Syntax: @code{\\mark} @var{marker}
308 Example: @code{\\mark \"A\"}")
309 (types . (general-music mark-event event))
313 . ((description . "Used to signal the start and end of a measure count.")
314 (types . (general-music measure-counter-event span-event event))
317 (MultiMeasureRestEvent
318 . ((description . "Used internally by @code{MultiMeasureRestMusic}
320 (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
321 (types . (general-music event rhythmic-event
322 multi-measure-rest-event))
325 (MultiMeasureRestMusic
326 . ((description . "Rests that may be compressed into Multi rests.
328 Syntax: @code{R2.*4} for 4 measures in 3/4 time.")
329 (iterator-ctor . ,ly:sequential-iterator::constructor)
330 (elements-callback . ,mm-rest-child-list)
331 (types . (general-music multi-measure-rest))
334 (MultiMeasureTextEvent
335 . ((description . "Texts on multi measure rests.
337 Syntax: @code{R-\\markup @{ \\roman \"bla\" @}}
339 Note the explicit font switch.")
340 (types . (general-music post-event event multi-measure-text-event))
344 . ((description . "Generic type for music expressions.")
345 (types . (general-music))
349 . ((description . "A note.
351 Outside of chords, any events in @code{articulations} with a listener
352 are broadcast like chord articulations, the others are retained.
354 For iteration inside of chords, @xref{EventChord}.")
355 (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
356 (types . (general-music event note-event rhythmic-event
361 . ((description . "Start or stop grouping brackets.")
362 (types . (general-music post-event event note-grouping-event))
366 . ((description . "Start or stop an ottava bracket.")
367 (iterator-ctor . ,ly:sequential-iterator::constructor)
368 (elements-callback . ,make-ottava-set)
369 (types . (general-music ottava-music))
373 . ((description . "Extend the definition of a graphical object.
375 Syntax: @code{\\override} [ @var{context} @code{.} ]
376 @var{object} @var{property} @code{=} @var{value}")
377 (types . (general-music layout-instruction-event
378 override-property-event))
379 (iterator-ctor . ,ly:push-property-iterator::constructor)
380 (untransposable . #t)
384 . ((description . "Allow, forbid or force a page break.")
385 (types . (general-music break-event page-break-event event))
389 . ((description . "Allow, forbid or force a page turn.")
390 (types . (general-music break-event page-turn-event event))
393 (PartCombineForceEvent
394 . ((description . "Override the part-combiner's strategy.")
395 (types . (general-music part-combine-force-event event))
399 . ((description . "Create an anacrusis or upbeat (partial measure).")
400 (iterator-ctor . ,ly:partial-iterator::constructor)
401 ;; The length-callback is kind of cheesy since 'elements is
402 ;; empty. We just use that in order to get a zero length
403 ;; for the overall timing in spite of having a non-zero
405 (length-callback . ,ly:music-sequence::cumulative-length-callback)
406 (types . (general-music partial-set))
410 . ((description . "Combine two parts on a staff, either merged or
411 as separate voices.")
412 (length-callback . ,ly:music-sequence::maximum-length-callback)
413 (start-callback . ,ly:music-sequence::minimum-start-callback)
414 (types . (general-music part-combine-music))
415 (iterator-ctor . ,ly:part-combine-iterator::constructor)
419 . ((description . "Used internally to signal percent repeats.")
420 (types . (general-music event percent-event rhythmic-event))
423 (PercentRepeatedMusic
424 . ((description . "Repeats encoded by percents and slashes.")
425 (iterator-ctor . ,ly:percent-repeat-iterator::constructor)
426 (start-callback . ,ly:repeated-music::first-start)
427 (length-callback . ,ly:repeated-music::unfolded-music-length)
428 (types . (general-music repeated-music percent-repeated-music))
432 . ((description . "Within a ligature, mark the previous and the
433 following note to form a pes (if melody goes up) or a flexa (if melody
435 (types . (general-music pes-or-flexa-event event))
439 . ((description . "Start or end phrasing slur.
441 Syntax: @var{note}@code{\\(} and @var{note}@code{\\)}")
443 (types . (general-music post-event span-event event phrasing-slur-event))
447 . ((description . "Container for several postevents.
449 This can be used to package several events into a single one. Should not be seen outside of the parser.")
450 (types . (post-event post-event-wrapper))))
453 . ((description . "Set a context property.
455 Syntax: @code{\\set @var{context}.@var{prop} = @var{scheme-val}}")
456 (types . (layout-instruction-event general-music))
457 (iterator-ctor . ,ly:property-iterator::constructor)
458 (untransposable . #t)
462 . ((description . "Restore the default setting for a context
463 property. See @ref{PropertySet}.
465 Syntax: @code{\\unset @var{context}.@var{prop}}")
466 (types . (layout-instruction-event general-music))
467 (iterator-ctor . ,ly:property-unset-iterator::constructor)
471 . ((description . "Quote preprocessed snippets of music.")
472 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
473 (length-callback . ,ly:music-wrapper::length-callback)
474 (start-callback . ,ly:music-wrapper::start-callback)
475 (types . (general-music music-wrapper-music))
479 . ((description . "Check if a pitch is in the correct octave.")
480 (to-relative-callback . ,ly:relative-octave-check::relative-callback)
481 (types . (general-music relative-octave-check))
485 . ((description . "Music that was entered in relative octave notation.")
486 (to-relative-callback . ,ly:relative-octave-music::relative-callback)
487 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
488 (length-callback . ,ly:music-wrapper::length-callback)
489 (start-callback . ,ly:music-wrapper::start-callback)
490 (types . (music-wrapper-music general-music relative-octave-music))
494 . ((description . "Repeat music in different ways.")
495 (types . (general-music repeated-music))
499 . ((description . "Used internally to signal beat repeats.")
500 (types . (general-music event repeat-slash-event rhythmic-event))
504 . ((description . "Ties for starting a second volta bracket.")
505 (types . (general-music post-event event repeat-tie-event))
509 . ((description . "A Rest.
511 Syntax: @code{r4} for a quarter rest.")
512 (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
513 (types . (general-music event rhythmic-event rest-event))
517 . ((description . "The opposite of @ref{OverrideProperty}: remove a
518 previously added property from a graphical object definition.")
519 (types . (general-music layout-instruction-event))
520 (iterator-ctor . ,ly:pop-property-iterator::constructor)
524 . ((description . "Add an articulation mark to a note.")
525 (types . (general-music event))
529 . ((description . "Music expressions concatenated.
531 Syntax: @code{\\sequential @{ @dots{} @}} or simply @code{@{ @dots{} @}}")
532 (length-callback . ,ly:music-sequence::cumulative-length-callback)
533 (start-callback . ,ly:music-sequence::first-start-callback)
534 (elements-callback . ,(lambda (m) (ly:music-property m 'elements)))
535 (iterator-ctor . ,ly:sequential-iterator::constructor)
536 (types . (general-music sequential-music))
540 . ((description . "Music playing together.
542 Syntax: @code{\\simultaneous @{ @dots{} @}} or @code{<< @dots{} >>}")
543 (iterator-ctor . ,ly:simultaneous-music-iterator::constructor)
544 (start-callback . ,ly:music-sequence::minimum-start-callback)
545 (length-callback . ,ly:music-sequence::maximum-length-callback)
546 (to-relative-callback .
547 ,ly:music-sequence::simultaneous-relative-callback)
548 (types . (general-music simultaneous-music))
552 . ((description . "Filler that takes up duration, but does not
555 Syntax: @code{s4} for a skip equivalent to a quarter rest.")
556 (iterator-ctor . ,ly:rhythmic-music-iterator::constructor)
557 (types . (general-music event rhythmic-event skip-event))
561 . ((description . "Filler that takes up duration, does not
562 print anything, and also does not create staves or voices implicitly.
564 Syntax: @code{\\skip} @var{duration}")
565 (length-callback . ,ly:music-duration-length)
566 (iterator-ctor . ,ly:simple-music-iterator::constructor)
567 (types . (general-music event skip-event))
571 . ((description . "Start or end slur.
573 Syntax: @var{note}@code{(} and @var{note}@code{)}")
575 (types . (general-music post-event span-event event slur-event))
579 . ((description . "Print @q{Solo@tie{}1}.")
580 (part-combine-status . solo1)
581 (types . (general-music event part-combine-event solo-one-event))
585 . ((description . "Print @q{Solo@tie{}2}.")
586 (part-combine-status . solo2)
587 (types . (general-music event part-combine-event solo-two-event))
591 . ((description . "Depress or release sostenuto pedal.")
592 (types . (general-music post-event event pedal-event sostenuto-event))
596 . ((description . "Start a new spacing section.")
597 (types . (general-music event spacing-section-event))))
600 . ((description . "Event for anything that is started at a
601 different time than stopped.")
602 (types . (general-music event))
606 . ((description . "Start or stop a staff symbol.")
607 (types . (general-music event span-event staff-span-event))
611 . ((description . "Specify on which string to play this note.
613 Syntax: @code{\\@var{number}}")
614 (types . (general-music post-event string-number-event event))
618 . ((description . "Specify with which finger to pluck a string.
620 Syntax: @code{\\rightHandFinger @var{text}}")
621 (types . (general-music post-event stroke-finger-event event))
625 . ((description . "Depress or release sustain pedal.")
626 (types . (general-music post-event event pedal-event sustain-event))
630 . ((description . "A metronome mark or tempo indication.")
631 (types . (general-music event tempo-change-event))
635 . ((description . "Print text.")
636 (types . (general-music post-event script-event text-script-event event))
640 . ((description . "Start a text spanner, for example, an
642 (types . (general-music post-event span-event event text-span-event))
646 . ((description . "A tie.
648 Syntax: @w{@var{note}@code{-~}}")
649 (types . (general-music post-event tie-event event))
653 . ((description . "Multiply durations, as in tuplets.
655 Syntax: @code{\\times @var{fraction} @var{music}}, e.g.,
656 @code{\\times 2/3 @{ @dots{} @}} for triplets.")
657 (length-callback . ,ly:music-wrapper::length-callback)
658 (start-callback . ,ly:music-wrapper::start-callback)
659 (iterator-ctor . ,ly:tuplet-iterator::constructor)
660 (types . (time-scaled-music music-wrapper-music general-music))
664 . ((description . "Set a new time signature")
665 (iterator-ctor . ,ly:sequential-iterator::constructor)
666 (elements-callback . ,make-time-signature-set)
667 (types . (general-music time-signature-music))
671 . ((description . "An event created when setting a new time signature")
672 (types . (general-music event time-signature-event))
676 . ((description . "Music that has been transposed.")
677 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
678 (start-callback . ,ly:music-wrapper::start-callback)
679 (length-callback . ,ly:music-wrapper::length-callback)
680 (to-relative-callback .
681 ,ly:relative-octave-music::no-relative-callback)
682 (types . (music-wrapper-music general-music transposed-music))
686 . ((description . "Unmeasured tremolo.")
687 (types . (general-music post-event event tremolo-event))
690 (TremoloRepeatedMusic
691 . ((description . "Repeated notes denoted by tremolo beams.")
692 (iterator-ctor . ,ly:chord-tremolo-iterator::constructor)
693 (start-callback . ,ly:repeated-music::first-start)
694 (length-callback . ,ly:repeated-music::unfolded-music-length)
695 (types . (general-music repeated-music tremolo-repeated-music))
699 . ((description . "Tremolo over two stems.")
700 (types . (general-music event span-event tremolo-span-event))
704 . ((description . "Start a trill spanner.")
705 (types . (general-music post-event span-event event trill-span-event))
709 . ((description . "Used internally to signal where tuplet
710 brackets start and stop.")
711 (types . (tuplet-span-event span-event event general-music post-event))
715 . ((description . "Depress or release una-corda pedal.")
716 (types . (general-music post-event event pedal-event una-corda-event))
719 (UnfoldedRepeatedMusic
720 . ((description . "Repeated music which is fully written (and
722 (iterator-ctor . ,ly:sequential-iterator::constructor)
723 (elements-callback . ,make-unfolded-set)
724 (start-callback . ,ly:repeated-music::first-start)
725 (types . (general-music repeated-music unfolded-repeated-music))
726 (length-callback . ,ly:repeated-music::unfolded-music-length)
730 . ((description . "Print @q{a@tie{}2}.")
731 (part-combine-status . unisono)
732 (types . (general-music event part-combine-event unisono-event))))
735 . ((description . "Music that cannot be converted from relative
736 to absolute notation. For example, transposed music.")
737 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
738 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
739 (length-callback . ,ly:music-wrapper::length-callback)
740 (types . (music-wrapper-music general-music unrelativable-music))
744 . ((description . "Separate polyphonic voices in simultaneous music.
746 Syntax: @code{\\\\}")
747 (types . (separator general-music))
751 . ((description . "Repeats with alternatives placed sequentially.")
752 (iterator-ctor . ,ly:volta-repeat-iterator::constructor)
753 (elements-callback . ,make-volta-set)
754 (start-callback . ,ly:repeated-music::first-start)
755 (length-callback . ,ly:repeated-music::volta-music-length)
756 (types . (general-music repeated-music volta-repeated-music))
760 (set! music-descriptions
761 (sort music-descriptions alist<?))
763 (define-public music-name-to-property-table (make-hash-table 59))
766 ;; transport description to an object property.
770 (set-object-property! (car x)
772 (cdr (assq 'description (cdr x))))
774 (set! lst (assoc-set! lst 'name (car x)))
775 (set! lst (assq-remove! lst 'description))
776 (hashq-set! music-name-to-property-table (car x) lst)
780 (define-safe-public (make-music name . music-properties)
781 "Create a music object of given name, and set its properties
782 according to @code{music-properties}, a list of alternating property symbols
785 (make-music 'OverrideProperty
787 'grob-property 'thickness
788 'grob-value (* 2 1.5))
790 Instead of a successive symbol and value, an entry in the list may
791 also be an alist or a music object in which case its elements,
792 respectively its @emph{mutable} property list (properties not inherent
793 to the type of the music object) will get taken.
795 The argument list will be interpreted left-to-right, so later entries
796 override earlier ones."
797 (if (not (symbol? name))
798 (ly:error (_ "symbol expected: ~S") name))
799 (let ((props (hashq-ref music-name-to-property-table name '())))
800 (if (not (pair? props))
801 (ly:error (_ "cannot find music object: ~S") name))
802 (let ((m (ly:make-music props)))
803 (define (alist-set-props lst)
804 (for-each (lambda (e)
805 (set! (ly:music-property m (car e)) (cdr e)))
807 (define (set-props mus-props)
808 (if (pair? mus-props)
809 (let ((e (car mus-props))
810 (mus-props (cdr mus-props)))
812 (set! (ly:music-property m e) (car mus-props))
813 (set-props (cdr mus-props)))
815 (alist-set-props (ly:music-mutable-properties e))
816 (set-props mus-props))
819 (set-props mus-props))
821 (ly:error (_ "bad make-music argument: ~S") e))))))
822 (set-props music-properties)