4 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "rhythmic-head.hh"
10 #include "engraver.hh"
12 #include "side-position-interface.hh"
13 #include "script-interface.hh"
15 #include "note-column.hh"
16 #include "duration.hh"
18 class Drum_notes_engraver : public Engraver
20 Link_array<Item> notes_;
21 Link_array<Item> dots_;
22 Link_array<Item> scripts_;
23 Link_array<Music> events_;
26 TRANSLATOR_DECLARATIONS (Drum_notes_engraver);
29 virtual bool try_music (Music *ev);
30 PRECOMPUTED_VIRTUAL void process_music ();
31 virtual void acknowledge_grob (Grob_info);
32 PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
35 Drum_notes_engraver::Drum_notes_engraver ()
40 Drum_notes_engraver::try_music (Music *m)
42 if (m->is_mus_type ("note-event"))
47 else if (m->is_mus_type ("busy-playing-event"))
48 return events_.size ();
54 Drum_notes_engraver::process_music ()
57 for (int i = 0; i < events_.size (); i++)
60 tab = get_property ("drumStyleTable");
62 Music *ev = events_[i];
63 Item *note = make_item ("NoteHead", ev->self_scm ());
65 Duration dur = *unsmob_duration (ev->get_property ("duration"));
67 note->set_property ("duration-log", scm_int2num (dur.duration_log ()));
71 Item *d = make_item ("Dots", ev->self_scm ());
72 Rhythmic_head::set_dots (note, d);
75 != robust_scm2int (d->get_property ("dot-count"), 0))
76 d->set_property ("dot-count", scm_int2num (dur.dot_count ()));
78 d->set_parent (note, Y_AXIS);
83 SCM drum_type = ev->get_property ("drum-type");
87 if (scm_hash_table_p (tab) == SCM_BOOL_T)
88 defn = scm_hashq_ref (tab, drum_type, SCM_EOL);
90 if (scm_is_pair (defn))
92 SCM pos = scm_caddr (defn);
93 SCM style = scm_car (defn);
94 SCM script = scm_cadr (defn);
96 if (scm_integer_p (pos) == SCM_BOOL_T)
97 note->set_property ("staff-position", pos);
98 if (scm_is_symbol (style))
99 note->set_property ("style", style);
101 if (scm_is_string (script))
103 Item *p = make_item ("Script", ev->self_scm ());
105 make_script_from_event (p, &follow,
109 if (p->get_property ("follow-into-staff"))
110 p->set_property ("staff-padding", SCM_EOL);
112 p->set_parent (note, Y_AXIS);
113 Side_position_interface::add_support (p, note);
123 Drum_notes_engraver::acknowledge_grob (Grob_info inf)
125 if (Stem::has_interface (inf.grob ()))
127 for (int i = 0; i < scripts_.size (); i++)
129 Grob *e = scripts_[i];
131 if (to_dir (e->get_property ("side-relative-direction")))
132 e->set_object ("direction-source", inf.grob ()->self_scm ());
137 e->add_dependency (inf.grob ());
138 Side_position_interface::add_support (e, inf.grob ());
141 else if (Note_column::has_interface (inf.grob ()))
143 for (int i = 0; i < scripts_.size (); i++)
145 Grob *e = scripts_[i];
147 if (!e->get_parent (X_AXIS)
148 && Side_position_interface::get_axis (e) == Y_AXIS)
150 e->set_parent (inf.grob (), X_AXIS);
157 Drum_notes_engraver::stop_translation_timestep ()
166 #include "translator.icc"
168 ADD_TRANSLATOR (Drum_notes_engraver,
169 /* descr */ "Generate noteheads.",
170 /* creats*/ "NoteHead Dots Script",
171 /* accepts */ "note-event busy-playing-event",
172 /* acks */ "stem-interface note-column-interface",
173 /* reads */ "drumStyleTable",