source file of the GNU LilyPond music typesetter
- (c) 1998--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1998--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "engraver-group-engraver.hh"
class Beam_engraver : public Engraver
{
+protected:
Drul_array<Span_req*> reqs_drul_;
-
- Link_array<Stem> stems_;
-
Spanner *finished_beam_p_;
Spanner *beam_p_;
void typeset_beam ();
void set_melisma (bool);
-protected:
+
+ Moment last_stem_added_at_;
+
+
+
virtual void stop_translation_timestep ();
virtual void start_translation_timestep ();
virtual void finalize ();
- virtual void create_grobs ();
+
virtual void acknowledge_grob (Grob_info);
virtual bool try_music (Music*);
virtual void process_music ();
+ virtual bool valid_start_moment();
+ virtual bool valid_end_moment ();
+
public:
TRANSLATOR_DECLARATIONS( Beam_engraver );
};
+/*
+ Hmm. this isn't necessary, since grace beams and normal beams are
+ always nested.
+ */
+bool
+Beam_engraver::valid_start_moment()
+{
+ Moment n = now_mom ();
+
+ return n.grace_part_ == Rational (0);
+}
+
+bool
+Beam_engraver::valid_end_moment()
+{
+ return last_stem_added_at_.grace_part_ == Rational(0);
+}
+
+
Beam_engraver::Beam_engraver ()
{
beam_p_ = 0;
beam_p_ = 0;
}
else if (scm_equal_p (c->get_mus_property ("span-type"),
- ly_str02scm ("beam")) == SCM_BOOL_T)
+ ly_str02scm ("beam")) == SCM_BOOL_T)
{
-
Direction d =c->get_span_dir ();
- if (d == STOP && !beam_p_)
- {
- m->origin ()->warning (_ ("can't find start of beam"));
- return false;
- }
+ if (d == STOP && !valid_end_moment())
+ return false;
+
+ if (d == START && !valid_start_moment ())
+ return false;
+
if (d == STOP)
{
SCM m = get_property ("automaticMelismata");
- SCM b = get_property ("noAutoBeaming");
- if (to_boolean (m) && to_boolean (b))
+ SCM b = get_property ("autoBeaming");
+ if (to_boolean (m) && !to_boolean (b))
{
set_melisma (false);
}
{
if (reqs_drul_[STOP])
{
- if (!beam_p_)
- reqs_drul_[STOP]->origin ()->warning (_ ("can't find start of beam"));
prev_start_req_ =0;
finished_beam_p_ = beam_p_;
finished_beam_info_p_ = beam_info_p_;
{
top_engraver ()->forbid_breaks ();
}
-}
-
-
-void
-Beam_engraver::create_grobs ()
-{
if (reqs_drul_[START])
{
if (beam_p_)
/* urg, must copy to Auto_beam_engraver too */
- announce_grob (beam_p_, reqs_drul_[START]);
+ announce_grob(beam_p_, reqs_drul_[START]->self_scm());
}
- reqs_drul_[STOP] = 0;
- reqs_drul_[START] = 0;
+
}
+
void
Beam_engraver::typeset_beam ()
{
delete finished_beam_info_p_;
finished_beam_info_p_ =0;
finished_beam_p_ = 0;
-
- reqs_drul_[STOP] = 0;
}
}
Beam_engraver::start_translation_timestep ()
{
reqs_drul_ [START] =0;
- if (beam_p_) {
- SCM m = get_property ("automaticMelismata");
- SCM b = get_property ("noAutoBeaming");
- if (to_boolean (m) && to_boolean (b)) {
- set_melisma (true);
+ reqs_drul_[STOP] = 0;
+
+ if (beam_p_)
+ {
+ SCM m = get_property ("automaticMelismata");
+ SCM b = get_property ("autoBeaming");
+ if (to_boolean (m) && !to_boolean (b))
+ {
+ set_melisma (true);
+ }
+ subdivide_beams_ = to_boolean(get_property("subdivideBeams"));
}
- subdivide_beams_ = gh_scm2bool(get_property("subdivideBeams"));
- }
}
void
{
Moment now = now_mom();
- if(bool (now.grace_part_ ) != bool (beam_start_mom_.grace_part_))
+ if (!valid_start_moment ())
return ;
Item *stem_l = dynamic_cast<Item*> (info.grob_l_);
return;
}
- int durlog = unsmob_duration (rhythmic_req->get_mus_property ("duration"))-> duration_log ();
+
+ last_stem_added_at_ = now;
+ int durlog = unsmob_duration (rhythmic_req->get_mus_property ("duration"))-> duration_log ();
if (durlog <= 2)
{
rhythmic_req->origin ()->warning (_ ("stem doesn't fit in beam"));
gh_int2scm (durlog));
Moment stem_location = now - beam_start_mom_ + beam_start_location_;
beam_info_p_->add_stem (stem_location,
- (durlog- 2) >? 1);
+ (durlog- 2) >? 0);
Beam::add_stem (beam_p_, stem_l);
}
}
/* acks */ "stem-interface rest-interface",
/* reads */ "beamMelismaBusy subdivideBeams",
/* write */ "");
+
+
+class Grace_beam_engraver : public Beam_engraver
+{
+public:
+ TRANSLATOR_DECLARATIONS(Grace_beam_engraver);
+
+protected:
+ virtual bool valid_start_moment();
+ virtual bool valid_end_moment ();
+};
+
+Grace_beam_engraver::Grace_beam_engraver()
+{
+}
+
+bool
+Grace_beam_engraver::valid_start_moment()
+{
+ Moment n = now_mom ();
+
+ return n.grace_part_ != Rational (0);
+}
+
+
+bool
+Grace_beam_engraver::valid_end_moment ()
+{
+ return beam_p_ && last_stem_added_at_.grace_part_ != Rational(0);
+}
+
+
+
+ENTER_DESCRIPTION(Grace_beam_engraver,
+/* descr */ "Handles Beam_requests by engraving Beams. If omitted, then notes will
+be printed with flags instead of beams. Only engraves beams when we
+are at grace points in time.
+",
+/* creats*/ "Beam",
+/* acks */ "stem-interface rest-interface",
+/* reads */ "beamMelismaBusy subdivideBeams",
+/* write */ "");
+