]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/*.scm: make-music-by-name is replaced by make-music, which
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 28 Feb 2004 19:37:42 +0000 (19:37 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 28 Feb 2004 19:37:42 +0000 (19:37 +0000)
also accept music property settings, eg:
  (make-music 'TextScriptEvent 'direction DOWN 'text
      (make-simple-markup x))

Patch courtesy Nicolas Sceaux

15 files changed:
ChangeLog
input/regression/music-map.ly
input/test/add-staccato.ly
input/test/add-text-script.ly
input/test/music-creation.ly
lily/music.cc
ly/declarations-init.ly
ly/dynamic-scripts-init.ly
ly/property-init.ly
ly/script-init.ly
scm/chord-entry.scm
scm/clef.scm
scm/define-music-types.scm
scm/music-functions.scm
scm/part-combiner.scm

index 680335dfea604c4b42c9b7feff1949f4e3274403..cf3a6c4e242003e6cd83cdbdfade398293e6aacc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2004-02-28  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * scm/*.scm: make-music-by-name is replaced by make-music, which
+       also accept music property settings, eg:
+         (make-music 'TextScriptEvent 'direction DOWN 'text
+             (make-simple-markup x))
+
+       Patch courtesy Nicolas Sceaux
+
        * lily/beam-quanting.cc: cleanup, separate counts for left and
        right beam ends.
 
index c7fa3e946dedd1e9c85a279644c79a33661646c7..7536d93002760e66a35d31ca90e6bb3f0d050339 100644 (file)
@@ -17,7 +17,7 @@ dynamics are left over. These are put onto the 2nd measure."
 Scripts and dynamics are maintained.
 "
   (if (memq 'rhythmic-event (ly:music-property m 'types))
-       (let* ((newmus    (make-music-by-name 'SkipEvent)))
+       (let* ((newmus    (make-music 'SkipEvent)))
                (map
                  (lambda (x) (ly:music-set-property! newmus (car x) (cdr x)))
                  (ly:get-mutable-properties m))
index fa8379fbc9265f1b9e935d5716bda9a6bae11bd0..8dff3e4efdfb9121aa762c64613367f50557c918 100644 (file)
@@ -11,16 +11,15 @@ it is not necessary to use scm constructs (see @code{separate-staccato.ly}).
 } 
 
 #(define (make-script x)
-   (let ((m (make-music-by-name 'ArticulationEvent)))
-     (ly:music-set-property! m 'articulation-type x)
-     m))
+   (make-music 'ArticulationEvent
+               'articulation-type x))
     
 #(define (add-script m x)
    (if
-    (equal? (ly:music-property m 'name) 'EventChord)
-    (ly:music-set-property! m 'elements
-                         (cons (make-script x)
-                               (ly:music-property m 'elements))))
+     (equal? (ly:music-property m 'name) 'EventChord)
+     (set! (ly:music-property m 'elements)
+           (cons (make-script x)
+                 (ly:music-property m 'elements))))
    m)
 
 #(define (add-staccato m)
index 4df05478a4fdf03d865c4d00819f2326ca2bc189..6b115871ecb052f8263514bfc33823b73992ca09 100644 (file)
@@ -11,19 +11,17 @@ create, then write a function that will structure the music for you.
 } 
 
 #(define (make-text-script x) 
-   (let ((m (make-music-by-name 'TextScriptEvent)))
-    (ly:music-set-property! m 'direction DOWN) 
-     (ly:music-set-property! m 'text (make-simple-markup x))
-     m))
+   (make-music 'TextScriptEvent
+               'direction DOWN
+               'text (make-simple-markup x)))
      
 #(define (add-text-script m x)
    (if (equal? (ly:music-property m 'name) 'EventChord)
-       (ly:music-set-property! m 'elements
-                           (cons (make-text-script x)
-                                 (ly:music-property m 'elements)))
-       
+       (set! (ly:music-property m 'elements)
+             (cons (make-text-script x)
+                  (ly:music-property m 'elements)))       
        (let ((es (ly:music-property m 'elements))
-            (e (ly:music-property m 'element)) )
+            (e (ly:music-property m 'element)))
         (map (lambda (y) (add-text-script y x)) es)
         (if (ly:music? e)
             (add-text-script e x))))
index 6a1cfc730f4c194b3e4635cff2940778b9d457b1..598de513113b431f636b14cb1fe5c8acdd90c779 100644 (file)
@@ -8,26 +8,21 @@ clumsy to use, so avoid them, if possible. "
 }
 
 #(define (make-note-req p d)
-   (let* ((ml (make-music-by-name 'NoteEvent)))
-   (ly:music-set-property! ml 'duration d)
-   (ly:music-set-property! ml 'pitch p)
-   ml))
+   (make-music 'NoteEvent
+    'duration d
+    'pitch p))
 
 #(define (make-note elts)
-   (let* ((ml (make-music-by-name 'EventChord)))
-   (ly:music-set-property! ml 'elements elts)
-   ml))
+   (make-music 'EventChord
+    'elements elts))
 
 #(define (seq-music-list elts)
-   (let* ((ml (make-music-by-name 'SequentialMusic)))
-   (ly:music-set-property! ml 'elements elts)
-   ml))
-
+   (make-music 'SequentialMusic
+    'elements elts))
 
 fooMusic = #(seq-music-list
-  (list (make-note (list (make-note-req (ly:make-pitch 1 0 0) (ly:make-duration 2 0))))
-     (make-note (list (make-note-req (ly:make-pitch 1 1 0) (ly:make-duration 2 0)))))
-     )
+             (list (make-note (list (make-note-req (ly:make-pitch 1 0 0) (ly:make-duration 2 0))))
+                   (make-note (list (make-note-req (ly:make-pitch 1 1 0) (ly:make-duration 2 0))))))
      
 \score { \fooMusic 
 \paper { raggedright = ##t }
index bcc942e095ac9625a18a27b1c285ed06c03ba707..b5964c87fc64af03aec4f59784edf7b71fe2897a 100644 (file)
@@ -295,7 +295,7 @@ LY_DEFINE(ly_extended_make_music,
          "@var{props}. \n\n"
          ""
          "This function is for internal use, and is only called by "
-         "@code{make-music-by-name}, which is the preferred interface "
+         "@code{make-music}, which is the preferred interface "
          "for creating music objects. "
          )
 {
@@ -312,7 +312,7 @@ LY_DEFINE(ly_get_mutable_properties,
          "ly:get-mutable-properties", 1, 0, 0,  (SCM mus),
          "Return an alist containing the mutable properties of @var{mus}.\n"
          "The immutable properties are not available; they should be initialized\n"
-         "by the  @code{make-music-by-name} function.\n"
+         "by the  @code{make-music} function.\n"
          )
 {
   Music *m = unsmob_music (mus);
@@ -379,7 +379,7 @@ Music*
 make_music_by_name (SCM sym)
 {
   if (!make_music_proc)
-    make_music_proc = scm_primitive_eval (ly_symbol2scm ("make-music-by-name"));
+    make_music_proc = scm_primitive_eval (ly_symbol2scm ("make-music"));
        
   SCM rv = scm_call_1 (make_music_proc, sym);
 
index b95af192718632b1f83e2f9f2eb599abfeb38f3d..08756da83120e5e2652369cea2d2ba594329d7d1 100644 (file)
@@ -30,7 +30,7 @@ working with lyric sections)
 break =#(make-event-chord (list (make-penalty-music -10001)))
 noBreak = #(make-event-chord (list (make-penalty-music 10001)))
 
-noBeam = #(make-music-by-name 'BeamForbidEvent) 
+noBeam = #(make-music 'BeamForbidEvent) 
 
 \include "scale-definitions-init.ly"
 
index b6393ac000df934721bce212b944c92fb7443923..ca6358ea15e2651d6cd95d248423c6aab5e67b59 100644 (file)
@@ -5,10 +5,8 @@
 %
 
 #(define (make-dynamic-script str)
-  (let* ((m (make-music-by-name  'AbsoluteDynamicEvent)))
-  (ly:music-set-property! m 'text str)
-  m
-  ))
+   (make-music 'AbsoluteDynamicEvent
+              'text str))
 ppppp = #(make-dynamic-script "pppp")
 pppp = #(make-dynamic-script "pppp")
 ppp = #(make-dynamic-script "ppp")
index 3f6f68407f80fddc67c24647ad6c1e8b02ba3956..6787beabc5ce3347a00ef2748069c95e0e946394 100644 (file)
@@ -132,8 +132,8 @@ turnOff = #(cons '() '())
 % cross-staff brackets are desired. 
 
 arpeggioBracket = #Arpeggio::brew_chord_bracket
-arpeggio = #(make-music-by-name 'ArpeggioEvent)
-glissando = #(make-music-by-name 'GlissandoEvent)
+arpeggio = #(make-music 'ArpeggioEvent)
+glissando = #(make-music 'GlissandoEvent)
 
 fermataMarkup = \markup { \musicglyph #"scripts-ufermata" } 
 
index 6dda44182cf0112cc57832130eb9e8d06c3c2d27..adc8d91678c66ad48b1c03619423ee1de73b7f18 100644 (file)
@@ -9,7 +9,7 @@ dashLarger= "accent"
 dashDot= "staccato"
 dashUnderscore = "portato"
 
-harmonic = #(make-music-by-name 'HarmonicEvent)
+harmonic = #(make-music 'HarmonicEvent)
 
 thumb = #(make-articulation "thumb")
 accent = #(make-articulation "accent")
index 068078db968f5ce36c941b5752b5d19ca0bedf86..93a1c80a1c46577a953d9bbca0e17dc0a1936582 100644 (file)
@@ -163,10 +163,9 @@ the bass specified.
   "Make EventChord with notes corresponding to PITCHES, BASS and
 DURATION, and INVERSION."
   (define (make-note-ev pitch)
-    (let ((ev (make-music-by-name 'NoteEvent)))
-      (set! (ly:music-property ev 'duration) duration)
-      (set! (ly:music-property ev 'pitch) pitch)
-      ev))
+    (make-music 'NoteEvent
+                'duration duration
+                'pitch pitch))
   (let ((nots (map make-note-ev pitches))
        (bass-note (if bass (make-note-ev bass) #f))
        (inv-note (if inversion (make-note-ev inversion) #f)))
index 5634abe905adc9a6f254fb2fa9ff552daac8adde..1f8fb7843656abcf0c562bb4b0fd254f1dec763e 100644 (file)
@@ -93,7 +93,7 @@
 (define-public (make-clef-set clef-name)
   "Generate the clef setting commands for a clef with name CL."
   (define (make-prop-set props)
-    (let ((m (make-music-by-name 'PropertySet)))
+    (let ((m (make-music 'PropertySet)))
       (map (lambda (x) (set! (ly:music-property m (car x)) (cdr x))) props)
       m))
   (let ((e '())
                                            (cdr (assoc (cadr e) c0-pitch-alist)))))
                              ((symbol . clefPosition) (value . ,(caddr e)))
                              ((symbol . clefOctavation) (value . ,(- oct))))))
-              (seq (make-music-by-name 'SequentialMusic))
-              (csp (make-music-by-name 'ContextSpeccedMusic)))
-         (set! (ly:music-property seq 'elements) musics)
+              (seq (make-music 'SequentialMusic
+                               'elements musics))
+              (csp (make-music 'ContextSpeccedMusic)))
          (context-spec-music seq 'Staff))
        (begin
          (ly:warn (format "Unknown clef type `~a'
 See scm/lily.scm for supported clefs" clef-name))
-         (make-music-by-name 'Music)))))
+         (make-music 'Music)))))
 
index cac28f33d803f0b5b9b692aab2bc54f72f6def2f..e6e6f2d23021244936d7e5ddcbaad3805bbe55f7 100644 (file)
@@ -3,7 +3,7 @@
 ;;;;  source file of the GNU LilyPond music typesetter
 ;;;; 
 ;;;; (c)  1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-;;;;                 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;;                Jan Nieuwenhuizen <janneke@gnu.org>
 
 (define-public music-descriptions
   `(
@@ -40,9 +40,9 @@ arguments to func are 1. the grob, 2. the originating context,
        ))
     (ArpeggioEvent 
      . (
-       (description .  "Make an arpeggio on this note. Syntax:
+       (description .  "Make an arpeggio on this note. Syntax:
 @var{note}-@code{\\arpeggio}")
-       (internal-class-name .  "Event")
+       (internal-class-name .  "Event")
        (types . (general-music arpeggio-event event))
        ))
 
@@ -61,7 +61,7 @@ is an articulation (such as @code{-.}, @code{->}, @code{\\tenuto},
        )) 
     (AutoChangeMusic
      . (
-       (description .  "Used for making voices that switch between piano staves automatically.")
+       (description .  "Used for making voices that switch between piano staves automatically.")
 
        (internal-class-name . "Music_wrapper")
        (iterator-ctor . ,Auto_change_iterator::constructor)
@@ -77,7 +77,7 @@ is an articulation (such as @code{-.}, @code{->}, @code{\\tenuto},
        ))
     (BassFigureEvent
      . (
-       (description .  "Print a bass-figure text")
+       (description .  "Print a bass-figure text")
 
        (internal-class-name . "Event")
        (types . (general-music event rhythmic-event bass-figure-event))
@@ -98,7 +98,7 @@ c8-[ c c-] c8")
        ))
     (BreathingSignEvent
      . (
-       (description .  "Creates a `breath mark' or `comma'.  Syntax:
+       (description .  "Creates a `breath mark' or `comma'.  Syntax:
 @var{note}\\breathe.")
 
        (internal-class-name . "Event")
@@ -106,14 +106,14 @@ c8-[ c c-] c8")
        )) 
     (BusyPlayingEvent
      . (
-       (description .  "Used internally to signal beginning and ending of notes.")
+       (description .  "Used internally to signal beginning and ending of notes.")
 
        (internal-class-name . "Event")
        (types . (general-music event busy-playing-event))
        ))
     (StartPlayingEvent
      . (
-       (description .  "Used internally to signal beginning of notes.")
+       (description .  "Used internally to signal beginning of notes.")
 
        (internal-class-name . "Event")
        (types . (general-music event start-playing-event))
@@ -121,7 +121,7 @@ c8-[ c c-] c8")
     
     (ClusterNoteEvent
      . (
-       (description .  "A note that is part of a cluster.")
+       (description .  "A note that is part of a cluster.")
        (internal-class-name . "Event")
 
        ; not a note-event, to ensure that Note_engraver doesn't eat it. 
@@ -130,7 +130,7 @@ c8-[ c c-] c8")
     
     (ContextSpeccedMusic
      . (
-       (description .  "Interpret the argument music within a specific context.")
+       (description .  "Interpret the argument music within a specific context.")
        (iterator-ctor . ,Context_specced_music_iterator::constructor)
        (internal-class-name . "Music_wrapper")
        (types . (context-specification general-music music-wrapper-music))
@@ -138,7 +138,7 @@ c8-[ c c-] c8")
     
     (CrescendoEvent
      . (
-       (description .  "Begins or ends a crescendo.  Syntax: @var{note}\\cr
+       (description .  "Begins or ends a crescendo.  Syntax: @var{note}\\cr
 ... @var{note}\\rc (you can also use \\<, \\!, \\cresc, and
 \\endcresc.  See the user manual for details.).")
 
@@ -147,7 +147,7 @@ c8-[ c c-] c8")
        )) 
     (DecrescendoEvent
      . (
-       (description .  "See @ref{CrescendoEvent}.")
+       (description .  "See @ref{CrescendoEvent}.")
 
        (internal-class-name . "Event")
        (types . (general-music dynamic-event decrescendo-event event))
@@ -155,7 +155,7 @@ c8-[ c c-] c8")
  
     (ExtenderEvent
      . (
-       (description .  "Extend lyrics.")
+       (description .  "Extend lyrics.")
 
        (internal-class-name . "Event")
        (types . (general-music extender-event event))
@@ -174,14 +174,14 @@ c8-[ c c-] c8")
        ))
     (GlissandoEvent
      . (
-       (description .  "Start  a glissando on this note.")
+       (description .  "Start  a glissando on this note.")
        (internal-class-name . "Event")
        (types . (general-music glissando-event event))
        ))
     
     (GraceMusic
      . (
-       (description .  "Interpret the argument as grace notes. ")
+       (description .  "Interpret the argument as grace notes. ")
 
        (internal-class-name . "Grace_music")
        (iterator-ctor . ,Grace_iterator::constructor)
@@ -201,7 +201,7 @@ c8-[ c c-] c8")
        ))
     (HyphenEvent
      . (
-       (description .  "A hyphen between lyric syllables.")
+       (description .  "A hyphen between lyric syllables.")
 
        (internal-class-name . "Event")
        (types . (general-music hyphen-event event))
@@ -209,7 +209,7 @@ c8-[ c c-] c8")
     
     (KeyChangeEvent
      . (
-       (description .  "Change the key signature. Syntax: @code{\\key } @var{name} @var{scale}.")
+       (description .  "Change the key signature. Syntax: @code{\\key } @var{name} @var{scale}.")
 
        (internal-class-name . "Key_change_ev")
        (types . (general-music key-change-event event))
@@ -217,7 +217,7 @@ c8-[ c c-] c8")
     
     (LigatureEvent
      . (
-       (description .  "(docme).")
+       (description .  "(docme).")
 
        (internal-class-name . "Event")
        (span-type . ligature)
@@ -226,7 +226,7 @@ c8-[ c c-] c8")
     
     (LyricCombineMusic
      . (
-       (description .  "Align lyrics to the start of notes.
+       (description .  "Align lyrics to the start of notes.
 Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
 
        (internal-class-name . "Lyric_combine_music")
@@ -236,7 +236,7 @@ Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
     
     (NewLyricCombineMusic
      . (
-       (description .  "Align lyrics to the start of notes.
+       (description .  "Align lyrics to the start of notes.
 Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
        (internal-class-name . "Music")
        (length . ,(ly:make-moment 0 1))
@@ -246,7 +246,7 @@ Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
 
     (LyricEvent
      . (
-       (description .  "A lyric syllable. Must be entered in lyrics mode, i.e.
+       (description .  "A lyric syllable. Must be entered in lyrics mode, i.e.
 @code{\\lyrics @{ twinkle4 twinkle4 @} } .")
 
        (internal-class-name . "Event")
@@ -254,7 +254,7 @@ Syntax @var{\\addlyrics }@var{music} @var{lyrics}.")
        ))
     (MarkEvent
      . (
-       (description .  "Insert a rehearsal mark. Syntax: @code{\\mark} @var{marker},
+       (description .  "Insert a rehearsal mark. Syntax: @code{\\mark} @var{marker},
 e.g. @code{\\mark \"A\"}.")
 
        (internal-class-name . "Event")
@@ -262,13 +262,13 @@ e.g. @code{\\mark \"A\"}.")
        ))
     (MelismaPlayingEvent
      . (
-       (description .  "Used internally to signal melismas.")
+       (description .  "Used internally to signal melismas.")
        (internal-class-name . "Event")
        (types . (general-music melisma-playing-event event))
        ))
     (ManualMelismaEvent
      . (
-       (description .  "Start or stop a melisma.
+       (description .  "Start or stop a melisma.
 
 Syntax:@code{c4\\melisma d\\melismaEnd}.")
        (internal-class-name . "Event")
@@ -293,14 +293,14 @@ Syntax:@code{c4\\melisma d\\melismaEnd}.")
 
     (Music
      . (
-       (description .  "Generic type for music expressions.")
+       (description .  "Generic type for music expressions.")
 
        (internal-class-name . "Music")
        (types . (general-music)) 
        ))
     (NoteEvent
      . (
-       (description .  "A note.")
+       (description .  "A note.")
 
        (internal-class-name . "Event")
        (types . (general-music event note-event rhythmic-event melodic-event))
@@ -308,7 +308,7 @@ Syntax:@code{c4\\melisma d\\melismaEnd}.")
     
     (OverrideProperty
      . (
-       (description .  "Extend the definition of a graphical object.
+       (description .  "Extend the definition of a graphical object.
 
 SYNTAX
 
@@ -322,7 +322,7 @@ SYNTAX
        ))
     (PartCombineMusic
      . (
-       (description .  "Combine two parts on a staff, either merged or
+       (description .  "Combine two parts on a staff, either merged or
 as separate voices.")
 
        (internal-class-name . "Simultaneous_music")
@@ -338,7 +338,7 @@ as separate voices.")
     
     (PropertySet
      . (
-       (description .  "Set a context property.
+       (description .  "Set a context property.
 
 Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
        (internal-class-name . "Music")
@@ -349,7 +349,7 @@ Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
     
     (PropertyUnset
      . (
-       (description .  "Remove the definition of a context @code{\\property}.")
+       (description .  "Remove the definition of a context @code{\\property}.")
 
        (internal-class-name . "Music")
        (types . (layout-instruction general-music))
@@ -359,7 +359,7 @@ Syntax: @code{\\property @var{context}.@var{prop} = @var{scheme-val}}.")
     
     (PesOrFlexaEvent
      . (
-       (description .  "Within a ligature, mark the previous and the
+       (description .  "Within a ligature, mark the previous and the
 following note to form a pes (if melody goes up) or a flexa (if melody
 goes down).")
 
@@ -383,15 +383,15 @@ goes down).")
     
     (RepeatedMusic
      . (
-       (description .  "Repeat music in different ways")
+       (description .  "Repeat music in different ways")
 
-       (type .  repeated-music)
+       (type .  repeated-music)
        (types . (general-music repeated-music))
        ))
     
     (Event
      . (
-       (description .  "Atomic music event.")
+       (description .  "Atomic music event.")
 
        (internal-class-name . "Event")
        (types . (general-music event))
@@ -399,14 +399,14 @@ goes down).")
     
     (RestEvent
      . (
-       (description .  "A Rest. Syntax @code{r4} for a quarter rest. ")
+       (description .  "A Rest. Syntax @code{r4} for a quarter rest. ")
 
        (internal-class-name . "Event")
        (types . (general-music event rhythmic-event rest-event))
        )) 
     (SequentialMusic
      . (
-       (description .  "Music expressions concatenated. Syntax \\sequential @{..@} or simply @{..@} .")
+       (description .  "Music expressions concatenated. Syntax \\sequential @{..@} or simply @{..@} .")
 
        (internal-class-name . "Sequential_music")
        (iterator-ctor . ,Sequential_music_iterator::constructor)
@@ -415,7 +415,7 @@ goes down).")
     
     (MultiMeasureRestMusicGroup
      . (
-       (description .  "Like sequential-music, but specifically intended
+       (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")
        (iterator-ctor . ,Sequential_music_iterator::constructor)
@@ -438,13 +438,13 @@ to group start-mmrest, skip, stop-mmrest sequence. Syntax @code{R2.*5} for 5 mea
        ))
     (UnisonoEvent
      . ((description . "Print a2")
-       (internal-class-name .  "Event")
+       (internal-class-name .  "Event")
        (part-combine-status . unisono)
        (types . (general-music event part-combine-event))))
     
     (SimultaneousMusic
      . (
-       (description .  "Music playing together.
+       (description .  "Music playing together.
 
 SYNTAX
 
@@ -458,14 +458,14 @@ SYNTAX
     
     (SlurEvent
      . (
-       (description . "Start or end slur. Syntax NOTE(  and )NOTE")
+       (description . "Start or end slur. Syntax NOTE(  and )NOTE")
        (internal-class-name . "Event")
        (types . (general-music span-event slur-event))
        ))
 
     (RevertProperty
      . (
-       (description .  "The opposite of @ref{OverrideProperty}: remove a
+       (description .  "The opposite of @ref{OverrideProperty}: remove a
 previously added property from a graphical object definition
  ")
 
@@ -476,7 +476,7 @@ previously added property from a graphical object definition
 
     (OutputPropertySetMusic
      . (
-       (description .  "Set grob properties in objects
+       (description .  "Set grob properties in objects
 individually. Syntax @code{\\outputproperty @var{predicate} @var{prop}
 = @var{val}}.")
 
@@ -494,7 +494,7 @@ individually. Syntax @code{\\outputproperty @var{predicate} @var{prop}
     
     (TranslatorChange
      . (
-       (description .  "Change staffs in Piano staff. Syntax @code{\\translator Staff = @var{new-id}}.")
+       (description .  "Change staffs in Piano staff. Syntax @code{\\translator Staff = @var{new-id}}.")
        (internal-class-name . "Music")
        (iterator-ctor . , Change_iterator::constructor)
        (types . (general-music translator-change-instruction))
@@ -502,7 +502,7 @@ individually. Syntax @code{\\outputproperty @var{predicate} @var{prop}
     
     (TimeScaledMusic
      . (
-       (description .  "Multiply durations, as in tuplets. Syntax @code{\\times @var{fraction} @var{music}}, e.g.
+       (description .  "Multiply durations, as in tuplets. Syntax @code{\\times @var{fraction} @var{music}}, e.g.
 @code{\\times 2/3 @{ ... @}} for triplets.
  ")
        (internal-class-name . "Time_scaled_music")
@@ -512,14 +512,14 @@ individually. Syntax @code{\\outputproperty @var{predicate} @var{prop}
     
     (TransposedMusic
      . (
-       (description .  "Music that has been transposed.")
+       (description .  "Music that has been transposed.")
        (internal-class-name . "Transposed_music")
        (types . (music-wrapper-music general-music transposed-music))
        ))
 
     (UntransposableMusic
      . (
-       (description .  "Music that can not be transposed.")
+       (description .  "Music that can not be transposed.")
 
        (internal-class-name . "Untransposable_music")
        (types . (music-wrapper-music general-music untransposable-music)) 
@@ -527,7 +527,7 @@ individually. Syntax @code{\\outputproperty @var{predicate} @var{prop}
 
     (UnrelativableMusic
      . (
-       (description .  "Music that can not be converted from relative to absolute notation.
+       (description .  "Music that can not be converted from relative to absolute notation.
 For example, transposed music.")
        (internal-class-name . "Un_relativable_music")
        (types . (music-wrapper-music general-music unrelativable-music))
@@ -535,7 +535,7 @@ For example, transposed music.")
 
     (RelativeOctaveMusic
      . (
-       (description .  "Music that was entered in relative octave notation.")
+       (description .  "Music that was entered in relative octave notation.")
 
        (internal-class-name . "Relative_octave_music")
        (types . (music-wrapper-music general-music relative-octave-music))
@@ -543,7 +543,7 @@ For example, transposed music.")
     
     (EventChord
      . (
-       (description .  "Internally used to group a set of events.")
+       (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))
@@ -552,7 +552,7 @@ For example, transposed music.")
     
     (ScriptEvent
      . (
-       (description .  "Add an articulation mark to a note. ")
+       (description .  "Add an articulation mark to a note. ")
 
        (internal-class-name . "Event")
        (types . (general-music event))
@@ -560,7 +560,7 @@ For example, transposed music.")
 
     (SkipMusic
      . (
-       (description .  "Filler that takes up duration, does not print anything, and also
+       (description .  "Filler that takes up duration, does not print anything, and also
 does not create staffs or voices implicitly.
 
 Syntax: @code{\\skip }@var{duration}.")
@@ -572,7 +572,7 @@ Syntax: @code{\\skip }@var{duration}.")
      
     (SkipEvent
      . (
-       (description .  "Filler that takes up duration, but does not print anything.
+       (description .  "Filler that takes up duration, but does not print anything.
 
 Syntax: @code{s}@var{duration}")
 
@@ -581,7 +581,7 @@ Syntax: @code{s}@var{duration}")
        ))
     (SpanEvent
      . (
-       (description .  "Event for anything that is started at a different time than stopped.")
+       (description .  "Event for anything that is started at a different time than stopped.")
 
        (internal-class-name . "Event")
        (types . (general-music event))
@@ -610,7 +610,7 @@ Syntax: @code{s}@var{duration}")
     
     (StringNumberEvent
      . (
-       (description .  "Specify on which string to play this note. Syntax: @code{\\@var{number}}.")
+       (description .  "Specify on which string to play this note. Syntax: @code{\\@var{number}}.")
 
        (internal-class-name . "Event")
        (types . (general-music string-number-event event))
@@ -618,20 +618,20 @@ Syntax: @code{s}@var{duration}")
 
     (MetronomeChangeEvent
      . (
-       (description .  "Change tempo setting (in beats per minute).")
+       (description .  "Change tempo setting (in beats per minute).")
        (internal-class-name . "Event")
        (types . (general-music metronome-change-event tempo-event event))
        ))
     
     (TextScriptEvent
      . (
-       (description .  "")
+       (description .  "")
        (internal-class-name . "Event")
        (types . (general-music script-event text-script-event event))
        )) 
     (TieEvent
      . (
-       (description .  "A tie.  Entered as @var{note}-~.")
+       (description .  "A tie.  Entered as @var{note}-~.")
        (internal-class-name . "Event")
        (types . (general-music tie-event event))
        ))
@@ -644,7 +644,7 @@ Syntax: @code{s}@var{duration}")
     
     (VoiceSeparator
      . (
-       (description .  "Separate polyphonic voices in simultaneous music. Syntax: @code{\\\\}")
+       (description .  "Separate polyphonic voices in simultaneous music. Syntax: @code{\\\\}")
 
        (internal-class-name . "Music")
        (types . (separator general-music))
@@ -663,7 +663,7 @@ Syntax: @code{s}@var{duration}")
     (UnfoldedRepeatedMusic
      . (
        (iterator-ctor . ,Unfolded_repeat_iterator::constructor)
-       (description .  "")
+       (description .  "")
        (start-moment-function .  ,Repeated_music::first_start)
        (internal-class-name . "Repeated_music")
        (types . (general-music repeated-music unfolded-repeated-music))
@@ -672,7 +672,7 @@ Syntax: @code{s}@var{duration}")
     (PercentRepeatedMusic
      . (
        (internal-class-name . "Repeated_music")
-       (description .  "Repeats encoded by percents.")
+       (description .  "Repeats encoded by percents.")
        (iterator-ctor . ,Percent_repeat_iterator::constructor)
        (start-moment-function .  ,Repeated_music::first_start)
        (length . ,Repeated_music::unfolded_music_length)
@@ -682,7 +682,7 @@ Syntax: @code{s}@var{duration}")
     (TremoloRepeatedMusic
      . (
        (iterator-ctor . ,Chord_tremolo_iterator::constructor)
-       (description .  "Repeated notes denoted by tremolo beams.")
+       (description .  "Repeated notes denoted by tremolo beams.")
        (internal-class-name . "Repeated_music")
        (start-moment-function .  ,Repeated_music::first_start)
 
@@ -695,8 +695,8 @@ Syntax: @code{s}@var{duration}")
     (FoldedRepeatedMusic
      . (
        (internal-class-name . "Repeated_music")
-       (description .  "Repeats with alternatives placed in parallel. ")
-       (iterator-ctor  . ,Folded_repeat_iterator::constructor)
+       (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)
        (types . (general-music repeated-music folded-repeated-music))
@@ -720,55 +720,52 @@ Syntax: @code{s}@var{duration}")
        (let
            ((l (cdr x)))
          (set! l (assoc-set! l 'name (car x)))
-         (set! l (assq-remove!  l 'description))
+         (set! l (assq-remove!  l 'description))
          (hashq-set! music-name-to-property-table (car x) l)
          (cons (car x) l)
          ))
       music-descriptions))
 
+(define-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:
+  (make-music 'OverrideProperty 
+             'symbol 'Stem
+             'grob-property 'thickness
+             'grob-value (* 2 1.5))"
+  (if (not (symbol? name))
+      (error (format "Not a symbol: ~a" name)))
+  (let ((props (hashq-ref music-name-to-property-table name '())))
+    (if (not (pair? props))
+       (error "Can not find music object" 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))
+                (not (null? (cdr mus-props))))
+           (begin
+             (set! (ly:music-property m (car mus-props)) (cadr mus-props))
+             (set-props (cddr mus-props)))))
+      (set-props music-properties)
+      m)))
 
-
+;; TODO remove make-music-by-name
 (define-public (make-music-by-name x)
-  (if (not (symbol? x))
-      (error (format "Not a symbol: ~a" x)))
-  (let*
-      (
-       (props (hashq-ref music-name-to-property-table x '()))
-       (name (if (pair? props)
-                (cdr (assoc 'internal-class-name props))
-                (error "Can not find music object" x)))
-       )
-
-    (if (eq? props '())
-       (ly:warn (format "Could not find music type `~a'" x)))  
-    (ly:make-bare-music name props)
-    ))
-
-
+  "Deprecated. See make-music."
+  (ly:warn "make-music-by-name is deprecated. Use make-music instead.")
+  (make-music x))
 
 (define-public (make-repeated-music name)
-  (let*
-      (
-       (handle (assoc
-               name
-               '(("volta" . VoltaRepeatedMusic)
-                 ("unfold" . UnfoldedRepeatedMusic)
-                 ("percent" . PercentRepeatedMusic)
-                 ("tremolo" . TremoloRepeatedMusic)
-                 ("fold" . FoldedRepeatedMusic)
-                 )))
-       (music-name
-       (if (pair? handle)
-           (cdr handle)
-           (begin
-             (ly:warn
-              (string-append "Unknown repeat type `" name
-                             "'\nSee music-types.scm for supported repeats"))
-             'VoltaRepeatedMusic)
-           )
-       )
-       )
-
-    (make-music-by-name music-name)
-    ))
+  (let* ((handle (assoc name '(("volta" . VoltaRepeatedMusic)
+                              ("unfold" . UnfoldedRepeatedMusic)
+                              ("percent" . PercentRepeatedMusic)
+                              ("tremolo" . TremoloRepeatedMusic)
+                              ("fold" . FoldedRepeatedMusic))))
+        (music-name (if (pair? handle)
+                        (cdr handle)
+                        (begin
+                          (ly:warn (string-append "Unknown repeat type `" name
+                                                  "'\nSee music-types.scm for supported repeats"))
+                          'VoltaRepeatedMusic))))
+    (make-music music-name)))
 
index 38e4239967cfe67660317448fdf65acbc1767e71..f6888ff4f3d9c908c5bfac012c829c9eaf8213c5 100644 (file)
@@ -51,7 +51,7 @@
   (set! music (inner-music-filter pred? music))
   (if (ly:music? music)
       music
-      (make-music-by-name 'Music)))      ;must return music.
+      (make-music 'Music)))      ;must return music.
 
 (define-public (remove-tag tag)
   (lambda (mus)
 (define-public (note-to-cluster music)
   "Replace NoteEvents by ClusterNoteEvents."
   (if (eq? (ly:music-property music 'name) 'NoteEvent)
-      (let ((cn (make-music-by-name 'ClusterNoteEvent)))
-       (set! (ly:music-property cn 'pitch)
-             (ly:music-property music 'pitch))
-       (set! (ly:music-property cn 'duration)
-             (ly:music-property music 'duration))
-       cn)
+      (make-music 'ClusterNoteEvent
+                 'pitch (ly:music-property music 'pitch)
+                 'duration (ly:music-property music 'duration))
       music))
 
 (define-public (notes-to-clusters music)
@@ -157,28 +154,25 @@ written by Rune Zedeler. "
 (define-public (make-grob-property-set grob gprop val)
   "Make a Music expression that sets GPROP to VAL in GROB. Does a pop first,
 i.e.  this is not an override"
-  (let ((m (make-music-by-name 'OverrideProperty)))
-    (set! (ly:music-property m 'symbol) grob)
-    (set! (ly:music-property m 'grob-property) gprop)
-    (set! (ly:music-property m 'grob-value) val)
-    (set! (ly:music-property m 'pop-first) #t)
-    m))
+  (make-music 'OverrideProperty
+             'symbol grob
+             'grob-property gprop
+             'grob-value val
+             'pop-first #t))
 
 (define-public (make-grob-property-override grob gprop val)
   "Make a Music expression that sets GPROP to VAL in GROB. Does a pop first,
 i.e.  this is not an override"
-  (let ((m (make-music-by-name 'OverrideProperty)))
-    (set! (ly:music-property m 'symbol) grob)
-    (set! (ly:music-property m 'grob-property) gprop)
-    (set! (ly:music-property m 'grob-value) val)
-    m))
+  (make-music 'OverrideProperty
+             'symbol grob
+             'grob-property gprop
+             'grob-value val))
 
 (define-public (make-grob-property-revert grob gprop)
   "Revert the grob property GPROP for GROB."
-   (let* ((m (make-music-by-name  'OverrideProperty)))
-     (set! (ly:music-property m 'symbol) grob)
-     (set! (ly:music-property m 'grob-property) gprop)
-     m))
+  (make-music 'OverrideProperty
+             'symbol grob
+             'grob-property gprop))
 
 (define direction-polyphonic-grobs
   '(Tie Rest Slur Script TextScript Stem Dots DotColumn))
@@ -201,71 +195,60 @@ i.e.  this is not an override"
     (list (make-grob-property-revert 'NoteColumn 'horizontal-shift)))))
 
 
-(define-public (context-spec-music m context . rest)
-  "Add \\context CONTEXT = foo to M. "
-  (let ((cm (make-music-by-name 'ContextSpeccedMusic)))
-    (set! (ly:music-property cm 'element) m)
-    (set! (ly:music-property cm 'context-type) context)
-    (if (and  (pair? rest) (string? (car rest)))
-       (set! (ly:music-property cm 'context-id) (car rest)))
+(define*-public (context-spec-music m context #:optional id)
+  "Add \\context CONTEXT = ID to M. "
+  (let ((cm (make-music 'ContextSpeccedMusic
+                       'element m
+                       'context-type context)))
+    (if (string? id)
+       (set! (ly:music-property cm 'context-id) id))
     cm))
 
 (define-public (make-apply-context func)
-  (let ((m (make-music-by-name 'ApplyContext)))
-    (set! (ly:music-property m 'procedure) func)
-    m))
+  (make-music 'ApplyContext
+             'procedure func))
 
 (define-public (make-sequential-music elts)
-  (let ((m (make-music-by-name 'SequentialMusic)))
-    (set! (ly:music-property m 'elements) elts)
-    m))
+  (make-music 'SequentialMusic
+             'elements elts))
 
 (define-public (make-simultaneous-music elts)
-  (let ((m (make-music-by-name 'SimultaneousMusic)))
-    (set! (ly:music-property m 'elements) elts)
-    m))
+  (make-music 'SimultaneousMusic
+             'elements elts))
 
 (define-public (make-event-chord elts)
-  (let ((m (make-music-by-name 'EventChord)))
-    (set! (ly:music-property m 'elements) elts)
-    m))
+  (make-music 'EventChord
+             'elements elts))
 
 (define-public (make-skip-music dur)
-  (let ((m (make-music-by-name 'SkipMusic)))
-    (set! (ly:music-property m 'duration) dur)
-    m))
+  (make-music 'SkipMusic
+             'duration dur))
 
 ;;;;;;;;;;;;;;;;
 
 ;; mmrest
 (define-public (make-multi-measure-rest duration location)
-  (let ((start (make-music-by-name 'MultiMeasureRestEvent))
-       (ch    (make-music-by-name 'BarCheck))
-       (ch2   (make-music-by-name 'BarCheck))
-       (seq   (make-music-by-name 'MultiMeasureRestMusicGroup)))
-    (map (lambda (x) (set! (ly:music-property x 'origin) location))
-        (list start ch ch2 seq))
-    (set! (ly:music-property start 'duration) duration)
-    (set! (ly:music-property seq 'elements)
-         (list ch
-               (make-event-chord (list start))
-               ch2))
-    seq))
+  (make-music 'MultiMeasureRestMusicGroup
+             'origin location
+             'elements (list (make-music 'BarCheck
+                                         'origin location)
+                             (make-event-chord (list (make-music 'MultiMeasureRestEvent
+                                                                 'origin location
+                                                                 'duration duration)))
+                             (make-music 'BarCheck
+                                         'origin location))))
 
 (define-public (glue-mm-rest-texts music)
   "Check if we have R1*4-\\markup { .. }, and if applicable convert to
 a property set for MultiMeasureRestNumber."
-  
   (define (script-to-mmrest-text script-music)
     "Extract 'direction and 'text   from SCRIPT-MUSIC, and transform into property sets."
-    (let ((text (ly:music-property script-music 'text))
-         (dir  (ly:music-property script-music 'direction))
-         (p    (make-music-by-name 'MultiMeasureTextEvent)))
+    (let ((dir (ly:music-property script-music 'direction))
+         (p   (make-music 'MultiMeasureTextEvent
+                          'text (ly:music-property script-music 'text))))
       (if (ly:dir? dir)
          (set! (ly:music-property p 'direction) dir))
-      (set! (ly:music-property p 'text) text)
       p))
-  
   (if (eq? (ly:music-property music 'name) 'MultiMeasureRestMusicGroup)
       (let* ((text? (lambda (x) (memq 'script-event (ly:music-property x 'types))))
             (es (ly:music-property  music 'elements))
@@ -278,14 +261,12 @@ a property set for MultiMeasureRestNumber."
 
 
 (define-public (make-property-set sym val)
-  (let ((m (make-music-by-name 'PropertySet)))
-    (set! (ly:music-property m 'symbol) sym)
-    (set! (ly:music-property m 'value) val)
-    m))
+  (make-music 'PropertySet
+             'symbol sym
+             'value val))
 
 (define-public (make-ottava-set octavation)
-  (let ((m (make-music-by-name 'ApplyContext)))
-    
+  (let ((m (make-music 'ApplyContext)))
     (define (ottava-modify context)
       "Either reset centralCPosition to the stored original, or remember
 old centralCPosition, add OCTAVATION to centralCPosition, and set
@@ -337,7 +318,7 @@ Rest can contain a list of beat groupings
                  (context-spec-music (make-property-set 'rehearsalMark label)
                                      'Score)
                  #f))
-        (ev (make-music-by-name 'MarkEvent))
+        (ev (make-music 'MarkEvent))
         (ch (make-event-chord (list ev))))
     (if set
        (make-sequential-music (list set ch))
@@ -349,25 +330,21 @@ Rest can contain a list of beat groupings
   (ly:export (apply make-time-signature-set `(,num ,den . ,rest))))
 
 (define-public (make-penalty-music pen)
- (let ((m (make-music-by-name 'BreakEvent)))
-   (set! (ly:music-property m 'penalty) pen)
-   m))
+  (make-music 'BreakEvent
+             'penalty pen))
 
 (define-public (make-articulation name)
-  (let ((m (make-music-by-name 'ArticulationEvent)))
-    (set! (ly:music-property m 'articulation-type) name)
-    m))
+  (make-music 'ArticulationEvent
+             'articulation-type name))
 
 (define-public (make-lyric-event string duration)
-  (let ((m (make-music-by-name 'LyricEvent)))
-    (set! (ly:music-property m 'duration) duration)
-    (set! (ly:music-property m 'text) string)
-    m))
+  (make-music 'LyricEvent
+             'duration duration
+             'text string))
 
 (define-public (make-span-event type spandir)
-  (let ((m (make-music-by-name type)))
-    (set! (ly:music-property m 'span-direction) spandir)
-    m))
+  (make-music type
+             'span-direction spandir))
 
 (define-public (set-mus-properties! m alist)
   "Set all of ALIST as properties of M." 
@@ -424,7 +401,7 @@ Rest can contain a list of beat groupings
     m))
 
 (define-public (empty-music)
-  (ly:export (make-music-by-name 'Music)))
+  (ly:export (make-music 'Music)))
 ;;;
 
 ; Make a function that checks score element for being of a specific type. 
@@ -454,7 +431,7 @@ Rest can contain a list of beat groupings
 (define-public (smart-bar-check n)
   "Make         a bar check that checks for a specific bar number. 
 "
-  (let ((m (make-music-by-name 'ApplyContext)))
+  (let ((m (make-music 'ApplyContext)))
     (define (checker tr)
       (let* ((bn (ly:context-property tr 'currentBarNumber)))
        (if (= bn n)
index 0ba7529d0162202a3d109b2f71070acecf087efe..f27fe34a94d4651d400e75fd9e104f0405168ddd 100644 (file)
@@ -193,7 +193,7 @@ Voice-state objects
   (set! noticed (acons (ly:context-id context) lst noticed)))
 
 (define-public (make-part-combine-music music-list)
-  (let ((m (make-music-by-name 'PartCombineMusic))
+  (let ((m (make-music 'PartCombineMusic))
        (m1 (context-spec-music (car music-list) 'Voice "one"))
        (m2 (context-spec-music (cadr music-list) 'Voice "two")))
     (set! (ly:music-property m 'elements) (list m1 m2))
@@ -453,7 +453,7 @@ the mark when there are no spanners active."
                                   (cons (cons now (sign (ly:pitch-steps pitch))) acc))
              (generate-split-list (cdr event-list) acc)))))
   (set! noticed '())
-  (let* ((m (make-music-by-name 'AutoChangeMusic))
+  (let* ((m (make-music 'AutoChangeMusic))
         (context (ly:run-translator music part-combine-listener))
         (evs (last-pair noticed))
         (split (reverse! (generate-split-list (if (pair? evs)