1 ;;;; define-music-types.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2006 Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
8 ;; TODO: should link back into user manual.
10 (define-public music-descriptions
14 (description . "Creates a dynamic mark.
16 Syntax: @var{note}@code{\\x},
17 where x is one of \\ppp, \\pp, \\p, \\mp, \\mf, \\f, \\ff, \\fff.")
18 (types . (general-music event dynamic-event absolute-dynamic-event))
22 (description . "Call the argument with the current context during interpreting phase")
23 (types . (general-music apply-context))
24 (iterator-ctor . ,ly:apply-context-iterator::constructor)
29 Call the argument with all current grobs during interpreting phase.
33 \\applyOutput #'Context FUNC
35 arguments to func are 1. the grob, 2. the originating context,
36 3. context where FUNC is called.
39 (types . (general-music event layout-instruction))
43 (description . "Make an arpeggio on this note.
46 @var{note}-@code{\\arpeggio}")
47 (types . (general-music arpeggio-event event))
50 ;; todo: use articulation-event for slur as well.
51 ;; separate non articulation scripts
54 (description . "Adds an articulation marking to a note.
57 @var{note}@code{X}@code{Y}, where X is a direction (up @code{^}, down
58 @code{_}, or LilyPond's choice (no direction specified)), and where Y
59 is an articulation (such as @code{-.}, @code{->}, @code{\\tenuto},
60 @code{\\downbow}). See the user manual for details.")
62 (types . (general-music event articulation-event script-event))
66 (description . "Used for making voices that switch between piano staves automatically.")
67 (iterator-ctor . ,ly:auto-change-iterator::constructor)
68 (start-callback . ,ly:music-wrapper::start-callback)
69 (length-callback . ,ly:music-wrapper::length-callback)
70 (types . (general-music music-wrapper-music auto-change-instruction))
75 "Check whether this music coincides with the start of the measure.")
76 (types . (general-music bar-check))
77 (iterator-ctor . ,ly:bar-check-iterator::constructor)
81 (description . "Print a bass-figure text")
83 (types . (general-music event rhythmic-event bass-figure-event))
87 (description . "Starts or stops a beam.
89 Syntax for manual control:
91 (types . (general-music event beam-event span-event))
95 (description . "Create a line break, Syntax: \\break or page break, Syntax: \\pagebreak.")
97 (types . (general-music break-event event))
101 (description . "Creates a `breath mark' or `comma'.
104 @var{note}\\breathe.")
106 (types . (general-music event breathing-event))
110 (description . "Used internally to signal beginning and ending of notes.")
112 (types . (general-music event busy-playing-event))
116 (description . "Change staffs in Piano staff.
118 Syntax @code{\\translator Staff = @var{new-id}}.")
119 (iterator-ctor . , ly:change-iterator::constructor)
120 (types . (general-music translator-change-instruction))
124 . ((description . "A note that is part of a cluster.")
126 ;; not a note-event, to ensure that Note_engraver doesn't eat it.
127 (types . (general-music cluster-note-event melodic-event rhythmic-event event))
132 (description . "Interpret the argument music within a specific context.")
133 (iterator-ctor . ,ly:context-specced-music-iterator::constructor)
134 (length-callback . ,ly:music-wrapper::length-callback)
135 (start-callback . ,ly:music-wrapper::start-callback)
136 (types . (context-specification general-music music-wrapper-music))
141 (description . "Begins or ends a crescendo.
143 Syntax: @var{note}\\cr
144 ... @var{note}\\rc (you can also use \\<, \\!, \\cresc, and
145 \\endcresc. See the user manual for details.).")
147 (types . (general-music dynamic-event crescendo-event event))
151 (description . "See @ref{CrescendoEvent}.")
153 (types . (general-music dynamic-event decrescendo-event event))
158 (description . "Extend lyrics.")
160 (types . (general-music extender-event event))
166 (description . "Internally used to group a set of events.")
167 (iterator-ctor . ,ly:event-chord-iterator::constructor)
168 (length-callback . ,ly:music-sequence::maximum-length-callback)
169 (to-relative-callback . ,ly:music-sequence::event-chord-relative-callback)
170 (types . (general-music event-chord simultaneous-music))
175 (description . "Specify what finger to use for this note.")
176 (types . (general-music fingering-event event))
180 (description . "Specify that a note may not auto-beamed ")
181 (types . (general-music event beam-forbid-event))
185 (description . "Start a glissando on this note.")
186 (types . (general-music glissando-event event))
191 (description . "Interpret the argument as grace notes. ")
192 (start-callback . ,ly:grace-music::start-callback)
193 (length . ,ZERO-MOMENT)
194 (iterator-ctor . ,ly:grace-iterator::constructor)
195 (types . (grace-music music-wrapper-music general-music))
199 (description . "Start or stop grouping brackets.")
200 (types . (general-music event note-grouping-event))
204 (description . "Mark a note as harmonic")
205 (types . (general-music event harmonic-event))
209 (description . "A hyphen between lyric syllables.")
211 (types . (general-music hyphen-event event))
216 (description . "Change the key signature.
218 Syntax: @code{\\key } @var{name} @var{scale}.")
219 (to-relative-callback . ,(lambda (x p) p))
220 (types . (general-music key-change-event event))
223 . ((description . "Don't damp this chord.
225 Syntax: @var{note}\\laissezVibrer.")
227 (types . (general-music event laissez-vibrer-event))
231 (description . "Start or end a ligature.")
232 (span-type . ligature)
233 (types . (general-music span-event ligature-event event))
237 (description . "Allow, forbid or force a line break.")
238 (types . (general-music break-event event))
243 (description . "Align lyrics to the start of notes.
245 Syntax @var{\\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)
253 (description . "A lyric syllable. Must be entered in lyrics mode, i.e.
254 @code{\\lyrics @{ twinkle4 twinkle4 @} } .")
256 (types . (general-music rhythmic-event lyric-event event))
260 (description . "Insert a rehearsal mark.
262 Syntax: @code{\\mark} @var{marker},
263 e.g. @code{\\mark \"A\"}.")
265 (types . (general-music mark-event event))
269 (description . "Used internally to signal melismas.")
270 (types . (general-music melisma-playing-event event))
274 (description . "Start or stop a melisma.
276 Syntax: @code{c4\\melisma d\\melismaEnd}.")
277 (types . (general-music melisma-span-event event))
280 (MultiMeasureRestEvent
282 (description . "Rests that may be compressed into Multi rests.
285 @code{R2.*4} for 4 measures in 3/4 time. Note the capital R.")
286 (types . (general-music event rhythmic-event multi-measure-rest-event))
289 (MultiMeasureRestMusicGroup
291 (description . "Like sequential-music, but specifically intended
292 to group start-mmrest, skip, stop-mmrest sequence.
294 Syntax @code{R2.*5} for 5 measures in 3/4 time.")
295 (length-callback . ,ly:music-sequence::cumulative-length-callback)
296 (start-callback . ,ly:music-sequence::first-start-callback)
297 (iterator-ctor . ,ly:sequential-music-iterator::constructor)
298 (types . (general-music sequential-music))
301 (MultiMeasureTextEvent
303 (description . "Texts on mm rests.
306 @code{R-\\markup @{ \\roman \"bla\" @}}. Note the explicit font switch.")
307 (types . (general-music event multi-measure-text-event))
312 (description . "Generic type for music expressions.")
314 (types . (general-music))
318 (description . "A note.")
319 (types . (general-music event note-event rhythmic-event melodic-event))
324 (description . "Extend the definition of a graphical object.
328 @code{\\override [ @var{Ctxt} . ] @var{Obj} @var{prop} = @var{val}}
330 (types . (general-music layout-instruction))
331 (iterator-ctor . ,ly:push-property-iterator::constructor)
335 (description . "Allow, forbid or force a page break.")
336 (types . (general-music break-event event))
340 (description . "Allow, forbid or force a page turn.")
341 (types . (general-music break-event event))
345 (description . "Combine two parts on a staff, either merged or
346 as separate voices.")
347 (length-callback . ,ly:music-sequence::maximum-length-callback)
348 (start-callback . ,ly:music-sequence::minimum-start-callback)
349 (types . (general-music part-combine-music))
350 (iterator-ctor . ,ly:part-combine-iterator::constructor)
354 (description . "Start or end phrasing slur.
356 Syntax NOTE \\( and \\) NOTE")
357 (types . (general-music span-event event phrasing-slur-event))
362 (description . "Set a context property.
364 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
365 (types . (layout-instruction general-music))
366 (iterator-ctor . ,ly:property-iterator::constructor)
371 (description . "Remove the definition of a context @code{\\property}.")
373 (types . (layout-instruction general-music))
374 (iterator-ctor . ,ly:property-unset-iterator::constructor)
379 (description . "Used internally to signal percent repeats.")
380 (types . (general-music event percent-event))
385 (description . "Within a ligature, mark the previous and the
386 following note to form a pes (if melody goes up) or a flexa (if melody
389 (types . (general-music pes-or-flexa-event event))
394 (description . "Quote preprocessed snippets of music. ")
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 . (general-music music-wrapper-music))
402 . ((description . "Check if a pitch is in the correct octave.")
403 (to-relative-callback . ,ly:relative-octave-check::relative-callback)
404 (types . (general-music relative-octave-check))
409 (description . "Repeat music in different ways")
410 (types . (general-music repeated-music))
414 (description . "Ties for starting a second volta bracket.")
415 (types . (general-music event repeat-tie-event))
419 (description . "Atomic music event.")
420 (types . (general-music event))
425 (description . "A Rest.
427 Syntax @code{r4} for a quarter rest. ")
429 (types . (general-music event rhythmic-event rest-event))
433 (description . "The opposite of @ref{OverrideProperty}: remove a
434 previously added property from a graphical object definition
437 (types . (general-music layout-instruction))
438 (iterator-ctor . , ly:pop-property-iterator::constructor)
443 (description . "Music expressions concatenated.
445 Syntax \\sequential @{..@} or simply @{..@} .")
447 (length-callback . ,ly:music-sequence::cumulative-length-callback)
448 (start-callback . ,ly:music-sequence::first-start-callback)
449 (iterator-ctor . ,ly:sequential-music-iterator::constructor)
450 (types . (general-music sequential-music))
455 (description . "Print Solo.1")
456 (part-combine-status . solo1)
457 (types . (general-music event part-combine-event))
461 (description . "Print Solo.2")
462 (part-combine-status . solo2)
463 (types . (general-music event part-combine-event))
466 . ((description . "Print a2")
467 (part-combine-status . unisono)
468 (types . (general-music event part-combine-event))))
472 (description . "Music playing together.
476 @code{ \\simultaneous @{ .. @}} or << .. >>.")
478 (iterator-ctor . ,ly:simultaneous-music-iterator::constructor)
479 (start-callback . ,ly:music-sequence::minimum-start-callback)
480 (length-callback . ,ly:music-sequence::maximum-length-callback)
481 (to-relative-callback . ,ly:music-sequence::simultaneous-relative-callback)
483 (types . (general-music simultaneous-music))
488 (description . "Start or end slur.
490 Syntax NOTE( and NOTE) ")
492 (types . (general-music span-event event slur-event))
496 . ((description . "Start or stop a staff symbol.")
497 (types . (general-music event span-event staff-span-event))
502 (description . "Used internally to signal beginning of notes.")
504 (types . (general-music event start-playing-event))
509 (description . "Start a text spanner like 8va.....|")
510 (types . (general-music span-event event text-span-event))
515 (description . "Start a trill spanner tr~~~")
516 (types . (general-music span-event event trill-span-event))
521 (description . "Music that has been transposed.")
522 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
523 (start-callback . ,ly:music-wrapper::start-callback)
524 (length-callback . ,ly:music-wrapper::length-callback)
525 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
526 (types . (music-wrapper-music general-music transposed-music))
531 (description . "Multiply durations, as in tuplets.
533 Syntax @code{\\times @var{fraction} @var{music}}, e.g.
534 @code{\\times 2/3 @{ ... @}} for triplets.
536 (length-callback . ,ly:music-wrapper::length-callback)
537 (start-callback . ,ly:music-wrapper::start-callback)
538 (iterator-ctor . ,ly:time-scaled-music-iterator::constructor)
539 (types . (time-scaled-music music-wrapper-music general-music))
544 (description . "Used internally to signal where tuplet brackets start and stop.")
545 (types . (tuplet-spanner-event span-event event general-music))
550 (description . "Music that can not be converted from relative to absolute notation.
551 For example, transposed music.")
552 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
553 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
554 (length-callback . ,ly:music-wrapper::length-callback)
555 (types . (music-wrapper-music general-music unrelativable-music))
560 (description . "Music that was entered in relative octave notation.")
561 (to-relative-callback . ,ly:relative-octave-music::relative-callback)
562 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
563 (length-callback . ,ly:music-wrapper::length-callback)
564 (start-callback . ,ly:music-wrapper::start-callback)
565 (types . (music-wrapper-music general-music relative-octave-music))
569 (description . "Add an articulation mark to a note. ")
571 (types . (general-music event))
576 (description . "Filler that takes up duration, does not print anything, and also
577 does not create staffs or voices implicitly.
581 Syntax: @code{\\skip }@var{duration}.")
582 (length-callback . ,ly:music-duration-length)
583 (iterator-ctor . ,ly:simple-music-iterator::constructor)
584 (types . (general-music event rhythmic-event skip-event))
589 (description . "Filler that takes up duration, but does not print anything.
593 Syntax: @code{s}@var{duration}")
595 (types . (general-music event rhythmic-event skip-event))
599 (description . "Event for anything that is started at a different time than stopped.")
601 (types . (general-music event))
606 (description . "Depress or release sustain pedal. ")
607 (types . (general-music event pedal-event sustain-pedal-event))
612 (description . "Depress or release sostenuto pedal. ")
613 (types . (general-music event pedal-event sostenuto-pedal-event))
618 (description . "Depress or release una-corda pedal.")
619 (types . (general-music event pedal-event una-corda-pedal-event))
624 (description . "Specify on which string to play this note.
626 Syntax: @code{\\@var{number}}.")
628 (types . (general-music string-number-event event))
631 (MetronomeChangeEvent
633 (description . "Change tempo setting (in beats per minute).")
634 (types . (general-music metronome-change-event tempo-event event))
640 (types . (general-music script-event text-script-event event))
644 (description . "A tie. Entered as @var{note}-~.")
645 (types . (general-music tie-event event))
649 (description . "Un measured tremolo.")
650 (types . (general-music event tremolo-event))
655 (description . "Tremolo over two stems")
656 (types . (general-music event span-event tremolo-span-event))
661 (description . "Separate polyphonic voices in simultaneous music.
663 Syntax: @code{\\\\}")
665 (types . (separator general-music))
670 (iterator-ctor . ,ly:volta-repeat-iterator::constructor)
672 (start-callback . ,ly:repeated-music::first-start)
673 (length-callback . ,ly:repeated-music::volta-music-length)
674 (types . (general-music repeated-music volta-repeated-music))
677 (UnfoldedRepeatedMusic
679 (iterator-ctor . ,ly:unfolded-repeat-iterator::constructor)
681 (start-callback . ,ly:repeated-music::first-start)
682 (types . (general-music repeated-music unfolded-repeated-music))
683 (length-callback . ,ly:repeated-music::unfolded-music-length)
685 (PercentRepeatedMusic
687 (description . "Repeats encoded by percents.")
688 (iterator-ctor . ,ly:percent-repeat-iterator::constructor)
689 (start-callback . ,ly:repeated-music::first-start)
690 (length-callback . ,ly:repeated-music::unfolded-music-length)
691 (types . (general-music repeated-music percent-repeated-music))
694 (TremoloRepeatedMusic
696 (iterator-ctor . ,ly:chord-tremolo-iterator::constructor)
697 (description . "Repeated notes denoted by tremolo beams.")
698 (start-callback . ,ly:repeated-music::first-start)
700 ;; the length of the repeat is handled by shifting the note logs
701 (length-callback . ,ly:repeated-music::folded-music-length)
702 (types . (general-music repeated-music tremolo-repeated-music))
708 (description . "Repeats with alternatives placed in parallel. ")
709 (iterator-ctor . ,ly:folded-repeat-iterator::constructor)
710 (start-callback . ,ly:repeated-music::minimum-start)
711 (length-callback . ,ly:repeated-music::folded-music-length)
712 (types . (general-music repeated-music folded-repeated-music))
716 (set! music-descriptions
717 (sort music-descriptions alist<?))
719 (define-public music-name-to-property-table (make-vector 59 '()))
722 ;; transport description to an object property.
726 (set-object-property! (car x)
728 (cdr (assq 'description (cdr x))))
730 (set! lst (assoc-set! lst 'name (car x)))
731 (set! lst (assq-remove! lst 'description))
732 (hashq-set! music-name-to-property-table (car x) lst)
736 (define-safe-public (make-music name . music-properties)
737 "Create a music object of given name, and set its properties
738 according to `music-properties', a list of alterning property symbols
740 (make-music 'OverrideProperty
742 'grob-property 'thickness
743 'grob-value (* 2 1.5))"
744 (if (not (symbol? name))
745 (ly:error (_ "symbol expected: ~S") name))
746 (let ((props (hashq-ref music-name-to-property-table name '())))
747 (if (not (pair? props))
748 (ly:error (_ "can't find music object: ~S") name))
749 (let ((m (ly:make-music props)))
750 (define (set-props mus-props)
751 (if (and (not (null? mus-props))
752 (not (null? (cdr mus-props))))
754 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
755 (set-props (cddr mus-props)))))
756 (set-props music-properties)
759 (define-public (make-repeated-music name)
760 (let* ((handle (assoc name '(("volta" . VoltaRepeatedMusic)
761 ("unfold" . UnfoldedRepeatedMusic)
762 ("percent" . PercentRepeatedMusic)
763 ("tremolo" . TremoloRepeatedMusic)
764 ("fold" . FoldedRepeatedMusic))))
765 (music-name (if (pair? handle)
768 (ly:warning (_ "unknown repeat type `~S'") name)
769 (ly:warning (_ "See music-types.scm for supported repeats"))
770 'VoltaRepeatedMusic))))
771 (make-music music-name)))