1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 1998--2009 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 . "Atomic music event.")
182 (types . (general-music event))
186 . ((description . "Internally used to group a set of events.")
187 (iterator-ctor . ,ly:event-chord-iterator::constructor)
188 (length-callback . ,ly:music-sequence::maximum-length-callback)
189 (to-relative-callback .
190 ,ly:music-sequence::event-chord-relative-callback)
191 (types . (general-music event-chord simultaneous-music))
195 . ((description . "Extend lyrics.")
196 (types . (general-music extender-event event))
200 . ((description . "Specify what finger to use for this note.")
201 (types . (general-music fingering-event event))
205 . ((description . "Start a glissando on this note.")
206 (types . (general-music glissando-event event))
210 . ((description . "Interpret the argument as grace notes.")
211 (start-callback . ,ly:grace-music::start-callback)
212 (length . ,ZERO-MOMENT)
213 (iterator-ctor . ,ly:grace-iterator::constructor)
214 (types . (grace-music music-wrapper-music general-music))
218 . ((description . "Mark a note as harmonic.")
219 (types . (general-music event harmonic-event))
223 . ((description . "A hyphen between lyric syllables.")
224 (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))
236 . ((description . "Place a bookmarking label.")
237 (types . (general-music label-event event))
241 . ((description . "Don't damp this chord.
243 Syntax: @var{note}@code{\\laissezVibrer}")
244 (types . (general-music event laissez-vibrer-event))
248 . ((description . "Start or end a ligature.")
249 (span-type . ligature)
250 (types . (general-music span-event ligature-event event))
254 . ((description . "Allow, forbid or force a line break.")
255 (types . (general-music line-break-event break-event event))
259 . ((description . "Align lyrics to the start of notes.
261 Syntax: @code{\\lyricsto} @var{voicename} @var{lyrics}")
262 (length . ,ZERO-MOMENT)
263 (types . (general-music lyric-combine-music))
264 (iterator-ctor . ,ly:lyric-combine-music-iterator::constructor)
268 . ((description . "A lyric syllable. Must be entered in lyrics mode,
269 i.e., @code{\\lyrics @{ twinkle4 twinkle4 @} }.")
270 (types . (general-music rhythmic-event lyric-event event))
274 . ((description . "Insert a rehearsal mark.
276 Syntax: @code{\\mark} @var{marker}
278 Example: @code{\\mark \"A\"}")
279 (types . (general-music mark-event event))
282 (MultiMeasureRestEvent
283 . ((description . "Used internally by @code{MultiMeasureRestMusic}
285 (types . (general-music event rhythmic-event
286 multi-measure-rest-event))
289 (MultiMeasureRestMusic
290 . ((description . "Rests that may be compressed into Multi rests.
292 Syntax: @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 (MultiMeasureTextEvent
299 . ((description . "Texts on multi measure rests.
301 Syntax: @code{R-\\markup @{ \\roman \"bla\" @}}
303 Note the explicit font switch.")
304 (types . (general-music event multi-measure-text-event))
308 . ((description . "Generic type for music expressions.")
309 (types . (general-music))
313 . ((description . "A note.")
314 (types . (general-music event note-event rhythmic-event
319 . ((description . "Start or stop grouping brackets.")
320 (types . (general-music event note-grouping-event))
324 . ((description . "Extend the definition of a graphical object.
326 Syntax: @code{\\override} [ @var{context} @code{.} ]
327 @var{object} @var{property} @code{=} @var{value}")
328 (types . (general-music layout-instruction-event
329 override-property-event))
330 (iterator-ctor . ,ly:push-property-iterator::constructor)
334 . ((description . "Allow, forbid or force a page break.")
335 (types . (general-music break-event page-break-event event))
339 . ((description . "Allow, forbid or force a page turn.")
340 (types . (general-music break-event page-turn-event event))
344 . ((description . "Combine two parts on a staff, either merged or
345 as separate voices.")
346 (length-callback . ,ly:music-sequence::maximum-length-callback)
347 (start-callback . ,ly:music-sequence::minimum-start-callback)
348 (types . (general-music part-combine-music))
349 (iterator-ctor . ,ly:part-combine-iterator::constructor)
353 . ((description . "Used internally to signal percent repeats.")
354 (types . (general-music event percent-event rhythmic-event))
357 (PercentRepeatedMusic
358 . ((description . "Repeats encoded by percents.")
359 (iterator-ctor . ,ly:percent-repeat-iterator::constructor)
360 (start-callback . ,ly:repeated-music::first-start)
361 (length-callback . ,ly:repeated-music::unfolded-music-length)
362 (types . (general-music repeated-music percent-repeated-music))
366 . ((description . "Within a ligature, mark the previous and the
367 following note to form a pes (if melody goes up) or a flexa (if melody
369 (types . (general-music pes-or-flexa-event event))
373 . ((description . "Start or end phrasing slur.
375 Syntax: @var{note}@code{\\(} and @var{note}@code{\\)}")
376 (types . (general-music span-event event phrasing-slur-event))
380 . ((description . "Set a context property.
382 Syntax: @code{\\set @var{context}.@var{prop} = @var{scheme-val}}")
383 (types . (layout-instruction-event general-music))
384 (iterator-ctor . ,ly:property-iterator::constructor)
388 . ((description . "Restore the default setting for a context
389 property. See @ref{PropertySet}.
391 Syntax: @code{\\unset @var{context}.@var{prop}}")
392 (types . (layout-instruction-event general-music))
393 (iterator-ctor . ,ly:property-unset-iterator::constructor)
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))
411 . ((description . "Music that was entered in relative octave notation.")
412 (to-relative-callback . ,ly:relative-octave-music::relative-callback)
413 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
414 (length-callback . ,ly:music-wrapper::length-callback)
415 (start-callback . ,ly:music-wrapper::start-callback)
416 (types . (music-wrapper-music general-music relative-octave-music))
420 . ((description . "A chord repetition")
421 (to-relative-callback . ,ly:music-sequence::repeated-chord-relative-callback)
422 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
423 (start-callback . ,ly:music-wrapper::start-callback)
424 (length-callback . ,ly:music-wrapper::length-callback)
425 (types . (general-music music-wrapper-music))
429 . ((description . "Repeat music in different ways.")
430 (types . (general-music repeated-music))
434 . ((description . "Ties for starting a second volta bracket.")
435 (types . (general-music event repeat-tie-event))
439 . ((description . "A Rest.
441 Syntax: @code{r4} for a quarter rest.")
442 (types . (general-music event rhythmic-event rest-event))
446 . ((description . "The opposite of @ref{OverrideProperty}: remove a
447 previously added property from a graphical object definition.")
448 (types . (general-music layout-instruction-event))
449 (iterator-ctor . ,ly:pop-property-iterator::constructor)
453 . ((description . "Add an articulation mark to a note.")
454 (types . (general-music event))
458 . ((description . "Music expressions concatenated.
460 Syntax: @code{\\sequential @{ @dots{} @}} or simply @code{@{ @dots{} @}}")
461 (length-callback . ,ly:music-sequence::cumulative-length-callback)
462 (start-callback . ,ly:music-sequence::first-start-callback)
463 (elements-callback . ,(lambda (m) (ly:music-property m 'elements)))
464 (iterator-ctor . ,ly:sequential-iterator::constructor)
465 (types . (general-music sequential-music))
469 . ((description . "Music playing together.
471 Syntax: @code{\\simultaneous @{ @dots{} @}} or @code{<< @dots{} >>}")
472 (iterator-ctor . ,ly:simultaneous-music-iterator::constructor)
473 (start-callback . ,ly:music-sequence::minimum-start-callback)
474 (length-callback . ,ly:music-sequence::maximum-length-callback)
475 (to-relative-callback .
476 ,ly:music-sequence::simultaneous-relative-callback)
477 (types . (general-music simultaneous-music))
481 . ((description . "Filler that takes up duration, but does not
484 Syntax: @code{s4} for a skip equivalent to a quarter rest.")
485 (types . (general-music event rhythmic-event skip-event))
489 . ((description . "Filler that takes up duration, does not
490 print anything, and also does not create staves or voices implicitly.
492 Syntax: @code{\\skip} @var{duration}")
493 (length-callback . ,ly:music-duration-length)
494 (iterator-ctor . ,ly:simple-music-iterator::constructor)
495 (types . (general-music event rhythmic-event skip-event))
499 . ((description . "Start or end slur.
501 Syntax: @var{note}@code{(} and @var{note}@code{)}")
502 (types . (general-music span-event event slur-event))
506 . ((description . "Print @q{Solo@tie{}1}.")
507 (part-combine-status . solo1)
508 (types . (general-music event part-combine-event solo-one-event))
512 . ((description . "Print @q{Solo@tie{}2}.")
513 (part-combine-status . solo2)
514 (types . (general-music event part-combine-event solo-two-event))
518 . ((description . "Depress or release sostenuto pedal.")
519 (types . (general-music event pedal-event sostenuto-event))
523 . ((description . "Start a new spacing section.")
524 (types . (general-music event spacing-section-event))))
527 . ((description . "Event for anything that is started at a
528 different time than stopped.")
529 (types . (general-music event))
533 . ((description . "Start or stop a staff symbol.")
534 (types . (general-music event span-event staff-span-event))
538 . ((description . "Specify on which string to play this note.
540 Syntax: @code{\\@var{number}}")
541 (types . (general-music string-number-event event))
545 . ((description . "Specify with which finger to pluck a string.
547 Syntax: @code{\\rightHandFinger @var{text}}")
548 (types . (general-music stroke-finger-event event))
552 . ((description . "Depress or release sustain pedal.")
553 (types . (general-music event pedal-event sustain-event))
557 . ((description . "Print text.")
558 (types . (general-music script-event text-script-event event))
562 . ((description . "Start a text spanner, for example, an
564 (types . (general-music span-event event text-span-event))
568 . ((description . "A tie.
570 Syntax: @var{note}@code{-~}")
571 (types . (general-music tie-event event))
575 . ((description . "Multiply durations, as in tuplets.
577 Syntax: @code{\\times @var{fraction} @var{music}}, e.g.,
578 @code{\\times 2/3 @{ @dots{} @}} for triplets.")
579 (length-callback . ,ly:music-wrapper::length-callback)
580 (start-callback . ,ly:music-wrapper::start-callback)
581 (iterator-ctor . ,ly:time-scaled-music-iterator::constructor)
582 (types . (time-scaled-music music-wrapper-music general-music))
586 . ((description . "Music that has been transposed.")
587 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
588 (start-callback . ,ly:music-wrapper::start-callback)
589 (length-callback . ,ly:music-wrapper::length-callback)
590 (to-relative-callback .
591 ,ly:relative-octave-music::no-relative-callback)
592 (types . (music-wrapper-music general-music transposed-music))
596 . ((description . "Unmeasured tremolo.")
597 (types . (general-music event tremolo-event))
600 (TremoloRepeatedMusic
601 . ((description . "Repeated notes denoted by tremolo beams.")
602 (iterator-ctor . ,ly:chord-tremolo-iterator::constructor)
603 (start-callback . ,ly:repeated-music::first-start)
604 ;; the length of the repeat is handled by shifting the note logs
605 (length-callback . ,ly:repeated-music::folded-music-length)
606 (types . (general-music repeated-music tremolo-repeated-music))
610 . ((description . "Tremolo over two stems.")
611 (types . (general-music event span-event tremolo-span-event))
615 . ((description . "Start a trill spanner.")
616 (types . (general-music span-event event trill-span-event))
620 . ((description . "Used internally to signal where tuplet
621 brackets start and stop.")
622 (types . (tuplet-span-event span-event event general-music))
626 . ((description . "Depress or release una-corda pedal.")
627 (types . (general-music event pedal-event una-corda-event))
630 (UnfoldedRepeatedMusic
631 . ((description . "Repeated music which is fully written
633 (iterator-ctor . ,ly:unfolded-repeat-iterator::constructor)
634 (start-callback . ,ly:repeated-music::first-start)
635 (types . (general-music repeated-music unfolded-repeated-music))
636 (length-callback . ,ly:repeated-music::unfolded-music-length)
640 . ((description . "Print @q{a@tie{}2}.")
641 (part-combine-status . unisono)
642 (types . (general-music event part-combine-event unisono-event))))
645 . ((description . "Music that cannot be converted from relative
646 to absolute notation. For example, transposed music.")
647 (to-relative-callback . ,ly:relative-octave-music::no-relative-callback)
648 (iterator-ctor . ,ly:music-wrapper-iterator::constructor)
649 (length-callback . ,ly:music-wrapper::length-callback)
650 (types . (music-wrapper-music general-music unrelativable-music))
654 . ((description . "Separate polyphonic voices in simultaneous music.
656 Syntax: @code{\\\\}")
657 (types . (separator general-music))
661 . ((description . "Repeats with alternatives placed sequentially.")
662 (iterator-ctor . ,ly:volta-repeat-iterator::constructor)
663 (start-callback . ,ly:repeated-music::first-start)
664 (length-callback . ,ly:repeated-music::volta-music-length)
665 (types . (general-music repeated-music volta-repeated-music))
669 (set! music-descriptions
670 (sort music-descriptions alist<?))
672 (define-public music-name-to-property-table (make-vector 59 '()))
675 ;; transport description to an object property.
679 (set-object-property! (car x)
681 (cdr (assq 'description (cdr x))))
683 (set! lst (assoc-set! lst 'name (car x)))
684 (set! lst (assq-remove! lst 'description))
685 (hashq-set! music-name-to-property-table (car x) lst)
689 (define-safe-public (make-music name . music-properties)
690 "Create a music object of given name, and set its properties
691 according to @code{music-properties}, a list of alternating property symbols
693 (make-music 'OverrideProperty
695 'grob-property 'thickness
696 'grob-value (* 2 1.5))"
697 (if (not (symbol? name))
698 (ly:error (_ "symbol expected: ~S") name))
699 (let ((props (hashq-ref music-name-to-property-table name '())))
700 (if (not (pair? props))
701 (ly:error (_ "cannot find music object: ~S") name))
702 (let ((m (ly:make-music props)))
703 (define (set-props mus-props)
704 (if (and (not (null? mus-props))
705 (not (null? (cdr mus-props))))
707 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
708 (set-props (cddr mus-props)))))
709 (set-props music-properties)
712 (define-public (make-repeated-music name)
713 (let* ((repeated-music (assoc-get name '(("volta" . VoltaRepeatedMusic)
714 ("unfold" . UnfoldedRepeatedMusic)
715 ("percent" . PercentRepeatedMusic)
716 ("tremolo" . TremoloRepeatedMusic))))
717 (repeated-music-name (if repeated-music
720 (ly:warning (_ "unknown repeat type `~S'") name)
721 (ly:warning (_ "See define-music-types.scm for supported repeats"))
722 'VoltaRepeatedMusic))))
723 (make-music repeated-music-name)))