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