1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 1998--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
4 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
6 ;;;; LilyPond is free software: you can redistribute it and/or modify
7 ;;;; it under the terms of the GNU General Public License as published by
8 ;;;; the Free Software Foundation, either version 3 of the License, or
9 ;;;; (at your option) any later version.
11 ;;;; LilyPond is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;;; GNU General Public License for more details.
16 ;;;; You should have received a copy of the GNU General Public License
17 ;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
19 ;; TODO: should link back into user manual.
21 (define (mm-rest-child-list music)
22 "Generate events for multimeasure rests,
23 to be used by the sequential-iterator"
24 (let ((location (ly:music-property music 'origin))
25 (duration (ly:music-property music 'duration)))
26 (list (make-music 'BarCheck
28 (make-event-chord (cons (make-music 'MultiMeasureRestEvent
31 (ly:music-property music 'articulations)))
35 (define-public music-descriptions
38 . ((description . "Create a dynamic mark.
40 Syntax: @var{note}@code{\\x}, where @code{\\x} is a dynamic mark like
41 @code{\\ppp} or @code{\\sfz}. A complete list is in file
42 @file{ly/@/dynamic-scripts-init.ly}.")
43 (types . (general-music event dynamic-event absolute-dynamic-event))
47 . ((description . "Print an annotation of an output element.")
48 (types . (general-music event annotate-output-event))
52 . ((description . "Call the argument with the current context during
54 (types . (general-music apply-context))
55 (iterator-ctor . ,ly:apply-context-iterator::constructor)
59 . ((description . "Call the argument with all current grobs during
62 Syntax: @code{\\applyOutput #'@var{context} @var{func}}
64 Arguments to @var{func} are 1.@tie{}the grob, 2.@tie{}the originating
65 context, and 3.@tie{}the context where @var{func} is called.")
66 (types . (general-music event apply-output-event))
70 . ((description . "Make an arpeggio on this note.
72 Syntax: @var{note}@code{-\\arpeggio}")
73 (types . (general-music arpeggio-event event))
76 ;; todo: use articulation-event for slur as well.
77 ;; separate non articulation scripts
79 . ((description . "Add an articulation marking to a note.
81 Syntax: @var{note}@code{x}@code{y}, where @code{x} is a direction
82 (@code{^} for up or @code{_} for down), or LilyPond's choice
83 (no direction specified)), and where @code{y} is an articulation
84 (such as @code{-.}, @code{->}, @code{\\tenuto}, @code{\\downbow}).
85 See the Notation Reference for details.")
86 (types . (general-music event articulation-event script-event))
90 . ((description . "Used for making voices that switch between
91 piano staves automatically.")
92 (iterator-ctor . ,ly:auto-change-iterator::constructor)
93 (start-callback . ,ly:music-wrapper::start-callback)
94 (length-callback . ,ly:music-wrapper::length-callback)
95 (types . (general-music music-wrapper-music auto-change-instruction))
99 . ((description . "Check whether this music coincides with
100 the start of the measure.")
101 (types . (general-music bar-check))
102 (iterator-ctor . ,ly:bar-check-iterator::constructor)
106 . ((description . "Print a bass-figure text.")
107 (types . (general-music event rhythmic-event bass-figure-event))
111 . ((description . "Start or stop a beam.
113 Syntax for manual control: @code{c8-[ c c-] c8}")
114 (types . (general-music event beam-event span-event))
118 . ((description . "Specify that a note may not auto-beamed.")
119 (types . (general-music event beam-forbid-event))
123 . ((description . "A drop/fall/doit jazz articulation.")
124 (types . (general-music bend-after-event event))))
127 . ((description . "Create a @q{breath mark} or @q{comma}.
129 Syntax: @var{note}@code{\\breathe}")
131 (types . (general-music event breathing-event))
135 . ((description . "A note that is part of a cluster.")
136 ;; not a note-event, to ensure that Note_heads_engraver doesn't eat it.
137 (types . (general-music cluster-note-event melodic-event
138 rhythmic-event event))
141 (CompletizeExtenderEvent
142 . ((description . "Used internally to signal the end of a lyrics block to
143 ensure extenders are completed correctly when a @code{Lyrics} context ends
144 before its associated @code{Voice} context.")
145 (types . (general-music completize-extender-event event))
149 . ((description . "Change staves in Piano staff.
151 Syntax: @code{\\change Staff = @var{new-id}}")
152 (iterator-ctor . ,ly:change-iterator::constructor)
153 (types . (general-music translator-change-instruction))
157 . ((description . "Interpret the argument music within a
159 (iterator-ctor . ,ly:context-specced-music-iterator::constructor)
160 (length-callback . ,ly:music-wrapper::length-callback)
161 (start-callback . ,ly:music-wrapper::start-callback)
162 (types . (context-specification general-music music-wrapper-music))
166 . ((description . "Begin or end a crescendo.
168 Syntax: @var{note}@code{\\<} @dots{} @var{note}@code{\\!}
170 An alternative syntax is @var{note}@code{\\cr} @dots{}
171 @var{note}@code{\\endcr}.")
172 (types . (general-music span-event span-dynamic-event crescendo-event
177 . ((description . "Begin or end a decrescendo.
179 Syntax: @var{note}@code{\\>} @dots{} @var{note}@code{\\!}
181 An alternative syntax is @var{note}@code{\\decr} @dots{}
182 @var{note}@code{\\enddecr}.")
183 (types . (general-music span-event span-dynamic-event decrescendo-event
188 . ((description . "Begin or end an episema.")
189 (types . (general-music span-event event episema-event))
193 . ((description . "Atomic music event.")
194 (types . (general-music event))
198 . ((description . "Internally used to group a set of events.")
199 (iterator-ctor . ,ly:event-chord-iterator::constructor)
200 (length-callback . ,ly:music-sequence::maximum-length-callback)
201 (to-relative-callback .
202 ,ly:music-sequence::event-chord-relative-callback)
203 (types . (general-music event-chord simultaneous-music))
207 . ((description . "Extend lyrics.")
208 (types . (general-music extender-event event))
212 . ((description . "Specify what finger to use for this note.")
213 (types . (general-music fingering-event event))
217 . ((description . "Start a glissando on this note.")
218 (types . (general-music glissando-event event))
222 . ((description . "Interpret the argument as grace notes.")
223 (start-callback . ,ly:grace-music::start-callback)
224 (length . ,ZERO-MOMENT)
225 (iterator-ctor . ,ly:grace-iterator::constructor)
226 (types . (grace-music music-wrapper-music general-music))
230 . ((description . "Mark a note as harmonic.")
231 (types . (general-music event harmonic-event))
235 . ((description . "A hyphen between lyric syllables.")
236 (types . (general-music hyphen-event event))
240 . ((description . "Change the key signature.
242 Syntax: @code{\\key} @var{name} @var{scale}")
243 (to-relative-callback . ,(lambda (x p) p))
244 (types . (general-music key-change-event event))
248 . ((description . "Place a bookmarking label.")
249 (types . (general-music label-event event))
253 . ((description . "Don't damp this chord.
255 Syntax: @var{note}@code{\\laissezVibrer}")
256 (types . (general-music event laissez-vibrer-event))
260 . ((description . "Start or end a ligature.")
261 (types . (general-music span-event ligature-event event))
265 . ((description . "Allow, forbid or force a line break.")
266 (types . (general-music line-break-event break-event event))
270 . ((description . "Align lyrics to the start of notes.
272 Syntax: @code{\\lyricsto} @var{voicename} @var{lyrics}")
273 (length . ,ZERO-MOMENT)
274 (types . (general-music lyric-combine-music))
275 (iterator-ctor . ,ly:lyric-combine-music-iterator::constructor)
279 . ((description . "A lyric syllable. Must be entered in lyrics mode,
280 i.e., @code{\\lyrics @{ twinkle4 twinkle4 @} }.")
281 (types . (general-music rhythmic-event lyric-event event))
285 . ((description . "Insert a rehearsal mark.
287 Syntax: @code{\\mark} @var{marker}
289 Example: @code{\\mark \"A\"}")
290 (types . (general-music mark-event event))
293 (MultiMeasureRestEvent
294 . ((description . "Used internally by @code{MultiMeasureRestMusic}
296 (types . (general-music event rhythmic-event
297 multi-measure-rest-event))
300 (MultiMeasureRestMusic
301 . ((description . "Rests that may be compressed into Multi rests.
303 Syntax: @code{R2.*4} for 4 measures in 3/4 time.")
304 (iterator-ctor . ,ly:sequential-iterator::constructor)
305 (elements-callback . ,mm-rest-child-list)
306 (types . (general-music multi-measure-rest))
309 (MultiMeasureTextEvent
310 . ((description . "Texts on multi measure rests.
312 Syntax: @code{R-\\markup @{ \\roman \"bla\" @}}
314 Note the explicit font switch.")
315 (types . (general-music event multi-measure-text-event))
319 . ((description . "Generic type for music expressions.")
320 (types . (general-music))
324 . ((description . "A note.")
325 (types . (general-music event note-event rhythmic-event
330 . ((description . "Start or stop grouping brackets.")
331 (types . (general-music event note-grouping-event))
335 . ((description . "Extend the definition of a graphical object.
337 Syntax: @code{\\override} [ @var{context} @code{.} ]
338 @var{object} @var{property} @code{=} @var{value}")
339 (types . (general-music layout-instruction-event
340 override-property-event))
341 (iterator-ctor . ,ly:push-property-iterator::constructor)
345 . ((description . "Allow, forbid or force a page break.")
346 (types . (general-music break-event page-break-event event))
350 . ((description . "Allow, forbid or force a page turn.")
351 (types . (general-music break-event page-turn-event event))
355 . ((description . "Combine two parts on a staff, either merged or
356 as separate voices.")
357 (length-callback . ,ly:music-sequence::maximum-length-callback)
358 (start-callback . ,ly:music-sequence::minimum-start-callback)
359 (types . (general-music part-combine-music))
360 (iterator-ctor . ,ly:part-combine-iterator::constructor)
364 . ((description . "Used internally to signal percent repeats.")
365 (types . (general-music event percent-event rhythmic-event))
368 (PercentRepeatedMusic
369 . ((description . "Repeats encoded by percents.")
370 (iterator-ctor . ,ly:percent-repeat-iterator::constructor)
371 (start-callback . ,ly:repeated-music::first-start)
372 (length-callback . ,ly:repeated-music::unfolded-music-length)
373 (types . (general-music repeated-music percent-repeated-music))
377 . ((description . "Within a ligature, mark the previous and the
378 following note to form a pes (if melody goes up) or a flexa (if melody
380 (types . (general-music pes-or-flexa-event event))
384 . ((description . "Start or end phrasing slur.
386 Syntax: @var{note}@code{\\(} and @var{note}@code{\\)}")
387 (types . (general-music span-event event phrasing-slur-event))
391 . ((description . "Set a context property.
393 Syntax: @code{\\set @var{context}.@var{prop} = @var{scheme-val}}")
394 (types . (layout-instruction-event general-music))
395 (iterator-ctor . ,ly:property-iterator::constructor)
399 . ((description . "Restore the default setting for a context
400 property. See @ref{PropertySet}.
402 Syntax: @code{\\unset @var{context}.@var{prop}}")
403 (types . (layout-instruction-event general-music))
404 (iterator-ctor . ,ly:property-unset-iterator::constructor)
408 . ((description . "Quote preprocessed snippets of music.")
409 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
410 (length-callback . ,ly:music-wrapper::length-callback)
411 (start-callback . ,ly:music-wrapper::start-callback)
412 (types . (general-music music-wrapper-music))
416 . ((description . "Check if a pitch is in the correct octave.")
417 (to-relative-callback . ,ly:relative-octave-check::relative-callback)
418 (types . (general-music relative-octave-check))
422 . ((description . "Music that was entered in relative octave notation.")
423 (to-relative-callback . ,ly:relative-octave-music::relative-callback)
424 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
425 (length-callback . ,ly:music-wrapper::length-callback)
426 (start-callback . ,ly:music-wrapper::start-callback)
427 (types . (music-wrapper-music general-music relative-octave-music))
431 . ((description . "A chord repetition")
432 (to-relative-callback . ,ly:music-sequence::repeated-chord-relative-callback)
433 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
434 (start-callback . ,ly:music-wrapper::start-callback)
435 (length-callback . ,ly:music-wrapper::length-callback)
436 (types . (general-music music-wrapper-music))
440 . ((description . "Repeat music in different ways.")
441 (types . (general-music repeated-music))
445 . ((description . "Ties for starting a second volta bracket.")
446 (types . (general-music event repeat-tie-event))
450 . ((description . "A Rest.
452 Syntax: @code{r4} for a quarter rest.")
453 (types . (general-music event rhythmic-event rest-event))
457 . ((description . "The opposite of @ref{OverrideProperty}: remove a
458 previously added property from a graphical object definition.")
459 (types . (general-music layout-instruction-event))
460 (iterator-ctor . ,ly:pop-property-iterator::constructor)
464 . ((description . "Add an articulation mark to a note.")
465 (types . (general-music event))
469 . ((description . "Music expressions concatenated.
471 Syntax: @code{\\sequential @{ @dots{} @}} or simply @code{@{ @dots{} @}}")
472 (length-callback . ,ly:music-sequence::cumulative-length-callback)
473 (start-callback . ,ly:music-sequence::first-start-callback)
474 (elements-callback . ,(lambda (m) (ly:music-property m 'elements)))
475 (iterator-ctor . ,ly:sequential-iterator::constructor)
476 (types . (general-music sequential-music))
480 . ((description . "Music playing together.
482 Syntax: @code{\\simultaneous @{ @dots{} @}} or @code{<< @dots{} >>}")
483 (iterator-ctor . ,ly:simultaneous-music-iterator::constructor)
484 (start-callback . ,ly:music-sequence::minimum-start-callback)
485 (length-callback . ,ly:music-sequence::maximum-length-callback)
486 (to-relative-callback .
487 ,ly:music-sequence::simultaneous-relative-callback)
488 (types . (general-music simultaneous-music))
492 . ((description . "Filler that takes up duration, but does not
495 Syntax: @code{s4} for a skip equivalent to a quarter rest.")
496 (types . (general-music event rhythmic-event skip-event))
500 . ((description . "Filler that takes up duration, does not
501 print anything, and also does not create staves or voices implicitly.
503 Syntax: @code{\\skip} @var{duration}")
504 (length-callback . ,ly:music-duration-length)
505 (iterator-ctor . ,ly:simple-music-iterator::constructor)
506 (types . (general-music event rhythmic-event skip-event))
510 . ((description . "Start or end slur.
512 Syntax: @var{note}@code{(} and @var{note}@code{)}")
513 (types . (general-music span-event event slur-event))
517 . ((description . "Print @q{Solo@tie{}1}.")
518 (part-combine-status . solo1)
519 (types . (general-music event part-combine-event solo-one-event))
523 . ((description . "Print @q{Solo@tie{}2}.")
524 (part-combine-status . solo2)
525 (types . (general-music event part-combine-event solo-two-event))
529 . ((description . "Depress or release sostenuto pedal.")
530 (types . (general-music event pedal-event sostenuto-event))
534 . ((description . "Start a new spacing section.")
535 (types . (general-music event spacing-section-event))))
538 . ((description . "Event for anything that is started at a
539 different time than stopped.")
540 (types . (general-music event))
544 . ((description . "Start or stop a staff symbol.")
545 (types . (general-music event span-event staff-span-event))
549 . ((description . "Specify on which string to play this note.
551 Syntax: @code{\\@var{number}}")
552 (types . (general-music string-number-event event))
556 . ((description . "Specify with which finger to pluck a string.
558 Syntax: @code{\\rightHandFinger @var{text}}")
559 (types . (general-music stroke-finger-event event))
563 . ((description . "Depress or release sustain pedal.")
564 (types . (general-music event pedal-event sustain-event))
568 . ((description . "Print text.")
569 (types . (general-music script-event text-script-event event))
573 . ((description . "Start a text spanner, for example, an
575 (types . (general-music span-event event text-span-event))
579 . ((description . "A tie.
581 Syntax: @var{note}@code{-~}")
582 (types . (general-music tie-event event))
586 . ((description . "Multiply durations, as in tuplets.
588 Syntax: @code{\\times @var{fraction} @var{music}}, e.g.,
589 @code{\\times 2/3 @{ @dots{} @}} for triplets.")
590 (length-callback . ,ly:music-wrapper::length-callback)
591 (start-callback . ,ly:music-wrapper::start-callback)
592 (iterator-ctor . ,ly:tuplet-iterator::constructor)
593 (types . (time-scaled-music music-wrapper-music general-music))
597 . ((description . "Music that has been transposed.")
598 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
599 (start-callback . ,ly:music-wrapper::start-callback)
600 (length-callback . ,ly:music-wrapper::length-callback)
601 (to-relative-callback .
602 ,ly:relative-octave-music::no-relative-callback)
603 (types . (music-wrapper-music general-music transposed-music))
607 . ((description . "Unmeasured tremolo.")
608 (types . (general-music event tremolo-event))
611 (TremoloRepeatedMusic
612 . ((description . "Repeated notes denoted by tremolo beams.")
613 (iterator-ctor . ,ly:chord-tremolo-iterator::constructor)
614 (start-callback . ,ly:repeated-music::first-start)
615 ;; the length of the repeat is handled by shifting the note logs
616 (length-callback . ,ly:repeated-music::folded-music-length)
617 (types . (general-music repeated-music tremolo-repeated-music))
621 . ((description . "Tremolo over two stems.")
622 (types . (general-music event span-event tremolo-span-event))
626 . ((description . "Start a trill spanner.")
627 (types . (general-music span-event event trill-span-event))
631 . ((description . "Used internally to signal where tuplet
632 brackets start and stop.")
633 (types . (tuplet-span-event span-event event general-music))
637 . ((description . "Depress or release una-corda pedal.")
638 (types . (general-music event pedal-event una-corda-event))
641 (UnfoldedRepeatedMusic
642 . ((description . "Repeated music which is fully written
644 (iterator-ctor . ,ly:unfolded-repeat-iterator::constructor)
645 (start-callback . ,ly:repeated-music::first-start)
646 (types . (general-music repeated-music unfolded-repeated-music))
647 (length-callback . ,ly:repeated-music::unfolded-music-length)
651 . ((description . "Print @q{a@tie{}2}.")
652 (part-combine-status . unisono)
653 (types . (general-music event part-combine-event unisono-event))))
656 . ((description . "Music that cannot be converted from relative
657 to absolute notation. For example, transposed music.")
658 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
659 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
660 (length-callback . ,ly:music-wrapper::length-callback)
661 (types . (music-wrapper-music general-music unrelativable-music))
665 . ((description . "Separate polyphonic voices in simultaneous music.
667 Syntax: @code{\\\\}")
668 (types . (separator general-music))
672 . ((description . "Repeats with alternatives placed sequentially.")
673 (iterator-ctor . ,ly:volta-repeat-iterator::constructor)
674 (start-callback . ,ly:repeated-music::first-start)
675 (length-callback . ,ly:repeated-music::volta-music-length)
676 (types . (general-music repeated-music volta-repeated-music))
680 (set! music-descriptions
681 (sort music-descriptions alist<?))
683 (define-public music-name-to-property-table (make-vector 59 '()))
686 ;; transport description to an object property.
690 (set-object-property! (car x)
692 (cdr (assq 'description (cdr x))))
694 (set! lst (assoc-set! lst 'name (car x)))
695 (set! lst (assq-remove! lst 'description))
696 (hashq-set! music-name-to-property-table (car x) lst)
700 (define-safe-public (make-music name . music-properties)
701 "Create a music object of given name, and set its properties
702 according to @code{music-properties}, a list of alternating property symbols
704 (make-music 'OverrideProperty
706 'grob-property 'thickness
707 'grob-value (* 2 1.5))"
708 (if (not (symbol? name))
709 (ly:error (_ "symbol expected: ~S") name))
710 (let ((props (hashq-ref music-name-to-property-table name '())))
711 (if (not (pair? props))
712 (ly:error (_ "cannot find music object: ~S") name))
713 (let ((m (ly:make-music props)))
714 (define (set-props mus-props)
715 (if (and (not (null? mus-props))
716 (not (null? (cdr mus-props))))
718 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
719 (set-props (cddr mus-props)))))
720 (set-props music-properties)
723 (define-public (make-repeated-music name)
724 (let* ((repeated-music (assoc-get name '(("volta" . VoltaRepeatedMusic)
725 ("unfold" . UnfoldedRepeatedMusic)
726 ("percent" . PercentRepeatedMusic)
727 ("tremolo" . TremoloRepeatedMusic))))
728 (repeated-music-name (if repeated-music
731 (ly:warning (_ "unknown repeat type `~S'") name)
732 (ly:warning (_ "See define-music-types.scm for supported repeats"))
733 'VoltaRepeatedMusic))))
734 (make-music repeated-music-name)))