1 ;;;; define-music-types.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2006 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 user manual 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 user manual 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 . "Repeats with alternatives placed in parallel.")
190 (iterator-ctor . ,ly:folded-repeat-iterator::constructor)
191 (start-callback . ,ly:repeated-music::minimum-start)
192 (length-callback . ,ly:repeated-music::folded-music-length)
193 (types . (general-music repeated-music folded-repeated-music))
197 . ((description . "Start a glissando on this note.")
198 (types . (general-music glissando-event event))
202 . ((description . "Interpret the argument as grace notes.")
203 (start-callback . ,ly:grace-music::start-callback)
204 (length . ,ZERO-MOMENT)
205 (iterator-ctor . ,ly:grace-iterator::constructor)
206 (types . (grace-music music-wrapper-music general-music))
210 . ((description . "Mark a note as harmonic.")
211 (types . (general-music event harmonic-event))
215 . ((description . "A hyphen between lyric syllables.")
216 (types . (general-music hyphen-event event))
220 . ((description . "Change the key signature.
222 Syntax: @code{\\key} @var{name} @var{scale}")
223 (to-relative-callback . ,(lambda (x p) p))
224 (types . (general-music key-change-event event))
228 . ((description . "Place a bookmarking label.")
229 (types . (general-music label-event event))
233 . ((description . "Don't damp this chord.
235 Syntax: @var{note}@code{\\laissezVibrer}")
236 (types . (general-music event laissez-vibrer-event))
240 . ((description . "Start or end a ligature.")
241 (span-type . ligature)
242 (types . (general-music span-event ligature-event event))
246 . ((description . "Allow, forbid or force a line break.")
247 (types . (general-music line-break-event break-event event))
251 . ((description . "Align lyrics to the start of notes.
253 Syntax: @code{\\lyricsto} @var{voicename} @var{lyrics}")
254 (length . ,ZERO-MOMENT)
255 (types . (general-music lyric-combine-music))
256 (iterator-ctor . ,ly:lyric-combine-music-iterator::constructor)
260 . ((description . "A lyric syllable. Must be entered in lyrics mode,
261 i.e., @code{\\lyrics @{ twinkle4 twinkle4 @} }.")
262 (types . (general-music rhythmic-event lyric-event event))
266 . ((description . "Insert a rehearsal mark.
268 Syntax: @code{\\mark} @var{marker}
270 Example: @code{\\mark \"A\"}")
271 (types . (general-music mark-event event))
274 (MultiMeasureRestEvent
275 . ((description . "Used internally by @code{MultiMeasureRestMusic}
277 (types . (general-music event rhythmic-event
278 multi-measure-rest-event))
281 (MultiMeasureRestMusic
282 . ((description . "Rests that may be compressed into Multi rests.
284 Syntax: @code{R2.*4} for 4 measures in 3/4 time.")
285 (iterator-ctor . ,ly:sequential-iterator::constructor)
286 (elements-callback . ,mm-rest-child-list)
287 (types . (general-music multi-measure-rest))
290 (MultiMeasureTextEvent
291 . ((description . "Texts on multi measure rests.
293 Syntax: @code{R-\\markup @{ \\roman \"bla\" @}}
295 Note the explicit font switch.")
296 (types . (general-music event multi-measure-text-event))
300 . ((description . "Generic type for music expressions.")
301 (types . (general-music))
305 . ((description . "A note.")
306 (types . (general-music event note-event rhythmic-event
311 . ((description . "Start or stop grouping brackets.")
312 (types . (general-music event note-grouping-event))
316 . ((description . "Extend the definition of a graphical object.
318 Syntax: @code{\\override} [ @var{context} @code{.} ]
319 @var{object} @var{property} @code{=} @var{value}")
320 (types . (general-music layout-instruction-event
321 override-property-event))
322 (iterator-ctor . ,ly:push-property-iterator::constructor)
326 . ((description . "Allow, forbid or force a page break.")
327 (types . (general-music break-event page-break-event event))
331 . ((description . "Allow, forbid or force a page turn.")
332 (types . (general-music break-event page-turn-event event))
336 . ((description . "Combine two parts on a staff, either merged or
337 as separate voices.")
338 (length-callback . ,ly:music-sequence::maximum-length-callback)
339 (start-callback . ,ly:music-sequence::minimum-start-callback)
340 (types . (general-music part-combine-music))
341 (iterator-ctor . ,ly:part-combine-iterator::constructor)
345 . ((description . "Used internally to signal percent repeats.")
346 (types . (general-music event percent-event rhythmic-event))
349 (PercentRepeatedMusic
350 . ((description . "Repeats encoded by percents.")
351 (iterator-ctor . ,ly:percent-repeat-iterator::constructor)
352 (start-callback . ,ly:repeated-music::first-start)
353 (length-callback . ,ly:repeated-music::unfolded-music-length)
354 (types . (general-music repeated-music percent-repeated-music))
358 . ((description . "Within a ligature, mark the previous and the
359 following note to form a pes (if melody goes up) or a flexa (if melody
361 (types . (general-music pes-or-flexa-event event))
365 . ((description . "Start or end phrasing slur.
367 Syntax: @var{note}@code{\\(} and @var{note}@code{\\)}")
368 (types . (general-music span-event event phrasing-slur-event))
372 . ((description . "Set a context property.
374 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}")
375 (types . (layout-instruction-event general-music))
376 (iterator-ctor . ,ly:property-iterator::constructor)
380 . ((description . "Remove the definition of a context
382 (types . (layout-instruction-event general-music))
383 (iterator-ctor . ,ly:property-unset-iterator::constructor)
387 . ((description . "Quote preprocessed snippets of music.")
388 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
389 (length-callback . ,ly:music-wrapper::length-callback)
390 (start-callback . ,ly:music-wrapper::start-callback)
391 (types . (general-music music-wrapper-music))
395 . ((description . "Check if a pitch is in the correct octave.")
396 (to-relative-callback . ,ly:relative-octave-check::relative-callback)
397 (types . (general-music relative-octave-check))
401 . ((description . "Music that was entered in relative octave notation.")
402 (to-relative-callback . ,ly:relative-octave-music::relative-callback)
403 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
404 (length-callback . ,ly:music-wrapper::length-callback)
405 (start-callback . ,ly:music-wrapper::start-callback)
406 (types . (music-wrapper-music general-music relative-octave-music))
410 . ((description . "Ties for starting a second volta bracket.")
411 (types . (general-music event repeat-tie-event))
415 . ((description . "Repeat music in different ways.")
416 (types . (general-music repeated-music))
420 . ((description . "A Rest.
422 Syntax: @code{r4} for a quarter rest.")
423 (types . (general-music event rhythmic-event rest-event))
427 . ((description . "The opposite of @ref{OverrideProperty}: remove a
428 previously added property from a graphical object definition.")
429 (types . (general-music layout-instruction-event))
430 (iterator-ctor . ,ly:pop-property-iterator::constructor)
434 . ((description . "Add an articulation mark to a note.")
435 (types . (general-music event))
439 . ((description . "Music expressions concatenated.
441 Syntax: @code{\\sequential @{ @dots{} @}} or simply @code{@{ @dots{} @}}")
442 (length-callback . ,ly:music-sequence::cumulative-length-callback)
443 (start-callback . ,ly:music-sequence::first-start-callback)
444 (elements-callback . ,(lambda (m) (ly:music-property m 'elements)))
445 (iterator-ctor . ,ly:sequential-iterator::constructor)
446 (types . (general-music sequential-music))
450 . ((description . "Music playing together.
452 Syntax: @code{\\simultaneous @{ @dots{} @}} or @code{<< @dots{} >>}")
453 (iterator-ctor . ,ly:simultaneous-music-iterator::constructor)
454 (start-callback . ,ly:music-sequence::minimum-start-callback)
455 (length-callback . ,ly:music-sequence::maximum-length-callback)
456 (to-relative-callback .
457 ,ly:music-sequence::simultaneous-relative-callback)
458 (types . (general-music simultaneous-music))
462 . ((description . "Filler that takes up duration, but does not
465 Syntax: @code{s4} for a skip equivalent to a quarter rest.")
466 (types . (general-music event rhythmic-event skip-event))
470 . ((description . "Filler that takes up duration, does not
471 print anything, and also does not create staves or voices implicitly.
473 Syntax: @code{\\skip} @var{duration}")
474 (length-callback . ,ly:music-duration-length)
475 (iterator-ctor . ,ly:simple-music-iterator::constructor)
476 (types . (general-music event rhythmic-event skip-event))
480 . ((description . "Start or end slur.
482 Syntax: @var{note}@code{(} and @var{note}@code{)}")
483 (types . (general-music span-event event slur-event))
487 . ((description . "Print @q{Solo@tie{}1}.")
488 (part-combine-status . solo1)
489 (types . (general-music event part-combine-event solo-one-event))
493 . ((description . "Print @q{Solo@tie{}2}.")
494 (part-combine-status . solo2)
495 (types . (general-music event part-combine-event solo-two-event))
499 . ((description . "Depress or release sostenuto pedal.")
500 (types . (general-music event pedal-event sostenuto-event))
504 . ((description . "Start a new spacing section.")
505 (types . (general-music event spacing-section-event))))
508 . ((description . "Event for anything that is started at a
509 different time than stopped.")
510 (types . (general-music event))
514 . ((description . "Start or stop a staff symbol.")
515 (types . (general-music event span-event staff-span-event))
519 . ((description . "Specify on which string to play this note.
521 Syntax: @code{\\@var{number}}")
522 (types . (general-music string-number-event event))
526 . ((description . "Specify with which finger to pluck a string.
528 Syntax: @code{\\rightHandFinger @var{text}}")
529 (types . (general-music stroke-finger-event event))
533 . ((description . "Depress or release sustain pedal.")
534 (types . (general-music event pedal-event sustain-event))
538 . ((description . "Print text.")
539 (types . (general-music script-event text-script-event event))
543 . ((description . "Start a text spanner, e.g., 8va.....|")
544 (types . (general-music span-event event text-span-event))
548 . ((description . "A tie.
550 Syntax: @var{note}@code{-~}")
551 (types . (general-music tie-event event))
555 . ((description . "Multiply durations, as in tuplets.
557 Syntax: @code{\\times @var{fraction} @var{music}}, e.g.
558 @code{\\times 2/3 @{ @dots{} @}} for triplets.")
559 (length-callback . ,ly:music-wrapper::length-callback)
560 (start-callback . ,ly:music-wrapper::start-callback)
561 (iterator-ctor . ,ly:time-scaled-music-iterator::constructor)
562 (types . (time-scaled-music music-wrapper-music general-music))
566 . ((description . "Music that has been transposed.")
567 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
568 (start-callback . ,ly:music-wrapper::start-callback)
569 (length-callback . ,ly:music-wrapper::length-callback)
570 (to-relative-callback .
571 ,ly:relative-octave-music::no-relative-callback)
572 (types . (music-wrapper-music general-music transposed-music))
576 . ((description . "Unmeasured tremolo.")
577 (types . (general-music event tremolo-event))
580 (TremoloRepeatedMusic
581 . ((description . "Repeated notes denoted by tremolo beams.")
582 (iterator-ctor . ,ly:chord-tremolo-iterator::constructor)
583 (start-callback . ,ly:repeated-music::first-start)
584 ;; the length of the repeat is handled by shifting the note logs
585 (length-callback . ,ly:repeated-music::folded-music-length)
586 (types . (general-music repeated-music tremolo-repeated-music))
590 . ((description . "Tremolo over two stems")
591 (types . (general-music event span-event tremolo-span-event))
595 . ((description . "Start a trill spanner tr~~~")
596 (types . (general-music span-event event trill-span-event))
600 . ((description . "Used internally to signal where tuplet
601 brackets start and stop.")
602 (types . (tuplet-span-event span-event event general-music))
606 . ((description . "Depress or release una-corda pedal.")
607 (types . (general-music event pedal-event una-corda-event))
610 (UnfoldedRepeatedMusic
611 . ((description . "Repeated music which is fully written
613 (iterator-ctor . ,ly:unfolded-repeat-iterator::constructor)
614 (start-callback . ,ly:repeated-music::first-start)
615 (types . (general-music repeated-music unfolded-repeated-music))
616 (length-callback . ,ly:repeated-music::unfolded-music-length)
620 . ((description . "Print @q{a@tie{}2}.")
621 (part-combine-status . unisono)
622 (types . (general-music event part-combine-event unisono-event))))
625 . ((description . "Music that cannot be converted from relative
626 to absolute notation. For example, transposed music.")
627 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
628 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
629 (length-callback . ,ly:music-wrapper::length-callback)
630 (types . (music-wrapper-music general-music unrelativable-music))
634 . ((description . "Separate polyphonic voices in simultaneous music.
636 Syntax: @code{\\\\}")
637 (types . (separator general-music))
641 . ((description . "Repeats with alternatives placed sequentially.")
642 (iterator-ctor . ,ly:volta-repeat-iterator::constructor)
643 (start-callback . ,ly:repeated-music::first-start)
644 (length-callback . ,ly:repeated-music::volta-music-length)
645 (types . (general-music repeated-music volta-repeated-music))
649 (set! music-descriptions
650 (sort music-descriptions alist<?))
652 (define-public music-name-to-property-table (make-vector 59 '()))
655 ;; transport description to an object property.
659 (set-object-property! (car x)
661 (cdr (assq 'description (cdr x))))
663 (set! lst (assoc-set! lst 'name (car x)))
664 (set! lst (assq-remove! lst 'description))
665 (hashq-set! music-name-to-property-table (car x) lst)
669 (define-safe-public (make-music name . music-properties)
670 "Create a music object of given name, and set its properties
671 according to @code{music-properties}, a list of alterning property symbols
673 (make-music 'OverrideProperty
675 'grob-property 'thickness
676 'grob-value (* 2 1.5))"
677 (if (not (symbol? name))
678 (ly:error (_ "symbol expected: ~S") name))
679 (let ((props (hashq-ref music-name-to-property-table name '())))
680 (if (not (pair? props))
681 (ly:error (_ "cannot find music object: ~S") name))
682 (let ((m (ly:make-music props)))
683 (define (set-props mus-props)
684 (if (and (not (null? mus-props))
685 (not (null? (cdr mus-props))))
687 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
688 (set-props (cddr mus-props)))))
689 (set-props music-properties)
692 (define-public (make-repeated-music name)
693 (let* ((handle (assoc name '(("volta" . VoltaRepeatedMusic)
694 ("unfold" . UnfoldedRepeatedMusic)
695 ("percent" . PercentRepeatedMusic)
696 ("tremolo" . TremoloRepeatedMusic)
697 ("fold" . FoldedRepeatedMusic))))
698 (music-name (if (pair? handle)
701 (ly:warning (_ "unknown repeat type `~S'") name)
702 (ly:warning (_ "See music-types.scm for supported repeats"))
703 'VoltaRepeatedMusic))))
704 (make-music music-name)))