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