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