Re: Gets the beam collision engraver to handle autobeams (issue4287061)

2011-03-23 Thread m...@apollinemike.com
On Mar 22, 2011, at 7:22 PM, n.putt...@gmail.com wrote:

 On 2011/03/20 12:00:34, MikeSol wrote:
 This is now fully functional.
 The only issue is that, for auto-beams, I don't have a good method yet
 for
 keeping note-heads that are part of the beam out of the covered grobs
 list.
 This is doable, though - I just have to think of the cleanest way.
 
 Before you attempt that, can you think of a cleaner way to implement the
 basic functionality which doesn't involve creating a dummy grob?
 
 Cheers,
 Neil

OK, idea:

In the auto beam engraver, every time a beam is created, a variable called 
timestep_ticker_ gets reset to 0 and increments by +1 for every timestep passed 
until the beam is completed (or junked if the beam is junked).  This is stashed 
as an internal property called timesteps-spanned.

Then, in the beam collision engraver, there is a vectorvectorGrob * * 
called covered_grobs_queue_ that stores vectors of all acknowledged grobs 
(clefs, note-heads, accidentals, etc.) for a given timestep (with an empty 
vector being assigned for a acknowledged-grobless timestep).  This vector is 
cleared at every barline (w/ appropriate deletes for the pointers to vectors).  
When an autobeam is completed (which we'll know because it will be announced 
during the same timestep as its end-grob), we look at the property 
timesteps-spanned and iterate through covered_grobs_queue_ starting from 
covered_grobs_queue_.size () - timesteps_spanned to the end, adding its 
contents to the grob array covered-grobs.

Does this seem like a good idea?  It'd need some tweaking to deal w/ covered 
interior grobs  to avoid code dups, but I think it's clean.

Cheers,
Mike
___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: Gets the beam collision engraver to handle autobeams (issue4287061)

2011-03-22 Thread n . puttock

On 2011/03/20 12:00:34, MikeSol wrote:

This is now fully functional.
The only issue is that, for auto-beams, I don't have a good method yet

for

keeping note-heads that are part of the beam out of the covered grobs

list.

This is doable, though - I just have to think of the cleanest way.


Before you attempt that, can you think of a cleaner way to implement the
basic functionality which doesn't involve creating a dummy grob?

Cheers,
Neil

http://codereview.appspot.com/4287061/

___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


Re: Gets the beam collision engraver to handle autobeams (issue4287061)

2011-03-20 Thread mtsolo

This is now fully functional.
The only issue is that, for auto-beams, I don't have a good method yet
for keeping note-heads that are part of the beam out of the covered
grobs list.  This is doable, though - I just have to think of the
cleanest way.

http://codereview.appspot.com/4287061/

___
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel


Gets the beam collision engraver to handle autobeams (issue4287061)

2011-03-19 Thread mtsolo

Reviewers: ,

Message:
This is my attempt to get the beam-collision-engraver to handle auto
beams, except...it doesn't work!  For some reason, in spite of the fact
that I'm creating AutoBeamStub grobs just fine, the acknowledger in the
beam collision engraver is not picking them up.  Can anyone suggest
where the system is broken?

Cheers,
Mike

Description:
Gets the beam collision engraver to handle autobeams

intermediary

Please review this at http://codereview.appspot.com/4287061/

Affected files:
  M lily/auto-beam-engraver.cc
  M lily/beam-collision-engraver.cc
  M scm/define-grobs.scm


Index: lily/auto-beam-engraver.cc
diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc
index  
dbff4e95a2f8803bfe87fa2b7afd18fe307422e9..e6c9b854060a21d7159c50cbfdd2728c85337487  
100644

--- a/lily/auto-beam-engraver.cc
+++ b/lily/auto-beam-engraver.cc
@@ -71,6 +71,7 @@ private:
   Moment shortest_mom_;
   Spanner *finished_beam_;
   vectorItem * *stems_;
+  Grob *stub_;

   int process_acknowledged_count_;
   Moment last_add_mom_;
@@ -147,6 +148,7 @@ Auto_beam_engraver::Auto_beam_engraver ()
   forbid_ = 0;
   process_acknowledged_count_ = 0;
   stems_ = 0;
+  stub_ = 0;
   shortest_mom_ = Moment (Rational (1, 4));
   finished_beam_ = 0;
   finished_grouping_ = 0;
