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