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 (internal-class-name . "Event")
19 (types . (general-music event dynamic-event absolute-dynamic-event))
23 (description . "Call the argument with the current context during interpreting phase")
24 (internal-class-name . "Music")
25 (types . (general-music apply-context))
26 (iterator-ctor . ,Apply_context_iterator::constructor)
31 Call the argument with all current grobs during interpreting phase.
37 arguments to func are 1. the grob, 2. the originating context,
38 3. context where FUNC is called.
41 (internal-class-name . "Event")
42 (iterator-ctor . ,Output_property_music_iterator::constructor)
43 (types . (general-music layout-instruction))
47 (description . "Make an arpeggio on this note.
50 @var{note}-@code{\\arpeggio}")
51 (internal-class-name . "Event")
52 (types . (general-music arpeggio-event event))
55 ;; todo: use articulation-event for slur as well.
56 ;; separate non articulation scripts
59 (description . "Adds an articulation marking to a note.
62 @var{note}@code{X}@code{Y}, where X is a direction (up @code{^}, down
63 @code{_}, or LilyPond's choice (no direction specified)), and where Y
64 is an articulation (such as @code{-.}, @code{->}, @code{\\tenuto},
65 @code{\\downbow}). See the user manual for details.")
67 (internal-class-name . "Event")
68 (types . (general-music event articulation-event script-event))
72 (description . "Used for making voices that switch between piano staves automatically.")
74 (internal-class-name . "Music_wrapper")
75 (iterator-ctor . ,Auto_change_iterator::constructor)
76 (types . (general-music music-wrapper-music auto-change-instruction))
81 "Check whether this music coincides with the start of the measure.")
82 (internal-class-name . "Music")
83 (types . (general-music bar-check))
84 (iterator-ctor . ,Bar_check_iterator::constructor)
88 (description . "Print a bass-figure text")
90 (internal-class-name . "Event")
91 (types . (general-music event rhythmic-event bass-figure-event))
95 (description . "Starts or stops a beam.
97 Syntax for manual control:
99 (internal-class-name . "Event")
100 (types . (general-music event beam-event span-event))
104 (description . "Create a line break, Syntax: \\break or page break, Syntax: \\pagebreak.")
106 (internal-class-name . "Event")
107 (types . (general-music break-event event))
111 (description . "Creates a `breath mark' or `comma'.
114 @var{note}\\breathe.")
116 (internal-class-name . "Event")
117 (types . (general-music event breathing-event))
121 (description . "Used internally to signal beginning and ending of notes.")
123 (internal-class-name . "Event")
124 (types . (general-music event busy-playing-event))
128 (description . "Change staffs in Piano staff.
130 Syntax @code{\\translator Staff = @var{new-id}}.")
131 (internal-class-name . "Music")
132 (iterator-ctor . , Change_iterator::constructor)
133 (types . (general-music translator-change-instruction))
138 (description . "A note that is part of a cluster.")
139 (internal-class-name . "Event")
141 ; not a note-event, to ensure that Note_engraver doesn't eat it.
142 (types . (general-music cluster-note-event melodic-event rhythmic-event event))
147 (description . "Interpret the argument music within a specific context.")
148 (iterator-ctor . ,Context_specced_music_iterator::constructor)
149 (internal-class-name . "Music_wrapper")
150 (types . (context-specification general-music music-wrapper-music))
155 (description . "Begins or ends a crescendo.
157 Syntax: @var{note}\\cr
158 ... @var{note}\\rc (you can also use \\<, \\!, \\cresc, and
159 \\endcresc. See the user manual for details.).")
161 (internal-class-name . "Event")
162 (types . (general-music dynamic-event crescendo-event event))
166 (description . "See @ref{CrescendoEvent}.")
168 (internal-class-name . "Event")
169 (types . (general-music dynamic-event decrescendo-event event))
174 (description . "Extend lyrics.")
176 (internal-class-name . "Event")
177 (types . (general-music extender-event event))
181 (description . "Specify what finger to use for this note.")
182 (internal-class-name . "Event")
183 (types . (general-music fingering-event event))
187 (description . "Specify that a note may not auto-beamed ")
188 (internal-class-name . "Event")
189 (types . (general-music event beam-forbid-event))
193 (description . "Start a glissando on this note.")
194 (internal-class-name . "Event")
195 (types . (general-music glissando-event event))
200 (description . "Interpret the argument as grace notes. ")
201 (internal-class-name . "Music_wrapper")
202 (start-callback . ,Grace_music::start_callback)
203 (length . ,(ly:make-moment 0 1))
204 (iterator-ctor . ,Grace_iterator::constructor)
205 (types . (grace-music music-wrapper-music general-music))
209 (description . "Start or stop grouping brackets.")
210 (internal-class-name . "Event")
211 (types . (general-music event note-grouping-event))
215 (description . "Mark a note as harmonic")
216 (internal-class-name . "Event")
217 (types . (general-music event harmonic-event))
221 (description . "A hyphen between lyric syllables.")
223 (internal-class-name . "Event")
224 (types . (general-music hyphen-event event))
229 (description . "Change the key signature.
231 Syntax: @code{\\key } @var{name} @var{scale}.")
233 (internal-class-name . "Event")
234 (types . (general-music key-change-event event))
239 (description . "(docme).")
241 (internal-class-name . "Event")
242 (span-type . ligature)
243 (types . (general-music span-event ligature-event event))
248 (description . "Align lyrics to the start of notes.
250 Syntax @var{\\oldaddlyrics }@var{music} @var{lyrics}.")
252 (internal-class-name . "Music")
253 (types . (general-music lyric-combine-music))
254 (length-callback . ,Lyric_combine_music::length_callback)
255 (start-callback . ,Music_sequence::first_start_callback)
256 (iterator-ctor . ,Lyric_combine_music_iterator::constructor)
259 (NewLyricCombineMusic
261 (description . "Align lyrics to the start of notes.
263 Syntax @var{\\lyricsto }@var{voicename} @var{lyrics}.")
264 (internal-class-name . "Music")
265 (length . ,(ly:make-moment 0 1))
266 (types . (general-music lyric-combine-music))
267 (iterator-ctor . ,New_lyric_combine_music_iterator::constructor)
272 (description . "A lyric syllable. Must be entered in lyrics mode, i.e.
273 @code{\\lyrics @{ twinkle4 twinkle4 @} } .")
275 (internal-class-name . "Event")
276 (types . (general-music rhythmic-event lyric-event event))
280 (description . "Insert a rehearsal mark.
282 Syntax: @code{\\mark} @var{marker},
283 e.g. @code{\\mark \"A\"}.")
285 (internal-class-name . "Event")
286 (types . (general-music mark-event event))
290 (description . "Used internally to signal melismas.")
291 (internal-class-name . "Event")
292 (types . (general-music melisma-playing-event event))
296 (description . "Start or stop a melisma.
298 Syntax: @code{c4\\melisma d\\melismaEnd}.")
299 (internal-class-name . "Event")
300 (types . (general-music melisma-span-event event))
303 (MultiMeasureRestEvent
305 (description . "Rests that may be compressed into Multi rests.
308 @code{R2.*4} for 4 measures in 3/4 time. Note the capital R.")
309 (internal-class-name . "Event")
310 (types . (general-music event rhythmic-event multi-measure-rest-event))
313 (MultiMeasureTextEvent
315 (description . "Texts on mm rests.
318 @code{R-\\markup @{ \\roman \"bla\" @}}. Note the explicit font switch.")
319 (internal-class-name . "Event")
320 (types . (general-music event multi-measure-text-event))
325 (description . "Generic type for music expressions.")
327 (internal-class-name . "Music")
328 (types . (general-music))
332 (description . "A note.")
334 (internal-class-name . "Event")
335 (types . (general-music event note-event rhythmic-event melodic-event))
340 (description . "Extend the definition of a graphical object.
344 @code{\\propery Foo.Bar \\override} @var{SYMBOL} = @var{VALUE}
347 (internal-class-name . "Music")
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 (internal-class-name . "Music")
356 (length-callback . ,Music_sequence::maximum_length_callback)
357 (start-callback . ,Music_sequence::minimum_start_callback)
358 (types . (general-music part-combine-music))
359 (iterator-ctor . ,Part_combine_iterator::constructor)
363 (description . "Start or end phrasing slur.
365 Syntax NOTE \\( and \\) NOTE")
366 (internal-class-name . "Event")
367 (types . (general-music span-event phrasing-slur-event))
372 (description . "Set a context property.
374 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
375 (internal-class-name . "Music")
376 (types . (layout-instruction general-music))
377 (iterator-ctor . ,Property_iterator::constructor)
382 (description . "Remove the definition of a context @code{\\property}.")
384 (internal-class-name . "Music")
385 (types . (layout-instruction general-music))
386 (iterator-ctor . ,Property_unset_iterator::constructor)
391 (description . "Within a ligature, mark the previous and the
392 following note to form a pes (if melody goes up) or a flexa (if melody
395 (internal-class-name . "Event")
396 (types . (general-music pes-or-flexa-event event))
401 (description . "Quote preprocessed snippets of music. ")
402 (internal-class-name . "Music_wrapper")
403 (iterator-ctor . ,Quote_iterator::constructor)
404 (types . (general-music))
408 . ((description . "Check if a pitch is in the correct octave.")
409 (internal-class-name . "Music")
410 (to-relative-callback . ,Relative_octave_check::relative_callback)
411 (types . (general-music relative-octave-check))
416 (description . "Repeat music in different ways")
417 (type . repeated-music)
418 (types . (general-music repeated-music))
423 (description . "Atomic music event.")
425 (internal-class-name . "Event")
426 (types . (general-music event))
431 (description . "A Rest.
433 Syntax @code{r4} for a quarter rest. ")
435 (internal-class-name . "Event")
436 (types . (general-music event rhythmic-event rest-event))
440 (description . "The opposite of @ref{OverrideProperty}: remove a
441 previously added property from a graphical object definition
444 (internal-class-name . "Music")
445 (types . (general-music layout-instruction))
446 (iterator-ctor . , Pop_property_iterator::constructor)
451 (description . "Music expressions concatenated.
453 Syntax \\sequential @{..@} or simply @{..@} .")
455 (internal-class-name . "Music")
456 (length-callback . ,Music_sequence::cumulative_length_callback)
457 (start-callback . ,Music_sequence::first_start_callback)
458 (iterator-ctor . ,Sequential_music_iterator::constructor)
459 (types . (general-music sequential-music))
462 (MultiMeasureRestMusicGroup
464 (description . "Like sequential-music, but specifically intended
465 to group start-mmrest, skip, stop-mmrest sequence.
467 Syntax @code{R2.*5} for 5 measures in 3/4 time.")
468 (internal-class-name . "Music")
469 (length-callback . ,Music_sequence::cumulative_length_callback)
470 (start-callback . ,Music_sequence::first_start_callback)
471 (iterator-ctor . ,Sequential_music_iterator::constructor)
472 (types . (general-music sequential-music))
477 (description . "Print Solo.1")
478 (internal-class-name . "Event")
479 (part-combine-status . solo1)
480 (types . (general-music event part-combine-event))
484 (description . "Print Solo.2")
485 (internal-class-name . "Event")
486 (part-combine-status . solo2)
487 (types . (general-music event part-combine-event))
490 . ((description . "Print a2")
491 (internal-class-name . "Event")
492 (part-combine-status . unisono)
493 (types . (general-music event part-combine-event))))
497 (description . "Music playing together.
501 @code{ \\simultaneous @{ .. @}} or < .. >.")
503 (internal-class-name . "Music")
504 (iterator-ctor . ,Simultaneous_music_iterator::constructor)
505 (start-callback . ,Music_sequence::minimum_start_callback)
506 (length-callback . ,Music_sequence::maximum_length_callback)
507 (to-relative-callback . ,Music_sequence::simultaneous_relative_callback)
509 (types . (general-music simultaneous-music))
514 (description . "Start or end slur.
516 Syntax NOTE( and )NOTE")
517 (internal-class-name . "Event")
518 (types . (general-music span-event slur-event))
523 (description . "Used internally to signal beginning of notes.")
525 (internal-class-name . "Event")
526 (types . (general-music event start-playing-event))
529 (OutputPropertySetMusic
531 (description . "Set grob properties in objects
534 Syntax @code{\\outputproperty @var{predicate} @var{prop}
537 (internal-class-name . "Music")
538 (iterator-ctor . ,Output_property_music_iterator::constructor)
539 (types . (general-music layout-instruction))
544 (description . "Start a text spanner like 8va.....|")
545 (internal-class-name . "Event")
546 (types . (general-music span-event text-span-event))
551 (description . "Start a trill spanner tr~~~")
552 (internal-class-name . "Event")
553 (types . (general-music span-event trill-span-event))
558 (description . "Multiply durations, as in tuplets.
560 Syntax @code{\\times @var{fraction} @var{music}}, e.g.
561 @code{\\times 2/3 @{ ... @}} for triplets.
563 (internal-class-name . "Music_wrapper")
564 (iterator-ctor . ,Time_scaled_music_iterator::constructor)
565 (types . (time-scaled-music music-wrapper-music general-music))
570 (description . "Music that has been transposed.")
571 (internal-class-name . "Music_wrapper")
572 (to-relative-callback . ,Relative_octave_music::no_relative_callback)
573 (types . (music-wrapper-music general-music transposed-music))
578 (description . "Music that can not be transposed.")
579 (to-relative-callback . ,Relative_octave_music::no_relative_callback)
580 (untransposable . #t)
581 (internal-class-name . "Music_wrapper")
582 (types . (music-wrapper-music general-music untransposable-music))
587 (description . "Music that can not be converted from relative to absolute notation.
588 For example, transposed music.")
589 (to-relative-callback . ,Relative_octave_music::no_relative_callback)
590 (internal-class-name . "Music_wrapper")
591 (types . (music-wrapper-music general-music unrelativable-music))
596 (description . "Music that was entered in relative octave notation.")
597 (to-relative-callback . ,Relative_octave_music::relative_callback)
598 (internal-class-name . "Music_wrapper")
599 (types . (music-wrapper-music general-music relative-octave-music))
604 (description . "Internally used to group a set of events.")
605 (internal-class-name . "Music")
606 (iterator-ctor . ,Event_chord_iterator::constructor)
607 (length-callback . ,Music_sequence::maximum_length_callback)
608 (to-relative-callback . ,Music_sequence::event_chord_relative_callback)
609 (types . (general-music event-chord simultaneous-music))
614 (description . "Add an articulation mark to a note. ")
616 (internal-class-name . "Event")
617 (types . (general-music event))
622 (description . "Filler that takes up duration, does not print anything, and also
623 does not create staffs or voices implicitly.
627 Syntax: @code{\\skip }@var{duration}.")
628 (internal-class-name . "Music")
629 (length-callback . ,ly:music-duration-length)
630 (iterator-ctor . ,Simple_music_iterator::constructor)
631 (types . (general-music event rhythmic-event skip-event))
636 (description . "Filler that takes up duration, but does not print anything.
640 Syntax: @code{s}@var{duration}")
642 (internal-class-name . "Event")
643 (types . (general-music event rhythmic-event skip-event))
647 (description . "Event for anything that is started at a different time than stopped.")
649 (internal-class-name . "Event")
650 (types . (general-music event))
655 (description . "Depress or release sustain pedal. ")
656 (internal-class-name . "Event")
657 (types . (general-music pedal-event sustain-pedal-event))
662 (description . "Depress or release sostenuto pedal. ")
663 (internal-class-name . "Event")
664 (types . (general-music pedal-event sostenuto-pedal-event))
669 (description . "Depress or release una-corda pedal.")
670 (internal-class-name . "Event")
671 (types . (general-music pedal-event una-corda-pedal-event))
676 (description . "Specify on which string to play this note.
678 Syntax: @code{\\@var{number}}.")
680 (internal-class-name . "Event")
681 (types . (general-music string-number-event event))
684 (MetronomeChangeEvent
686 (description . "Change tempo setting (in beats per minute).")
687 (internal-class-name . "Event")
688 (types . (general-music metronome-change-event tempo-event event))
694 (internal-class-name . "Event")
695 (types . (general-music script-event text-script-event event))
699 (description . "A tie. Entered as @var{note}-~.")
700 (internal-class-name . "Event")
701 (types . (general-music tie-event event))
705 (description . "Un measured tremolo.")
706 (internal-class-name . "Event")
707 (types . (general-music event tremolo-event))
712 (description . "Separate polyphonic voices in simultaneous music.
714 Syntax: @code{\\\\}")
716 (internal-class-name . "Music")
717 (types . (separator general-music))
722 (iterator-ctor . ,Volta_repeat_iterator::constructor)
723 (internal-class-name . "Music")
725 (start-callback . ,Repeated_music::first_start)
726 (length-callback . ,Repeated_music::volta_music_length)
727 (types . (general-music repeated-music volta-repeated-music))
730 (UnfoldedRepeatedMusic
732 (iterator-ctor . ,Unfolded_repeat_iterator::constructor)
734 (start-callback . ,Repeated_music::first_start)
735 (internal-class-name . "Music")
736 (types . (general-music repeated-music unfolded-repeated-music))
737 (length-callback . ,Repeated_music::unfolded_music_length)
739 (PercentRepeatedMusic
741 (internal-class-name . "Music")
742 (description . "Repeats encoded by percents.")
743 (iterator-ctor . ,Percent_repeat_iterator::constructor)
744 (start-callback . ,Repeated_music::first_start)
745 (length-callback . ,Repeated_music::unfolded_music_length)
746 (types . (general-music repeated-music percent-repeated-music))
749 (TremoloRepeatedMusic
751 (iterator-ctor . ,Chord_tremolo_iterator::constructor)
752 (description . "Repeated notes denoted by tremolo beams.")
753 (internal-class-name . "Music")
754 (start-callback . ,Repeated_music::first_start)
756 ;; the length of the repeat is handled by shifting the note logs
757 (length-callback . ,Repeated_music::folded_music_length)
758 (types . (general-music repeated-music tremolo-repeated-music))
764 (internal-class-name . "Music")
765 (description . "Repeats with alternatives placed in parallel. ")
766 (iterator-ctor . ,Folded_repeat_iterator::constructor)
767 (start-callback . ,Repeated_music::minimum_start)
768 (length-callback . ,Repeated_music::folded_music_length)
769 (types . (general-music repeated-music folded-repeated-music))
773 (set! music-descriptions
774 (sort music-descriptions alist<?))
776 (define music-name-to-property-table (make-vector 59 '()))
779 ;; transport description to an object property.
783 (set-object-property! (car x)
785 (cdr (assq 'description (cdr x))))
787 (set! lst (assoc-set! lst 'name (car x)))
788 (set! lst (assq-remove! lst 'description))
789 (hashq-set! music-name-to-property-table (car x) lst)
793 (define-public (make-music name . music-properties)
794 "Create a music object of given name, and set its properties
795 according to `music-properties', a list of alterning property symbols
797 (make-music 'OverrideProperty
799 'grob-property 'thickness
800 'grob-value (* 2 1.5))"
801 (if (not (symbol? name))
802 (error (format "Not a symbol: ~a" name)))
803 (let ((props (hashq-ref music-name-to-property-table name '())))
804 (if (not (pair? props))
805 (error "Can not find music object" name))
806 (let ((m (ly:make-bare-music (cdr (assoc 'internal-class-name props)) props)))
807 (define (set-props mus-props)
808 (if (and (not (null? mus-props))
809 (not (null? (cdr mus-props))))
811 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
812 (set-props (cddr mus-props)))))
813 (set-props music-properties)
816 (define-public (make-repeated-music name)
817 (let* ((handle (assoc name '(("volta" . VoltaRepeatedMusic)
818 ("unfold" . UnfoldedRepeatedMusic)
819 ("percent" . PercentRepeatedMusic)
820 ("tremolo" . TremoloRepeatedMusic)
821 ("fold" . FoldedRepeatedMusic))))
822 (music-name (if (pair? handle)
825 (ly:warn "Unknown repeat type `~S'\nSee music-types.scm for supported repeats" name)
826 'VoltaRepeatedMusic))))
827 (make-music music-name)))