X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fambitus-engraver.cc;h=ee8c1c47c507c205a4efaa0ff0426bf67fbca143;hb=7a748b8d385139bf3c68d1370a119d277d92134b;hp=adfa5b8f77103c4f7adc049d608baf2f96ed5abb;hpb=3a8bdbfb00fdc32e150baf0b6fa855677fad57dd;p=lilypond.git diff --git a/lily/ambitus-engraver.cc b/lily/ambitus-engraver.cc index adfa5b8f77..ee8c1c47c5 100644 --- a/lily/ambitus-engraver.cc +++ b/lily/ambitus-engraver.cc @@ -3,16 +3,23 @@ source file of the GNU LilyPond music typesetter - (C) 2002 Juergen Reuter + (c) 2002--2004 Juergen Reuter */ #include "engraver.hh" #include "item.hh" #include "note-head.hh" #include "staff-symbol-referencer.hh" -#include "musical-request.hh" +#include "event.hh" #include "pitch.hh" + +/* + UGH UGH UGH . + + rewrite this complely. --hwn + */ + /* * This class implements an engraver for ambitus grobs. * @@ -45,13 +52,13 @@ * * - If a piece consists of several loosely coupled sections, should * there be multiple ambitus grobs allowed, one for each section? - * Then there probably should be some "\ambitus" request added to + * Then there probably should be some "\ambitus" event added to * mudela, stating where an ambitus grob should be placed. This * ambitus grob should then represent the ambitus in the range of time - * between this "\ambitus" request and the next one (or the end of the - * piece, if there is no more such request). To be compliant with the + * between this "\ambitus" event and the next one (or the end of the + * piece, if there is no more such event). To be compliant with the * current implementation, we might implicitly assume an "\ambitus" - * request at the beginning of the piece, but then the question where + * event at the beginning of the piece, but then the question where * to put this first ambitus grob (before/after the clef?) becomes * even more urgent. * @@ -63,7 +70,7 @@ class Ambitus_engraver : public Engraver { public: -TRANSLATOR_DECLARATIONS(Ambitus_engraver); +TRANSLATOR_DECLARATIONS (Ambitus_engraver); virtual void process_music (); virtual void acknowledge_grob (Grob_info); virtual void stop_translation_timestep (); @@ -71,22 +78,22 @@ TRANSLATOR_DECLARATIONS(Ambitus_engraver); private: void create_ambitus (); - Item *ambitus_p_; - int/*bool*/ is_typeset; + Item *ambitus_; + bool is_typeset; Pitch pitch_min, pitch_max; }; Ambitus_engraver::Ambitus_engraver () { - ambitus_p_ = 0; + ambitus_ = 0; is_typeset = 0; /* * (pitch_min > pitch_max) means that pitches are not yet * initialized */ - pitch_min = Pitch (0, 0, +1); - pitch_max = Pitch (0, 0, -1); + pitch_min = Pitch (0, 0, SHARP); + pitch_max = Pitch (0, 0, FLAT); } void @@ -98,7 +105,7 @@ Ambitus_engraver::process_music () * Otherwise, if a voice begins with a rest, the ambitus grob will * be placed after the rest. */ - if (!ambitus_p_) { + if (!ambitus_) { create_ambitus (); } } @@ -106,40 +113,40 @@ Ambitus_engraver::process_music () void Ambitus_engraver::stop_translation_timestep () { - if (ambitus_p_ && !is_typeset) + if (ambitus_ && !is_typeset) { /* - * Evaluate centralCPosition not until now, since otherwise we + * Evaluate middleCPosition not until now, since otherwise we * may then oversee a clef that is defined in a staff context if - * we are in a voice context; centralCPosition would then be + * we are in a voice context; middleCPosition would then be * assumed to be 0. */ - SCM c0 = get_property ("centralCPosition"); - ambitus_p_->set_grob_property ("centralCPosition", c0); + SCM c0 = get_property ("middleCPosition"); + ambitus_->set_property ("c0-position", c0); /* * Similar for keySignature. */ SCM key_signature = get_property ("keySignature"); - ambitus_p_->set_grob_property ("keySignature", key_signature); + ambitus_->set_property ("accidentals", key_signature); - typeset_grob (ambitus_p_); - is_typeset = 1; + typeset_grob (ambitus_); + is_typeset = true; } } void Ambitus_engraver::acknowledge_grob (Grob_info info) { - Item *item = dynamic_cast (info.grob_l_); + Item *item = dynamic_cast (info.grob_); if (item) { - if (Note_head::has_interface (info.grob_l_)) + if (Note_head::has_interface (info.grob_)) { - Note_req *nr = dynamic_cast (info.music_cause ()); - if (nr) + Music *nr = info.music_cause (); + if (nr && nr->is_mus_type ("note-event")) { - Pitch pitch = *unsmob_pitch (nr->get_mus_property ("pitch")); + Pitch pitch = *unsmob_pitch (nr->get_property ("pitch")); if (Pitch::compare (pitch_min, pitch_max) > 0) // already init'd? { // not yet init'd; use current pitch to init min/max @@ -162,23 +169,23 @@ Ambitus_engraver::acknowledge_grob (Grob_info info) void Ambitus_engraver::create_ambitus () { - SCM basicProperties = get_property ("Ambitus"); - ambitus_p_ = new Item (basicProperties); is_typeset = 0; - announce_grob (ambitus_p_, SCM_EOL); + ambitus_ = make_item ("Ambitus"); + is_typeset = false; + announce_grob (ambitus_, SCM_EOL); } void Ambitus_engraver::finalize () { - if (ambitus_p_) + if (ambitus_) { if (Pitch::compare (pitch_min, pitch_max) <= 0) - { - ambitus_p_->set_grob_property ("pitch-min", - pitch_min.smobbed_copy ()); - ambitus_p_->set_grob_property ("pitch-max", - pitch_max.smobbed_copy ()); - } + { + ambitus_->set_property ("pitch-min", + pitch_min.smobbed_copy ()); + ambitus_->set_property ("pitch-max", + pitch_max.smobbed_copy ()); + } else // have not seen any pitch, so forget about the ambitus { /* @@ -186,17 +193,15 @@ Ambitus_engraver::finalize () * most probably arises from an empty voice, such as shared * global timesig/clef definitions. */ -#if 0 - ambitus_p_->warning("empty ambitus range [ignored]"); -#endif - ambitus_p_->suicide(); + ambitus_->suicide (); } } } -ENTER_DESCRIPTION(Ambitus_engraver, +ENTER_DESCRIPTION (Ambitus_engraver, /* descr */ "", /* creats*/ "Ambitus", -/* acks */ "note-head-interface", +/* accepts */ "", +/* acks */ "note-head-interface", /* reads */ "", /* write */ "");