]> git.donarmstrong.com Git - lilypond.git/commitdiff
*** empty log message ***
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 5 Jun 2006 13:57:04 +0000 (13:57 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 5 Jun 2006 13:57:04 +0000 (13:57 +0000)
12 files changed:
ChangeLog
VERSION
input/regression/spacing-section.ly [new file with mode: 0644]
lily/include/input.hh
lily/include/paper-column.hh
lily/input.cc
lily/music-iterator.cc
lily/paper-column.cc
lily/spacing-engraver.cc
lily/spacing-spanner.cc
ly/spanners-init.ly
scm/define-music-types.scm

index d5c84f3ce22fdfdd01f660321629d634261d4d2a..d229094c972c4f1e33c2a4f46db761adf42a5cd2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,29 @@
 
 2006-06-05  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
+       * input/regression/spacing-section.ly: new file.
+
+       * lily/input.cc (programming_error): new function.
+
+       * lily/spacing-engraver.cc (try_music): new function. Accept
+       spacing-section-event
+
+       * lily/spacing-spanner.cc (set_springs): take slices of all
+       columns for spacing.
+
+       * lily/include/paper-column.hh (class Paper_column): add
+       Paper_column::compare.
+
+       * ly/spanners-init.ly (newSpacingSection): add newSpacingSection.
+
+       * scm/define-music-types.scm (music-descriptions): add
+       SpacingSectionEvent
+
+       * lily/music-iterator.cc (report_event): use programming_error for
+       sending non-event error.
+
+       * lily/input.cc (programming_error): new function
+
        * buildscripts/output-distance.py (main): use compare-XXX for
        compare files.
        (main): --threshold option, default at 0.30
diff --git a/VERSION b/VERSION
index 404fb35970dc01d8d6e6af43d0efada7ef663f42..56bf762d10c17b943c7536e6dafd84053a4e119b 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1,6 +1,6 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=2
 MINOR_VERSION=9
-PATCH_LEVEL=7
+PATCH_LEVEL=8
 MY_PATCH_LEVEL=
 
diff --git a/input/regression/spacing-section.ly b/input/regression/spacing-section.ly
new file mode 100644 (file)
index 0000000..1b6f5d7
--- /dev/null
@@ -0,0 +1,26 @@
+\header {
+
+  texidoc = "New sections for spacing can be started with
+@code{\newSpacingSection}. In this example, a section is started at
+the 4/16, and a 16th in the second section takes as much space as a
+8th in first section."
+
+}
+
+\paper
+{
+  ragged-right = ##t
+  }
+\version "2.9.8"
+\relative {
+  \time 2/4
+  c4 c8 c 
+  c8 c c4 c16[ c c8] c4
+
+  \newSpacingSection
+  \time 4/16
+  c8[ c16 c]
+  c16[ c  c8]
+} 
+  
+
index e1b4169841000f48b806fdfd0a81cd8c3fe0c175..e211dc15c3f5dda4b323797ef77e76d55580c1e2 100644 (file)
@@ -27,14 +27,17 @@ public:
   char const *end () const;
 
   void set (Source_file *, char const *, char const *);
-  void warning (string) const; // should use member func?
+  void warning (string) const;
+  void programming_error (string) const;
   void non_fatal_error (string) const;
   void error (string) const;
   void message (string) const;
   void set_spot (Input const &);
   void step_forward ();
   void set_location (Input const &, Input const &);
+
   Input spot () const;
+
   string location_string () const;
   string line_number_string () const;
   string file_string ()const;
index 6ef3daacc4cdf60e2061d2c942afff5941fb0459..d21828c374ee5c5105b13ee98c97b99e3282f988 100644 (file)
@@ -30,6 +30,8 @@ public:
   virtual Paper_column *get_column () const;
   virtual System *get_system () const;
 
+  static int compare (Grob * const &a,
+                     Grob * const &b);
   int get_rank () const { return rank_; }
   void set_rank (int);
 
index 1379f1c7b579ed76f3937f4c84ae891149668882..5ab2be4c7864830cd5d2b6f196c58ec09554f86b 100644 (file)
@@ -75,6 +75,15 @@ Input::message (string s) const
   ::message (s);
 }
 
