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>
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. ")
202 (internal-class-name . "Grace_music")
203 (iterator-ctor . ,Grace_iterator::constructor)
204 (types . (grace-music music-wrapper-music general-music))
208 (description . "Start or stop grouping brackets.")
209 (internal-class-name . "Event")
210 (types . (general-music event note-grouping-event))
214 (description . "Mark a note as harmonic")
215 (internal-class-name . "Event")
216 (types . (general-music event harmonic-event))
220 (description . "A hyphen between lyric syllables.")
222 (internal-class-name . "Event")
223 (types . (general-music hyphen-event event))
228 (description . "Change the key signature.
230 Syntax: @code{\\key } @var{name} @var{scale}.")
232 (internal-class-name . "Key_change_ev")
233 (types . (general-music key-change-event event))
238 (description . "(docme).")
240 (internal-class-name . "Event")
241 (span-type . ligature)
242 (types . (general-music span-event ligature-event event))
247 (description . "Align lyrics to the start of notes.
250 Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
252 (internal-class-name . "Lyric_combine_music")
253 (types . (general-music lyric-combine-music))
254 (iterator-ctor . ,Lyric_combine_music_iterator::constructor)
257 (NewLyricCombineMusic
259 (description . "Align lyrics to the start of notes.
262 Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
263 (internal-class-name . "Music")
264 (length . ,(ly:make-moment 0 1))
265 (types . (general-music lyric-combine-music))
266 (iterator-ctor . ,New_lyric_combine_music_iterator::constructor)
271 (description . "A lyric syllable. Must be entered in lyrics mode, i.e.
272 @code{\\lyrics @{ twinkle4 twinkle4 @} } .")
274 (internal-class-name . "Event")
275 (types . (general-music rhythmic-event lyric-event event))
279 (description . "Insert a rehearsal mark.
281 Syntax: @code{\\mark} @var{marker},
282 e.g. @code{\\mark \"A\"}.")
284 (internal-class-name . "Event")
285 (types . (general-music mark-event event))
289 (description . "Used internally to signal melismas.")
290 (internal-class-name . "Event")
291 (types . (general-music melisma-playing-event event))
295 (description . "Start or stop a melisma.
297 Syntax: @code{c4\\melisma d\\melismaEnd}.")
298 (internal-class-name . "Event")
299 (types . (general-music melisma-span-event event))
302 (MultiMeasureRestEvent
304 (description . "Rests that may be compressed into Multi rests.
307 @code{R2.*4} for 4 measures in 3/4 time. Note the capital R.")
308 (internal-class-name . "Event")
309 (types . (general-music event rhythmic-event multi-measure-rest-event))
312 (MultiMeasureTextEvent
314 (description . "Texts on mm rests.
317 @code{R-\\markup @{ \\roman \"bla\" @}}. Note the explicit font switch.")
318 (internal-class-name . "Event")
319 (types . (general-music event multi-measure-text-event))
324 (description . "Generic type for music expressions.")
326 (internal-class-name . "Music")
327 (types . (general-music))
331 (description . "A note.")
333 (internal-class-name . "Event")
334 (types . (general-music event note-event rhythmic-event melodic-event))
339 (description . "Extend the definition of a graphical object.
343 @code{\\propery Foo.Bar \\override} @var{SYMBOL} = @var{VALUE}
346 (internal-class-name . "Music")
347 (types . (general-music layout-instruction))
348 (iterator-ctor . , Push_property_iterator::constructor)
352 (description . "Combine two parts on a staff, either merged or
353 as separate voices.")
354 (internal-class-name . "Simultaneous_music")
355 (types . (general-music part-combine-music))
356 (iterator-ctor . ,Part_combine_iterator::constructor)
360 (description . "Start or end phrasing slur.
362 Syntax NOTE \\( and \\) NOTE")
363 (internal-class-name . "Event")
364 (types . (general-music span-event phrasing-slur-event))
369 (description . "Set a context property.
373 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
374 (internal-class-name . "Music")
375 (types . (layout-instruction general-music))
376 (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)
392 (description . "Within a ligature, mark the previous and the
393 following note to form a pes (if melody goes up) or a flexa (if melody
396 (internal-class-name . "Event")
397 (types . (general-music pes-or-flexa-event event))
402 (description . "Quote preprocessed snippets of music. ")
403 (internal-class-name . "Music_wrapper")
404 (iterator-ctor . ,Quote_iterator::constructor)
405 (types . (general-music))
409 . ((description . "Check if a pitch is in the correct octave.")
410 (internal-class-name . "Relative_octave_check")
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 . "Sequential_music")
456 (iterator-ctor . ,Sequential_music_iterator::constructor)
457 (types . (general-music sequential-music))
460 (MultiMeasureRestMusicGroup
462 (description . "Like sequential-music, but specifically intended
463 to group start-mmrest, skip, stop-mmrest sequence.
465 Syntax @code{R2.*5} for 5 measures in 3/4 time.")
466 (internal-class-name . "Sequential_music")
467 (iterator-ctor . ,Sequential_music_iterator::constructor)
468 (types . (general-music sequential-music))
473 (description . "Print Solo.1")
474 (internal-class-name . "Event")
475 (part-combine-status . solo1)
476 (types . (general-music event part-combine-event))
480 (description . "Print Solo.2")
481 (internal-class-name . "Event")
482 (part-combine-status . solo2)
483 (types . (general-music event part-combine-event))
486 . ((description . "Print a2")
487 (internal-class-name . "Event")
488 (part-combine-status . unisono)
489 (types . (general-music event part-combine-event))))
493 (description . "Music playing together.
497 @code{ \\simultaneous @{ .. @}} or < .. >.")
499 (internal-class-name . "Simultaneous_music")
500 (iterator-ctor . ,Simultaneous_music_iterator::constructor)
502 (types . (general-music simultaneous-music))
507 (description . "Start or end slur.
509 Syntax NOTE( and )NOTE")
510 (internal-class-name . "Event")
511 (types . (general-music span-event slur-event))
516 (description . "Used internally to signal beginning of notes.")
518 (internal-class-name . "Event")
519 (types . (general-music event start-playing-event))
522 (OutputPropertySetMusic
524 (description . "Set grob properties in objects
527 Syntax @code{\\outputproperty @var{predicate} @var{prop}
530 (internal-class-name . "Music")
531 (iterator-ctor . ,Output_property_music_iterator::constructor)
532 (types . (general-music layout-instruction))
537 (description . "Start a text spanner like 8va.....|")
538 (internal-class-name . "Event")
539 (types . (general-music span-event text-span-event))
544 (description . "Start a trill spanner tr~~~")
545 (internal-class-name . "Event")
546 (types . (general-music span-event trill-span-event))
551 (description . "Multiply durations, as in tuplets.
553 Syntax @code{\\times @var{fraction} @var{music}}, e.g.
554 @code{\\times 2/3 @{ ... @}} for triplets.
556 (internal-class-name . "Time_scaled_music")
557 (iterator-ctor . ,Time_scaled_music_iterator::constructor)
558 (types . (time-scaled-music music-wrapper-music general-music))
563 (description . "Music that has been transposed.")
564 (internal-class-name . "Transposed_music")
565 (types . (music-wrapper-music general-music transposed-music))
570 (description . "Music that can not be transposed.")
572 (internal-class-name . "Untransposable_music")
573 (types . (music-wrapper-music general-music untransposable-music))
578 (description . "Music that can not be converted from relative to absolute notation.
579 For example, transposed music.")
580 (internal-class-name . "Un_relativable_music")
581 (types . (music-wrapper-music general-music unrelativable-music))
586 (description . "Music that was entered in relative octave notation.")
588 (internal-class-name . "Relative_octave_music")
589 (types . (music-wrapper-music general-music relative-octave-music))
594 (description . "Internally used to group a set of events.")
595 (internal-class-name . "Event_chord")
596 (iterator-ctor . ,Event_chord_iterator::constructor)
597 (types . (general-music event-chord simultaneous-music))
603 (description . "Add an articulation mark to a note. ")
605 (internal-class-name . "Event")
606 (types . (general-music event))
611 (description . "Filler that takes up duration, does not print anything, and also
612 does not create staffs or voices implicitly.
616 Syntax: @code{\\skip }@var{duration}.")
617 (internal-class-name . "Music")
618 (length . ,ly:music-duration-length)
619 (iterator-ctor . ,Simple_music_iterator::constructor)
620 (types . (general-music event rhythmic-event skip-event))
625 (description . "Filler that takes up duration, but does not print anything.
629 Syntax: @code{s}@var{duration}")
631 (internal-class-name . "Event")
632 (types . (general-music event rhythmic-event skip-event))
636 (description . "Event for anything that is started at a different time than stopped.")
638 (internal-class-name . "Event")
639 (types . (general-music event))
644 (description . "Depress or release sustain pedal. ")
645 (internal-class-name . "Event")
646 (types . (general-music pedal-event sustain-pedal-event))
651 (description . "Depress or release sostenuto pedal. ")
652 (internal-class-name . "Event")
653 (types . (general-music pedal-event sostenuto-pedal-event))
658 (description . "Depress or release una-corda pedal.")
659 (internal-class-name . "Event")
660 (types . (general-music pedal-event una-corda-pedal-event))
665 (description . "Specify on which string to play this note.
667 Syntax: @code{\\@var{number}}.")
669 (internal-class-name . "Event")
670 (types . (general-music string-number-event event))
673 (MetronomeChangeEvent
675 (description . "Change tempo setting (in beats per minute).")
676 (internal-class-name . "Event")
677 (types . (general-music metronome-change-event tempo-event event))
683 (internal-class-name . "Event")
684 (types . (general-music script-event text-script-event event))
688 (description . "A tie. Entered as @var{note}-~.")
689 (internal-class-name . "Event")
690 (types . (general-music tie-event event))
694 (description . "Un measured tremolo.")
695 (internal-class-name . "Event")
696 (types . (general-music event tremolo-event))
701 (description . "Separate polyphonic voices in simultaneous music.
703 Syntax: @code{\\\\}")
705 (internal-class-name . "Music")
706 (types . (separator general-music))
711 (iterator-ctor . ,Volta_repeat_iterator::constructor)
712 (internal-class-name . "Repeated_music")
714 (start-moment-function . ,Repeated_music::first_start)
715 (length . ,Repeated_music::volta_music_length)
716 (types . (general-music repeated-music volta-repeated-music))
719 (UnfoldedRepeatedMusic
721 (iterator-ctor . ,Unfolded_repeat_iterator::constructor)
723 (start-moment-function . ,Repeated_music::first_start)
724 (internal-class-name . "Repeated_music")
725 (types . (general-music repeated-music unfolded-repeated-music))
726 (length . ,Repeated_music::unfolded_music_length)
728 (PercentRepeatedMusic
730 (internal-class-name . "Repeated_music")
731 (description . "Repeats encoded by percents.")
732 (iterator-ctor . ,Percent_repeat_iterator::constructor)
733 (start-moment-function . ,Repeated_music::first_start)
734 (length . ,Repeated_music::unfolded_music_length)
735 (types . (general-music repeated-music percent-repeated-music))
738 (TremoloRepeatedMusic
740 (iterator-ctor . ,Chord_tremolo_iterator::constructor)
741 (description . "Repeated notes denoted by tremolo beams.")
742 (internal-class-name . "Repeated_music")
743 (start-moment-function . ,Repeated_music::first_start)
745 ;; the length of the repeat is handled by shifting the note logs
746 (length . ,Repeated_music::folded_music_length)
747 (types . (general-music repeated-music tremolo-repeated-music))
753 (internal-class-name . "Repeated_music")
754 (description . "Repeats with alternatives placed in parallel. ")
755 (iterator-ctor . ,Folded_repeat_iterator::constructor)
756 (start-moment-function . ,Repeated_music::minimum_start)
757 (length . ,Repeated_music::folded_music_length)
758 (types . (general-music repeated-music folded-repeated-music))
762 (set! music-descriptions
763 (sort music-descriptions alist<?))
765 (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))))
776 (set! lst (assoc-set! lst 'name (car x)))
777 (set! lst (assq-remove! lst 'description))
778 (hashq-set! music-name-to-property-table (car x) lst)
782 (define-public (make-music name . music-properties)
783 "Create a music object of given name, and set its properties
784 according to `music-properties', a list of alterning property symbols
786 (make-music 'OverrideProperty
788 'grob-property 'thickness
789 'grob-value (* 2 1.5))"
790 (if (not (symbol? name))
791 (error (format "Not a symbol: ~a" name)))
792 (let ((props (hashq-ref music-name-to-property-table name '())))
793 (if (not (pair? props))
794 (error "Can not find music object" name))
795 (let ((m (ly:make-bare-music (cdr (assoc 'internal-class-name props)) props)))
796 (define (set-props mus-props)
797 (if (and (not (null? mus-props))
798 (not (null? (cdr mus-props))))
800 (set! (ly:music-property m (car mus-props)) (cadr mus-props))
801 (set-props (cddr mus-props)))))
802 (set-props music-properties)
805 (define-public (make-repeated-music name)
806 (let* ((handle (assoc name '(("volta" . VoltaRepeatedMusic)
807 ("unfold" . UnfoldedRepeatedMusic)
808 ("percent" . PercentRepeatedMusic)
809 ("tremolo" . TremoloRepeatedMusic)
810 ("fold" . FoldedRepeatedMusic))))
811 (music-name (if (pair? handle)
814 (ly:warn "Unknown repeat type `~S'\nSee music-types.scm for supported repeats" name)
815 'VoltaRepeatedMusic))))
816 (make-music music-name)))