]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/define-grobs.scm (all-grob-descriptions): default to ramp.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 17 Jul 2003 09:12:11 +0000 (09:12 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 17 Jul 2003 09:12:11 +0000 (09:12 +0000)
* scripts/convert-ly.py (FatalConversionError.conv): add cluster rule.

* lily/cluster.cc (brew_molecule): examine ClusterSpannerBeacons
to get positions.

* lily/cluster-engraver.cc: rewrite: catch cluster-note-events,
make ClusterSpannerBeacon to record Y positions. This removes the
need to switch off notes. Use \apply #notes-to-clusters { .. }  to
make cluster-note-events.

ChangeLog
Documentation/user/refman.itely
input/regression/cluster.ly
lily/cluster-engraver.cc
lily/cluster.cc
scm/define-grobs.scm
scm/define-music-types.scm
scm/music-functions.scm
scripts/convert-ly.py

index 466d64f5df1c8ee70f513da9ad55be7597dce87a..d661053f7a13194811ade38e61d242329959b890 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2003-07-17  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * scm/define-grob-interfaces.scm (cluster-beacon-interface): add
+       cluster-beacon-interface
+
+       * scm/define-grobs.scm (all-grob-descriptions): default to ramp.
+
+       * scripts/convert-ly.py (FatalConversionError.conv): add cluster rule.
+
+       * ly/spanners-init.ly (stopGroup): remove start/stopCluster.
+
+       * lily/cluster.cc (brew_molecule): examine ClusterSpannerBeacons
+       to get positions.
+
+       * lily/cluster-engraver.cc: rewrite: catch cluster-note-events,
+       make ClusterSpannerBeacon to record Y positions. This removes the
+       need to switch off notes. Use \apply #notes-to-clusters { .. }  to
+       make cluster-note-events.
+
 2003-07-17  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * configure.in: Use lily/main.cc as identifying source file.
index c04dfb9b8776dfc3fd73946e8a0afaa21adb2854..35aeb84c1b25c6f6d909fa1805810a1a1219751e 100644 (file)
@@ -6595,15 +6595,12 @@ reasonable to specify a cluster as the envelope of a set of notes.
 
 @syntax
 
-A cluster is engraved as the envelope of a set of notes. The starting
-note is marked with @code{\startCluster}, and the ending note with
-@code{\stopCluster}, e.g.,
-
-@example
-  c4-\startCluster
-     ...
-  f4-\stopCluster 
-@end example
+A cluster is engraved as the envelope of a set of cluster-notes. This
+is achieved by applying the function @code{notes-to-cluster} to a
+sequence of chords, eg.
+@lilypond[relative 2]
+    \apply #notes-to-cluster {  << c e >> <<b f'>>  }
+@end lilypond
 
 The following example (from
 @inputfileref{input/regression,cluster.ly}) shows what the result
index ece5d6f3bd346ab7cabcb7b6c21af2545927b5e9..1daceec9d79ac73b4f01780524ea4bdafd73ca70 100644 (file)
@@ -5,23 +5,16 @@ notes is to be played."
 }
 
 fragment =\notes \relative c' {
-         c4 f4 a4 <<e d'>>4
+         c4 f4 <<e d'>>4
          <<g a>>8 <<e a>> a4 c2 <<d b>>4 e4 
-         c4 a4 f4 g4 a4 }
+         c4 }
 
 \score {
  \notes <
      \context Staff = SA \fragment
-     \context Staff = SB
-       \context Voice <
-          \fragment
-          { s2 \hideNotes
-            s4-\startCluster
-            s1*2
-            s4-\stopCluster
-           \unHideNotes
-       } >
+     \context Staff = SB \apply #notes-to-clusters \fragment
      >
+ \paper { raggedright = ##t }
 }
 
 
index 92162413191e13c4ceca3be5a2f22f58039c566a..e0cdf1b36adda32ed0616c12a3752574f8894b9a 100644 (file)
@@ -104,15 +104,16 @@ Cluster_spanner_engraver::process_music ()
          pmin = pmin <? p;
        }
       
-      Item *it = new Item (get_property ("ClusterSpannerBeacon"));
-      it->set_grob_property ("positions", scm_cons (gh_int2scm (pmin),
-                                                  gh_int2scm (pmax)));
-      
+      beacon_ = new Item (get_property ("ClusterSpannerBeacon"));
+      beacon_->set_grob_property ("positions",
+                                 scm_cons (gh_int2scm (pmin),
+                                           gh_int2scm (pmax)));
+      announce_grob (beacon_, cluster_notes_[0]->self_scm ());
     }
 
   if (beacon_ && !spanner_)
     {    
-      spanner_ = new Spanner (get_property ("Cluster"));
+      spanner_ = new Spanner (get_property ("ClusterSpanner"));
       announce_grob (spanner_, cluster_notes_[0]->self_scm ());
     }
   
@@ -145,8 +146,9 @@ Cluster_spanner_engraver::acknowledge_grob (Grob_info info)
 
 ENTER_DESCRIPTION(Cluster_spanner_engraver,
 /* descr */    "Engraves a cluster using Spanner notation ",
-/* creats*/    "Cluster",
+/* creats*/    "ClusterSpanner ClusterSpannerBeacon",
 /* accepts */  "cluster-note-event abort-event",
 /* acks  */    "note-column-interface",
 /* reads */    "",
 /* write */    "");
+
index c86adfdd84cc90209ac56363368e68ef0083fc7d..483c4363d47a7a956cb463fcb1f532dfba13f757 100644 (file)
@@ -10,8 +10,8 @@
 */
 
 #include <stdio.h>
+
 #include "cluster.hh"