+
+void
+Input::programming_error (string s) const
+{
+  message (_f ("programming error: %s", s.c_str ()));
+  message (_ ("continuing, cross fingers") + "\n");
+}
+
+
 void
 Input::warning (string s) const
 {
index fcfd2fc1f45cfe31923730b7d957eb49b5dde9dc..83838427df32aac99a381dd0b2f157bff6b6faaa 100644 (file)
@@ -165,8 +165,11 @@ Music_iterator::report_event (Music *m)
 {
   descend_to_bottom_context ();
 
+  /*
+    FIXME: then don't do it. 
+  */
   if (!m->is_mus_type ("event"))
-    m->origin ()->warning (_f ("Sending non-event to context"));
+    m->origin ()->programming_error (_f ("Sending non-event to context"));
 
   m->send_to_context (get_outlet ());
 }
index 525dca36b89fca5d7ee639d354f3d774b8d956fd..fccdba6e7f694d4549f0008438126e17fbc6ba0f 100644 (file)
@@ -65,6 +65,14 @@ Paper_column::Paper_column (Paper_column const &src, int count)
   rank_ = src.rank_;
 }
 
+int
+Paper_column::compare (Grob * const &a,
+                      Grob * const &b)
+{
+  return sign (dynamic_cast<Paper_column*> (a)->rank_
+              - dynamic_cast<Paper_column*> (b)->rank_);
+}
+
 Moment
 Paper_column::when_mom (Grob *me)
 {
index d567cb6ebc279d53e1f55ed741b7c9020bf2cf22..b3ca5753932cb2253c2cc3e3d385bc8d18c61940 100644 (file)
@@ -32,9 +32,21 @@ struct Rhythmic_tuple
   static int time_compare (Rhythmic_tuple const &, Rhythmic_tuple const &);
 };
 
-/*
-  TODO: allow starting & stopping of spacing regions.
-*/
+inline int
+compare (Rhythmic_tuple const &a, Rhythmic_tuple const &b)
+{
+  return Rhythmic_tuple::time_compare (a, b);
+}
+
+int
+Rhythmic_tuple::time_compare (Rhythmic_tuple const &h1,
+                             Rhythmic_tuple const &h2)
+{
+  return (h1.end_ - h2.end_).main_part_.sign ();
+}
+
+/****************************************************************/
+
 /*
   Acknowledge rhythmic elements, for initializing spacing fields in
   the columns.
@@ -46,7 +58,8 @@ class Spacing_engraver : public Engraver
   vector<Rhythmic_tuple> stopped_durations_;
   Moment now_;
   Spanner *spacing_;
-
+  Music *start_section_;
+  
   TRANSLATOR_DECLARATIONS (Spacing_engraver);
 
 protected:
@@ -57,39 +70,55 @@ protected:
   void start_translation_timestep ();
   void stop_translation_timestep ();
   void process_music ();
+  
   virtual void finalize ();
+  virtual bool try_music (Music *m);
+
+  void start_spanner ();
+  void stop_spanner ();
 };
 
-inline int
-compare (Rhythmic_tuple const &a, Rhythmic_tuple const &b)
+Spacing_engraver::Spacing_engraver ()
 {
-  return Rhythmic_tuple::time_compare (a, b);
+  spacing_ = 0;
+  start_section_ = 0;
 }
 
-int
-Rhythmic_tuple::time_compare (Rhythmic_tuple const &h1,
-                             Rhythmic_tuple const &h2)
+bool
+Spacing_engraver::try_music (Music *m)
 {
-  return (h1.end_ - h2.end_).main_part_.sign ();
+  start_section_ = m;
+  return true;  
 }
 
-Spacing_engraver::Spacing_engraver ()
+void
+Spacing_engraver::process_music ()
 {
-  spacing_ = 0;
+  if (start_section_ && spacing_)
+    stop_spanner ();
+  
+  if (!spacing_)
+    start_spanner ();
 }
 
 void
-Spacing_engraver::process_music ()
+Spacing_engraver::start_spanner ()
 {
-  if (!spacing_)
-    {
-      spacing_ = make_spanner ("SpacingSpanner", SCM_EOL);
-      spacing_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
-    }
+  assert (!spacing_);
+
+  spacing_ = make_spanner ("SpacingSpanner", SCM_EOL);
+  spacing_->set_bound (LEFT,
+                      unsmob_grob (get_property ("currentCommandColumn")));
 }
 
 void
 Spacing_engraver::finalize ()
+{
+  stop_spanner ();
+}
+
+void
+Spacing_engraver::stop_spanner ()
 {
   if (spacing_)
     {
@@ -186,8 +215,11 @@ Spacing_engraver::stop_translation_timestep ()
 void
 Spacing_engraver::start_translation_timestep ()
 {
+  start_section_ = 0;
+
   now_ = now_mom ();
   stopped_durations_.clear ();
+  
   while (playing_durations_.size () && playing_durations_.front ().end_ < now_)
     playing_durations_.delmin ();
   while (playing_durations_.size () && playing_durations_.front ().end_ == now_)
@@ -203,7 +235,8 @@ ADD_TRANSLATOR (Spacing_engraver,
                "bookkeeping of shortest starting and playing notes  ",
 
                /* create */ "SpacingSpanner",
