1 ;;;; define-music-types.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2005 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 . ,Apply_context_iterator::constructor)
29 Call the argument with all current grobs during interpreting phase.
35 arguments to func are 1. the grob, 2. the originating context,
36 3. context where FUNC is called.
39 (iterator-ctor . ,Output_property_music_iterator::constructor)
40 (types . (general-music layout-instruction))
44 (description . "Make an arpeggio on this note.
47 @var{note}-@code{\\arpeggio}")
48 (types . (general-music arpeggio-event event))
51 ;; todo: use articulation-event for slur as well.
52 ;; separate non articulation scripts
55 (description . "Adds an articulation marking to a note.
58 @var{note}@code{X}@code{Y}, where X is a direction (up @code{^}, down
59 @code{_}, or LilyPond's choice (no direction specified)), and where Y
60 is an articulation (such as @code{-.}, @code{->}, @code{\\tenuto},
61 @code{\\downbow}). See the user manual for details.")
63 (types . (general-music event articulation-event script-event))
67 (description . "Used for making voices that switch between piano staves automatically.")
68 (iterator-ctor . ,Auto_change_iterator::constructor)
69 (start-callback . ,Music_wrapper::start_callback)
70 (length-callback . ,Music_wrapper::length_callback)
71 (types . (general-music music-wrapper-music auto-change-instruction))
76 "Check whether this music coincides with the start of the measure.")
77 (types . (general-music bar-check))
78 (iterator-ctor . ,Bar_check_iterator::constructor)
82 (description . "Print a bass-figure text")
84 (types . (general-music event rhythmic-event bass-figure-event))
88 (description . "Starts or stops a beam.
90 Syntax for manual control:
92 (types . (general-music event beam-event span-event))
96 (description . "Create a line break, Syntax: \\break or page break, Syntax: \\pagebreak.")
98 (types . (general-music break-event event))
102 (description . "Creates a `breath mark' or `comma'.
105 @var{note}\\breathe.")
107 (types . (general-music event breathing-event))
111 (description . "Used internally to signal beginning and ending of notes.")
113 (types . (general-music event busy-playing-event))
117 (description . "Change staffs in Piano staff.
119 Syntax @code{\\translator Staff = @var{new-id}}.")
120 (iterator-ctor . , Change_iterator::constructor)
121 (types . (general-music translator-change-instruction))
126 (description . "A note that is part of a cluster.")
128 ;; not a note-event, to ensure that Note_engraver doesn't eat it.
129 (types . (general-music cluster-note-event melodic-event rhythmic-event event))
134 (description . "Interpret the argument music within a specific context.")
135 (iterator-ctor . ,Context_specced_music_iterator::constructor)
136 (length-callback . ,Music_wrapper::length_callback)
137 (start-callback . ,Music_wrapper::start_callback)
138 (types . (context-specification general-music music-wrapper-music))
143 (description . "Begins or ends a crescendo.
145 Syntax: @var{note}\\cr
146 ... @var{note}\\rc (you can also use \\<, \\!, \\cresc, and
147 \\endcresc. See the user manual for details.).")
149 (types . (general-music dynamic-event crescendo-event event))
153 (description . "See @ref{CrescendoEvent}.")
155 (types . (general-music dynamic-event decrescendo-event event))
160 (description . "Extend lyrics.")
162 (types . (general-music extender-event event))
168 (description . "Internally used to group a set of events.")
169 (iterator-ctor . ,Event_chord_iterator::constructor)
170 (length-callback . ,Music_sequence::maximum_length_callback)
171 (to-relative-callback . ,Music_sequence::event_chord_relative_callback)
172 (types . (general-music event-chord simultaneous-music))
177 (description . "Specify what finger to use for this note.")
178 (types . (general-music fingering-event event))
182 (description . "Specify that a note may not auto-beamed ")
183 (types . (general-music event beam-forbid-event))
187 (description . "Start a glissando on this note.")
188 (types . (general-music glissando-event event))
193 (description . "Interpret the argument as grace notes. ")
194 (start-callback . ,Grace_music::start_callback)
195 (length . ,(ly:make-moment 0 1))
196 (iterator-ctor . ,Grace_iterator::constructor)
197 (types . (grace-music music-wrapper-music general-music))
201 (description . "Start or stop grouping brackets.")
202 (types . (general-music event note-grouping-event))
206 (description . "Mark a note as harmonic")
207 (types . (general-music event harmonic-event))
211 (description . "A hyphen between lyric syllables.")
213 (types . (general-music hyphen-event event))
218 (description . "Change the key signature.
220 Syntax: @code{\\key } @var{name} @var{scale}.")
222 (types . (general-music key-change-event event))
227 (description . "(docme).")
229 (span-type . ligature)
230 (types . (general-music span-event ligature-event event))
233 (OldLyricCombineMusic
235 (description . "Align lyrics to the start of notes.
237 Syntax @var{\\oldaddlyrics }@var{music} @var{lyrics}.")
239 (types . (general-music lyric-combine-music))
240 (length-callback . ,Lyric_combine_music::length_callback)
241 (start-callback . ,Music_sequence::first_start_callback)
242 (iterator-ctor . ,Old_lyric_combine_music_iterator::constructor)
247 (description . "Align lyrics to the start of notes.
249 Syntax @var{\\lyricsto }@var{voicename} @var{lyrics}.")
250 (length . ,(ly:make-moment 0 1))
251 (types . (general-music lyric-combine-music))
252 (iterator-ctor . ,Lyric_combine_music_iterator::constructor)
257 (description . "A lyric syllable. Must be entered in lyrics mode, i.e.
258 @code{\\lyrics @{ twinkle4 twinkle4 @} } .")
260 (types . (general-music rhythmic-event lyric-event event))
264 (description . "Insert a rehearsal mark.
266 Syntax: @code{\\mark} @var{marker},
267 e.g. @code{\\mark \"A\"}.")
269 (types . (general-music mark-event event))
273 (description . "Used internally to signal melismas.")
274 (types . (general-music melisma-playing-event event))
278 (description . "Start or stop a melisma.
280 Syntax: @code{c4\\melisma d\\melismaEnd}.")
281 (types . (general-music melisma-span-event event))
284 (MultiMeasureRestEvent
286 (description . "Rests that may be compressed into Multi rests.
289 @code{R2.*4} for 4 measures in 3/4 time. Note the capital R.")
290 (types . (general-music event rhythmic-event multi-measure-rest-event))
293 (MultiMeasureRestMusicGroup
295 (description . "Like sequential-music, but specifically intended
296 to group start-mmrest, skip, stop-mmrest sequence.
298 Syntax @code{R2.*5} for 5 measures in 3/4 time.")
299 (length-callback . ,Music_sequence::cumulative_length_callback)
300 (start-callback . ,Music_sequence::first_start_callback)
301 (iterator-ctor . ,Sequential_music_iterator::constructor)
302 (types . (general-music sequential-music))
305 (MultiMeasureTextEvent
307 (description . "Texts on mm rests.
310 @code{R-\\markup @{ \\roman \"bla\" @}}. Note the explicit font switch.")
311 (types . (general-music event multi-measure-text-event))
316 (description . "Generic type for music expressions.")
318 (types . (general-music))
322 (description . "A note.")
324 (types . (general-music event note-event rhythmic-event melodic-event))
327 (OutputPropertySetMusic
329 (description . "Set grob properties in objects
332 Syntax @code{\\outputproperty @var{predicate} @var{prop}
335 (iterator-ctor . ,Output_property_music_iterator::constructor)
336 (types . (general-music layout-instruction))
341 (description . "Extend the definition of a graphical object.
345 @code{\\propery Foo.Bar \\override} @var{SYMBOL} = @var{VALUE}
348 (types . (general-music layout-instruction))
349 (iterator-ctor . ,Push_property_iterator::constructor)
353 (description . "Combine two parts on a staff, either merged or
354 as separate voices.")
355 (length-callback . ,Music_sequence::maximum_length_callback)
356 (start-callback . ,Music_sequence::minimum_start_callback)
357 (types . (general-music part-combine-music))
358 (iterator-ctor . ,Part_combine_iterator::constructor)
362 (description . "Start or end phrasing slur.
364 Syntax NOTE \\( and \\) NOTE")
365 (types . (general-music span-event event phrasing-slur-event))
370 (description . "Set a context property.
372 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
373 (types . (layout-instruction general-music))
374 (iterator-ctor . ,Property_iterator::constructor)
379 (description . "Remove the definition of a context @code{\\property}.")
381 (types . (layout-instruction general-music))
382 (iterator-ctor . ,Property_unset_iterator::constructor)
387 (description . "Within a ligature, mark the previous and the
388 following note to form a pes (if melody goes up) or a flexa (if melody
391 (types . (general-music pes-or-flexa-event event))
396 (description . "Quote preprocessed snippets of music. ")
397 (iterator-ctor . ,Quote_iterator::constructor)
398 (types . (general-music))
402 . ((description . "Check if a pitch is in the correct octave.")
403 (to-relative-callback . ,Relative_octave_check::relative_callback)
404 (types . (general-music relative-octave-check))
409 (description . "Repeat music in different ways")
410 (type . repeated-music)
411 (types . (general-music repeated-music))
416 (description . "Atomic music event.")
418 (types . (general-music event))
423 (description . "A Rest.
425 Syntax @code{r4} for a quarter rest. ")
427 (types . (general-music event rhythmic-event rest-event))
431 (description . "The opposite of @ref{OverrideProperty}: remove a
432 previously added property from a graphical object definition
435 (types . (general-music layout-instruction))
436 (iterator-ctor . , Pop_property_iterator::constructor)
441 (description . "Music expressions concatenated.
443 Syntax \\sequential @{..@} or simply @{..@} .")
445 (length-callback . ,Music_sequence::cumulative_length_callback)
446 (start-callback . ,Music_sequence::first_start_callback)
447 (iterator-ctor . ,Sequential_music_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))
459 (description . "Print Solo.2")
460 (part-combine-status . solo2)
461 (types . (general-music event part-combine-event))
464 . ((description . "Print a2")
465 (part-combine-status . unisono)
466 (types . (general-music event part-combine-event))))
470 (description . "Music playing together.
474 @code{ \\simultaneous @{ .. @}} or < .. >.")
476 (iterator-ctor . ,Simultaneous_music_iterator::constructor)
477 (start-callback . ,Music_sequence::minimum_start_callback)
478 (length-callback . ,Music_sequence::maximum_length_callback)
479 (to-relative-callback . ,Music_sequence::simultaneous_relative_callback)
481 (types . (general-music simultaneous-music))
486 (description . "Start or end slur.
488 Syntax NOTE( and )NOTE")
489 (types . (general-music span-event event slur-event))
493 . ((description . "Start or stop a staff symbol.")
494 (types . (general-music event span-event staff-span-event))
499 (description . "Used internally to signal beginning of notes.")
501 (types . (general-music event start-playing-event))
506 (description . "Start a text spanner like 8va.....|")
507 (types . (general-music span-event event text-span-event))
512 (description . "Start a trill spanner tr~~~")
513 (types . (general-music span-event event trill-span-event))
518 (description . "Multiply durations, as in tuplets.
520 Syntax @code{\\times @var{fraction} @var{music}}, e.g.
521 @code{\\times 2/3 @{ ... @}} for triplets.
523 (length-callback . ,Music_wrapper::length_callback)
524 (start-callback . ,Music_wrapper::start_callback)
525 (iterator-ctor . ,Time_scaled_music_iterator::constructor)
526 (types . (time-scaled-music music-wrapper-music general-music))
531 (description . "Music that has been transposed.")
532 (iterator-ctor . ,Music_wrapper_iterator::constructor)
533 (start-callback . ,Music_wrapper::start_callback)
534 (length-callback . ,Music_wrapper::length_callback)
535 (to-relative-callback . ,Relative_octave_music::no_relative_callback)
536 (types . (music-wrapper-music general-music transposed-music))
541 (description . "Music that can not be converted from relative to absolute notation.
542 For example, transposed music.")
543 (to-relative-callback . ,Relative_octave_music::no_relative_callback)
544 (iterator-ctor . ,Music_wrapper_iterator::constructor)
545 (length-callback . ,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 . ,Relative_octave_music::relative_callback)
553 (iterator-ctor . ,Music_wrapper_iterator::constructor)
554 (length-callback . ,Music_wrapper::length_callback)
555 (start-callback . ,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 . ,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 . "Event for anything that is started at a different time than stopped.")
592 (types . (general-music event))
597 (description . "Depress or release sustain pedal. ")
598 (types . (general-music event pedal-event sustain-pedal-event))
603 (description . "Depress or release sostenuto pedal. ")
604 (types . (general-music event pedal-event sostenuto-pedal-event))
609 (description . "Depress or release una-corda pedal.")
610 (types . (general-music event pedal-event una-corda-pedal-event))
615 (description . "Specify on which string to play this note.
617 Syntax: @code{\\@var{number}}.")
619 (types . (general-music string-number-event event))
622 (MetronomeChangeEvent
624 (description . "Change tempo setting (in beats per minute).")
625 (types . (general-music metronome-change-event tempo-event event))
631 (types . (general-music script-event text-script-event event))
635 (description . "A tie. Entered as @var{note}-~.")
636 (types . (general-music tie-event event))
640 (description . "Un measured tremolo.")
641 (types . (general-music event tremolo-event))
646 (description . "Separate polyphonic voices in simultaneous music.
648 Syntax: @code{\\\\}")
650 (types . (separator general-music))
655 (iterator-ctor . ,Volta_repeat_iterator::constructor)
657 (start-callback . ,Repeated_music::first_start)
658 (length-callback . ,Repeated_music::volta_music_length)
659 (types . (general-music repeated-music volta-repeated-music))
662 (UnfoldedRepeatedMusic
664 (iterator-ctor . ,Unfolded_repeat_iterator::constructor)
666 (start-callback . ,Repeated_music::first_start)
667 (types . (general-music repeated-music unfolded-repeated-music))
668 (length-callback . ,Repeated_music::unfolded_music_length)
670 (PercentRepeatedMusic
672 (description . "Repeats encoded by percents.")
673 (iterator-ctor . ,Percent_repeat_iterator::constructor)
674 (start-callback . ,Repeated_music::first_start)
675 (length-callback . ,Repeated_music::unfolded_music_length)
676 (types . (general-music repeated-music percent-repeated-music))
679 (TremoloRepeatedMusic
681 (iterator-ctor . ,Chord_tremolo_iterator::constructor)
682 (description . "Repeated notes denoted by tremolo beams.")
683 (start-callback . ,Repeated_music::first_start)
685 ;; the length of the repeat is handled by shifting the note logs
686 (length-callback . ,Repeated_music::folded_music_length)
687 (types . (general-music repeated-music tremolo-repeated-music))
693 (description . "Repeats with alternatives placed in parallel. ")
694 (iterator-ctor . ,Folded_repeat_iterator::constructor)
695 (start-callback . ,Repeated_music::minimum_start)
696 (length-callback . ,Repeated_music::folded_music_length)
697 (types . (general-music repeated-music folded-repeated-music))
701 (set! music-descriptions
702 (sort music-descriptions alist<?))
704 (define music-name-to-property-table (make-vector 59 '()))
707 ;; transport description to an object property.
711 (set-object-property! (car x)
713 (cdr (assq 'description (cdr x))))
715 (set! lst (assoc-set! lst 'name (car x)))
716 (set! lst (assq-remove! lst 'description))
717 (hashq-set! music-name-to-property-table (car x) lst)
721 (define-safe-public (make-music name . music-properties)
722 "Create a music object of given name, and set its properties
723 according to `music-properties', a list of alterning property symbols
725 (make-music 'OverrideProperty
727 'grob-property 'thickness
728 'grob-value (* 2 1.5))"
729 (if (not (symbol? name))
730 (ly:error (_ "symbol expected: ~S") name))
731 (let ((props (hashq-ref music-name-to-property-table name '())))
732 (if (not (pair? props))
733 (ly:error (_ "can't find music object: ~S") name))
734 (let ((m (ly:make-music props)))
735 (define (set-props mus-props)
736 (if (and (not (null? mus-props))
737 (not (null? (cdr mus-props))))
739 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
740 (set-props (cddr mus-props)))))
741 (set-props music-properties)
744 (define-public (make-repeated-music name)
745 (let* ((handle (assoc name '(("volta" . VoltaRepeatedMusic)
746 ("unfold" . UnfoldedRepeatedMusic)
747 ("percent" . PercentRepeatedMusic)
748 ("tremolo" . TremoloRepeatedMusic)
749 ("fold" . FoldedRepeatedMusic))))
750 (music-name (if (pair? handle)
753 (ly:warning (_ "unknown repeat type `~S'") name)
754 (ly:warning (_ "See music-types.scm for supported repeats"))
755 'VoltaRepeatedMusic))))
756 (make-music music-name)))