]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/define-music-types.scm
* scm/output-lib.scm (fret-number-tablature-format): vcenter and
[lilypond.git] / scm / define-music-types.scm
index 5784760d328878357ef9592a0cc688f720357a14..4593aba5a8fc80172637f015e02fa99f238b8622 100644 (file)
@@ -2,7 +2,7 @@
 ;;;;
 ;;;;  source file of the GNU LilyPond music typesetter
 ;;;; 
-;;;; (c)  1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+;;;; (c) 1998--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 ;;;;                Jan Nieuwenhuizen <janneke@gnu.org>
 
 ;; TODO: should link back into user manual.
@@ -176,6 +176,18 @@ Syntax: @var{note}\\cr
        (internal-class-name . "Event")
        (types . (general-music extender-event event))
        ))
+
+    
+    (EventChord
+     . (
+       (description .  "Internally used to group a set of events.")
+       (internal-class-name . "Music")
+       (iterator-ctor . ,Event_chord_iterator::constructor)
+       (length-callback . ,Music_sequence::maximum_length_callback)
+       (to-relative-callback . ,Music_sequence::event_chord_relative_callback)
+       (types . (general-music event-chord simultaneous-music))
+       ))
+
     (FingerEvent
      . (
        (description . "Specify what finger to use for this note.")
@@ -198,8 +210,9 @@ Syntax: @var{note}\\cr
     (GraceMusic
      . (
        (description .  "Interpret the argument as grace notes. ")
-
-       (internal-class-name . "Grace_music")
+       (internal-class-name . "Music_wrapper")
+       (start-callback . ,Grace_music::start_callback)
+       (length . ,(ly:make-moment 0 1))
        (iterator-ctor . ,Grace_iterator::constructor)
        (types . (grace-music music-wrapper-music general-music))
        ))
@@ -229,7 +242,7 @@ Syntax: @var{note}\\cr
 
 Syntax: @code{\\key } @var{name} @var{scale}.")
 
-       (internal-class-name . "Key_change_ev")
+       (internal-class-name . "Event")
        (types . (general-music key-change-event event))
        ))
     
@@ -242,24 +255,24 @@ Syntax: @code{\\key } @var{name} @var{scale}.")
        (types . (general-music span-event ligature-event event))
        ))
     
