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))
142 . ((description . "Change staves in Piano staff.
144 Syntax: @code{\\change Staff = @var{new-id}}")
145 (iterator-ctor . ,ly:change-iterator::constructor)
146 (types . (general-music translator-change-instruction))
150 . ((description . "Interpret the argument music within a
152 (iterator-ctor . ,ly:context-specced-music-iterator::constructor)
153 (length-callback . ,ly:music-wrapper::length-callback)
154 (start-callback . ,ly:music-wrapper::start-callback)
155 (types . (context-specification general-music music-wrapper-music))
159 . ((description . "Begin or end a crescendo.
161 Syntax: @var{note}@code{\\<} @dots{} @var{note}@code{\\!}
163 An alternative syntax is @var{note}@code{\\cr} @dots{}
164 @var{note}@code{\\endcr}.")
165 (types . (general-music span-event span-dynamic-event crescendo-event
170 . ((description . "Begin or end a decrescendo.
172 Syntax: @var{note}@code{\\>} @dots{} @var{note}@code{\\!}
174 An alternative syntax is @var{note}@code{\\decr} @dots{}
175 @var{note}@code{\\enddecr}.")
176 (types . (general-music span-event span-dynamic-event decrescendo-event
181 . ((description . "Begin or end an episema.")
182 (types . (general-music span-event event episema-event))
186 . ((description . "Atomic music event.")
187 (types . (general-music event))
191 . ((description . "Internally used to group a set of events.")
192 (iterator-ctor . ,ly:event-chord-iterator::constructor)
193 (length-callback . ,ly:music-sequence::maximum-length-callback)
194 (to-relative-callback .
195 ,ly:music-sequence::event-chord-relative-callback)
196 (types . (general-music event-chord simultaneous-music))
200 . ((description . "Extend lyrics.")
201 (types . (general-music extender-event event))
205 . ((description . "Specify what finger to use for this note.")
206 (types . (general-music fingering-event event))
210 . ((description . "Start a glissando on this note.")
211 (types . (general-music glissando-event event))
215 . ((description . "Interpret the argument as grace notes.")
216 (start-callback . ,ly:grace-music::start-callback)
217 (length . ,ZERO-MOMENT)
218 (iterator-ctor . ,ly:grace-iterator::constructor)
219 (types . (grace-music music-wrapper-music general-music))
223 . ((description . "Mark a note as harmonic.")
224 (types . (general-music event harmonic-event))
228 . ((description . "A hyphen between lyric syllables.")
229 (types . (general-music hyphen-event event))
233 . ((description . "Change the key signature.
235 Syntax: @code{\\key} @var{name} @var{scale}")
236 (to-relative-callback . ,(lambda (x p) p))
237 (types . (general-music key-change-event event))
241 . ((description . "Place a bookmarking label.")
242 (types . (general-music label-event event))
246 . ((description . "Don't damp this chord.
248 Syntax: @var{note}@code{\\laissezVibrer}")
249 (types . (general-music event laissez-vibrer-event))
253 . ((description . "Start or end a ligature.")
254 (types . (general-music span-event ligature-event event))
258 . ((description . "Allow, forbid or force a line break.")
259 (types . (general-music line-break-event break-event event))
263 . ((description . "Align lyrics to the start of notes.
265 Syntax: @code{\\lyricsto} @var{voicename} @var{lyrics}")
266 (length . ,ZERO-MOMENT)
267 (types . (general-music lyric-combine-music))
268 (iterator-ctor . ,ly:lyric-combine-music-iterator::constructor)
272 . ((description . "A lyric syllable. Must be entered in lyrics mode,
273 i.e., @code{\\lyrics @{ twinkle4 twinkle4 @} }.")
274 (types . (general-music rhythmic-event lyric-event event))
278 . ((description . "Insert a rehearsal mark.
280 Syntax: @code{\\mark} @var{marker}
282 Example: @code{\\mark \"A\"}")
283 (types . (general-music mark-event event))
286 (MultiMeasureRestEvent
287 . ((description . "Used internally by @code{MultiMeasureRestMusic}
289 (types . (general-music event rhythmic-event
290 multi-measure-rest-event))
293 (MultiMeasureRestMusic
294 . ((description . "Rests that may be compressed into Multi rests.
296 Syntax: @code{R2.*4} for 4 measures in 3/4 time.")
297 (iterator-ctor . ,ly:sequential-iterator::constructor)
298 (elements-callback . ,mm-rest-child-list)
299 (types . (general-music multi-measure-rest))
302 (MultiMeasureTextEvent
303 . ((description . "Texts on multi measure rests.
305 Syntax: @code{R-\\markup @{ \\roman \"bla\" @}}
307 Note the explicit font switch.")
308 (types . (general-music event multi-measure-text-event))
312 . ((description . "Generic type for music expressions.")
313 (types . (general-music))
317 . ((description . "A note.")
318 (types . (general-music event note-event rhythmic-event
323 . ((description . "Start or stop grouping brackets.")
324 (types . (general-music event note-grouping-event))
328 . ((description . "Extend the definition of a graphical object.
330 Syntax: @code{\\override} [ @var{context} @code{.} ]
331 @var{object} @var{property} @code{=} @var{value}")
332 (types . (general-music layout-instruction-event
333 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 . "Used internally to signal percent repeats.")
358 (types . (general-music event percent-event rhythmic-event))
361 (PercentRepeatedMusic
362 . ((description . "Repeats encoded by percents.")
363 (iterator-ctor . ,ly:percent-repeat-iterator::constructor)
364 (start-callback . ,ly:repeated-music::first-start)
365 (length-callback . ,ly:repeated-music::unfolded-music-length)
366 (types . (general-music repeated-music percent-repeated-music))
370 . ((description . "Within a ligature, mark the previous and the
371 following note to form a pes (if melody goes up) or a flexa (if melody
373 (types . (general-music pes-or-flexa-event event))
377 . ((description . "Start or end phrasing slur.
379 Syntax: @var{note}@code{\\(} and @var{note}@code{\\)}")
380 (types . (general-music span-event event phrasing-slur-event))
384 . ((description . "Set a context property.
386 Syntax: @code{\\set @var{context}.@var{prop} = @var{scheme-val}}")
387 (types . (layout-instruction-event general-music))
388 (iterator-ctor . ,ly:property-iterator::constructor)
392 . ((description . "Restore the default setting for a context
393 property. See @ref{PropertySet}.
395 Syntax: @code{\\unset @var{context}.@var{prop}}")
396 (types . (layout-instruction-event general-music))
397 (iterator-ctor . ,ly:property-unset-iterator::constructor)
401 . ((description . "Quote preprocessed snippets of music.")
402 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
403 (length-callback . ,ly:music-wrapper::length-callback)
404 (start-callback . ,ly:music-wrapper::start-callback)
405 (types . (general-music music-wrapper-music))
409 . ((description . "Check if a pitch is in the correct octave.")
410 (to-relative-callback . ,ly:relative-octave-check::relative-callback)
411 (types . (general-music relative-octave-check))
415 . ((description . "Music that was entered in relative octave notation.")
416 (to-relative-callback . ,ly:relative-octave-music::relative-callback)
417 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
418 (length-callback . ,ly:music-wrapper::length-callback)
419 (start-callback . ,ly:music-wrapper::start-callback)
420 (types . (music-wrapper-music general-music relative-octave-music))
424 . ((description . "A chord repetition")
425 (to-relative-callback . ,ly:music-sequence::repeated-chord-relative-callback)
426 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
427 (start-callback . ,ly:music-wrapper::start-callback)
428 (length-callback . ,ly:music-wrapper::length-callback)
429 (types . (general-music music-wrapper-music))
433 . ((description . "Repeat music in different ways.")
434 (types . (general-music repeated-music))
438 . ((description . "Ties for starting a second volta bracket.")
439 (types . (general-music event repeat-tie-event))
443 . ((description . "A Rest.
445 Syntax: @code{r4} for a quarter rest.")
446 (types . (general-music event rhythmic-event rest-event))
450 . ((description . "The opposite of @ref{OverrideProperty}: remove a
451 previously added property from a graphical object definition.")
452 (types . (general-music layout-instruction-event))
453 (iterator-ctor . ,ly:pop-property-iterator::constructor)
457 . ((description . "Add an articulation mark to a note.")
458 (types . (general-music event))
462 . ((description . "Music expressions concatenated.
464 Syntax: @code{\\sequential @{ @dots{} @}} or simply @code{@{ @dots{} @}}")
465 (length-callback . ,ly:music-sequence::cumulative-length-callback)
466 (start-callback . ,ly:music-sequence::first-start-callback)
467 (elements-callback . ,(lambda (m) (ly:music-property m 'elements)))
468 (iterator-ctor . ,ly:sequential-iterator::constructor)
469 (types . (general-music sequential-music))
473 . ((description . "Music playing together.
475 Syntax: @code{\\simultaneous @{ @dots{} @}} or @code{<< @dots{} >>}")
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 .
480 ,ly:music-sequence::simultaneous-relative-callback)
481 (types . (general-music simultaneous-music))
485 . ((description . "Filler that takes up duration, but does not
488 Syntax: @code{s4} for a skip equivalent to a quarter rest.")
489 (types . (general-music event rhythmic-event skip-event))
493 . ((description . "Filler that takes up duration, does not
494 print anything, and also does not create staves or voices implicitly.
496 Syntax: @code{\\skip} @var{duration}")
497 (length-callback . ,ly:music-duration-length)
498 (iterator-ctor . ,ly:simple-music-iterator::constructor)
499 (types . (general-music event rhythmic-event skip-event))
503 . ((description . "Start or end slur.
505 Syntax: @var{note}@code{(} and @var{note}@code{)}")
506 (types . (general-music span-event event slur-event))
510 . ((description . "Print @q{Solo@tie{}1}.")
511 (part-combine-status . solo1)
512 (types . (general-music event part-combine-event solo-one-event))
516 . ((description . "Print @q{Solo@tie{}2}.")
517 (part-combine-status . solo2)
518 (types . (general-music event part-combine-event solo-two-event))
522 . ((description . "Depress or release sostenuto pedal.")
523 (types . (general-music event pedal-event sostenuto-event))
527 . ((description . "Start a new spacing section.")
528 (types . (general-music event spacing-section-event))))
531 . ((description . "Event for anything that is started at a
532 different time than stopped.")
533 (types . (general-music event))
537 . ((description . "Start or stop a staff symbol.")
538 (types . (general-music event span-event staff-span-event))
542 . ((description . "Specify on which string to play this note.
544 Syntax: @code{\\@var{number}}")
545 (types . (general-music string-number-event event))
549 . ((description . "Specify with which finger to pluck a string.
551 Syntax: @code{\\rightHandFinger @var{text}}")
552 (types . (general-music stroke-finger-event event))
556 . ((description . "Depress or release sustain pedal.")
557 (types . (general-music event pedal-event sustain-event))
561 . ((description . "Print text.")
562 (types . (general-music script-event text-script-event event))
566 . ((description . "Start a text spanner, for example, an
568 (types . (general-music span-event event text-span-event))
572 . ((description . "A tie.
574 Syntax: @var{note}@code{-~}")
575 (types . (general-music tie-event event))
579 . ((description . "Multiply durations, as in tuplets.
581 Syntax: @code{\\times @var{fraction} @var{music}}, e.g.,
582 @code{\\times 2/3 @{ @dots{} @}} for triplets.")
583 (length-callback . ,ly:music-wrapper::length-callback)
584 (start-callback . ,ly:music-wrapper::start-callback)
585 (iterator-ctor . ,ly:tuplet-iterator::constructor)
586 (types . (time-scaled-music music-wrapper-music general-music))
590 . ((description . "Music that has been transposed.")
591 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
592 (start-callback . ,ly:music-wrapper::start-callback)
593 (length-callback . ,ly:music-wrapper::length-callback)
594 (to-relative-callback .
595 ,ly:relative-octave-music::no-relative-callback)
596 (types . (music-wrapper-music general-music transposed-music))
600 . ((description . "Unmeasured tremolo.")
601 (types . (general-music event tremolo-event))
604 (TremoloRepeatedMusic
605 . ((description . "Repeated notes denoted by tremolo beams.")
606 (iterator-ctor . ,ly:chord-tremolo-iterator::constructor)
607 (start-callback . ,ly:repeated-music::first-start)
608 ;; the length of the repeat is handled by shifting the note logs
609 (length-callback . ,ly:repeated-music::folded-music-length)
610 (types . (general-music repeated-music tremolo-repeated-music))
614 . ((description . "Tremolo over two stems.")
615 (types . (general-music event span-event tremolo-span-event))
619 . ((description . "Start a trill spanner.")
620 (types . (general-music span-event event trill-span-event))
624 . ((description . "Used internally to signal where tuplet
625 brackets start and stop.")
626 (types . (tuplet-span-event span-event event general-music))
630 . ((description . "Depress or release una-corda pedal.")
631 (types . (general-music event pedal-event una-corda-event))
634 (UnfoldedRepeatedMusic
635 . ((description . "Repeated music which is fully written
637 (iterator-ctor . ,ly:unfolded-repeat-iterator::constructor)
638 (start-callback . ,ly:repeated-music::first-start)
639 (types . (general-music repeated-music unfolded-repeated-music))
640 (length-callback . ,ly:repeated-music::unfolded-music-length)
644 . ((description . "Print @q{a@tie{}2}.")
645 (part-combine-status . unisono)
646 (types . (general-music event part-combine-event unisono-event))))
649 . ((description . "Music that cannot be converted from relative
650 to absolute notation. For example, transposed music.")
651 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
652 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
653 (length-callback . ,ly:music-wrapper::length-callback)
654 (types . (music-wrapper-music general-music unrelativable-music))
658 . ((description . "Separate polyphonic voices in simultaneous music.
660 Syntax: @code{\\\\}")
661 (types . (separator general-music))
665 . ((description . "Repeats with alternatives placed sequentially.")
666 (iterator-ctor . ,ly:volta-repeat-iterator::constructor)
667 (start-callback . ,ly:repeated-music::first-start)
668 (length-callback . ,ly:repeated-music::volta-music-length)
669 (types . (general-music repeated-music volta-repeated-music))
673 (set! music-descriptions
674 (sort music-descriptions alist<?))
676 (define-public music-name-to-property-table (make-vector 59 '()))
679 ;; transport description to an object property.
683 (set-object-property! (car x)
685 (cdr (assq 'description (cdr x))))
687 (set! lst (assoc-set! lst 'name (car x)))
688 (set! lst (assq-remove! lst 'description))
689 (hashq-set! music-name-to-property-table (car x) lst)
693 (define-safe-public (make-music name . music-properties)
694 "Create a music object of given name, and set its properties
695 according to @code{music-properties}, a list of alternating property symbols
697 (make-music 'OverrideProperty
699 'grob-property 'thickness
700 'grob-value (* 2 1.5))"
701 (if (not (symbol? name))
702 (ly:error (_ "symbol expected: ~S") name))
703 (let ((props (hashq-ref music-name-to-property-table name '())))
704 (if (not (pair? props))
705 (ly:error (_ "cannot find music object: ~S") name))
706 (let ((m (ly:make-music props)))
707 (define (set-props mus-props)
708 (if (and (not (null? mus-props))
709 (not (null? (cdr mus-props))))
711 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
712 (set-props (cddr mus-props)))))
713 (set-props music-properties)
716 (define-public (make-repeated-music name)
717 (let* ((repeated-music (assoc-get name '(("volta" . VoltaRepeatedMusic)
718 ("unfold" . UnfoldedRepeatedMusic)
719 ("percent" . PercentRepeatedMusic)
720 ("tremolo" . TremoloRepeatedMusic))))
721 (repeated-music-name (if repeated-music
724 (ly:warning (_ "unknown repeat type `~S'") name)
725 (ly:warning (_ "See define-music-types.scm for supported repeats"))
726 'VoltaRepeatedMusic))))
727 (make-music repeated-music-name)))