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
PACKAGE_NAME=LilyPond
MAJOR_VERSION=2
MINOR_VERSION=9
-PATCH_LEVEL=7
+PATCH_LEVEL=8
MY_PATCH_LEVEL=
--- /dev/null
+\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]
+}
+
+
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;
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);
::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
{
{
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 ());
}
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)
{
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.
vector<Rhythmic_tuple> stopped_durations_;
Moment now_;
Spanner *spacing_;
-
+ Music *start_section_;
+
TRANSLATOR_DECLARATIONS (Spacing_engraver);
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_)
{
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_)
"bookkeeping of shortest starting and playing notes ",
/* create */ "SpacingSpanner",
- /* accept */ "",
+ /* accept */
+ "spacing-section-event ",
/* read */
"currentMusicalColumn "
"currentCommandColumn "
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;
"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",
%crescpoco = \set crescendoText = "cresc. poco a poco"
%decresc = \set crescendoText = "decr."
%dim = \set crescendoText = "dim."
+
+newSpacingSection = #(make-event-chord (list (make-music 'SpacingSectionEvent)))
(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.")
(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.
(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.")