-    (LyricCombineMusic
+    (OldLyricCombineMusic
      . (
        (description .  "Align lyrics to the start of notes.
 
+Syntax @var{\\oldaddlyrics }@var{music} @var{lyrics}.")
 
-Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
-
-       (internal-class-name . "Lyric_combine_music")
+       (internal-class-name . "Music")
        (types . (general-music lyric-combine-music))
+       (length-callback . ,Lyric_combine_music::length_callback)
+       (start-callback . ,Music_sequence::first_start_callback)
        (iterator-ctor . ,Lyric_combine_music_iterator::constructor)
        ))
     
-    (NewLyricCombineMusic
+    (LyricCombineMusic
      . (
        (description .  "Align lyrics to the start of notes.
 
-
-Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
+Syntax @var{\\lyricsto }@var{voicename} @var{lyrics}.")
        (internal-class-name . "Music")
        (length . ,(ly:make-moment 0 1))
        (types . (general-music lyric-combine-music))
@@ -309,6 +322,19 @@ Syntax
        (types . (general-music event rhythmic-event multi-measure-rest-event))
        ))
     
+    (MultiMeasureRestMusicGroup
+     . (
+       (description .  "Like sequential-music, but specifically intended
+to group start-mmrest, skip, stop-mmrest sequence. 
+
+Syntax @code{R2.*5} for 5 measures in 3/4 time.")
+       (internal-class-name . "Music")
+       (length-callback . ,Music_sequence::cumulative_length_callback)
+       (start-callback . ,Music_sequence::first_start_callback)
+       (iterator-ctor . ,Sequential_music_iterator::constructor)
+       (types . (general-music sequential-music))
+       ))
+    
     (MultiMeasureTextEvent
      . (
        (description . "Texts on mm rests. 
@@ -334,6 +360,19 @@ Syntax
        (types . (general-music event note-event rhythmic-event melodic-event))
        ))
     
+    (OutputPropertySetMusic
+     . (
+       (description .  "Set grob properties in objects
+individually. 
+
+Syntax @code{\\outputproperty @var{predicate} @var{prop}
+= @var{val}}.")
+
+       (internal-class-name . "Music")
+       (iterator-ctor . ,Output_property_music_iterator::constructor)
+       (types . (general-music layout-instruction))
+       ))
+    
     (OverrideProperty
      . (
        (description .  "Extend the definition of a graphical object.
@@ -351,7 +390,9 @@ SYNTAX
      . (
        (description .  "Combine two parts on a staff, either merged or
 as separate voices.")
-       (internal-class-name . "Simultaneous_music")
+       (internal-class-name . "Music")
+       (length-callback . ,Music_sequence::maximum_length_callback)
+       (start-callback . ,Music_sequence::minimum_start_callback)
        (types . (general-music part-combine-music))
        (iterator-ctor . ,Part_combine_iterator::constructor)
        ))
@@ -368,15 +409,12 @@ Syntax NOTE \\(  and \\) NOTE")
      . (
        (description .  "Set a context property.
 
-
-
 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
        (internal-class-name . "Music")
        (types . (layout-instruction general-music))
        (iterator-ctor . ,Property_iterator::constructor)
-       )
-     )
-    
+       ))
+
     (PropertyUnset
      . (
        (description .  "Remove the definition of a context @code{\\property}.")
@@ -384,8 +422,7 @@ Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
        (internal-class-name . "Music")
        (types . (layout-instruction general-music))
        (iterator-ctor . ,Property_unset_iterator::constructor)
-       )
-     )
+       ))
     
     (PesOrFlexaEvent
      . (
@@ -407,7 +444,8 @@ goes down).")
     
     (RelativeOctaveCheck
      . ((description . "Check if a pitch is in the correct octave.")
-       (internal-class-name . "Relative_octave_check")
+       (internal-class-name . "Music")
+       (to-relative-callback . ,Relative_octave_check::relative_callback)
        (types . (general-music relative-octave-check))
        ))
     
@@ -452,18 +490,9 @@ previously added property from a graphical object definition
 
 Syntax \\sequential @{..@} or simply @{..@} .")
 
-       (internal-class-name . "Sequential_music")
-       (iterator-ctor . ,Sequential_music_iterator::constructor)
-       (types . (general-music sequential-music))
-       ))
-    
-    (MultiMeasureRestMusicGroup
-     . (
-       (description .  "Like sequential-music, but specifically intended
-to group start-mmrest, skip, stop-mmrest sequence. 
-
-Syntax @code{R2.*5} for 5 measures in 3/4 time.")
-       (internal-class-name . "Sequential_music")
+       (internal-class-name . "Music")
+       (length-callback . ,Music_sequence::cumulative_length_callback)
+       (start-callback . ,Music_sequence::first_start_callback)
        (iterator-ctor . ,Sequential_music_iterator::constructor)
        (types . (general-music sequential-music))
        ))
@@ -496,8 +525,11 @@ SYNTAX
 
 @code{ \\simultaneous @{ .. @}} or < .. >.")
 
-       (internal-class-name . "Simultaneous_music")
+       (internal-class-name . "Music")
        (iterator-ctor . ,Simultaneous_music_iterator::constructor)
+       (start-callback . ,Music_sequence::minimum_start_callback)
+       (length-callback . ,Music_sequence::maximum_length_callback)
+       (to-relative-callback . ,Music_sequence::simultaneous_relative_callback)
        
        (types . (general-music simultaneous-music))
        ))
@@ -510,7 +542,13 @@ Syntax NOTE(        and )NOTE")
        (internal-class-name . "Event")
        (types . (general-music span-event slur-event))
        ))
-
+    
+    (StaffSpanEvent
+     . ((description . "Start or  stop a staff symbol.")
+       (internal-class-name . "Event")
+       (types . (general-music event span-event staff-span-event))
+     ))
+    
     (StartPlayingEvent
      . (
        (description .  "Used internally to signal beginning of notes.")
@@ -519,19 +557,6 @@ Syntax NOTE(        and )NOTE")
        (types . (general-music event start-playing-event))
        ))
     
-    (OutputPropertySetMusic
-     . (
-       (description .  "Set grob properties in objects
-individually. 
-
-Syntax @code{\\outputproperty @var{predicate} @var{prop}
-= @var{val}}.")
-
-       (internal-class-name . "Music")
-       (iterator-ctor . ,Output_property_music_iterator::constructor)
-       (types . (general-music layout-instruction))
-       ))
-    
     (TextSpanEvent
      . (
        (description . "Start a text spanner like 8va.....|")
@@ -553,7 +578,7 @@ Syntax @code{\\outputproperty @var{predicate} @var{prop}
 Syntax @code{\\times @var{fraction} @var{music}}, e.g.
 @code{\\times 2/3 @{ ... @}} for triplets.
  ")
-       (internal-class-name . "Time_scaled_music")
+       (internal-class-name . "Music_wrapper")
        (iterator-ctor . ,Time_scaled_music_iterator::constructor)
        (types . (time-scaled-music music-wrapper-music general-music))
        ))
@@ -561,43 +586,27 @@ Syntax @code{\\times @var{fraction} @var{music}}, e.g.
     (TransposedMusic
      . (
        (description .  "Music that has been transposed.")
-       (internal-class-name . "Transposed_music")
+       (internal-class-name . "Music_wrapper")
+       (to-relative-callback . ,Relative_octave_music::no_relative_callback)
        (types . (music-wrapper-music general-music transposed-music))
        ))
 
-    (UntransposableMusic
-     . (
-       (description .  "Music that can not be transposed.")
-
-       (internal-class-name . "Untransposable_music")
-       (types . (music-wrapper-music general-music untransposable-music)) 
-       ))
-
     (UnrelativableMusic
      . (
        (description .  "Music that can not be converted from relative to absolute notation.
 For example, transposed music.")
-       (internal-class-name . "Un_relativable_music")
+       (to-relative-callback . ,Relative_octave_music::no_relative_callback)
+       (internal-class-name . "Music_wrapper")
        (types . (music-wrapper-music general-music unrelativable-music))
        ))
 
     (RelativeOctaveMusic
      . (
        (description .  "Music that was entered in relative octave notation.")
-
-       (internal-class-name . "Relative_octave_music")
+       (to-relative-callback . ,Relative_octave_music::relative_callback)
+       (internal-class-name . "Music_wrapper")
        (types . (music-wrapper-music general-music relative-octave-music))
        ))
-    
-    (EventChord
-     . (
-       (description .  "Internally used to group a set of events.")
-       (internal-class-name . "Event_chord")
-       (iterator-ctor . ,Event_chord_iterator::constructor)
-       (types . (general-music event-chord simultaneous-music))
-       )
-     )
-    
     (ScriptEvent
      . (
        (description .  "Add an articulation mark to a note. ")
@@ -615,7 +624,7 @@ does not create staffs or voices implicitly.
 
 Syntax: @code{\\skip }@var{duration}.")
        (internal-class-name . "Music")
-       (length . ,ly:music-duration-length)
+       (length-callback . ,ly:music-duration-length)
        (iterator-ctor . ,Simple_music_iterator::constructor)
        (types . (general-music event rhythmic-event skip-event))
        ))
@@ -709,10 +718,10 @@ Syntax: @code{\\\\}")
     (VoltaRepeatedMusic
      . (
        (iterator-ctor . ,Volta_repeat_iterator::constructor)
-       (internal-class-name . "Repeated_music")
+       (internal-class-name . "Music")
        (description . "")
-       (start-moment-function .  ,Repeated_music::first_start)
-       (length . ,Repeated_music::volta_music_length)
+       (start-callback .  ,Repeated_music::first_start)
+       (length-callback . ,Repeated_music::volta_music_length)
        (types . (general-music repeated-music volta-repeated-music))
        ))
     
@@ -720,18 +729,18 @@ Syntax: @code{\\\\}")
      . (
        (iterator-ctor . ,Unfolded_repeat_iterator::constructor)
        (description .  "")
-       (start-moment-function .  ,Repeated_music::first_start)
-       (internal-class-name . "Repeated_music")
+       (start-callback .  ,Repeated_music::first_start)
+       (internal-class-name . "Music")
        (types . (general-music repeated-music unfolded-repeated-music))
-       (length . ,Repeated_music::unfolded_music_length)
+       (length-callback . ,Repeated_music::unfolded_music_length)
        ))
     (PercentRepeatedMusic
      . (
-       (internal-class-name . "Repeated_music")
+       (internal-class-name . "Music")
        (description .  "Repeats encoded by percents.")
        (iterator-ctor . ,Percent_repeat_iterator::constructor)
-       (start-moment-function .  ,Repeated_music::first_start)
-       (length . ,Repeated_music::unfolded_music_length)
+       (start-callback .  ,Repeated_music::first_start)
+       (length-callback . ,Repeated_music::unfolded_music_length)
        (types . (general-music repeated-music percent-repeated-music))
        ))
     
@@ -739,22 +748,22 @@ Syntax: @code{\\\\}")
      . (
        (iterator-ctor . ,Chord_tremolo_iterator::constructor)
        (description .  "Repeated notes denoted by tremolo beams.")
-       (internal-class-name . "Repeated_music")
-       (start-moment-function .  ,Repeated_music::first_start)
+       (internal-class-name . "Music")
+       (start-callback .  ,Repeated_music::first_start)
 
        ;; the length of the repeat is handled by shifting the note logs
-       (length . ,Repeated_music::folded_music_length)
+       (length-callback . ,Repeated_music::folded_music_length)
        (types . (general-music repeated-music tremolo-repeated-music))
        
        ))
     
     (FoldedRepeatedMusic
      . (
-       (internal-class-name . "Repeated_music")
+       (internal-class-name . "Music")
        (description .  "Repeats with alternatives placed in parallel. ")
        (iterator-ctor  . ,Folded_repeat_iterator::constructor)
-       (start-moment-function .  ,Repeated_music::minimum_start)
-       (length . ,Repeated_music::folded_music_length)
+       (start-callback .  ,Repeated_music::minimum_start)
+       (length-callback . ,Repeated_music::folded_music_length)
        (types . (general-music repeated-music folded-repeated-music))
        ))
     ))
@@ -779,7 +788,7 @@ Syntax: @code{\\\\}")
          (cons (car x) lst)))
       music-descriptions))
 
