2 head-grav.cc -- part of GNU LilyPond
4 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "rhythmic-head.hh"
9 #include "paper-def.hh"
10 #include "musical-request.hh"
12 #include "dot-column.hh"
13 #include "staff-symbol-referencer.hh"
15 #include "score-engraver.hh"
21 class Note_heads_engraver : public Engraver
23 Link_array<Item> note_p_arr_;
25 Link_array<Item> dot_p_arr_;
26 Link_array<Note_req> note_req_l_arr_;
29 TRANSLATOR_DECLARATIONS(Note_heads_engraver);
32 virtual void start_translation_timestep ();
33 virtual bool try_music (Music *req_l) ;
34 virtual void process_music ();
36 virtual void stop_translation_timestep ();
40 Note_heads_engraver::try_music (Music *m)
42 if (Note_req * n =dynamic_cast <Note_req *> (m))
44 note_req_l_arr_.push (n);
45 note_end_mom_ = note_end_mom_ >? now_mom () + m->length_mom ();
49 else if (dynamic_cast<Busy_playing_req*> (m))
51 return now_mom () < note_end_mom_;
59 Note_heads_engraver::process_music ()
61 for (int i=0; i < note_req_l_arr_.size (); i++)
63 Item *note_p = new Item (get_property ("NoteHead"));
65 Staff_symbol_referencer::set_interface (note_p);
69 Music * req = note_req_l_arr_[i];
71 Duration dur = *unsmob_duration (req->get_mus_property ("duration"));
73 note_p->set_grob_property ("duration-log", gh_int2scm (dur.duration_log ()));
77 Item * d = new Item (get_property ("Dots"));
78 Rhythmic_head::set_dots (note_p, d);
81 != gh_scm2int (d->get_grob_property ("dot-count")))
82 d->set_grob_property ("dot-count", gh_int2scm (dur.dot_count ()));
84 d->set_parent (note_p, Y_AXIS);
89 Pitch *pit =unsmob_pitch (req->get_mus_property ("pitch"));
91 int pos = pit->steps ();
92 SCM c0 = get_property ("centralCPosition");
94 pos += gh_scm2int (c0);
96 note_p->set_grob_property ("staff-position", gh_int2scm (pos));
97 if (to_boolean (get_property ("easyPlay")))
100 s[0] = (pit->notename_i_ + 2)%7 + 'a';
102 s[0] = toupper (s[0]);
103 note_p->set_grob_property ("note-character", ly_str02scm (s));
106 announce_grob (note_p,req);
107 note_p_arr_.push (note_p);
112 Note_heads_engraver::stop_translation_timestep ()
114 for (int i=0; i < note_p_arr_.size (); i++)
116 typeset_grob (note_p_arr_[i]);
118 note_p_arr_.clear ();
119 for (int i=0; i < dot_p_arr_.size (); i++)
121 typeset_grob (dot_p_arr_[i]);
125 note_req_l_arr_.clear ();
129 Note_heads_engraver::start_translation_timestep ()
135 Note_heads_engraver::Note_heads_engraver()
138 ENTER_DESCRIPTION(Note_heads_engraver,
139 /* descr */ "Generate one or more noteheads from Music of type Note_req.",
140 /* creats*/ "NoteHead Dots",