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))
165 (description . "Atomic music event.")
166 (types . (general-music event))
171 (description . "Internally used to group a set of events.")
172 (iterator-ctor . ,ly:event-chord-iterator::constructor)
173 (length-callback . ,ly:music-sequence::maximum-length-callback)
174 (to-relative-callback . ,ly:music-sequence::event-chord-relative-callback)
175 (types . (general-music event-chord simultaneous-music))
180 (description . "Specify what finger to use for this note.")
181 (types . (general-music fingering-event event))
185 (description . "Specify that a note may not auto-beamed ")
186 (types . (general-music event beam-forbid-event))
190 (description . "Start a glissando on this note.")
191 (types . (general-music glissando-event event))
196 (description . "Interpret the argument as grace notes. ")
197 (start-callback . ,ly:grace-music::start-callback)
198 (length . ,ZERO-MOMENT)
199 (iterator-ctor . ,ly:grace-iterator::constructor)
200 (types . (grace-music music-wrapper-music general-music))
204 (description . "Start or stop grouping brackets.")
205 (types . (general-music event note-grouping-event))
209 (description . "Mark a note as harmonic")
210 (types . (general-music event harmonic-event))
214 (description . "A hyphen between lyric syllables.")
216 (types . (general-music hyphen-event event))
221 (description . "Change the key signature.
223 Syntax: @code{\\key } @var{name} @var{scale}.")
224 (to-relative-callback . ,(lambda (x p) p))
225 (types . (general-music key-change-event event))
228 . ((description . "Don't damp this chord.
230 Syntax: @var{note}\\laissezVibrer.")
232 (types . (general-music event laissez-vibrer-event))
236 (description . "Start or end a ligature.")
237 (span-type . ligature)
238 (types . (general-music span-event ligature-event event))
242 (description . "Allow, forbid or force a line break.")
243 (types . (general-music break-event event))
248 (description . "Align lyrics to the start of notes.
250 Syntax @var{\\lyricsto }@var{voicename} @var{lyrics}.")
251 (length . ,ZERO-MOMENT)
252 (types . (general-music lyric-combine-music))
253 (iterator-ctor . ,ly:lyric-combine-music-iterator::constructor)
258 (description . "A lyric syllable. Must be entered in lyrics mode, i.e.
259 @code{\\lyrics @{ twinkle4 twinkle4 @} } .")
261 (types . (general-music rhythmic-event lyric-event event))
265 (description . "Insert a rehearsal mark.
267 Syntax: @code{\\mark} @var{marker},
268 e.g. @code{\\mark \"A\"}.")
270 (types . (general-music mark-event event))
274 (description . "Used internally to signal melismas.")
275 (types . (general-music melisma-playing-event event))
279 (description . "Start or stop a melisma.
281 Syntax: @code{c4\\melisma d\\melismaEnd}.")
282 (types . (general-music melisma-span-event event))
285 (MultiMeasureRestEvent
287 (description . "Rests that may be compressed into Multi rests.
290 @code{R2.*4} for 4 measures in 3/4 time. Note the capital R.")
291 (types . (general-music event rhythmic-event multi-measure-rest-event))
294 (MultiMeasureRestMusicGroup
296 (description . "Like sequential-music, but specifically intended
297 to group start-mmrest, skip, stop-mmrest sequence.
299 Syntax @code{R2.*5} for 5 measures in 3/4 time.")
300 (length-callback . ,ly:music-sequence::cumulative-length-callback)
301 (start-callback . ,ly:music-sequence::first-start-callback)
302 (iterator-ctor . ,ly:sequential-music-iterator::constructor)
303 (types . (general-music sequential-music))
306 (MultiMeasureTextEvent
308 (description . "Texts on mm rests.
311 @code{R-\\markup @{ \\roman \"bla\" @}}. Note the explicit font switch.")
312 (types . (general-music event multi-measure-text-event))
317 (description . "Generic type for music expressions.")
319 (types . (general-music))
323 (description . "A note.")
324 (types . (general-music event note-event rhythmic-event melodic-event))
329 (description . "Extend the definition of a graphical object.
333 @code{\\override [ @var{Ctxt} . ] @var{Obj} @var{prop} = @var{val}}
335 (types . (general-music layout-instruction))
336 (iterator-ctor . ,ly:push-property-iterator::constructor)
340 (description . "Allow, forbid or force a page break.")
341 (types . (general-music break-event event))
345 (description . "Allow, forbid or force a page turn.")
346 (types . (general-music break-event event))
350 (description . "Combine two parts on a staff, either merged or
351 as separate voices.")
352 (length-callback . ,ly:music-sequence::maximum-length-callback)
353 (start-callback . ,ly:music-sequence::minimum-start-callback)
354 (types . (general-music part-combine-music))
355 (iterator-ctor . ,ly:part-combine-iterator::constructor)
359 (description . "Start or end phrasing slur.
361 Syntax NOTE \\( and \\) NOTE")
362 (types . (general-music span-event event phrasing-slur-event))
367 (description . "Set a context property.
369 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
370 (types . (layout-instruction general-music))
371 (iterator-ctor . ,ly:property-iterator::constructor)
376 (description . "Remove the definition of a context @code{\\property}.")
378 (types . (layout-instruction general-music))
379 (iterator-ctor . ,ly:property-unset-iterator::constructor)
384 (description . "Used internally to signal percent repeats.")
385 (types . (general-music event percent-event))
390 (description . "Within a ligature, mark the previous and the
391 following note to form a pes (if melody goes up) or a flexa (if melody
394 (types . (general-music pes-or-flexa-event event))
399 (description . "Quote preprocessed snippets of music. ")
400 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
401 (length-callback . ,ly:music-wrapper::length-callback)
402 (start-callback . ,ly:music-wrapper::start-callback)
403 (types . (general-music music-wrapper-music))
407 . ((description . "Check if a pitch is in the correct octave.")
408 (to-relative-callback . ,ly:relative-octave-check::relative-callback)
409 (types . (general-music relative-octave-check))
414 (description . "Repeat music in different ways")
415 (types . (general-music repeated-music))
419 (description . "Ties for starting a second volta bracket.")
420 (types . (general-music event repeat-tie-event))
424 (description . "A Rest.
426 Syntax @code{r4} for a quarter rest. ")
428 (types . (general-music event rhythmic-event rest-event))
432 (description . "The opposite of @ref{OverrideProperty}: remove a
433 previously added property from a graphical object definition
436 (types . (general-music layout-instruction))
437 (iterator-ctor . , ly:pop-property-iterator::constructor)
442 (description . "Music expressions concatenated.
444 Syntax \\sequential @{..@} or simply @{..@} .")
446 (length-callback . ,ly:music-sequence::cumulative-length-callback)
447 (start-callback . ,ly:music-sequence::first-start-callback)
448 (iterator-ctor . ,ly:sequential-music-iterator::constructor)
449 (types . (general-music sequential-music))
454 (description . "Print Solo.1")
455 (part-combine-status . solo1)
456 (types . (general-music event part-combine-event))
460 (description . "Print Solo.2")
461 (part-combine-status . solo2)
462 (types . (general-music event part-combine-event))
465 . ((description . "Print a2")
466 (part-combine-status . unisono)
467 (types . (general-music event part-combine-event))))
471 (description . "Music playing together.
475 @code{ \\simultaneous @{ .. @}} or << .. >>.")
477 (iterator-ctor . ,ly:simultaneous-music-iterator::constructor)
478 (start-callback . ,ly:music-sequence::minimum-start-callback)
479 (length-callback . ,ly:music-sequence::maximum-length-callback)
480 (to-relative-callback . ,ly:music-sequence::simultaneous-relative-callback)
482 (types . (general-music simultaneous-music))
487 (description . "Start or end slur.
489 Syntax NOTE( and NOTE) ")
491 (types . (general-music span-event event slur-event))
495 . ((description . "Start or stop a staff symbol.")
496 (types . (general-music event span-event staff-span-event))
501 (description . "Used internally to signal beginning of notes.")
503 (types . (general-music event start-playing-event))
508 (description . "Start a text spanner like 8va.....|")
509 (types . (general-music span-event event text-span-event))
514 (description . "Start a trill spanner tr~~~")
515 (types . (general-music span-event event trill-span-event))
520 (description . "Music that has been transposed.")
521 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
522 (start-callback . ,ly:music-wrapper::start-callback)
523 (length-callback . ,ly:music-wrapper::length-callback)
524 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
525 (types . (music-wrapper-music general-music transposed-music))
530 (description . "Multiply durations, as in tuplets.
532 Syntax @code{\\times @var{fraction} @var{music}}, e.g.
533 @code{\\times 2/3 @{ ... @}} for triplets.
535 (length-callback . ,ly:music-wrapper::length-callback)
536 (start-callback . ,ly:music-wrapper::start-callback)
537 (iterator-ctor . ,ly:time-scaled-music-iterator::constructor)
538 (types . (time-scaled-music music-wrapper-music general-music))
543 (description . "Used internally to signal where tuplet brackets start and stop.")
544 (types . (tuplet-spanner-event span-event event general-music))
549 (description . "Music that can not be converted from relative to absolute notation.
550 For example, transposed music.")
551 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
552 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
553 (length-callback . ,ly:music-wrapper::length-callback)
554 (types . (music-wrapper-music general-music unrelativable-music))
559 (description . "Music that was entered in relative octave notation.")
560 (to-relative-callback . ,ly:relative-octave-music::relative-callback)
561 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
562 (length-callback . ,ly:music-wrapper::length-callback)
563 (start-callback . ,ly:music-wrapper::start-callback)
564 (types . (music-wrapper-music general-music relative-octave-music))
568 (description . "Add an articulation mark to a note. ")
570 (types . (general-music event))
575 (description . "Filler that takes up duration, does not print anything, and also
576 does not create staffs or voices implicitly.
580 Syntax: @code{\\skip }@var{duration}.")
581 (length-callback . ,ly:music-duration-length)
582 (iterator-ctor . ,ly:simple-music-iterator::constructor)
583 (types . (general-music event rhythmic-event skip-event))
588 (description . "Filler that takes up duration, but does not print anything.
592 Syntax: @code{s}@var{duration}")
594 (types . (general-music event rhythmic-event skip-event))
598 . ((description . "Start a new spacing section")
599 (types . (general-music event spacing-section-event))))
603 (description . "Event for anything that is started at a different time than stopped.")
605 (types . (general-music event))
610 (description . "Depress or release sustain pedal. ")
611 (types . (general-music event pedal-event sustain-pedal-event))
616 (description . "Depress or release sostenuto pedal. ")
617 (types . (general-music event pedal-event sostenuto-pedal-event))
622 (description . "Depress or release una-corda pedal.")
623 (types . (general-music event pedal-event una-corda-pedal-event))
628 (description . "Specify on which string to play this note.
630 Syntax: @code{\\@var{number}}.")
632 (types . (general-music string-number-event event))
635 (MetronomeChangeEvent
637 (description . "Change tempo setting (in beats per minute).")
638 (types . (general-music metronome-change-event tempo-event event))
644 (types . (general-music script-event text-script-event event))
648 (description . "A tie. Entered as @var{note}-~.")
649 (types . (general-music tie-event event))
653 (description . "Un measured tremolo.")
654 (types . (general-music event tremolo-event))
659 (description . "Tremolo over two stems")
660 (types . (general-music event span-event tremolo-span-event))
665 (description . "Separate polyphonic voices in simultaneous music.
667 Syntax: @code{\\\\}")
669 (types . (separator general-music))
674 (iterator-ctor . ,ly:volta-repeat-iterator::constructor)
676 (start-callback . ,ly:repeated-music::first-start)
677 (length-callback . ,ly:repeated-music::volta-music-length)
678 (types . (general-music repeated-music volta-repeated-music))
681 (UnfoldedRepeatedMusic
683 (iterator-ctor . ,ly:unfolded-repeat-iterator::constructor)
685 (start-callback . ,ly:repeated-music::first-start)
686 (types . (general-music repeated-music unfolded-repeated-music))
687 (length-callback . ,ly:repeated-music::unfolded-music-length)
689 (PercentRepeatedMusic
691 (description . "Repeats encoded by percents.")
692 (iterator-ctor . ,ly:percent-repeat-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 percent-repeated-music))
698 (TremoloRepeatedMusic
700 (iterator-ctor . ,ly:chord-tremolo-iterator::constructor)
701 (description . "Repeated notes denoted by tremolo beams.")
702 (start-callback . ,ly:repeated-music::first-start)
704 ;; the length of the repeat is handled by shifting the note logs
705 (length-callback . ,ly:repeated-music::folded-music-length)
706 (types . (general-music repeated-music tremolo-repeated-music))
712 (description . "Repeats with alternatives placed in parallel. ")
713 (iterator-ctor . ,ly:folded-repeat-iterator::constructor)
714 (start-callback . ,ly:repeated-music::minimum-start)
715 (length-callback . ,ly:repeated-music::folded-music-length)
716 (types . (general-music repeated-music folded-repeated-music))
720 (set! music-descriptions
721 (sort music-descriptions alist<?))
723 (define-public music-name-to-property-table (make-vector 59 '()))
726 ;; transport description to an object property.
730 (set-object-property! (car x)
732 (cdr (assq 'description (cdr x))))
734 (set! lst (assoc-set! lst 'name (car x)))
735 (set! lst (assq-remove! lst 'description))
736 (hashq-set! music-name-to-property-table (car x) lst)
740 (define-safe-public (make-music name . music-properties)
741 "Create a music object of given name, and set its properties
742 according to `music-properties', a list of alterning property symbols
744 (make-music 'OverrideProperty
746 'grob-property 'thickness
747 'grob-value (* 2 1.5))"
748 (if (not (symbol? name))
749 (ly:error (_ "symbol expected: ~S") name))
750 (let ((props (hashq-ref music-name-to-property-table name '())))
751 (if (not (pair? props))
752 (ly:error (_ "can't find music object: ~S") name))
753 (let ((m (ly:make-music props)))
754 (define (set-props mus-props)
755 (if (and (not (null? mus-props))
756 (not (null? (cdr mus-props))))
758 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
759 (set-props (cddr mus-props)))))
760 (set-props music-properties)
763 (define-public (make-repeated-music name)
764 (let* ((handle (assoc name '(("volta" . VoltaRepeatedMusic)
765 ("unfold" . UnfoldedRepeatedMusic)
766 ("percent" . PercentRepeatedMusic)
767 ("tremolo" . TremoloRepeatedMusic)
768 ("fold" . FoldedRepeatedMusic))))
769 (music-name (if (pair? handle)
772 (ly:warning (_ "unknown repeat type `~S'") name)
773 (ly:warning (_ "See music-types.scm for supported repeats"))
774 'VoltaRepeatedMusic))))
775 (make-music music-name)))