-#include "grob.hh"
 #include "spanner.hh"
 #include "item.hh"
 #include "pitch.hh"
 #include "box.hh"
 #include "interval.hh"
 #include "paper-def.hh"
-#include "paper-column.hh"
-#include "note-column.hh"
+#include "warn.hh"
+
 
 /*
- * TODO: Add support for cubic spline segments.
+   TODO: Add support for cubic spline segments.
+
  */
 Molecule
 brew_cluster_piece (Grob *me, Array<Offset> bottom_points, Array<Offset> top_points)
@@ -47,13 +48,16 @@ brew_cluster_piece (Grob *me, Array<Offset> bottom_points, Array<Offset> top_poi
 
   SCM shape_scm = me->get_grob_property ("style");
   String shape;
+
   if (gh_symbol_p (shape_scm))
     {
       shape = ly_symbol2string (shape_scm);
     }
   else
     {
-      shape = "leftsided-stairs";
+      programming_error ("#'style should be symbol.");
+      me->suicide();
+      return  Molecule();
     }
 
 
@@ -162,6 +166,13 @@ Cluster::brew_molecule (SCM smob)
 
   Real left_coord = left_bound->relative_coordinate (common, X_AXIS);
 
+  Real unit = Staff_symbol_referencer::staff_space (me) *0.5;
+
+  /*
+    TODO: should we move the cluster a little to the right to be in
+    line with the center of the note heads?
+    
+   */
   for (SCM s = cols; gh_pair_p (s); s = ly_cdr (s))
     {
       Grob * col = unsmob_grob (ly_car (s));
@@ -174,8 +185,8 @@ Cluster::brew_molecule (SCM smob)
                   gh_scm2int (gh_cdr (posns)));
 
       Real x = col->relative_coordinate (common, X_AXIS) - left_coord;
-      bottom_points.push (Offset (x, s[DOWN] *0.5));
-      top_points.push (Offset (x, s[UP] * 0.5));
+      bottom_points.push (Offset (x, s[DOWN] *unit));
+      top_points.push (Offset (x, s[UP] * unit));
     }
 
   /*
@@ -201,8 +212,8 @@ Cluster::brew_molecule (SCM smob)
 
              Real x = right_bound->relative_coordinate (common,X_AXIS) - left_coord;
              
-             bottom_points.insert (Offset (x, s[DOWN] * 0.5),0);
-             top_points.insert (Offset (x, s[UP] * 0.5),0);
+             bottom_points.insert (Offset (x, s[DOWN] * unit),0);
+             top_points.insert (Offset (x, s[UP] * unit),0);
            }
        }
     }
index b893f3b1d647f3a49651ba16a893772518c41297..08a37a0f7778e3a2b163348feb46fed7c7cd7071 100644 (file)
        (meta . ((interfaces . (cluster-beacon-interface item-interface))))
        ))
     
-    (Cluster
+    (ClusterSpanner
      . (
        (molecule-callback . ,Cluster::brew_molecule)
        (spacing-procedure . ,Spanner::set_spacing_rods)                
        (minimum-length . 0.0)
        (padding . 0.25)
-       (shape . leftsided-stairs)
+       (style . ramp)
        (meta . ((interfaces . (cluster-interface spanner-interface))))
        ))
 
index 1ff1c129ba75092debc63894aba8ab1d70ab0d7e..e23324770ca8560d707255c9819ced676e6582a1 100644 (file)
@@ -119,13 +119,17 @@ c8-[ c c-] c8")
 
        (internal-class-name . "Event")
        (types . (general-music event busy-playing-event))
-       )) 
+       ))
+    
     (ClusterNoteEvent
      . (
        (description .  "A note that is part of a cluster.")
        (internal-class-name . "Event")
-       (types . (general-music note-event cluster-note-event melodic-event rhythmic-event event))
+
+       ; not a note-event, to ensure that Note_engraver doesn't eat it. 
+       (types . (general-music cluster-note-event melodic-event rhythmic-event event))
        ))
+    
     (ContextSpeccedMusic
      . (
        (description .  "Interpret the argument music within a specific context.")
@@ -133,6 +137,7 @@ c8-[ c c-] c8")
        (internal-class-name . "Music_wrapper")
        (types . (context-specification general-music music-wrapper-music))
        ))
+    
     (CrescendoEvent
      . (
    (description .  "Begins or ends a crescendo.  Syntax: @var{note}\\cr
@@ -390,6 +395,7 @@ SYNTAX
        
        (types . (general-music simultaneous-music))
        ))
+    
     (SlurEvent
      . (
        (description . "Start or end slur. Syntax NOTE(  and )NOTE")
index 67056ef8597cab9769624ac3d35ef911a767e0b3..2ffc50f9514e76a475d6ec65d5489ab6fbe8f2ed 100644 (file)
@@ -90,7 +90,7 @@
             cn)
       music))
 
-(define-public (notes-to-cluster music)
+(define-public (notes-to-clusters music)
   (music-map note-to-cluster music))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
index 8323d21d124dcbd4f56728e0c11cd9611d0b16c5..e9bbe72dd5338c0b6c8f8ff8608466887325f35a 100644 (file)
@@ -1225,6 +1225,20 @@ if 1:
        conversions.append (((1,7,23), conv,"barNonAuto -> automaticBars"))
        
 
+if 1:
+       def conv(str):
+               if re.search( r'-(start|stop)Cluster', str):
+                       sys.stderr.write ("""Cluster syntax has been changed.
+Please refer to the manual for details, and convert manually.
+""")
+                       
+                       raise FatalConversionError()
+
+               return str
+       
+       conversions.append (((1,7,24), conv,"cluster syntax"))
+
+
 
 ################################
 #      END OF CONVERSIONS