@@ -217,6 +219,7 @@ Auto_beam_engraver::create_beam ()
   for (vsize i = 0; i  stems_-size (); i++)
 Beam::add_stem (beam, (*stems_)[i]);

+  beam-set_property (auto-beam-stub, stub_-self_scm ());
   announce_grob (beam, (*stems_)[0]-self_scm ());

   return beam;
@@ -225,7 +228,7 @@ Auto_beam_engraver::create_beam ()
 void
 Auto_beam_engraver::begin_beam ()
 {
-  if (stems_ || grouping_)
+  if (stems_ || grouping_ || stub_)
 {
   programming_error (already have autobeam);
   return;
@@ -251,6 +254,8 @@ Auto_beam_engraver::junk_beam ()
   stems_ = 0;
   delete grouping_;
   grouping_ = 0;
+  stub_-suicide ();
+  stub_ = 0;
   beam_settings_ = SCM_EOL;

   shortest_mom_ = Moment (Rational (1, 4));
@@ -274,6 +279,7 @@ Auto_beam_engraver::end_beam ()
   delete stems_;
   stems_ = 0;
   grouping_ = 0;
+  stub_ = 0;
   beam_settings_ = SCM_EOL;
 }

@@ -416,6 +422,8 @@ Auto_beam_engraver::acknowledge_stem (Grob_info info)
   durlog - 2,
   Stem::is_invisible (stem));
   stems_-push_back (stem);
+  if (stems_-size () == 1)
+stub_ = make_item (AutoBeamStub, (*stems_)[0]-self_scm ());
   last_add_mom_ = now;
   extend_mom_ = max (extend_mom_, now) + get_event_length (ev, now);
   if (recheck_needed)
@@ -537,6 +545,7 @@ ADD_TRANSLATOR (Auto_beam_engraver,
  @code{stemRightBeamCount}.,

 /* create */
+AutoBeamStub 
 Beam ,

 /* read */
Index: lily/beam-collision-engraver.cc
diff --git a/lily/beam-collision-engraver.cc  
b/lily/beam-collision-engraver.cc
index  
39e614c2a15dea10f3b72f88110959c35dc389a1..04fcea78dbbcdccb28fccd4ac810b0e80e061a49  
100644

--- a/lily/beam-collision-engraver.cc
+++ b/lily/beam-collision-engraver.cc
@@ -28,6 +28,7 @@ class Beam_collision_engraver : public Engraver
 protected:
   vectorGrob * active_beams_;
   vectorGrob * signaled_beams_;
+  vectorGrob * signaled_beam_stubs_;
   vectorGrob * end_beams_;
   vectorGrob * covered_grobs_;
   vectorGrob * covered_interior_grobs_;
@@ -35,6 +36,7 @@ protected:
   DECLARE_ACKNOWLEDGER (note_head);
   DECLARE_ACKNOWLEDGER (accidental);
   DECLARE_ACKNOWLEDGER (clef);
+  DECLARE_ACKNOWLEDGER (auto_beam_stub);
   DECLARE_ACKNOWLEDGER (key_signature);
   DECLARE_ACKNOWLEDGER (time_signature);
   DECLARE_ACKNOWLEDGER (beam);
@@ -47,8 +49,15 @@ public:
 void
 Beam_collision_engraver::stop_translation_timestep ()
 {
+  /*
+ Erase all beam stubs that have been suicided.
+  */
+  for (vsize i = signaled_beam_stubs_.size (); i--;)
+if (!signaled_beam_stubs_[i]-is_live ())
+  signaled_beam_stubs_.erase (signaled_beam_stubs_.begin () + i);
+
   /*
- First, for all grobs that fall to the left of a beam during
+ For all grobs that fall to the left of a beam during
  a timestep (i.e. clefs, time signatures), add these to
  the beams that are currently active.
   */
@@ -75,14 +84,25 @@ Beam_collision_engraver::stop_translation_timestep ()
  In auto beaming, beams both begin and end during the same timestep.
  This means that if there is a beam that is both in signaled_beams_ and
  end_beams_, it must either be an auto beam (likely) or a beam that
- has no notes under it (highly unlikely).  In either case, we cannot  
account

- for the grobs under this beam, and we erase it from signaled beams.
+ has no notes under it (highly unlikely).  In either case, we check for
+ a beam stub and assign covered-grobs accordingly.
   */
   for (vsize i = 0; i  end_beams_.size (); i++)
 for (vsize j = 0; j  signaled_beams_.size (); j++)
   if (end_beams_[i] == signaled_beams_[j])