]> git.donarmstrong.com Git - lilypond.git/blob - scm/define-music-types.scm
* lily/lily-guile.cc (alist_to_hashq): new function
[lilypond.git] / scm / define-music-types.scm
1
2 (define-public music-descriptions
3   `(
4     (AbsoluteDynamicEvent
5      . (
6    (description . "Creates a dynamic mark.  Syntax: @var{note}@code{\\x},
7 where x is one of \\ppp, \\pp, \\p, \\mp, \\mf, \\f, \\ff, \\fff.")
8         (internal-class-name . "Event")
9         (types . (general-music event dynamic-event absolute-dynamic-event))
10         ))
11     (ApplyContext
12      . (
13         (description . "Call the argument with the current context during interpreting phase")
14         (internal-class-name . "Music")
15         (types . (general-music apply-context))
16         (iterator-ctor . ,Apply_context_iterator::constructor)
17         ))
18     (ApplyOutputEvent
19      . (
20         (description . "
21 Call the argument with all current grobs during interpreting phase.
22
23 SYNTAX
24
25 \applyoutput FUNC
26
27 arguments to func are 1. the grob, 2. the originating context,
28 3. context where FUNC is called.
29
30 ")
31         (internal-class-name . "Event")
32         (iterator-ctor . ,Output_property_music_iterator::constructor)
33         (types . (general-music layout-instruction))
34         ))
35     (ArpeggioEvent 
36      . (
37         (description .  "Make an arpeggio on this note. Syntax:
38 @var{note}-@code{\\arpeggio}")
39         (internal-class-name .  "Event")
40         (types . (general-music arpeggio-event event))
41         ))
42
43     ;; todo: use articulation-event for slur as well.
44     ;; separate non articulation scripts  
45     (ArticulationEvent
46      . (
47    (description .  "Adds an articulation marking to a note.  Syntax:
48 @var{note}@code{X}@code{Y}, where X is a direction (up @code{^}, down
49 @code{_}, or LilyPond's choice (no direction specified)), and where Y
50 is an articulation (such as @code{-.}, @code{->}, @code{\\tenuto},
51 @code{\\downbow}).  See the user manual for details.")
52
53         (internal-class-name . "Event")
54         (types . (general-music event articulation-event script-event))
55         )) 
56     (AutoChangeMusic
57      . (
58         (description .  "Used for making voices that switch between piano staves automatically.")
59
60         (internal-class-name . "Music_wrapper")
61         (iterator-ctor . ,Auto_change_iterator::constructor)
62         (types . (general-music music-wrapper-music auto-change-instruction))
63         ))
64     (BarCheck
65      . (
66         (description .
67                      "Check whether this music coincides with the start of the measure.")
68         (internal-class-name . "Music")
69         (types . (general-music bar-check))
70         (iterator-ctor . ,Bar_check_iterator::constructor)
71         ))
72     (BassFigureEvent
73      . (
74         (description .  "Print a bass-figure text")
75
76         (internal-class-name . "Event")
77         (types . (general-music event rhythmic-event bass-figure-event))
78         ))
79     (BeamEvent
80      . (
81    (description .  "Starts or stops a beam.  Syntax for manual control:
82 c8-[ c c-] c8")
83         (internal-class-name . "Event")
84         (types . (general-music event beam-event span-event))
85         ))
86     (BreakEvent
87      . (
88    (description .  "Creates a line break.  Syntax: \\break.")
89
90         (internal-class-name . "Event")
91         (types . (general-music break-event event))
92         ))
93     (BreathingSignEvent
94      . (
95         (description .  "Creates a `breath mark' or `comma'.  Syntax:
96 @var{note}\\breathe.")
97
98         (internal-class-name . "Event")
99         (types . (general-music event breathing-event))
100         )) 
101     (BusyPlayingEvent
102      . (
103         (description .  "Used internally to signal beginning and ending of notes.")
104
105         (internal-class-name . "Event")
106         (types . (general-music event busy-playing-event))
107         ))
108     (StartPlayingEvent
109      . (
110         (description .  "Used internally to signal beginning of notes.")
111
112         (internal-class-name . "Event")
113         (types . (general-music event start-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     (NewLyricCombineMusic
220      . (
221         (description .  "Align lyrics to the start of notes.
222 Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
223         (internal-class-name . "Music")
224         (length . ,(ly:make-moment 0 1))
225         (types . (general-music lyric-combine-music))
226         (iterator-ctor . ,New_lyric_combine_music_iterator::constructor)
227         ))
228
229     (LyricEvent
230      . (
231         (description .  "A lyric syllable. Must be entered in lyrics mode, i.e.
232 @code{\\lyrics @{ twinkle4 twinkle4 @} } .")
233
234         (internal-class-name . "Event")
235         (types . (general-music rhythmic-event lyric-event event))
236         ))
237     (MarkEvent
238      . (
239         (description .  "Insert a rehearsal mark. Syntax: @code{\\mark} @var{marker},
240 e.g. @code{\\mark \"A\"}.")
241
242         (internal-class-name . "Event")
243         (types . (general-music mark-event event))
244         ))
245     (MelismaPlayingEvent
246      . (
247         (description .  "Used internally to signal melismas")
248         (internal-class-name . "Event")
249         (types . (general-music melisma-playing-event event))
250         ))
251     
252     (MultiMeasureRestEvent
253      . (
254         (description . "Rests that may be compressed into Multi rests. Syntax
255 @code{R2.*4} for 4 measures in 3/4 time. Note the capital R.")
256         (internal-class-name . "Event")
257         (types . (general-music event rhythmic-event multi-measure-rest-event))
258         ))
259     
260     (MultiMeasureTextEvent
261      . (
262         (description . "Texts on mm rests. Syntax
263 @code{R-\\markup @{ \\roman \"bla\" @}}. Note the explicit font switch.")
264         (internal-class-name . "Event")
265         (types . (general-music event multi-measure-text-event))
266         ))
267
268     (Music
269      . (
270         (description .  "Generic type for music expressions.")
271
272         (internal-class-name . "Music")
273         (types . (general-music)) 
274         ))
275     (NoteEvent
276      . (
277         (description .  "A note.")
278
279         (internal-class-name . "Event")
280         (types . (general-music event note-event rhythmic-event melodic-event))
281         ))
282     
283     (OverrideProperty
284      . (
285         (description .  "Extend the definition of a graphical object.
286
287 SYNTAX
288
289 @code{\\propery Foo.Bar \\override} @var{SYMBOL} = @var{VALUE}
290
291 ")
292
293         (internal-class-name . "Music")
294         (types . (general-music layout-instruction))
295         (iterator-ctor . ,      Push_property_iterator::constructor)
296         ))
297     (PartCombineMusic
298      . (
299         (description .  "Combine two parts on a staff, either merged or
300 as separate voices.")
301
302         (internal-class-name . "Simultaneous_music")
303         (types . (general-music part-combine-music))
304         (iterator-ctor . ,New_pc_iterator::constructor)
305         ))
306     
307     (PhrasingSlurEvent
308      . (
309         (description . "Start or end phrasing slur. Syntax NOTE \\(  and \\) NOTE")
310         (internal-class-name . "Event")
311         (types . (general-music span-event phrasing-slur-event))
312         ))
313     
314     (PropertySet
315      . (
316         (description .  "Set a context property.
317
318 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
319         (internal-class-name . "Music")
320         (types . (layout-instruction general-music))
321         (iterator-ctor . ,Property_iterator::constructor)
322         )
323      )
324     
325     (PropertyUnset
326      . (
327         (description .  "Remove the definition of a context @code{\\property}.")
328
329         (internal-class-name . "Music")
330         (types . (layout-instruction general-music))
331         (iterator-ctor . ,Property_unset_iterator::constructor)
332         )
333      )
334     
335     (PesOrFlexaEvent
336      . (
337         (description .  "Within a ligature, mark the previous and the
338 following note to form a pes (if melody goes up) or a flexa (if melody
339 goes down).")
340
341         (internal-class-name . "Event")
342         (types . (general-music pes-or-flexa-event event))
343         ))
344
345     (RelativeOctaveCheck
346      . ((description . "Check if a pitch is in the correct octave.")
347         (internal-class-name . "Relative_octave_check")
348         (types . (general-music relative-octave-check))
349         ))
350     
351     (RepeatedMusic
352      . (
353         (description .  "Repeat music in different ways")
354
355         (type .  repeated-music)
356         (types . (general-music repeated-music))
357         ))
358     
359     (Event
360      . (
361         (description .  "Atomic music event.")
362
363         (internal-class-name . "Event")
364         (types . (general-music event))
365         ))
366     
367     (RestEvent
368      . (
369         (description .  "A Rest. Syntax @code{r4} for a quarter rest. ")
370
371         (internal-class-name . "Event")
372         (types . (general-music event rhythmic-event rest-event))
373         )) 
374     (SequentialMusic
375      . (
376         (description .  "Music expressions concatenated. Syntax \\sequential @{..@} or simply @{..@} .")
377
378         (internal-class-name . "Sequential_music")
379         (iterator-ctor . ,Sequential_music_iterator::constructor)
380         (types . (general-music sequential-music))
381         ))
382     
383     (MultiMeasureRestMusicGroup
384      . (
385         (description .  "Like sequential-music, but specifically intended
386 to group start-mmrest, skip, stop-mmrest sequence. Syntax @code{R2.*5} for 5 measures in 3/4 time.")
387         (internal-class-name . "Sequential_music")
388         (iterator-ctor . ,Sequential_music_iterator::constructor)
389         (types . (general-music sequential-music))
390         ))
391
392     (SoloOneEvent
393      . (
394         (description . "Print Solo.1")
395         (internal-class-name . "Event")
396         (part-combine-status . solo1)
397         (types . (general-music event part-combine-event))
398         ))
399     (SoloTwoEvent
400      . (
401         (description . "Print Solo.2")
402         (internal-class-name . "Event")
403         (part-combine-status . solo2)
404         (types . (general-music event part-combine-event))
405         ))
406     (UnisonoEvent
407      . ((description . "Print a2")
408         (internal-class-name .  "Event")
409         (part-combine-status . unisono)
410         (types . (general-music event part-combine-event))))
411     
412     (SimultaneousMusic
413      . (
414         (description .  "Music playing together.
415
416 SYNTAX
417
418 @code{ \\simultaneous @{ .. @}} or < .. >.")
419
420         (internal-class-name . "Simultaneous_music")
421         (iterator-ctor . ,Simultaneous_music_iterator::constructor)
422         
423         (types . (general-music simultaneous-music))
424         ))
425     
426     (SlurEvent
427      . (
428         (description . "Start or end slur. Syntax NOTE(  and )NOTE")
429         (internal-class-name . "Event")
430         (types . (general-music span-event slur-event))
431         ))
432
433     (RevertProperty
434      . (
435         (description .  "The opposite of @ref{OverrideProperty}: remove a
436 previously added property from a graphical object definition
437  ")
438
439         (internal-class-name . "Music")
440         (types . (general-music layout-instruction))
441         (iterator-ctor . ,      Pop_property_iterator::constructor)
442         ))
443
444     (OutputPropertySetMusic
445      . (
446         (description .  "Set grob properties in objects
447 individually. Syntax @code{\\outputproperty @var{predicate} @var{prop}
448 = @var{val}}.")
449
450         (internal-class-name . "Music")
451         (iterator-ctor . ,Output_property_music_iterator::constructor)
452         (types . (general-music layout-instruction))
453         ))
454     
455     (TextSpanEvent
456      . (
457         (description . "Start a text spanner like 8va.....|")
458         (internal-class-name . "Event")
459         (types . (general-music span-event text-span-event))
460         ))
461     
462     (TranslatorChange
463      . (
464         (description .  "Change staffs in Piano staff. Syntax @code{\\translator Staff = @var{new-id}}.")
465         (internal-class-name . "Music")
466         (iterator-ctor . , Change_iterator::constructor)
467         (types . (general-music translator-change-instruction))
468         ))
469     
470     (TimeScaledMusic
471      . (
472         (description .  "Multiply durations, as in tuplets. Syntax @code{\\times @var{fraction} @var{music}}, e.g.
473 @code{\\times 2/3 @{ ... @}} for triplets.
474  ")
475         (internal-class-name . "Time_scaled_music")
476         (iterator-ctor . ,Time_scaled_music_iterator::constructor)
477         (types . (time-scaled-music music-wrapper-music general-music))
478         ))
479     
480     (TransposedMusic
481      . (
482         (description .  "Music that has been transposed.")
483         (internal-class-name . "Transposed_music")
484         (types . (music-wrapper-music general-music transposed-music))
485         ))
486
487     (UntransposableMusic
488      . (
489         (description .  "Music that can not be transposed.")
490
491         (internal-class-name . "Untransposable_music")
492         (types . (music-wrapper-music general-music untransposable-music)) 
493         ))
494
495     (UnrelativableMusic
496      . (
497         (description .  "Music that can not be converted from relative to absolute notation.
498 For example, transposed music.")
499         (internal-class-name . "Un_relativable_music")
500         (types . (music-wrapper-music general-music unrelativable-music))
501         ))
502
503     (RelativeOctaveMusic
504      . (
505         (description .  "Music that was entered in relative octave notation.")
506
507         (internal-class-name . "Relative_octave_music")
508         (types . (music-wrapper-music general-music relative-octave-music))
509         ))
510     
511     (EventChord
512      . (
513         (description .  "Internally used to group a set of events.")
514         (internal-class-name . "Event_chord")
515         (iterator-ctor . ,Event_chord_iterator::constructor)
516         (types . (general-music event-chord simultaneous-music))
517         )
518      )
519     
520     (ScriptEvent
521      . (
522         (description .  "Add an articulation mark to a note. ")
523
524         (internal-class-name . "Event")
525         (types . (general-music event))
526         ))
527
528     (NonEventSkip
529      . (
530         (description .  "Filler that takes up duration, but does not print anything. This also does not create any event-accepting contexts. ")
531         (internal-class-name . "Music")
532         (length . ,ly:music-duration-length)
533         (iterator-ctor . ,Simple_music_iterator::constructor)
534         (types . (general-music event rhythmic-event skip-event))
535         ))
536      
537     (SkipEvent
538      . (
539         (description .  "Filler that takes up duration, but does not print anything.")
540
541         (internal-class-name . "Event")
542         (types . (general-music event rhythmic-event skip-event))
543         ))
544     
545     (SpanEvent
546      . (
547         (description .  "Event for anything that is started at a different time than stopped.")
548
549         (internal-class-name . "Event")
550         (types . (general-music event))
551         ))
552     
553     (SustainEvent
554      . (
555         (description . "Depress or release sustain pedal. ")
556         (internal-class-name . "Event")
557         (types . (general-music pedal-event sustain-pedal-event))
558         ))
559     
560     (SostenutoEvent
561      . (
562         (description . "Depress or release sostenuto pedal. ")
563         (internal-class-name . "Event")
564         (types . (general-music pedal-event sostenuto-pedal-event))
565         ))
566     
567     (UnaCordaEvent
568      . (
569         (description . "Depress or release una-corda pedal.")
570         (internal-class-name . "Event")
571         (types . (general-music pedal-event una-corda-pedal-event))
572         ))
573     
574     (StringNumberEvent
575      . (
576         (description .  "Specify on which string to play this note. Syntax: @code{\\@var{number}}.")
577
578         (internal-class-name . "Event")
579         (types . (general-music string-number-event event))
580         )) 
581
582     (MetronomeChangeEvent
583      . (
584         (description .  "Change tempo setting (in beats per minute).")
585         (internal-class-name . "Event")
586         (types . (general-music metronome-change-event tempo-event event))
587         ))
588     
589     (TextScriptEvent
590      . (
591         (description .  "")
592         (internal-class-name . "Event")
593         (types . (general-music script-event text-script-event event))
594         )) 
595     (TieEvent
596      . (
597         (description .  "A tie.  Entered as @var{note}-~.")
598         (internal-class-name . "Event")
599         (types . (general-music tie-event event))
600         ))
601     (TremoloEvent
602      . (
603         (description . "Un measured tremolo.")
604         (internal-class-name . "Event")
605         (types . (general-music event tremolo-event))
606         ))
607     
608     (VoiceSeparator
609      . (
610         (description .  "Separate polyphonic voices in simultaneous music. Syntax: @code{\\\\}")
611
612         (internal-class-name . "Music")
613         (types . (separator general-music))
614         ))
615
616     (VoltaRepeatedMusic
617      . (
618         (iterator-ctor . ,Volta_repeat_iterator::constructor)
619         (internal-class-name . "Repeated_music")
620         (description . "")
621         (start-moment-function .  ,Repeated_music::first_start)
622         (length . ,Repeated_music::volta_music_length)
623         (types . (general-music repeated-music volta-repeated-music))
624         ))
625     
626     (UnfoldedRepeatedMusic
627      . (
628         (iterator-ctor . ,Unfolded_repeat_iterator::constructor)
629         (description .  "")
630         (start-moment-function .  ,Repeated_music::first_start)
631         (internal-class-name . "Repeated_music")
632         (types . (general-music repeated-music unfolded-repeated-music))
633         (length . ,Repeated_music::unfolded_music_length)
634         ))
635     (PercentRepeatedMusic
636      . (
637         (internal-class-name . "Repeated_music")
638         (description .  "Repeats encoded by percents.")
639         (iterator-ctor . ,Percent_repeat_iterator::constructor)
640         (start-moment-function .  ,Repeated_music::first_start)
641         (length . ,Repeated_music::unfolded_music_length)
642         (types . (general-music repeated-music percent-repeated-music))
643         ))
644     
645     (TremoloRepeatedMusic
646      . (
647         (iterator-ctor . ,Chord_tremolo_iterator::constructor)
648         (description .  "Repeated notes denoted by tremolo beams.")
649         (internal-class-name . "Repeated_music")
650         (start-moment-function .  ,Repeated_music::first_start)
651
652         ;; the length of the repeat is handled by shifting the note logs
653         (length . ,Repeated_music::folded_music_length)
654         (types . (general-music repeated-music tremolo-repeated-music))
655         
656         ))
657     
658     (FoldedRepeatedMusic
659      . (
660         (internal-class-name . "Repeated_music")
661         (description .  "Repeats with alternatives placed in parallel. ")
662         (iterator-ctor  . ,Folded_repeat_iterator::constructor)
663         (start-moment-function .  ,Repeated_music::minimum_start)
664         (length . ,Repeated_music::folded_music_length)
665         (types . (general-music repeated-music folded-repeated-music))
666         ))
667     ))
668
669 (set! music-descriptions
670       (sort music-descriptions alist<?))
671
672 (define music-name-to-property-table (make-vector 59 '()))
673
674
675 ;; init hash table,
676 ;; transport description to an object property.
677 (set!
678  music-descriptions
679  (map (lambda (x)
680         (set-object-property! (car x)
681                               'music-description
682                               (cdr (assq 'description (cdr x))))
683         (let
684             ((l (cdr x)))
685           (set! l (assoc-set! l 'name (car x)))
686           (set! l (assq-remove!  l 'description))
687           (hashq-set! music-name-to-property-table (car x) l)
688           (cons (car x) l)
689           ))
690       music-descriptions))
691
692
693
694 (define-public (make-music-by-name x)
695   (if (not (symbol? x))
696       (error (format "Not a symbol: ~a" x)))
697   (let*
698       (
699        (props (hashq-ref music-name-to-property-table x '()))
700        (name (if (pair? props)
701                  (cdr (assoc 'internal-class-name props))
702                  (error "Can not find music object" x)))
703        )
704
705     (if (eq? props '())
706         (ly:warn (format "Could not find music type `~a'" x)))  
707     (ly:make-bare-music name props)
708     ))
709
710
711
712 (define-public (make-repeated-music name)
713   (let*
714       (
715        (handle (assoc
716                 name
717                 '(("volta" . VoltaRepeatedMusic)
718                   ("unfold" . UnfoldedRepeatedMusic)
719                   ("percent" . PercentRepeatedMusic)
720                   ("tremolo" . TremoloRepeatedMusic)
721                   ("fold" . FoldedRepeatedMusic)
722                   )))
723        (music-name
724         (if (pair? handle)
725             (cdr handle)
726             (begin
727               (ly:warn
728                (string-append "Unknown repeat type `" name
729                               "'\nSee music-types.scm for supported repeats"))
730               'VoltaRepeatedMusic)
731             )
732         )
733        )
734
735     (make-music-by-name music-name)
736     ))
737