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