2 stem-grav.cc -- implement Stem_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "stem-engraver.hh"
10 #include "note-head.hh"
12 #include "musical-request.hh"
13 #include "duration-convert.hh"
15 #include "stem-tremolo.hh"
16 #include "staff-info.hh"
17 #include "translator-group.hh"
19 Stem_engraver::Stem_engraver()
24 default_abbrev_i_ = 16;
29 Stem_engraver::do_creation_processing ()
31 SCM prop = get_property ("abbrev", 0);
32 if (gh_number_p(prop))
34 default_abbrev_i_ = gh_scm2int (prop);
39 Stem_engraver::acknowledge_element(Score_element_info i)
41 if (Rhythmic_head * h = dynamic_cast<Rhythmic_head *> (i.elem_l_))
46 Rhythmic_req * r = dynamic_cast <Rhythmic_req *> (i.req_l_);
47 int duration_log = r->duration_.durlog_i_;
51 stem_p_->flag_i_ = duration_log;
58 hmm, which isn't so bad?
60 int t = abbrev_req_l_->type_i_;
62 t = default_abbrev_i_;
64 default_abbrev_i_ = t;
68 abbrev_p_ = new Stem_tremolo;
69 announce_element (Score_element_info (abbrev_p_, abbrev_req_l_));
70 abbrev_p_->abbrev_flags_i_ =intlog2 (t) - (duration_log>? 2);
74 // must give the request, to preserve the rhythmic info.
75 announce_element (Score_element_info (stem_p_, r));
78 if (stem_p_->flag_i_ != duration_log)
80 r->warning (_f ("Adding note head to incompatible stem (type = %d)", 1 << stem_p_->flag_i_));
83 stem_p_->add_head (h);
88 Stem_engraver::do_pre_move_processing()
92 abbrev_p_->set_stem (stem_p_);
93 typeset_element (abbrev_p_);
99 Translator_group* which;
100 SCM prop = get_property ("stemLeftBeamCount", &which);
101 if (gh_number_p(prop))
103 stem_p_->beams_i_drul_[LEFT] = gh_scm2int (prop);
104 ((Translator_group*)which)->set_property ("stemLeftBeamCount", SCM_UNDEFINED);
106 prop = get_property ("stemRightBeamCount", &which);
107 if (gh_number_p(prop))
109 stem_p_->beams_i_drul_[RIGHT] = gh_scm2int (prop);
110 ((Translator_group*)which)->set_property ("stemRightBeamCount", SCM_UNDEFINED);
113 // UGH. Should mark non-forced instead.
114 SCM dir = stem_p_->get_elt_property ("direction");
115 if (gh_number_p (dir) && gh_int2scm (dir))
117 stem_p_->set_elt_property ("dir-forced", SCM_BOOL_T);
121 typeset_element(stem_p_);
128 Stem_engraver::do_try_music (Music* r)
130 if (Tremolo_req* a = dynamic_cast <Tremolo_req *> (r))
139 ADD_THIS_TRANSLATOR(Stem_engraver);