2 note-heads-engraver.cc -- part of GNU LilyPond
4 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "rhythmic-head.hh"
9 #include "output-def.hh"
12 #include "dot-column.hh"
13 #include "staff-symbol-referencer.hh"
15 #include "engraver.hh"
18 class Note_heads_engraver : public Engraver
20 Link_array<Item> notes_;
21 Link_array<Item> dots_;
22 Link_array<Music> note_reqs_;
25 TRANSLATOR_DECLARATIONS (Note_heads_engraver);
28 virtual bool try_music (Music *req) ;
29 virtual void process_music ();
31 virtual void stop_translation_timestep ();
34 Note_heads_engraver::Note_heads_engraver ()
39 Note_heads_engraver::try_music (Music *m)
41 if (m->is_mus_type ("note-event"))
46 else if (m->is_mus_type ("busy-playing-event"))
47 return note_reqs_.size ();
48 else if (m->is_mus_type ("start-playing-event"))
49 return note_reqs_.size ();
56 Note_heads_engraver::process_music ()
58 for (int i=0; i < note_reqs_.size (); i++)
61 Music * req = note_reqs_[i];
62 Item *note = make_item ("NoteHead", req->self_scm ());
64 Duration dur = *unsmob_duration (req->get_property ("duration"));
66 note->set_property ("duration-log", scm_int2num (dur.duration_log ()));
69 Item * d = make_item ("Dots", note->self_scm ());
70 Rhythmic_head::set_dots (note, d);
73 != robust_scm2int (d->get_property ("dot-count"), 0))
74 d->set_property ("dot-count", scm_int2num (dur.dot_count ()));
76 d->set_parent (note, Y_AXIS);
81 Pitch *pit =unsmob_pitch (req->get_property ("pitch"));
83 int pos = pit ? pit->steps () : 0;
84 SCM c0 = get_property ("middleCPosition");
85 if (ly_c_number_p (c0))
86 pos += ly_scm2int (c0);
88 note->set_property ("staff-position", scm_int2num (pos));
94 Note_heads_engraver::stop_translation_timestep ()
104 ENTER_DESCRIPTION (Note_heads_engraver,
105 /* descr */ "Generate noteheads.",
106 /* creats*/ "NoteHead Dots",
107 /* accepts */ "note-event busy-playing-event",
109 /* reads */ "middleCPosition",