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