]> git.donarmstrong.com Git - lilypond.git/blob - scm/define-music-types.scm
* lily/auto-beam-engraver.cc (try_music): accept and process
[lilypond.git] / scm / define-music-types.scm
1
2 (define-public music-descriptions
3   `(
4     (AbsoluteDynamicEvent
5      . (
6    (description . "Creates a dynamic mark.  Syntax: @var{note}@code{\\x},
7 where x is one of \\ppp, \\pp, \\p, \\mp, \\mf, \\f, \\ff, \\fff.")
8         (internal-class-name . "Event")
9         (types . (general-music event dynamic-event absolute-dynamic-event))
10         ))
11     (ApplyContext
12      . (
13         (description . "Call the argument with the current context during interpreting phase")
14         (internal-class-name . "Music")
15         (types . (general-music apply-context))
16         (iterator-ctor . ,Apply_context_iterator::constructor)
17         ))
18     (ApplyOutputEvent
19      . (
20         (description . "
21 Call the argument with all current grobs during interpreting phase.
22
23 SYNTAX
24
25 \applyoutput FUNC
26
27 arguments to func are 1. the grob, 2. the originating context,
28 3. context where FUNC is called.
29
30 ")
31         (internal-class-name . "Event")
32         (iterator-ctor . ,Output_property_music_iterator::constructor)
33         (types . (general-music layout-instruction))
34         ))
35     (ArpeggioEvent 
36      . (
37         (description .  "Make an arpeggio on this note. Syntax:
38 @var{note}-@code{\\arpeggio}")
39         (internal-class-name .  "Event")
40         (types . (general-music arpeggio-event event))
41         ))
42
43     ;; todo: use articulation-event for slur as well.
44     ;; separate non articulation scripts  
45     (ArticulationEvent
46      . (
47    (description .  "Adds an articulation marking to a note.  Syntax:
48 @var{note}@code{X}@code{Y}, where X is a direction (up @code{^}, down
49 @code{_}, or LilyPond's choice (no direction specified)), and where Y
50 is an articulation (such as @code{-.}, @code{->}, @code{\\tenuto},
51 @code{\\downbow}).  See the user manual for details.")
52
53         (internal-class-name . "Event")
54         (types . (general-music event articulation-event script-event))
55         )) 
56     (AutoChangeMusic
57      . (
58         (description .  "Used for making voices that switch between piano staves automatically.")
59
60         (internal-class-name . "Music_wrapper")
61         (iterator-ctor . ,Auto_change_iterator::constructor)
62         (types . (general-music music-wrapper-music auto-change-instruction))
63         ))
64     (BarCheck
65      . (
66         (description .
67                      "Check whether this music coincides with the start of the measure.")
68         (internal-class-name . "Music")
69         (types . (general-music bar-check))
70         (iterator-ctor . ,Bar_check_iterator::constructor)
71         ))
72     (BassFigureEvent
73      . (
74         (description .  "Print a bass-figure text")
75
76         (internal-class-name . "Event")
77         (types . (general-music event rhythmic-event bass-figure-event))
78         ))
79     (BeamEvent
80      . (
81    (description .  "Starts or stops a beam.  Syntax for manual control:
82 c8-[ c c-] c8")
83         (internal-class-name . "Event")
84         (types . (general-music event beam-event span-event))
85         ))
86     (BreakEvent
87      . (
88    (description .  "Creates a line break.  Syntax: \\break.")
89
90         (internal-class-name . "Event")
91         (types . (general-music break-event event))
92         ))
93     (BreathingSignEvent
94      . (
95         (description .  "Creates a `breath mark' or `comma'.  Syntax:
96 @var{note}\\breathe.")
97
98         (internal-class-name . "Event")
99         (types . (general-music event breathing-event))
100         )) 
101     (BusyPlayingEvent
102      . (
103         (description .  "Used internally to signal beginning and ending of notes.")
104
105         (internal-class-name . "Event")
106         (types . (general-music event busy-playing-event))
107         ))
108     (StartPlayingEvent
109      . (
110         (description .  "Used internally to signal beginning of notes.")
111
112         (internal-class-name . "Event")
113         (types . (general-music event start-playing-event))
114         ))
115     
116     (ClusterNoteEvent
117      . (
118         (description .  "A note that is part of a cluster.")
119         (internal-class-name . "Event")
120
121         ; not a note-event, to ensure that Note_engraver doesn't eat it. 
122         (types . (general-music cluster-note-event melodic-event rhythmic-event event))
123         ))
124     
125     (ContextSpeccedMusic
126      . (
127         (description .  "Interpret the argument music within a specific context.")
128         (iterator-ctor . ,Context_specced_music_iterator::constructor)
129         (internal-class-name . "Music_wrapper")
130         (types . (context-specification general-music music-wrapper-music))
131         ))
132     
133     (CrescendoEvent
134      . (
135         (description .  "Begins or ends a crescendo.  Syntax: @var{note}\\cr
136 ... @var{note}\\rc (you can also use \\<, \\!, \\cresc, and
137 \\endcresc.  See the user manual for details.).")
138
139         (internal-class-name . "Event")
140         (types . (general-music dynamic-event crescendo-event event))
141         )) 
142     (DecrescendoEvent
143      . (
144         (description .  "See @ref{CrescendoEvent}.")
145
146         (internal-class-name . "Event")
147         (types . (general-music dynamic-event decrescendo-event event))
148         ))
149  
150     (ExtenderEvent
151      . (
152         (description .  "Extend lyrics.")
153
154         (internal-class-name . "Event")
155         (types . (general-music extender-event event))
156         ))
157     (FingerEvent
158      . (
159         (description . "Specify what finger to use for this note.")
160         (internal-class-name . "Event")
161         (types . (general-music fingering-event event))
162         ))
163     (BeamForbidEvent
164      . (
165         (description . "Specify that a note may not auto-beamed ")
166         (internal-class-name . "Event")
167         (types . (general-music event beam-forbid-event))
168         ))
169     (GlissandoEvent
170      . (
171         (description .  "Start  a glissando on this note.")
172         (internal-class-name . "Event")
173         (types . (general-music glissando-event event))
174         ))
175     
176     (GraceMusic
177      . (
178         (description .  "Interpret the argument as grace notes. ")
179
180         (internal-class-name . "Grace_music")
181         (iterator-ctor . ,Grace_iterator::constructor)
182         (types . (grace-music music-wrapper-music general-music))
183         ))
184     (NoteGroupingEvent
185      . (
186         (description . "Start or stop grouping brackets.")
187         (internal-class-name . "Event")
188         (types . (general-music event note-grouping-event))
189         ))
190     (HarmonicEvent
191      . (
192         (description . "Mark a note as harmonic")
193         (internal-class-name . "Event")
194         (types . (general-music event harmonic-event))
195         ))
196     (HyphenEvent
197      . (
198         (description .  "A hyphen between lyric syllables.")
199
200         (internal-class-name . "Event")
201         (types . (general-music hyphen-event event))
202         ))
203     
204     (KeyChangeEvent
205      . (
206         (description .  "Change the key signature. Syntax: @code{\\key } @var{name} @var{scale}.")
207
208         (internal-class-name . "Key_change_ev")
209         (types . (general-music key-change-event event))
210         ))
211     
212     (LigatureEvent
213      . (
214         (description .  "(docme).")
215
216         (internal-class-name . "Event")
217         (span-type . ligature)
218         (types . (general-music span-event ligature-event event))
219         ))
220     
221     (LyricCombineMusic
222      . (
223         (description .  "Align lyrics to the start of notes.
224 Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
225
226         (internal-class-name . "Lyric_combine_music")
227         (types . (general-music lyric-combine-music))
228         (iterator-ctor . ,Lyric_combine_music_iterator::constructor)
229         ))
230     
231     (NewLyricCombineMusic
232      . (
233         (description .  "Align lyrics to the start of notes.
234 Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
235         (internal-class-name . "Music")
236         (length . ,(ly:make-moment 0 1))
237         (types . (general-music lyric-combine-music))
238         (iterator-ctor . ,New_lyric_combine_music_iterator::constructor)
239         ))
240
241     (LyricEvent
242      . (
243         (description .  "A lyric syllable. Must be entered in lyrics mode, i.e.
244 @code{\\lyrics @{ twinkle4 twinkle4 @} } .")
245
246         (internal-class-name . "Event")
247         (types . (general-music rhythmic-event lyric-event event))
248         ))
249     (MarkEvent
250      . (
251         (description .  "Insert a rehearsal mark. Syntax: @code{\\mark} @var{marker},
252 e.g. @code{\\mark \"A\"}.")
253
254         (internal-class-name . "Event")
255         (types . (general-music mark-event event))
256         ))
257     (MelismaPlayingEvent
258      . (
259         (description .  "Used internally to signal melismas.")
260         (internal-class-name . "Event")
261         (types . (general-music melisma-playing-event event))
262         ))
263     (ManualMelismaEvent
264      . (
265         (description .  "Start or stop a melisma.
266
267 Syntax:@code{c4\\melisma d\\melismaEnd}.")
268         (internal-class-name . "Event")
269         (types . (general-music melisma-span-event event))
270         ))
271     
272     (MultiMeasureRestEvent
273      . (
274         (description . "Rests that may be compressed into Multi rests. Syntax
275 @code{R2.*4} for 4 measures in 3/4 time. Note the capital R.")
276         (internal-class-name . "Event")
277         (types . (general-music event rhythmic-event multi-measure-rest-event))
278         ))
279     
280     (MultiMeasureTextEvent
281      . (
282         (description . "Texts on mm rests. Syntax
283 @code{R-\\markup @{ \\roman \"bla\" @}}. Note the explicit font switch.")
284         (internal-class-name . "Event")
285         (types . (general-music event multi-measure-text-event))
286         ))
287
288     (Music
289      . (
290         (description .  "Generic type for music expressions.")
291
292         (internal-class-name . "Music")
293         (types . (general-music)) 
294         ))
295     (NoteEvent
296      . (
297         (description .  "A note.")
298
299         (internal-class-name . "Event")
300         (types . (general-music event note-event rhythmic-event melodic-event))
301         ))
302     
303     (OverrideProperty
304      . (
305         (description .  "Extend the definition of a graphical object.
306
307 SYNTAX
308
309 @code{\\propery Foo.Bar \\override} @var{SYMBOL} = @var{VALUE}
310
311 ")
312
313         (internal-class-name . "Music")
314         (types . (general-music layout-instruction))
315         (iterator-ctor . ,      Push_property_iterator::constructor)
316         ))
317     (PartCombineMusic
318      . (
319         (description .  "Combine two parts on a staff, either merged or
320 as separate voices.")
321
322         (internal-class-name . "Simultaneous_music")
323         (types . (general-music part-combine-music))
324         (iterator-ctor . ,New_pc_iterator::constructor)
325         ))
326     
327     (PhrasingSlurEvent
328      . (
329         (description . "Start or end phrasing slur. Syntax NOTE \\(  and \\) NOTE")
330         (internal-class-name . "Event")
331         (types . (general-music span-event phrasing-slur-event))
332         ))
333     
334     (PropertySet
335      . (
336         (description .  "Set a context property.
337
338 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
339         (internal-class-name . "Music")
340         (types . (layout-instruction general-music))
341         (iterator-ctor . ,Property_iterator::constructor)
342         )
343      )
344     
345     (PropertyUnset
346      . (
347         (description .  "Remove the definition of a context @code{\\property}.")
348
349         (internal-class-name . "Music")
350         (types . (layout-instruction general-music))
351         (iterator-ctor . ,Property_unset_iterator::constructor)
352         )
353      )
354     
355     (PesOrFlexaEvent
356      . (
357         (description .  "Within a ligature, mark the previous and the
358 following note to form a pes (if melody goes up) or a flexa (if melody
359 goes down).")
360
361         (internal-class-name . "Event")
362         (types . (general-music pes-or-flexa-event event))
363         ))
364
365     (RelativeOctaveCheck
366      . ((description . "Check if a pitch is in the correct octave.")
367         (internal-class-name . "Relative_octave_check")
368         (types . (general-music relative-octave-check))
369         ))
370     
371     (RepeatedMusic
372      . (
373         (description .  "Repeat music in different ways")
374
375         (type .  repeated-music)
376         (types . (general-music repeated-music))
377         ))
378     
379     (Event
380      . (
381         (description .  "Atomic music event.")
382
383         (internal-class-name . "Event")
384         (types . (general-music event))
385         ))
386     
387     (RestEvent
388      . (
389         (description .  "A Rest. Syntax @code{r4} for a quarter rest. ")
390
391         (internal-class-name . "Event")
392         (types . (general-music event rhythmic-event rest-event))
393         )) 
394     (SequentialMusic
395      . (
396         (description .  "Music expressions concatenated. Syntax \\sequential @{..@} or simply @{..@} .")
397
398         (internal-class-name . "Sequential_music")
399         (iterator-ctor . ,Sequential_music_iterator::constructor)
400         (types . (general-music sequential-music))
401         ))
402     
403     (MultiMeasureRestMusicGroup
404      . (
405         (description .  "Like sequential-music, but specifically intended
406 to group start-mmrest, skip, stop-mmrest sequence. Syntax @code{R2.*5} for 5 measures in 3/4 time.")
407         (internal-class-name . "Sequential_music")
408         (iterator-ctor . ,Sequential_music_iterator::constructor)
409         (types . (general-music sequential-music))
410         ))
411
412     (SoloOneEvent
413      . (
414         (description . "Print Solo.1")
415         (internal-class-name . "Event")
416         (part-combine-status . solo1)
417         (types . (general-music event part-combine-event))
418         ))
419     (SoloTwoEvent
420      . (
421         (description . "Print Solo.2")
422         (internal-class-name . "Event")
423         (part-combine-status . solo2)
424         (types . (general-music event part-combine-event))
425         ))
426     (UnisonoEvent
427      . ((description . "Print a2")
428         (internal-class-name .  "Event")
429         (part-combine-status . unisono)
430         (types . (general-music event part-combine-event))))
431     
432     (SimultaneousMusic
433      . (
434         (description .  "Music playing together.
435
436 SYNTAX
437
438 @code{ \\simultaneous @{ .. @}} or < .. >.")
439
440         (internal-class-name . "Simultaneous_music")
441         (iterator-ctor . ,Simultaneous_music_iterator::constructor)
442         
443         (types . (general-music simultaneous-music))
444         ))
445     
446     (SlurEvent
447      . (
448         (description . "Start or end slur. Syntax NOTE(  and )NOTE")
449         (internal-class-name . "Event")
450         (types . (general-music span-event slur-event))
451         ))
452
453     (RevertProperty
454      . (
455         (description .  "The opposite of @ref{OverrideProperty}: remove a
456 previously added property from a graphical object definition
457  ")
458
459         (internal-class-name . "Music")
460         (types . (general-music layout-instruction))
461         (iterator-ctor . ,      Pop_property_iterator::constructor)
462         ))
463
464     (OutputPropertySetMusic
465      . (
466         (description .  "Set grob properties in objects
467 individually. Syntax @code{\\outputproperty @var{predicate} @var{prop}
468 = @var{val}}.")
469
470         (internal-class-name . "Music")
471         (iterator-ctor . ,Output_property_music_iterator::constructor)
472         (types . (general-music layout-instruction))
473         ))
474     
475     (TextSpanEvent
476      . (
477         (description . "Start a text spanner like 8va.....|")
478         (internal-class-name . "Event")
479         (types . (general-music span-event text-span-event))
480         ))
481     
482     (TranslatorChange
483      . (
484         (description .  "Change staffs in Piano staff. Syntax @code{\\translator Staff = @var{new-id}}.")
485         (internal-class-name . "Music")
486         (iterator-ctor . , Change_iterator::constructor)
487         (types . (general-music translator-change-instruction))
488         ))
489     
490     (TimeScaledMusic
491      . (
492         (description .  "Multiply durations, as in tuplets. Syntax @code{\\times @var{fraction} @var{music}}, e.g.
493 @code{\\times 2/3 @{ ... @}} for triplets.
494  ")
495         (internal-class-name . "Time_scaled_music")
496         (iterator-ctor . ,Time_scaled_music_iterator::constructor)
497         (types . (time-scaled-music music-wrapper-music general-music))
498         ))
499     
500     (TransposedMusic
501      . (
502         (description .  "Music that has been transposed.")
503         (internal-class-name . "Transposed_music")
504         (types . (music-wrapper-music general-music transposed-music))
505         ))
506
507     (UntransposableMusic
508      . (
509         (description .  "Music that can not be transposed.")
510
511         (internal-class-name . "Untransposable_music")
512         (types . (music-wrapper-music general-music untransposable-music)) 
513         ))
514
515     (UnrelativableMusic
516      . (
517         (description .  "Music that can not be converted from relative to absolute notation.
518 For example, transposed music.")
519         (internal-class-name . "Un_relativable_music")
520         (types . (music-wrapper-music general-music unrelativable-music))
521         ))
522
523     (RelativeOctaveMusic
524      . (
525         (description .  "Music that was entered in relative octave notation.")
526
527         (internal-class-name . "Relative_octave_music")
528         (types . (music-wrapper-music general-music relative-octave-music))
529         ))
530     
531     (EventChord
532      . (
533         (description .  "Internally used to group a set of events.")
534         (internal-class-name . "Event_chord")
535         (iterator-ctor . ,Event_chord_iterator::constructor)
536         (types . (general-music event-chord simultaneous-music))
537         )
538      )
539     
540     (ScriptEvent
541      . (
542         (description .  "Add an articulation mark to a note. ")
543
544         (internal-class-name . "Event")
545         (types . (general-music event))
546         ))
547
548     (SkipMusic
549      . (
550         (description .  "Filler that takes up duration, does not print anything, and also
551 does not create staffs or voices implicitly.
552
553 Syntax: @code{\\skip }@var{duration}.")
554         (internal-class-name . "Music")
555         (length . ,ly:music-duration-length)
556         (iterator-ctor . ,Simple_music_iterator::constructor)
557         (types . (general-music event rhythmic-event skip-event))
558         ))
559      
560     (SkipEvent
561      . (
562         (description .  "Filler that takes up duration, but does not print anything.
563
564 Syntax: @code{s}@var{duration}")
565
566         (internal-class-name . "Event")
567         (types . (general-music event rhythmic-event skip-event))
568         ))
569     (SpanEvent
570      . (
571         (description .  "Event for anything that is started at a different time than stopped.")
572
573         (internal-class-name . "Event")
574         (types . (general-music event))
575         ))
576     
577     (SustainEvent
578      . (
579         (description . "Depress or release sustain pedal. ")
580         (internal-class-name . "Event")
581         (types . (general-music pedal-event sustain-pedal-event))
582         ))
583     
584     (SostenutoEvent
585      . (
586         (description . "Depress or release sostenuto pedal. ")
587         (internal-class-name . "Event")
588         (types . (general-music pedal-event sostenuto-pedal-event))
589         ))
590     
591     (UnaCordaEvent
592      . (
593         (description . "Depress or release una-corda pedal.")
594         (internal-class-name . "Event")
595         (types . (general-music pedal-event una-corda-pedal-event))
596         ))
597     
598     (StringNumberEvent
599      . (
600         (description .  "Specify on which string to play this note. Syntax: @code{\\@var{number}}.")
601
602         (internal-class-name . "Event")
603         (types . (general-music string-number-event event))
604         )) 
605
606     (MetronomeChangeEvent
607      . (
608         (description .  "Change tempo setting (in beats per minute).")
609         (internal-class-name . "Event")
610         (types . (general-music metronome-change-event tempo-event event))
611         ))
612     
613     (TextScriptEvent
614      . (
615         (description .  "")
616         (internal-class-name . "Event")
617         (types . (general-music script-event text-script-event event))
618         )) 
619     (TieEvent
620      . (
621         (description .  "A tie.  Entered as @var{note}-~.")
622         (internal-class-name . "Event")
623         (types . (general-music tie-event event))
624         ))
625     (TremoloEvent
626      . (
627         (description . "Un measured tremolo.")
628         (internal-class-name . "Event")
629         (types . (general-music event tremolo-event))
630         ))
631     
632     (VoiceSeparator
633      . (
634         (description .  "Separate polyphonic voices in simultaneous music. Syntax: @code{\\\\}")
635
636         (internal-class-name . "Music")
637         (types . (separator general-music))
638         ))
639
640     (VoltaRepeatedMusic
641      . (
642         (iterator-ctor . ,Volta_repeat_iterator::constructor)
643         (internal-class-name . "Repeated_music")
644         (description . "")
645         (start-moment-function .  ,Repeated_music::first_start)
646         (length . ,Repeated_music::volta_music_length)
647         (types . (general-music repeated-music volta-repeated-music))
648         ))
649     
650     (UnfoldedRepeatedMusic
651      . (
652         (iterator-ctor . ,Unfolded_repeat_iterator::constructor)
653         (description .  "")
654         (start-moment-function .  ,Repeated_music::first_start)
655         (internal-class-name . "Repeated_music")
656         (types . (general-music repeated-music unfolded-repeated-music))
657         (length . ,Repeated_music::unfolded_music_length)
658         ))
659     (PercentRepeatedMusic
660      . (
661         (internal-class-name . "Repeated_music")
662         (description .  "Repeats encoded by percents.")
663         (iterator-ctor . ,Percent_repeat_iterator::constructor)
664         (start-moment-function .  ,Repeated_music::first_start)
665         (length . ,Repeated_music::unfolded_music_length)
666         (types . (general-music repeated-music percent-repeated-music))
667         ))
668     
669     (TremoloRepeatedMusic
670      . (
671         (iterator-ctor . ,Chord_tremolo_iterator::constructor)
672         (description .  "Repeated notes denoted by tremolo beams.")
673         (internal-class-name . "Repeated_music")
674         (start-moment-function .  ,Repeated_music::first_start)
675
676         ;; the length of the repeat is handled by shifting the note logs
677         (length . ,Repeated_music::folded_music_length)
678         (types . (general-music repeated-music tremolo-repeated-music))
679         
680         ))
681     
682     (FoldedRepeatedMusic
683      . (
684         (internal-class-name . "Repeated_music")
685         (description .  "Repeats with alternatives placed in parallel. ")
686         (iterator-ctor  . ,Folded_repeat_iterator::constructor)
687         (start-moment-function .  ,Repeated_music::minimum_start)
688         (length . ,Repeated_music::folded_music_length)
689         (types . (general-music repeated-music folded-repeated-music))
690         ))
691     ))
692
693 (set! music-descriptions
694       (sort music-descriptions alist<?))
695
696 (define music-name-to-property-table (make-vector 59 '()))
697
698
699 ;; init hash table,
700 ;; transport description to an object property.
701 (set!
702  music-descriptions
703  (map (lambda (x)
704         (set-object-property! (car x)
705                               'music-description
706                               (cdr (assq 'description (cdr x))))
707         (let
708             ((l (cdr x)))
709           (set! l (assoc-set! l 'name (car x)))
710           (set! l (assq-remove!  l 'description))
711           (hashq-set! music-name-to-property-table (car x) l)
712           (cons (car x) l)
713           ))
714       music-descriptions))
715
716
717
718 (define-public (make-music-by-name x)
719   (if (not (symbol? x))
720       (error (format "Not a symbol: ~a" x)))
721   (let*
722       (
723        (props (hashq-ref music-name-to-property-table x '()))
724        (name (if (pair? props)
725                  (cdr (assoc 'internal-class-name props))
726                  (error "Can not find music object" x)))
727        )
728
729     (if (eq? props '())
730         (ly:warn (format "Could not find music type `~a'" x)))  
731     (ly:make-bare-music name props)
732     ))
733
734
735
736 (define-public (make-repeated-music name)
737   (let*
738       (
739        (handle (assoc
740                 name
741                 '(("volta" . VoltaRepeatedMusic)
742                   ("unfold" . UnfoldedRepeatedMusic)
743                   ("percent" . PercentRepeatedMusic)
744                   ("tremolo" . TremoloRepeatedMusic)
745                   ("fold" . FoldedRepeatedMusic)
746                   )))
747        (music-name
748         (if (pair? handle)
749             (cdr handle)
750             (begin
751               (ly:warn
752                (string-append "Unknown repeat type `" name
753                               "'\nSee music-types.scm for supported repeats"))
754               'VoltaRepeatedMusic)
755             )
756         )
757        )
758
759     (make-music-by-name music-name)
760     ))
761