]> git.donarmstrong.com Git - lilypond.git/blob - scm/define-music-types.scm
Massive changes - see ChangeLog.
[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     (RelativeOctaveCheck
345      . ((description . "Check if a pitch is in the correct octave.")
346         (internal-class-name . "Relative_octave_check")
347         (types . (general-music relative-octave-check))
348         ))
349     
350     (RepeatedMusic
351      . (
352         (description .  "Repeat music in different ways")
353
354         (type .  repeated-music)
355         (types . (general-music repeated-music))
356         ))
357     
358     (Event
359      . (
360         (description .  "Atomic music event.")
361
362         (internal-class-name . "Event")
363         (types . (general-music event))
364         ))
365     
366     (RestEvent
367      . (
368         (description .  "A Rest. Syntax @code{r4} for a quarter rest. ")
369
370         (internal-class-name . "Event")
371         (types . (general-music event rhythmic-event rest-event))
372         )) 
373     (SequentialMusic
374      . (
375         (description .  "Music expressions concatenated. Syntax \\sequential @{..@} or simply @{..@} .")
376
377         (internal-class-name . "Sequential_music")
378         (iterator-ctor . ,Sequential_music_iterator::constructor)
379         (types . (general-music sequential-music))
380         ))
381     
382     (MultiMeasureRestMusicGroup
383      . (
384         (description .  "Like sequential-music, but specifically intended
385 to group start-mmrest, skip, stop-mmrest sequence. Syntax @code{R2.*5} for 5 measures in 3/4 time.")
386         (internal-class-name . "Sequential_music")
387         (iterator-ctor . ,Sequential_music_iterator::constructor)
388         (types . (general-music sequential-music))
389         ))
390     
391     (SimultaneousMusic
392      . (
393         (description .  "Music playing together.
394
395 SYNTAX
396
397 @code{ \\simultaneous @{ .. @}} or < .. >.")
398
399         (internal-class-name . "Simultaneous_music")
400         (iterator-ctor . ,Simultaneous_music_iterator::constructor)
401         
402         (types . (general-music simultaneous-music))
403         ))
404     
405     (SlurEvent
406      . (
407         (description . "Start or end slur. Syntax NOTE(  and )NOTE")
408         (internal-class-name . "Event")
409         (types . (general-music span-event slur-event))
410         ))
411
412     (RevertProperty
413      . (
414         (description .  "The opposite of @ref{OverrideProperty}: remove a
415 previously added property from a graphical object definition
416  ")
417
418         (internal-class-name . "Music")
419         (types . (general-music layout-instruction))
420         (iterator-ctor . ,      Pop_property_iterator::constructor)
421         ))
422
423     (OutputPropertySetMusic
424      . (
425         (description .  "Set grob properties in objects
426 individually. Syntax @code{\\outputproperty @var{predicate} @var{prop}
427 = @var{val}}.")
428
429         (internal-class-name . "Music")
430         (iterator-ctor . ,Output_property_music_iterator::constructor)
431         (types . (general-music layout-instruction))
432         ))
433     
434     (TextSpanEvent
435      . (
436         (description . "Start a text spanner like 8va.....|")
437         (internal-class-name . "Event")
438         (types . (general-music span-event text-span-event))
439         ))
440     
441     (TranslatorChange
442      . (
443         (description .  "Change staffs in Piano staff. Syntax @code{\\translator Staff = @var{new-id}}.")
444         (internal-class-name . "Music")
445         (iterator-ctor . , Change_iterator::constructor)
446         (types . (general-music translator-change-instruction))
447         ))
448     
449     (TimeScaledMusic
450      . (
451         (description .  "Multiply durations, as in tuplets. Syntax @code{\\times @var{fraction} @var{music}}, e.g.
452 @code{\\times 2/3 @{ ... @}} for triplets.
453  ")
454         (internal-class-name . "Time_scaled_music")
455         (iterator-ctor . ,Time_scaled_music_iterator::constructor)
456         (types . (time-scaled-music music-wrapper-music general-music))
457         ))
458     
459     (TransposedMusic
460      . (
461         (description .  "Music that has been transposed.")
462         (internal-class-name . "Transposed_music")
463         (types . (music-wrapper-music general-music transposed-music))
464         ))
465
466     (UntransposableMusic
467      . (
468         (description .  "Music that can not be transposed.")
469
470         (internal-class-name . "Untransposable_music")
471         (types . (music-wrapper-music general-music untransposable-music)) 
472         ))
473
474     (UnrelativableMusic
475      . (
476         (description .  "Music that can not be converted from relative to absolute notation.
477 For example, transposed music.")
478         (internal-class-name . "Un_relativable_music")
479         (types . (music-wrapper-music general-music unrelativable-music))
480         ))
481
482     (RelativeOctaveMusic
483      . (
484         (description .  "Music that was entered in relative octave notation.")
485
486         (internal-class-name . "Relative_octave_music")
487         (types . (music-wrapper-music general-music relative-octave-music))
488         ))
489     
490     (EventChord
491      . (
492         (description .  "Internally used to group a set of events.")
493         (internal-class-name . "Event_chord")
494         (iterator-ctor . ,Event_chord_iterator::constructor)
495         (types . (general-music event-chord simultaneous-music))
496         )
497      )
498     
499     (ScriptEvent
500      . (
501         (description .  "Add an articulation mark to a note. ")
502
503         (internal-class-name . "Event")
504         (types . (general-music event))
505         ))
506
507     (NonEventSkip
508      . (
509         (description .  "Filler that takes up duration, but does not print anything. This also does not create any event-accepting contexts. ")
510         (internal-class-name . "Music")
511         (length . ,ly:music-duration-length)
512         (iterator-ctor . ,Simple_music_iterator::constructor)
513         (types . (general-music event rhythmic-event skip-event))
514         ))
515      
516     (SkipEvent
517      . (
518         (description .  "Filler that takes up duration, but does not print anything.")
519
520         (internal-class-name . "Event")
521         (types . (general-music event rhythmic-event skip-event))
522         ))
523     
524     (SpanEvent
525      . (
526         (description .  "Event for anything that is started at a different time than stopped.")
527
528         (internal-class-name . "Event")
529         (types . (general-music event))
530         ))
531     
532     (SustainEvent
533      . (
534         (description . "Depress or release sustain pedal. ")
535         (internal-class-name . "Event")
536         (types . (general-music pedal-event sustain-pedal-event))
537         ))
538     
539     (SostenutoEvent
540      . (
541         (description . "Depress or release sostenuto pedal. ")
542         (internal-class-name . "Event")
543         (types . (general-music pedal-event sostenuto-pedal-event))
544         ))
545     
546     (UnaCordaEvent
547      . (
548         (description . "Depress or release una-corda pedal.")
549         (internal-class-name . "Event")
550         (types . (general-music pedal-event una-corda-pedal-event))
551         ))
552     
553     (StringNumberEvent
554      . (
555         (description .  "Specify on which string to play this note. Syntax: @code{\\@var{number}}.")
556
557         (internal-class-name . "Event")
558         (types . (general-music string-number-event event))
559         )) 
560
561     (MetronomeChangeEvent
562      . (
563         (description .  "Change tempo setting (in beats per minute).")
564         (internal-class-name . "Event")
565         (types . (general-music metronome-change-event tempo-event event))
566         ))
567     
568     (TextScriptEvent
569      . (
570         (description .  "")
571         (internal-class-name . "Event")
572         (types . (general-music script-event text-script-event event))
573         )) 
574     (TieEvent
575      . (
576         (description .  "A tie.  Entered as @code{~}.")
577         (internal-class-name . "Event")
578         (types . (general-music tie-event event))
579         ))
580     (NewTieEvent
581      . (
582         (description .  "A tie.  Entered as @var{note}-~.")
583         (internal-class-name . "Event")
584         (types . (general-music new-tie-event event))
585         ))
586     (TremoloEvent
587      . (
588         (description . "Un measured tremolo.")
589         (internal-class-name . "Event")
590         (types . (general-music event tremolo-event))
591         ))
592     
593     (VoiceSeparator
594      . (
595         (description .  "Separate polyphonic voices in simultaneous music. Syntax: @code{\\\\}")
596
597         (internal-class-name . "Music")
598         (types . (separator general-music))
599         ))
600
601     (VoltaRepeatedMusic
602      . (
603         (iterator-ctor . ,Volta_repeat_iterator::constructor)
604         (internal-class-name . "Repeated_music")
605         (description . "")
606         (start-moment-function .  ,Repeated_music::first_start)
607         (length . ,Repeated_music::volta_music_length)
608         (types . (general-music repeated-music volta-repeated-music))
609         ))
610     
611     (UnfoldedRepeatedMusic
612      . (
613         (iterator-ctor . ,Unfolded_repeat_iterator::constructor)
614         (description .  "")
615         (start-moment-function .  ,Repeated_music::first_start)
616         (internal-class-name . "Repeated_music")
617         (types . (general-music repeated-music unfolded-repeated-music))
618         (length . ,Repeated_music::unfolded_music_length)
619         ))
620     (PercentRepeatedMusic
621      . (
622         (internal-class-name . "Repeated_music")
623         (description .  "Repeats encoded by percents.")
624         (iterator-ctor . ,Percent_repeat_iterator::constructor)
625         (start-moment-function .  ,Repeated_music::first_start)
626         (length . ,Repeated_music::unfolded_music_length)
627         (types . (general-music repeated-music percent-repeated-music))
628         ))
629     
630     (TremoloRepeatedMusic
631      . (
632         (iterator-ctor . ,Chord_tremolo_iterator::constructor)
633         (description .  "Repeated notes denoted by tremolo beams.")
634         (internal-class-name . "Repeated_music")
635         (start-moment-function .  ,Repeated_music::first_start)
636
637         ;; the length of the repeat is handled by shifting the note logs
638         (length . ,Repeated_music::folded_music_length)
639         (types . (general-music repeated-music tremolo-repeated-music))
640         
641         ))
642     
643     (FoldedRepeatedMusic
644      . (
645         (internal-class-name . "Repeated_music")
646         (description .  "Repeats with alternatives placed in parallel. ")
647         (iterator-ctor  . ,Folded_repeat_iterator::constructor)
648         (start-moment-function .  ,Repeated_music::minimum_start)
649         (length . ,Repeated_music::folded_music_length)
650         (types . (general-music repeated-music folded-repeated-music))
651         ))
652     ))
653
654 (set! music-descriptions
655       (sort music-descriptions alist<?))
656
657 (define music-name-to-property-table (make-vector 59 '()))
658
659
660 ;; init hash table,
661 ;; transport description to an object property.
662 (set!
663  music-descriptions
664  (map (lambda (x)
665         (set-object-property! (car x)
666                               'music-description
667                               (cdr (assq 'description (cdr x))))
668         (let
669             ((l (cdr x)))
670           (set! l (assoc-set! l 'name (car x)))
671           (set! l (assq-remove!  l 'description))
672           (hashq-set! music-name-to-property-table (car x) l)
673           (cons (car x) l)
674           ))
675       music-descriptions))
676
677
678
679 (define-public (make-music-by-name x)
680   (if (not (symbol? x))
681       (error (format "Not a symbol: ~a" x)))
682   (let*
683       (
684        (props (hashq-ref music-name-to-property-table x '()))
685        (name (if (pair? props)
686                  (cdr (assoc 'internal-class-name props))
687                  (error "Can not find music object" x)))
688        )
689
690     (if (eq? props '())
691         (ly:warn (format "Could not find music type `~a'" x)))  
692     (ly:make-bare-music name props)
693     ))
694
695
696
697 (define-public (make-repeated-music name)
698   (let*
699       (
700        (handle (assoc
701                 name
702                 '(("volta" . VoltaRepeatedMusic)
703                   ("unfold" . UnfoldedRepeatedMusic)
704                   ("percent" . PercentRepeatedMusic)
705                   ("tremolo" . TremoloRepeatedMusic)
706                   ("fold" . FoldedRepeatedMusic)
707                   )))
708        (music-name
709         (if (pair? handle)
710             (cdr handle)
711             (begin
712               (ly:warn
713                (string-append "Unknown repeat type `" name
714                               "'\nSee music-types.scm for supported repeats"))
715               'VoltaRepeatedMusic)
716             )
717         )
718        )
719
720     (make-music-by-name music-name)
721     ))
722