2 head-grav.cc -- part of GNU LilyPond
4 (c) 1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "rhythmic-head.hh"
9 #include "paper-def.hh"
12 #include "dot-column.hh"
13 #include "staff-symbol-referencer.hh"
15 #include "engraver.hh"
22 class Note_heads_engraver : public Engraver
24 Link_array<Item> notes_;
26 Link_array<Item> dots_;
27 Link_array<Music> note_reqs_;
30 TRANSLATOR_DECLARATIONS(Note_heads_engraver);
33 virtual void start_translation_timestep ();
34 virtual bool try_music (Music *req) ;
35 virtual void process_music ();
37 virtual void stop_translation_timestep ();
40 Note_heads_engraver::Note_heads_engraver()
45 Note_heads_engraver::try_music (Music *m)
47 if (m->is_mus_type ("note-event"))
52 else if (m->is_mus_type ("busy-playing-event"))
53 return note_reqs_.size ();
60 Note_heads_engraver::process_music ()
62 for (int i=0; i < note_reqs_.size (); i++)
64 Item *note = new Item (get_property ("NoteHead"));
66 Music * req = note_reqs_[i];
68 Duration dur = *unsmob_duration (req->get_mus_property ("duration"));
70 note->set_grob_property ("duration-log", gh_int2scm (dur.duration_log ()));
74 Item * d = new Item (get_property ("Dots"));
75 Rhythmic_head::set_dots (note, d);
78 != gh_scm2int (d->get_grob_property ("dot-count")))
79 d->set_grob_property ("dot-count", gh_int2scm (dur.dot_count ()));
81 d->set_parent (note, Y_AXIS);
82 announce_grob (d, SCM_EOL);
86 Pitch *pit =unsmob_pitch (req->get_mus_property ("pitch"));
88 int pos = pit->steps ();
89 SCM c0 = get_property ("centralCPosition");
91 pos += gh_scm2int (c0);
93 note->set_grob_property ("staff-position", gh_int2scm (pos));
94 announce_grob (note,req->self_scm());
100 Note_heads_engraver::stop_translation_timestep ()
102 for (int i=0; i < notes_.size (); i++)
104 typeset_grob (notes_[i]);
108 for (int i=0; i < dots_.size (); i++)
110 typeset_grob (dots_[i]);
117 Note_heads_engraver::start_translation_timestep ()
122 ENTER_DESCRIPTION(Note_heads_engraver,
123 /* descr */ "Generate noteheads.",
124 /* creats*/ "NoteHead Dots",
125 /* accepts */ "note-event busy-playing-event ligature-event abort-event",
127 /* reads */ "centralCPosition",