-(define-public (make-music name . music-properties)
+(define-safe-public (make-music name . music-properties)
   "Create a music object of given name, and set its properties
 according to `music-properties', a list of alterning property symbols
 and values. E.g:
@@ -788,10 +797,10 @@ and values. E.g:
              'grob-property 'thickness
              'grob-value (* 2 1.5))"
   (if (not (symbol? name))
-      (error (format "Not a symbol: ~a" name)))
+      (ly:error (_ "symbol expected: ~S") name))
   (let ((props (hashq-ref music-name-to-property-table name '())))
     (if (not (pair? props))
-       (error "Can not find music object" name))
+       (ly:error (_ "can't find music object: ~S") name))
     (let ((m (ly:make-bare-music (cdr (assoc 'internal-class-name props)) props)))
       (define (set-props mus-props)
        (if (and (not (null? mus-props))
@@ -811,7 +820,8 @@ and values. E.g:
         (music-name (if (pair? handle)
                         (cdr handle)
                         (begin
-                          (ly:warn "Unknown repeat type `~S'\nSee music-types.scm for supported repeats" name)
+                          (ly:warning (_ "unknown repeat type `~S'") name)
+                          (ly:warning (_ "See music-types.scm for supported repeats"))
                           'VoltaRepeatedMusic))))
     (make-music music-name)))