-               /* accept */ "",
+               /* accept */
+               "spacing-section-event ",
                /* read */
                "currentMusicalColumn "
                "currentCommandColumn "
index 4c301b6a648ff2cd293e8237b201695863d669cc..5aca1009612d5ffd9a3ac2fc80147a9faaad8000 100644 (file)
@@ -56,13 +56,20 @@ MAKE_SCHEME_CALLBACK (Spacing_spanner, set_springs, 1);
 SCM
 Spacing_spanner::set_springs (SCM smob)
 {
-  Grob *me = unsmob_grob (smob);
+  Spanner *me = unsmob_spanner (smob);
 
   /*
     can't use get_system() ? --hwn.
   */
   vector<Grob*> all (get_root_system (me)->columns ());
+  vsize start = binary_search (all, (Grob*)me->get_bound (LEFT),
+                              &Paper_column::compare);
+  vsize end = binary_search (all, (Grob*) me->get_bound (RIGHT),
+                            &Paper_column::compare);
 
+  all = vector<Grob*>::vector<Grob*> (all.begin () + start,
+                                     all.begin () + end + 1);
+  
   set_explicit_neighbor_columns (all);
 
   Spacing_options options;
@@ -489,15 +496,17 @@ ADD_INTERFACE (Spacing_spanner, "spacing-spanner-interface",
               "head width) A 16th note is followed by 0.5 note head width. The\n"
               "quarter note is followed by  3 NHW, the half by 4 NHW, etc.\n",
 
+              
               "average-spacing-wishes "
+              "base-shortest-duration "
+              "common-shortest-duration "
               "grace-space-factor "
+              "packed-spacing "
+              "shortest-duration-space "
               "spacing-increment "
-              "base-shortest-duration "
               "strict-note-spacing "
-              "shortest-duration-space "
-              "common-shortest-duration "
               "uniform-stretching "
-              "packed-spacing "
+              
               );
 
 ADD_INTERFACE (Spacing_interface, "spacing-interface",
index d2493903c99f186582b674e26fe3e1c6718505ed..43d0ef0cb6ea6467927191ad64c25f83a68c39dc 100644 (file)
@@ -91,3 +91,5 @@ sostenutoUp = #(make-span-event 'SostenutoEvent STOP)
 %crescpoco = \set crescendoText = "cresc. poco a poco"
 %decresc = \set crescendoText = "decr."
 %dim = \set crescendoText = "dim."
+
+newSpacingSection = #(make-event-chord (list (make-music 'SpacingSectionEvent)))
index 69c654b019467e3c24515a3f663f75ddb01c3802..fe31b3d40f2177fd9371495cbdb4760965e1c912 100644 (file)
@@ -160,7 +160,12 @@ Syntax: @var{note}\\cr
        (types . (general-music extender-event event))
        ))
 
-    
+    (Event
+     . (
+       (description .  "Atomic music event.")
+       (types . (general-music event))
+       ))
+        
     (EventChord
      . (
        (description .  "Internally used to group a set of events.")
@@ -414,12 +419,6 @@ goes down).")
        (description . "Ties for starting a second volta bracket.")
        (types . (general-music event repeat-tie-event))
        ))
-    (Event
-     . (
-       (description .  "Atomic music event.")
-       (types . (general-music event))
-       ))
-    
     (RestEvent
      . (
        (description .  "A Rest. 
@@ -594,6 +593,11 @@ Syntax: @code{s}@var{duration}")
 
        (types . (general-music event rhythmic-event skip-event))
        ))
+
+    (SpacingSectionEvent
+     . ((description . "Start a new spacing section")
+       (types . (general-music event spacing-section-event))))
+     
     (SpanEvent
      . (
        (description .  "Event for anything that is started at a different time than stopped.")