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