1 ;;;; define-music-types.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
8 ;; TODO: should link back into user manual.
10 (define (mm-rest-child-list music)
11 "Generate events for multimeasure rests,
12 to be used by the sequential-iterator"
13 (let ((location (ly:music-property music 'origin))
14 (duration (ly:music-property music 'duration)))
15 (list (make-music 'BarCheck
17 (make-event-chord (cons (make-music 'MultiMeasureRestEvent
20 (ly:music-property music 'articulations)))
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: @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 @code{-.}, @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))
112 . ((description . "A drop/fall/doit jazz articulation.")
113 (types . (general-music bend-after-event event))))
116 . ((description . "Create a @q{breath mark} or @q{comma}.
118 Syntax: @var{note}@code{\\breathe}")
120 (types . (general-music event breathing-event))
124 . ((description . "Change staves in Piano staff.
126 Syntax: @code{\\change Staff = @var{new-id}}")
127 (iterator-ctor . ,ly:change-iterator::constructor)
128 (types . (general-music translator-change-instruction))
132 . ((description . "A note that is part of a cluster.")
133 ;; not a note-event, to ensure that Note_engraver doesn't eat it.
134 (types . (general-music cluster-note-event melodic-event
135 rhythmic-event event))
139 . ((description . "Interpret the argument music within a
141 (iterator-ctor . ,ly:context-specced-music-iterator::constructor)
142 (length-callback . ,ly:music-wrapper::length-callback)
143 (start-callback . ,ly:music-wrapper::start-callback)
144 (types . (context-specification general-music music-wrapper-music))
148 . ((description . "Begin or end a crescendo.
150 Syntax: @var{note}@code{\\cr} @dots{} @var{note}@code{\\rc}
152 You can also use @code{\\<}, @code{\\!}, @code{\\cresc}, and
153 @code{\\endcresc}. See the Notation Reference for details.")
154 (types . (general-music span-event span-dynamic-event crescendo-event
159 . ((description . "See @ref{CrescendoEvent}.")
160 (types . (general-music span-event span-dynamic-event decrescendo-event
165 . ((description . "Extend lyrics.")
166 (types . (general-music extender-event event))
170 . ((description . "Atomic music event.")
171 (types . (general-music event))
175 . ((description . "Internally used to group a set of events.")
176 (iterator-ctor . ,ly:event-chord-iterator::constructor)
177 (length-callback . ,ly:music-sequence::maximum-length-callback)
178 (to-relative-callback .
179 ,ly:music-sequence::event-chord-relative-callback)
180 (types . (general-music event-chord simultaneous-music))
184 . ((description . "Specify what finger to use for this note.")
185 (types . (general-music fingering-event event))
189 . ((description . "Start a glissando on this note.")
190 (types . (general-music glissando-event event))
194 . ((description . "Interpret the argument as grace notes.")
195 (start-callback . ,ly:grace-music::start-callback)
196 (length . ,ZERO-MOMENT)
197 (iterator-ctor . ,ly:grace-iterator::constructor)
198 (types . (grace-music music-wrapper-music general-music))
202 . ((description . "Mark a note as harmonic.")
203 (types . (general-music event harmonic-event))
207 . ((description . "A hyphen between lyric syllables.")
208 (types . (general-music hyphen-event event))
212 . ((description . "Change the key signature.
214 Syntax: @code{\\key} @var{name} @var{scale}")
215 (to-relative-callback . ,(lambda (x p) p))
216 (types . (general-music key-change-event event))
220 . ((description . "Place a bookmarking label.")
221 (types . (general-music label-event event))
225 . ((description . "Don't damp this chord.
227 Syntax: @var{note}@code{\\laissezVibrer}")
228 (types . (general-music event laissez-vibrer-event))
232 . ((description . "Start or end a ligature.")
233 (span-type . ligature)
234 (types . (general-music span-event ligature-event event))
238 . ((description . "Allow, forbid or force a line break.")
239 (types . (general-music line-break-event break-event event))
243 . ((description . "Align lyrics to the start of notes.
245 Syntax: @code{\\lyricsto} @var{voicename} @var{lyrics}")
246 (length . ,ZERO-MOMENT)
247 (types . (general-music lyric-combine-music))
248 (iterator-ctor . ,ly:lyric-combine-music-iterator::constructor)
252 . ((description . "A lyric syllable. Must be entered in lyrics mode,
253 i.e., @code{\\lyrics @{ twinkle4 twinkle4 @} }.")
254 (types . (general-music rhythmic-event lyric-event event))
258 . ((description . "Insert a rehearsal mark.
260 Syntax: @code{\\mark} @var{marker}
262 Example: @code{\\mark \"A\"}")
263 (types . (general-music mark-event event))
266 (MultiMeasureRestEvent
267 . ((description . "Used internally by @code{MultiMeasureRestMusic}
269 (types . (general-music event rhythmic-event
270 multi-measure-rest-event))
273 (MultiMeasureRestMusic
274 . ((description . "Rests that may be compressed into Multi rests.
276 Syntax: @code{R2.*4} for 4 measures in 3/4 time.")
277 (iterator-ctor . ,ly:sequential-iterator::constructor)
278 (elements-callback . ,mm-rest-child-list)
279 (types . (general-music multi-measure-rest))
282 (MultiMeasureTextEvent
283 . ((description . "Texts on multi measure rests.
285 Syntax: @code{R-\\markup @{ \\roman \"bla\" @}}
287 Note the explicit font switch.")
288 (types . (general-music event multi-measure-text-event))
292 . ((description . "Generic type for music expressions.")
293 (types . (general-music))
297 . ((description . "A note.")
298 (types . (general-music event note-event rhythmic-event
303 . ((description . "Start or stop grouping brackets.")
304 (types . (general-music event note-grouping-event))
308 . ((description . "Extend the definition of a graphical object.
310 Syntax: @code{\\override} [ @var{context} @code{.} ]
311 @var{object} @var{property} @code{=} @var{value}")
312 (types . (general-music layout-instruction-event
313 override-property-event))
314 (iterator-ctor . ,ly:push-property-iterator::constructor)
318 . ((description . "Allow, forbid or force a page break.")
319 (types . (general-music break-event page-break-event event))
323 . ((description . "Allow, forbid or force a page turn.")
324 (types . (general-music break-event page-turn-event event))
328 . ((description . "Combine two parts on a staff, either merged or
329 as separate voices.")
330 (length-callback . ,ly:music-sequence::maximum-length-callback)
331 (start-callback . ,ly:music-sequence::minimum-start-callback)
332 (types . (general-music part-combine-music))
333 (iterator-ctor . ,ly:part-combine-iterator::constructor)
337 . ((description . "Used internally to signal percent repeats.")
338 (types . (general-music event percent-event rhythmic-event))
341 (PercentRepeatedMusic
342 . ((description . "Repeats encoded by percents.")
343 (iterator-ctor . ,ly:percent-repeat-iterator::constructor)
344 (start-callback . ,ly:repeated-music::first-start)
345 (length-callback . ,ly:repeated-music::unfolded-music-length)
346 (types . (general-music repeated-music percent-repeated-music))
350 . ((description . "Within a ligature, mark the previous and the
351 following note to form a pes (if melody goes up) or a flexa (if melody
353 (types . (general-music pes-or-flexa-event event))
357 . ((description . "Start or end phrasing slur.
359 Syntax: @var{note}@code{\\(} and @var{note}@code{\\)}")
360 (types . (general-music span-event event phrasing-slur-event))
364 . ((description . "Set a context property.
366 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}")
367 (types . (layout-instruction-event general-music))
368 (iterator-ctor . ,ly:property-iterator::constructor)
372 . ((description . "Remove the definition of a context
374 (types . (layout-instruction-event general-music))
375 (iterator-ctor . ,ly:property-unset-iterator::constructor)
379 . ((description . "Quote preprocessed snippets of music.")
380 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
381 (length-callback . ,ly:music-wrapper::length-callback)
382 (start-callback . ,ly:music-wrapper::start-callback)
383 (types . (general-music music-wrapper-music))
387 . ((description . "Check if a pitch is in the correct octave.")
388 (to-relative-callback . ,ly:relative-octave-check::relative-callback)
389 (types . (general-music relative-octave-check))
393 . ((description . "Music that was entered in relative octave notation.")
394 (to-relative-callback . ,ly:relative-octave-music::relative-callback)
395 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
396 (length-callback . ,ly:music-wrapper::length-callback)
397 (start-callback . ,ly:music-wrapper::start-callback)
398 (types . (music-wrapper-music general-music relative-octave-music))
402 . ((description . "Ties for starting a second volta bracket.")
403 (types . (general-music event repeat-tie-event))
407 . ((description . "Repeat music in different ways.")
408 (types . (general-music repeated-music))
412 . ((description . "A Rest.
414 Syntax: @code{r4} for a quarter rest.")
415 (types . (general-music event rhythmic-event rest-event))
419 . ((description . "The opposite of @ref{OverrideProperty}: remove a
420 previously added property from a graphical object definition.")
421 (types . (general-music layout-instruction-event))
422 (iterator-ctor . ,ly:pop-property-iterator::constructor)
426 . ((description . "Add an articulation mark to a note.")
427 (types . (general-music event))
431 . ((description . "Music expressions concatenated.
433 Syntax: @code{\\sequential @{ @dots{} @}} or simply @code{@{ @dots{} @}}")
434 (length-callback . ,ly:music-sequence::cumulative-length-callback)
435 (start-callback . ,ly:music-sequence::first-start-callback)
436 (elements-callback . ,(lambda (m) (ly:music-property m 'elements)))
437 (iterator-ctor . ,ly:sequential-iterator::constructor)
438 (types . (general-music sequential-music))
442 . ((description . "Music playing together.
444 Syntax: @code{\\simultaneous @{ @dots{} @}} or @code{<< @dots{} >>}")
445 (iterator-ctor . ,ly:simultaneous-music-iterator::constructor)
446 (start-callback . ,ly:music-sequence::minimum-start-callback)
447 (length-callback . ,ly:music-sequence::maximum-length-callback)
448 (to-relative-callback .
449 ,ly:music-sequence::simultaneous-relative-callback)
450 (types . (general-music simultaneous-music))
454 . ((description . "Filler that takes up duration, but does not
457 Syntax: @code{s4} for a skip equivalent to a quarter rest.")
458 (types . (general-music event rhythmic-event skip-event))
462 . ((description . "Filler that takes up duration, does not
463 print anything, and also does not create staves or voices implicitly.
465 Syntax: @code{\\skip} @var{duration}")
466 (length-callback . ,ly:music-duration-length)
467 (iterator-ctor . ,ly:simple-music-iterator::constructor)
468 (types . (general-music event rhythmic-event skip-event))
472 . ((description . "Start or end slur.
474 Syntax: @var{note}@code{(} and @var{note}@code{)}")
475 (types . (general-music span-event event slur-event))
479 . ((description . "Print @q{Solo@tie{}1}.")
480 (part-combine-status . solo1)
481 (types . (general-music event part-combine-event solo-one-event))
485 . ((description . "Print @q{Solo@tie{}2}.")
486 (part-combine-status . solo2)
487 (types . (general-music event part-combine-event solo-two-event))
491 . ((description . "Depress or release sostenuto pedal.")
492 (types . (general-music event pedal-event sostenuto-event))
496 . ((description . "Start a new spacing section.")
497 (types . (general-music event spacing-section-event))))
500 . ((description . "Event for anything that is started at a
501 different time than stopped.")
502 (types . (general-music event))
506 . ((description . "Start or stop a staff symbol.")
507 (types . (general-music event span-event staff-span-event))
511 . ((description . "Specify on which string to play this note.
513 Syntax: @code{\\@var{number}}")
514 (types . (general-music string-number-event event))
518 . ((description . "Specify with which finger to pluck a string.
520 Syntax: @code{\\rightHandFinger @var{text}}")
521 (types . (general-music stroke-finger-event event))
525 . ((description . "Depress or release sustain pedal.")
526 (types . (general-music event pedal-event sustain-event))
530 . ((description . "Print text.")
531 (types . (general-music script-event text-script-event event))
535 . ((description . "Start a text spanner, e.g., 8va.....|")
536 (types . (general-music span-event event text-span-event))
540 . ((description . "A tie.
542 Syntax: @var{note}@code{-~}")
543 (types . (general-music tie-event event))
547 . ((description . "Multiply durations, as in tuplets.
549 Syntax: @code{\\times @var{fraction} @var{music}}, e.g.
550 @code{\\times 2/3 @{ @dots{} @}} for triplets.")
551 (length-callback . ,ly:music-wrapper::length-callback)
552 (start-callback . ,ly:music-wrapper::start-callback)
553 (iterator-ctor . ,ly:time-scaled-music-iterator::constructor)
554 (types . (time-scaled-music music-wrapper-music general-music))
558 . ((description . "Music that has been transposed.")
559 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
560 (start-callback . ,ly:music-wrapper::start-callback)
561 (length-callback . ,ly:music-wrapper::length-callback)
562 (to-relative-callback .
563 ,ly:relative-octave-music::no-relative-callback)
564 (types . (music-wrapper-music general-music transposed-music))
568 . ((description . "Unmeasured tremolo.")
569 (types . (general-music event tremolo-event))
572 (TremoloRepeatedMusic
573 . ((description . "Repeated notes denoted by tremolo beams.")
574 (iterator-ctor . ,ly:chord-tremolo-iterator::constructor)
575 (start-callback . ,ly:repeated-music::first-start)
576 ;; the length of the repeat is handled by shifting the note logs
577 (length-callback . ,ly:repeated-music::folded-music-length)
578 (types . (general-music repeated-music tremolo-repeated-music))
582 . ((description . "Tremolo over two stems")
583 (types . (general-music event span-event tremolo-span-event))
587 . ((description . "Start a trill spanner tr~~~")
588 (types . (general-music span-event event trill-span-event))
592 . ((description . "Used internally to signal where tuplet
593 brackets start and stop.")
594 (types . (tuplet-span-event span-event event general-music))
598 . ((description . "Depress or release una-corda pedal.")
599 (types . (general-music event pedal-event una-corda-event))
602 (UnfoldedRepeatedMusic
603 . ((description . "Repeated music which is fully written
605 (iterator-ctor . ,ly:unfolded-repeat-iterator::constructor)
606 (start-callback . ,ly:repeated-music::first-start)
607 (types . (general-music repeated-music unfolded-repeated-music))
608 (length-callback . ,ly:repeated-music::unfolded-music-length)
612 . ((description . "Print @q{a@tie{}2}.")
613 (part-combine-status . unisono)
614 (types . (general-music event part-combine-event unisono-event))))
617 . ((description . "Music that cannot be converted from relative
618 to absolute notation. For example, transposed music.")
619 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
620 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
621 (length-callback . ,ly:music-wrapper::length-callback)
622 (types . (music-wrapper-music general-music unrelativable-music))
626 . ((description . "Separate polyphonic voices in simultaneous music.
628 Syntax: @code{\\\\}")
629 (types . (separator general-music))
633 . ((description . "Repeats with alternatives placed sequentially.")
634 (iterator-ctor . ,ly:volta-repeat-iterator::constructor)
635 (start-callback . ,ly:repeated-music::first-start)
636 (length-callback . ,ly:repeated-music::volta-music-length)
637 (types . (general-music repeated-music volta-repeated-music))
641 (set! music-descriptions
642 (sort music-descriptions alist<?))
644 (define-public music-name-to-property-table (make-vector 59 '()))
647 ;; transport description to an object property.
651 (set-object-property! (car x)
653 (cdr (assq 'description (cdr x))))
655 (set! lst (assoc-set! lst 'name (car x)))
656 (set! lst (assq-remove! lst 'description))
657 (hashq-set! music-name-to-property-table (car x) lst)
661 (define-safe-public (make-music name . music-properties)
662 "Create a music object of given name, and set its properties
663 according to @code{music-properties}, a list of alternating property symbols
665 (make-music 'OverrideProperty
667 'grob-property 'thickness
668 'grob-value (* 2 1.5))"
669 (if (not (symbol? name))
670 (ly:error (_ "symbol expected: ~S") name))
671 (let ((props (hashq-ref music-name-to-property-table name '())))
672 (if (not (pair? props))
673 (ly:error (_ "cannot find music object: ~S") name))
674 (let ((m (ly:make-music props)))
675 (define (set-props mus-props)
676 (if (and (not (null? mus-props))
677 (not (null? (cdr mus-props))))
679 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
680 (set-props (cddr mus-props)))))
681 (set-props music-properties)
684 (define-public (make-repeated-music name)
685 (let* ((handle (assoc name '(("volta" . VoltaRepeatedMusic)
686 ("unfold" . UnfoldedRepeatedMusic)
687 ("percent" . PercentRepeatedMusic)
688 ("tremolo" . TremoloRepeatedMusic))))
689 (music-name (if (pair? handle)
692 (ly:warning (_ "unknown repeat type `~S'") name)
693 (ly:warning (_ "See define-music-types.scm for supported repeats"))
694 'VoltaRepeatedMusic))))
695 (make-music music-name)))