From 8a2ffb5ce9a764c76b24b8f212b48b37f2d623d1 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 17 Jul 2003 09:12:11 +0000 Subject: [PATCH] * scm/define-grobs.scm (all-grob-descriptions): default to ramp. * 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 | 19 +++++++++++++++++++ Documentation/user/refman.itely | 15 ++++++--------- input/regression/cluster.ly | 15 ++++----------- lily/cluster-engraver.cc | 14 ++++++++------ lily/cluster.cc | 29 ++++++++++++++++++++--------- scm/define-grobs.scm | 4 ++-- scm/define-music-types.scm | 10 ++++++++-- scm/music-functions.scm | 2 +- scripts/convert-ly.py | 14 ++++++++++++++ 9 files changed, 82 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index 466d64f5df..d661053f7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2003-07-17 Han-Wen Nienhuys + + * 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 * configure.in: Use lily/main.cc as identifying source file. diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index c04dfb9b87..35aeb84c1b 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -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 >> <> } +@end lilypond The following example (from @inputfileref{input/regression,cluster.ly}) shows what the result diff --git a/input/regression/cluster.ly b/input/regression/cluster.ly index ece5d6f3bd..1daceec9d7 100644 --- a/input/regression/cluster.ly +++ b/input/regression/cluster.ly @@ -5,23 +5,16 @@ notes is to be played." } fragment =\notes \relative c' { - c4 f4 a4 <>4 + c4 f4 <>4 <>8 <> a4 c2 <>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 } } diff --git a/lily/cluster-engraver.cc b/lily/cluster-engraver.cc index 9216241319..e0cdf1b36a 100644 --- a/lily/cluster-engraver.cc +++ b/lily/cluster-engraver.cc @@ -104,15 +104,16 @@ Cluster_spanner_engraver::process_music () pmin = pmin 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 */ ""); + diff --git a/lily/cluster.cc b/lily/cluster.cc index c86adfdd84..483c4363d4 100644 --- a/lily/cluster.cc +++ b/lily/cluster.cc @@ -10,8 +10,8 @@ */ #include + #include "cluster.hh" -#include "grob.hh" #include "spanner.hh" #include "item.hh" #include "pitch.hh" @@ -20,11 +20,12 @@ #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 bottom_points, Array top_points) @@ -47,13 +48,16 @@ brew_cluster_piece (Grob *me, Array bottom_points, Array 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); } } } diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index b893f3b1d6..08a37a0f77 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -244,13 +244,13 @@ (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)))) )) diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index 1ff1c129ba..e23324770c 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -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") diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 67056ef859..2ffc50f951 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -90,7 +90,7 @@ cn) music)) -(define-public (notes-to-cluster music) +(define-public (notes-to-clusters music) (music-map note-to-cluster music)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index 8323d21d12..e9bbe72dd5 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -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 -- 2.39.2