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 (mm-rest-child-list music)
11 "Check if we have R1*4-\\markup { .. }, and if applicable convert to
12 a property set for MultiMeasureRestNumber."
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
28 (description . "Creates a dynamic mark.
30 Syntax: @var{note}@code{\\x},
31 where x is one of \\ppp, \\pp, \\p, \\mp, \\mf, \\f, \\ff, \\fff.")
32 (types . (general-music event dynamic-event absolute-dynamic-event))
36 (description . "Call the argument with the current context during interpreting phase")
37 (types . (general-music apply-context))
38 (iterator-ctor . ,ly:apply-context-iterator::constructor)
43 Call the argument with all current grobs during interpreting phase.
47 \\applyOutput #'Context FUNC
49 arguments to func are 1. the grob, 2. the originating context,
50 3. context where FUNC is called.
53 (types . (general-music event apply-output-event))
57 (description . "Make an arpeggio on this note.
60 @var{note}-@code{\\arpeggio}")
61 (types . (general-music arpeggio-event event))
64 ;; todo: use articulation-event for slur as well.
65 ;; separate non articulation scripts
68 (description . "Adds an articulation marking to a note.
71 @var{note}@code{X}@code{Y}, where X is a direction (up @code{^}, down
72 @code{_}, or LilyPond's choice (no direction specified)), and where Y
73 is an articulation (such as @code{-.}, @code{->}, @code{\\tenuto},
74 @code{\\downbow}). See the user manual for details.")
76 (types . (general-music event articulation-event script-event))
80 (description . "Used for making voices that switch between 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))
89 "Check whether this music coincides with 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")
97 (types . (general-music event rhythmic-event bass-figure-event))
101 (description . "Starts or stops a beam.
103 Syntax for manual control:
105 (types . (general-music event beam-event span-event))
108 . ((description . "A drop/fall/doit jazz articulation")
109 (types . (general-music bend-after-event event))))
113 (description . "Creates a `breath mark' or `comma'.
116 @var{note}\\breathe.")
118 (types . (general-music event breathing-event))
122 (description . "Change staffs in Piano staff.
124 Syntax @code{\\translator Staff = @var{new-id}}.")
125 (iterator-ctor . , ly:change-iterator::constructor)
126 (types . (general-music translator-change-instruction))
130 . ((description . "A note that is part of a cluster.")
132 ;; not a note-event, to ensure that Note_engraver doesn't eat it.
133 (types . (general-music cluster-note-event melodic-event rhythmic-event event))
138 (description . "Interpret the argument music within a specific context.")
139 (iterator-ctor . ,ly:context-specced-music-iterator::constructor)
140 (length-callback . ,ly:music-wrapper::length-callback)
141 (start-callback . ,ly:music-wrapper::start-callback)
142 (types . (context-specification general-music music-wrapper-music))
147 (description . "Begins or ends a crescendo.
149 Syntax: @var{note}\\cr
150 ... @var{note}\\rc (you can also use \\<, \\!, \\cresc, and
151 \\endcresc. See the user manual for details.).")
153 (types . (general-music dynamic-event crescendo-event event))
157 (description . "See @ref{CrescendoEvent}.")
159 (types . (general-music dynamic-event decrescendo-event event))
164 (description . "Extend lyrics.")
166 (types . (general-music extender-event event))
171 (description . "Atomic music event.")
172 (types . (general-music event))
177 (description . "Internally used to group a set of events.")
178 (iterator-ctor . ,ly:event-chord-iterator::constructor)
179 (length-callback . ,ly:music-sequence::maximum-length-callback)
180 (to-relative-callback . ,ly:music-sequence::event-chord-relative-callback)
181 (types . (general-music event-chord simultaneous-music))
187 (description . "Specify what finger to use for this note.")
188 (types . (general-music fingering-event event))
192 (description . "Specify that a note may not auto-beamed ")
193 (types . (general-music event beam-forbid-event))
197 (description . "Start a glissando on this note.")
198 (types . (general-music glissando-event event))
203 (description . "Interpret the argument as grace notes. ")
204 (start-callback . ,ly:grace-music::start-callback)
205 (length . ,ZERO-MOMENT)
206 (iterator-ctor . ,ly:grace-iterator::constructor)
207 (types . (grace-music music-wrapper-music general-music))
211 (description . "Start or stop grouping brackets.")
212 (types . (general-music event note-grouping-event))
216 (description . "Mark a note as harmonic")
217 (types . (general-music event harmonic-event))
221 (description . "A hyphen between lyric syllables.")
223 (types . (general-music hyphen-event event))
228 (description . "Change the key signature.
230 Syntax: @code{\\key } @var{name} @var{scale}.")
231 (to-relative-callback . ,(lambda (x p) p))
232 (types . (general-music key-change-event event))
235 . ((description . "Don't damp this chord.
237 Syntax: @var{note}\\laissezVibrer.")
239 (types . (general-music event laissez-vibrer-event))
243 (description . "Start or end a ligature.")
244 (span-type . ligature)
245 (types . (general-music span-event ligature-event event))
249 (description . "Allow, forbid or force a line break.")
250 (types . (general-music line-break-event break-event event))
255 (description . "Align lyrics to the start of notes.
257 Syntax @var{\\lyricsto }@var{voicename} @var{lyrics}.")
258 (length . ,ZERO-MOMENT)
259 (types . (general-music lyric-combine-music))
260 (iterator-ctor . ,ly:lyric-combine-music-iterator::constructor)
265 (description . "A lyric syllable. Must be entered in lyrics mode, i.e.
266 @code{\\lyrics @{ twinkle4 twinkle4 @} } .")
268 (types . (general-music rhythmic-event lyric-event event))
272 (description . "Insert a rehearsal mark.
274 Syntax: @code{\\mark} @var{marker},
275 e.g. @code{\\mark \"A\"}.")
277 (types . (general-music mark-event event))
281 (description . "Start or stop a melisma.
283 Syntax: @code{c4\\melisma d\\melismaEnd}.")
284 (types . (general-music melisma-span-event event))
287 (MultiMeasureRestMusic
289 (description . "Rests that may be compressed into Multi rests.
292 @code{R2.*4} for 4 measures in 3/4 time.")
293 (iterator-ctor . ,ly:sequential-iterator::constructor)
294 (elements-callback . ,mm-rest-child-list)
295 (types . (general-music multi-measure-rest))
298 (MultiMeasureRestEvent
300 (description . "Used internally by MultiMeasureRestMusic to signal rests")
301 (types . (general-music event rhythmic-event multi-measure-rest-event))
304 (MultiMeasureTextEvent
306 (description . "Texts on mm rests.
309 @code{R-\\markup @{ \\roman \"bla\" @}}. Note the explicit font switch.")
310 (types . (general-music event multi-measure-text-event))
315 (description . "Generic type for music expressions.")
317 (types . (general-music))
321 (description . "A note.")
322 (types . (general-music event note-event rhythmic-event melodic-event))
327 (description . "Extend the definition of a graphical object.
331 @code{\\override [ @var{Ctxt} . ] @var{Obj} @var{prop} = @var{val}}
333 (types . (general-music layout-instruction-event override-property-event))
334 (iterator-ctor . ,ly:push-property-iterator::constructor)
338 (description . "Allow, forbid or force a page break.")
339 (types . (general-music break-event page-break-event event))
343 (description . "Allow, forbid or force a page turn.")
344 (types . (general-music break-event page-turn-event event))
348 (description . "Combine two parts on a staff, either merged or
349 as separate voices.")
350 (length-callback . ,ly:music-sequence::maximum-length-callback)
351 (start-callback . ,ly:music-sequence::minimum-start-callback)
352 (types . (general-music part-combine-music))
353 (iterator-ctor . ,ly:part-combine-iterator::constructor)
357 (description . "Start or end phrasing slur.
359 Syntax NOTE \\( and \\) NOTE")
360 (types . (general-music span-event event phrasing-slur-event))
365 (description . "Set a context property.
367 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
368 (types . (layout-instruction-event general-music))
369 (iterator-ctor . ,ly:property-iterator::constructor)
374 (description . "Remove the definition of a context @code{\\property}.")
376 (types . (layout-instruction-event general-music))
377 (iterator-ctor . ,ly:property-unset-iterator::constructor)
382 (description . "Used internally to signal percent repeats.")
383 (types . (general-music event percent-event))
388 (description . "Within a ligature, mark the previous and the
389 following note to form a pes (if melody goes up) or a flexa (if melody
392 (types . (general-music pes-or-flexa-event event))
397 (description . "Quote preprocessed snippets of music. ")
398 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
399 (length-callback . ,ly:music-wrapper::length-callback)
400 (start-callback . ,ly:music-wrapper::start-callback)
401 (types . (general-music music-wrapper-music))
405 . ((description . "Check if a pitch is in the correct octave.")
406 (to-relative-callback . ,ly:relative-octave-check::relative-callback)
407 (types . (general-music relative-octave-check))
412 (description . "Repeat music in different ways")
413 (types . (general-music repeated-music))
417 (description . "Ties for starting a second volta bracket.")
418 (types . (general-music event repeat-tie-event))
422 (description . "A Rest.
424 Syntax @code{r4} for a quarter rest. ")
426 (types . (general-music event rhythmic-event rest-event))
430 (description . "The opposite of @ref{OverrideProperty}: remove a
431 previously added property from a graphical object definition
434 (types . (general-music layout-instruction-event))
435 (iterator-ctor . , ly:pop-property-iterator::constructor)
440 (description . "Music expressions concatenated.
442 Syntax \\sequential @{..@} or simply @{..@} .")
444 (length-callback . ,ly:music-sequence::cumulative-length-callback)
445 (start-callback . ,ly:music-sequence::first-start-callback)
446 (elements-callback . ,(lambda (m) (ly:music-property m 'elements)))
447 (iterator-ctor . ,ly:sequential-iterator::constructor)
448 (types . (general-music sequential-music))
453 (description . "Print Solo.1")
454 (part-combine-status . solo1)
455 (types . (general-music event part-combine-event solo-one-event))
459 (description . "Print Solo.2")
460 (part-combine-status . solo2)
461 (types . (general-music event part-combine-event solo-two-event))
464 . ((description . "Print a2")
465 (part-combine-status . unisono)
466 (types . (general-music event part-combine-event unisono-event))))
470 (description . "Music playing together.
474 @code{ \\simultaneous @{ .. @}} or << .. >>.")
476 (iterator-ctor . ,ly:simultaneous-music-iterator::constructor)
477 (start-callback . ,ly:music-sequence::minimum-start-callback)
478 (length-callback . ,ly:music-sequence::maximum-length-callback)
479 (to-relative-callback . ,ly:music-sequence::simultaneous-relative-callback)
481 (types . (general-music simultaneous-music))
486 (description . "Start or end slur.
488 Syntax NOTE( and NOTE) ")
490 (types . (general-music span-event event slur-event))
494 . ((description . "Start or stop a staff symbol.")
495 (types . (general-music event span-event staff-span-event))
500 (description . "Start a text spanner like 8va.....|")
501 (types . (general-music span-event event text-span-event))
506 (description . "Start a trill spanner tr~~~")
507 (types . (general-music span-event event trill-span-event))
512 (description . "Music that has been transposed.")
513 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
514 (start-callback . ,ly:music-wrapper::start-callback)
515 (length-callback . ,ly:music-wrapper::length-callback)
516 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
517 (types . (music-wrapper-music general-music transposed-music))
522 (description . "Multiply durations, as in tuplets.
524 Syntax @code{\\times @var{fraction} @var{music}}, e.g.
525 @code{\\times 2/3 @{ ... @}} for triplets.
527 (length-callback . ,ly:music-wrapper::length-callback)
528 (start-callback . ,ly:music-wrapper::start-callback)
529 (iterator-ctor . ,ly:time-scaled-music-iterator::constructor)
530 (types . (time-scaled-music music-wrapper-music general-music))
535 (description . "Used internally to signal where tuplet brackets start and stop.")
536 (types . (tuplet-span-event span-event event general-music))
541 (description . "Music that can not be converted from relative to absolute notation.
542 For example, transposed music.")
543 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
544 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
545 (length-callback . ,ly:music-wrapper::length-callback)
546 (types . (music-wrapper-music general-music unrelativable-music))
551 (description . "Music that was entered in relative octave notation.")
552 (to-relative-callback . ,ly:relative-octave-music::relative-callback)
553 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
554 (length-callback . ,ly:music-wrapper::length-callback)
555 (start-callback . ,ly:music-wrapper::start-callback)
556 (types . (music-wrapper-music general-music relative-octave-music))
560 (description . "Add an articulation mark to a note. ")
562 (types . (general-music event))
567 (description . "Filler that takes up duration, does not print anything, and also
568 does not create staffs or voices implicitly.
572 Syntax: @code{\\skip }@var{duration}.")
573 (length-callback . ,ly:music-duration-length)
574 (iterator-ctor . ,ly:simple-music-iterator::constructor)
575 (types . (general-music event rhythmic-event skip-event))
580 (description . "Filler that takes up duration, but does not print anything.
584 Syntax: @code{s}@var{duration}")
586 (types . (general-music event rhythmic-event skip-event))
590 . ((description . "Start a new spacing section")
591 (types . (general-music event spacing-section-event))))
595 (description . "Event for anything that is started at a different time than stopped.")
597 (types . (general-music event))
602 (description . "Depress or release sustain pedal. ")
603 (types . (general-music event pedal-event sustain-event))
608 (description . "Depress or release sostenuto pedal. ")
609 (types . (general-music event pedal-event sostenuto-pedal-event))
614 (description . "Depress or release una-corda pedal.")
615 (types . (general-music event pedal-event una-corda-pedal-event))
620 (description . "Specify on which string to play this note.
622 Syntax: @code{\\@var{number}}.")
624 (types . (general-music string-number-event event))
630 (types . (general-music script-event text-script-event event))
634 (description . "A tie. Entered as @var{note}-~.")
635 (types . (general-music tie-event event))
639 (description . "Un measured tremolo.")
640 (types . (general-music event tremolo-event))
645 (description . "Tremolo over two stems")
646 (types . (general-music event span-event tremolo-span-event))
651 (description . "Separate polyphonic voices in simultaneous music.
653 Syntax: @code{\\\\}")
655 (types . (separator general-music))
660 (iterator-ctor . ,ly:volta-repeat-iterator::constructor)
662 (start-callback . ,ly:repeated-music::first-start)
663 (length-callback . ,ly:repeated-music::volta-music-length)
664 (types . (general-music repeated-music volta-repeated-music))
667 (UnfoldedRepeatedMusic
669 (iterator-ctor . ,ly:unfolded-repeat-iterator::constructor)
671 (start-callback . ,ly:repeated-music::first-start)
672 (types . (general-music repeated-music unfolded-repeated-music))
673 (length-callback . ,ly:repeated-music::unfolded-music-length)
675 (PercentRepeatedMusic
677 (description . "Repeats encoded by percents.")
678 (iterator-ctor . ,ly:percent-repeat-iterator::constructor)
679 (start-callback . ,ly:repeated-music::first-start)
680 (length-callback . ,ly:repeated-music::unfolded-music-length)
681 (types . (general-music repeated-music percent-repeated-music))
684 (TremoloRepeatedMusic
686 (iterator-ctor . ,ly:chord-tremolo-iterator::constructor)
687 (description . "Repeated notes denoted by tremolo beams.")
688 (start-callback . ,ly:repeated-music::first-start)
690 ;; the length of the repeat is handled by shifting the note logs
691 (length-callback . ,ly:repeated-music::folded-music-length)
692 (types . (general-music repeated-music tremolo-repeated-music))
698 (description . "Repeats with alternatives placed in parallel. ")
699 (iterator-ctor . ,ly:folded-repeat-iterator::constructor)
700 (start-callback . ,ly:repeated-music::minimum-start)
701 (length-callback . ,ly:repeated-music::folded-music-length)
702 (types . (general-music repeated-music folded-repeated-music))
706 (set! music-descriptions
707 (sort music-descriptions alist<?))
709 (define-public music-name-to-property-table (make-vector 59 '()))
712 ;; transport description to an object property.
716 (set-object-property! (car x)
718 (cdr (assq 'description (cdr x))))
720 (set! lst (assoc-set! lst 'name (car x)))
721 (set! lst (assq-remove! lst 'description))
722 (hashq-set! music-name-to-property-table (car x) lst)
726 (define-safe-public (make-music name . music-properties)
727 "Create a music object of given name, and set its properties
728 according to `music-properties', a list of alterning property symbols
730 (make-music 'OverrideProperty
732 'grob-property 'thickness
733 'grob-value (* 2 1.5))"
734 (if (not (symbol? name))
735 (ly:error (_ "symbol expected: ~S") name))
736 (let ((props (hashq-ref music-name-to-property-table name '())))
737 (if (not (pair? props))
738 (ly:error (_ "can't find music object: ~S") name))
739 (let ((m (ly:make-music props)))
740 (define (set-props mus-props)
741 (if (and (not (null? mus-props))
742 (not (null? (cdr mus-props))))
744 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
745 (set-props (cddr mus-props)))))
746 (set-props music-properties)
749 (define-public (make-repeated-music name)
750 (let* ((handle (assoc name '(("volta" . VoltaRepeatedMusic)
751 ("unfold" . UnfoldedRepeatedMusic)
752 ("percent" . PercentRepeatedMusic)
753 ("tremolo" . TremoloRepeatedMusic)
754 ("fold" . FoldedRepeatedMusic))))
755 (music-name (if (pair? handle)
758 (ly:warning (_ "unknown repeat type `~S'") name)
759 (ly:warning (_ "See music-types.scm for supported repeats"))
760 'VoltaRepeatedMusic))))
761 (make-music music-name)))