1 ;;;; define-music-types.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
6 ;;;; Jan Nieuwenhuizen <janneke@gnu.org>
9 ;; TODO: should link back into user manual.
11 (define-public music-descriptions
15 (description . "Creates a dynamic mark.
17 Syntax: @var{note}@code{\\x},
18 where x is one of \\ppp, \\pp, \\p, \\mp, \\mf, \\f, \\ff, \\fff.")
19 (internal-class-name . "Event")
20 (types . (general-music event dynamic-event absolute-dynamic-event))
24 (description . "Call the argument with the current context during interpreting phase")
25 (internal-class-name . "Music")
26 (types . (general-music apply-context))
27 (iterator-ctor . ,Apply_context_iterator::constructor)
32 Call the argument with all current grobs during interpreting phase.
38 arguments to func are 1. the grob, 2. the originating context,
39 3. context where FUNC is called.
42 (internal-class-name . "Event")
43 (iterator-ctor . ,Output_property_music_iterator::constructor)
44 (types . (general-music layout-instruction))
48 (description . "Make an arpeggio on this note.
51 @var{note}-@code{\\arpeggio}")
52 (internal-class-name . "Event")
53 (types . (general-music arpeggio-event event))
56 ;; todo: use articulation-event for slur as well.
57 ;; separate non articulation scripts
60 (description . "Adds an articulation marking to a note.
63 @var{note}@code{X}@code{Y}, where X is a direction (up @code{^}, down
64 @code{_}, or LilyPond's choice (no direction specified)), and where Y
65 is an articulation (such as @code{-.}, @code{->}, @code{\\tenuto},
66 @code{\\downbow}). See the user manual for details.")
68 (internal-class-name . "Event")
69 (types . (general-music event articulation-event script-event))
73 (description . "Used for making voices that switch between piano staves automatically.")
75 (internal-class-name . "Music_wrapper")
76 (iterator-ctor . ,Auto_change_iterator::constructor)
77 (types . (general-music music-wrapper-music auto-change-instruction))
82 "Check whether this music coincides with the start of the measure.")
83 (internal-class-name . "Music")
84 (types . (general-music bar-check))
85 (iterator-ctor . ,Bar_check_iterator::constructor)
89 (description . "Print a bass-figure text")
91 (internal-class-name . "Event")
92 (types . (general-music event rhythmic-event bass-figure-event))
96 (description . "Starts or stops a beam.
98 Syntax for manual control:
100 (internal-class-name . "Event")
101 (types . (general-music event beam-event span-event))
105 (description . "Create a line break, Syntax: \\break or page break, Syntax: \\pagebreak.")
107 (internal-class-name . "Event")
108 (types . (general-music break-event event))
112 (description . "Creates a `breath mark' or `comma'.
115 @var{note}\\breathe.")
117 (internal-class-name . "Event")
118 (types . (general-music event breathing-event))
122 (description . "Used internally to signal beginning and ending of notes.")
124 (internal-class-name . "Event")
125 (types . (general-music event busy-playing-event))
129 (description . "Used internally to signal beginning of notes.")
131 (internal-class-name . "Event")
132 (types . (general-music event start-playing-event))
137 (description . "A note that is part of a cluster.")
138 (internal-class-name . "Event")
140 ; not a note-event, to ensure that Note_engraver doesn't eat it.
141 (types . (general-music cluster-note-event melodic-event rhythmic-event event))
146 (description . "Interpret the argument music within a specific context.")
147 (iterator-ctor . ,Context_specced_music_iterator::constructor)
148 (internal-class-name . "Music_wrapper")
149 (types . (context-specification general-music music-wrapper-music))
154 (description . "Begins or ends a crescendo.
156 Syntax: @var{note}\\cr
157 ... @var{note}\\rc (you can also use \\<, \\!, \\cresc, and
158 \\endcresc. See the user manual for details.).")
160 (internal-class-name . "Event")
161 (types . (general-music dynamic-event crescendo-event event))
165 (description . "See @ref{CrescendoEvent}.")
167 (internal-class-name . "Event")
168 (types . (general-music dynamic-event decrescendo-event event))
173 (description . "Extend lyrics.")
175 (internal-class-name . "Event")
176 (types . (general-music extender-event event))
180 (description . "Specify what finger to use for this note.")
181 (internal-class-name . "Event")
182 (types . (general-music fingering-event event))
186 (description . "Specify that a note may not auto-beamed ")
187 (internal-class-name . "Event")
188 (types . (general-music event beam-forbid-event))
192 (description . "Start a glissando on this note.")
193 (internal-class-name . "Event")
194 (types . (general-music glissando-event event))
199 (description . "Interpret the argument as grace notes. ")
201 (internal-class-name . "Grace_music")
202 (iterator-ctor . ,Grace_iterator::constructor)
203 (types . (grace-music music-wrapper-music general-music))
207 (description . "Start or stop grouping brackets.")
208 (internal-class-name . "Event")
209 (types . (general-music event note-grouping-event))
213 (description . "Mark a note as harmonic")
214 (internal-class-name . "Event")
215 (types . (general-music event harmonic-event))
219 (description . "A hyphen between lyric syllables.")
221 (internal-class-name . "Event")
222 (types . (general-music hyphen-event event))
227 (description . "Change the key signature.
229 Syntax: @code{\\key } @var{name} @var{scale}.")
231 (internal-class-name . "Key_change_ev")
232 (types . (general-music key-change-event event))
237 (description . "(docme).")
239 (internal-class-name . "Event")
240 (span-type . ligature)
241 (types . (general-music span-event ligature-event event))
246 (description . "Align lyrics to the start of notes.
249 Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
251 (internal-class-name . "Lyric_combine_music")
252 (types . (general-music lyric-combine-music))
253 (iterator-ctor . ,Lyric_combine_music_iterator::constructor)
256 (NewLyricCombineMusic
258 (description . "Align lyrics to the start of notes.
261 Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
262 (internal-class-name . "Music")
263 (length . ,(ly:make-moment 0 1))
264 (types . (general-music lyric-combine-music))
265 (iterator-ctor . ,New_lyric_combine_music_iterator::constructor)
270 (description . "A lyric syllable. Must be entered in lyrics mode, i.e.
271 @code{\\lyrics @{ twinkle4 twinkle4 @} } .")
273 (internal-class-name . "Event")
274 (types . (general-music rhythmic-event lyric-event event))
278 (description . "Insert a rehearsal mark.
280 Syntax: @code{\\mark} @var{marker},
281 e.g. @code{\\mark \"A\"}.")
283 (internal-class-name . "Event")
284 (types . (general-music mark-event event))
288 (description . "Used internally to signal melismas.")
289 (internal-class-name . "Event")
290 (types . (general-music melisma-playing-event event))
294 (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}
348 (internal-class-name . "Music")
349 (types . (general-music layout-instruction))
350 (iterator-ctor . , Push_property_iterator::constructor)
354 (description . "Combine two parts on a staff, either merged or
355 as separate voices.")
357 (internal-class-name . "Simultaneous_music")
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.
376 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
377 (internal-class-name . "Music")
378 (types . (layout-instruction general-music))
379 (iterator-ctor . ,Property_iterator::constructor)
385 (description . "Remove the definition of a context @code{\\property}.")
387 (internal-class-name . "Music")
388 (types . (layout-instruction general-music))
389 (iterator-ctor . ,Property_unset_iterator::constructor)
395 (description . "Within a ligature, mark the previous and the
396 following note to form a pes (if melody goes up) or a flexa (if melody
399 (internal-class-name . "Event")
400 (types . (general-music pes-or-flexa-event event))
405 (description . "Quote preprocessed snippets of music. ")
406 (internal-class-name . "Event") ;; so we get Event::get_length ().
407 (iterator-ctor . ,Quote_iterator::constructor)
408 (types . (general-music))
412 . ((description . "Check if a pitch is in the correct octave.")
413 (internal-class-name . "Relative_octave_check")
414 (types . (general-music relative-octave-check))
419 (description . "Repeat music in different ways")
421 (type . repeated-music)
422 (types . (general-music repeated-music))
427 (description . "Atomic music event.")
429 (internal-class-name . "Event")
430 (types . (general-music event))
435 (description . "A Rest.
437 Syntax @code{r4} for a quarter rest. ")
439 (internal-class-name . "Event")
440 (types . (general-music event rhythmic-event rest-event))
444 (description . "Music expressions concatenated.
446 Syntax \\sequential @{..@} or simply @{..@} .")
448 (internal-class-name . "Sequential_music")
449 (iterator-ctor . ,Sequential_music_iterator::constructor)
450 (types . (general-music sequential-music))
453 (MultiMeasureRestMusicGroup
455 (description . "Like sequential-music, but specifically intended
456 to group start-mmrest, skip, stop-mmrest sequence.
458 Syntax @code{R2.*5} for 5 measures in 3/4 time.")
459 (internal-class-name . "Sequential_music")
460 (iterator-ctor . ,Sequential_music_iterator::constructor)
461 (types . (general-music sequential-music))
466 (description . "Print Solo.1")
467 (internal-class-name . "Event")
468 (part-combine-status . solo1)
469 (types . (general-music event part-combine-event))
473 (description . "Print Solo.2")
474 (internal-class-name . "Event")
475 (part-combine-status . solo2)
476 (types . (general-music event part-combine-event))
479 . ((description . "Print a2")
480 (internal-class-name . "Event")
481 (part-combine-status . unisono)
482 (types . (general-music event part-combine-event))))
486 (description . "Music playing together.
490 @code{ \\simultaneous @{ .. @}} or < .. >.")
492 (internal-class-name . "Simultaneous_music")
493 (iterator-ctor . ,Simultaneous_music_iterator::constructor)
495 (types . (general-music simultaneous-music))
500 (description . "Start or end slur.
502 Syntax NOTE( and )NOTE")
503 (internal-class-name . "Event")
504 (types . (general-music span-event slur-event))
509 (description . "The opposite of @ref{OverrideProperty}: remove a
510 previously added property from a graphical object definition
513 (internal-class-name . "Music")
514 (types . (general-music layout-instruction))
515 (iterator-ctor . , Pop_property_iterator::constructor)
518 (OutputPropertySetMusic
520 (description . "Set grob properties in objects
523 Syntax @code{\\outputproperty @var{predicate} @var{prop}
526 (internal-class-name . "Music")
527 (iterator-ctor . ,Output_property_music_iterator::constructor)
528 (types . (general-music layout-instruction))
533 (description . "Start a text spanner like 8va.....|")
534 (internal-class-name . "Event")
535 (types . (general-music span-event text-span-event))
540 (description . "Change staffs in Piano staff.
542 Syntax @code{\\translator Staff = @var{new-id}}.")
543 (internal-class-name . "Music")
544 (iterator-ctor . , Change_iterator::constructor)
545 (types . (general-music translator-change-instruction))
550 (description . "Multiply durations, as in tuplets.
552 Syntax @code{\\times @var{fraction} @var{music}}, e.g.
553 @code{\\times 2/3 @{ ... @}} for triplets.
555 (internal-class-name . "Time_scaled_music")
556 (iterator-ctor . ,Time_scaled_music_iterator::constructor)
557 (types . (time-scaled-music music-wrapper-music general-music))
562 (description . "Music that has been transposed.")
563 (internal-class-name . "Transposed_music")
564 (types . (music-wrapper-music general-music transposed-music))
569 (description . "Music that can not be transposed.")
571 (internal-class-name . "Untransposable_music")
572 (types . (music-wrapper-music general-music untransposable-music))
577 (description . "Music that can not be converted from relative to absolute notation.
578 For example, transposed music.")
579 (internal-class-name . "Un_relativable_music")
580 (types . (music-wrapper-music general-music unrelativable-music))
585 (description . "Music that was entered in relative octave notation.")
587 (internal-class-name . "Relative_octave_music")
588 (types . (music-wrapper-music general-music relative-octave-music))
593 (description . "Internally used to group a set of events.")
594 (internal-class-name . "Event_chord")
595 (iterator-ctor . ,Event_chord_iterator::constructor)
596 (types . (general-music event-chord simultaneous-music))
602 (description . "Add an articulation mark to a note. ")
604 (internal-class-name . "Event")
605 (types . (general-music event))
610 (description . "Filler that takes up duration, does not print anything, and also
611 does not create staffs or voices implicitly.
615 Syntax: @code{\\skip }@var{duration}.")
616 (internal-class-name . "Music")
617 (length . ,ly:music-duration-length)
618 (iterator-ctor . ,Simple_music_iterator::constructor)
619 (types . (general-music event rhythmic-event skip-event))
624 (description . "Filler that takes up duration, but does not print anything.
628 Syntax: @code{s}@var{duration}")
630 (internal-class-name . "Event")
631 (types . (general-music event rhythmic-event skip-event))
635 (description . "Event for anything that is started at a different time than stopped.")
637 (internal-class-name . "Event")
638 (types . (general-music event))
643 (description . "Depress or release sustain pedal. ")
644 (internal-class-name . "Event")
645 (types . (general-music pedal-event sustain-pedal-event))
650 (description . "Depress or release sostenuto pedal. ")
651 (internal-class-name . "Event")
652 (types . (general-music pedal-event sostenuto-pedal-event))
657 (description . "Depress or release una-corda pedal.")
658 (internal-class-name . "Event")
659 (types . (general-music pedal-event una-corda-pedal-event))
664 (description . "Specify on which string to play this note.
666 Syntax: @code{\\@var{number}}.")
668 (internal-class-name . "Event")
669 (types . (general-music string-number-event event))
672 (MetronomeChangeEvent
674 (description . "Change tempo setting (in beats per minute).")
675 (internal-class-name . "Event")
676 (types . (general-music metronome-change-event tempo-event event))
682 (internal-class-name . "Event")
683 (types . (general-music script-event text-script-event event))
687 (description . "A tie. Entered as @var{note}-~.")
688 (internal-class-name . "Event")
689 (types . (general-music tie-event event))
693 (description . "Un measured tremolo.")
694 (internal-class-name . "Event")
695 (types . (general-music event tremolo-event))
700 (description . "Separate polyphonic voices in simultaneous music.
702 Syntax: @code{\\\\}")
704 (internal-class-name . "Music")
705 (types . (separator general-music))
710 (iterator-ctor . ,Volta_repeat_iterator::constructor)
711 (internal-class-name . "Repeated_music")
713 (start-moment-function . ,Repeated_music::first_start)
714 (length . ,Repeated_music::volta_music_length)
715 (types . (general-music repeated-music volta-repeated-music))
718 (UnfoldedRepeatedMusic
720 (iterator-ctor . ,Unfolded_repeat_iterator::constructor)
722 (start-moment-function . ,Repeated_music::first_start)
723 (internal-class-name . "Repeated_music")
724 (types . (general-music repeated-music unfolded-repeated-music))
725 (length . ,Repeated_music::unfolded_music_length)
727 (PercentRepeatedMusic
729 (internal-class-name . "Repeated_music")
730 (description . "Repeats encoded by percents.")
731 (iterator-ctor . ,Percent_repeat_iterator::constructor)
732 (start-moment-function . ,Repeated_music::first_start)
733 (length . ,Repeated_music::unfolded_music_length)
734 (types . (general-music repeated-music percent-repeated-music))
737 (TremoloRepeatedMusic
739 (iterator-ctor . ,Chord_tremolo_iterator::constructor)
740 (description . "Repeated notes denoted by tremolo beams.")
741 (internal-class-name . "Repeated_music")
742 (start-moment-function . ,Repeated_music::first_start)
744 ;; the length of the repeat is handled by shifting the note logs
745 (length . ,Repeated_music::folded_music_length)
746 (types . (general-music repeated-music tremolo-repeated-music))
752 (internal-class-name . "Repeated_music")
753 (description . "Repeats with alternatives placed in parallel. ")
754 (iterator-ctor . ,Folded_repeat_iterator::constructor)
755 (start-moment-function . ,Repeated_music::minimum_start)
756 (length . ,Repeated_music::folded_music_length)
757 (types . (general-music repeated-music folded-repeated-music))
761 (set! music-descriptions
762 (sort music-descriptions alist<?))
764 (define music-name-to-property-table (make-vector 59 '()))
768 ;; transport description to an object property.
772 (set-object-property! (car x)
774 (cdr (assq 'description (cdr x))))
777 (set! l (assoc-set! l 'name (car x)))
778 (set! l (assq-remove! l 'description))
779 (hashq-set! music-name-to-property-table (car x) l)
784 (define-public (make-music name . music-properties)
785 "Create a music object of given name, and set its properties
786 according to `music-properties', a list of alterning property symbols
788 (make-music 'OverrideProperty
790 'grob-property 'thickness
791 'grob-value (* 2 1.5))"
792 (if (not (symbol? name))
793 (error (format "Not a symbol: ~a" name)))
794 (let ((props (hashq-ref music-name-to-property-table name '())))
795 (if (not (pair? props))
796 (error "Can not find music object" name))
797 (let ((m (ly:make-bare-music (cdr (assoc 'internal-class-name props)) props)))
798 (define (set-props mus-props)
799 (if (and (not (null? mus-props))
800 (not (null? (cdr mus-props))))
802 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
803 (set-props (cddr mus-props)))))
804 (set-props music-properties)
808 (define-public (make-repeated-music name)
809 (let* ((handle (assoc name '(("volta" . VoltaRepeatedMusic)
810 ("unfold" . UnfoldedRepeatedMusic)
811 ("percent" . PercentRepeatedMusic)
812 ("tremolo" . TremoloRepeatedMusic)
813 ("fold" . FoldedRepeatedMusic))))
814 (music-name (if (pair? handle)
817 (ly:warn (string-append "Unknown repeat type `" name
818 "'\nSee music-types.scm for supported repeats"))
819 'VoltaRepeatedMusic))))
820 (make-music music-name)))