4 (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 #include "rhythmic-head.hh"
11 #include "engraver.hh"
13 #include "side-position-interface.hh"
14 #include "script-interface.hh"
16 #include "note-column.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 virtual void process_music ();
31 virtual void acknowledge_grob (Grob_info);
32 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 ();
49 else if (m->is_mus_type ("start-playing-event"))
50 return events_.size ();
57 Drum_notes_engraver::process_music ()
60 for (int i=0; i < events_.size (); i++)
63 tab = get_property ("drumStyleTable");
65 Music * ev = events_[i];
66 Item *note = make_item ("NoteHead", ev->self_scm ());
68 Duration dur = *unsmob_duration (ev->get_property ("duration"));
70 note->set_property ("duration-log", scm_int2num (dur.duration_log ()));
74 Item * d = make_item ("Dots", ev->self_scm ());
75 Rhythmic_head::set_dots (note, d);
78 != robust_scm2int (d->get_property ("dot-count"), 0))
79 d->set_property ("dot-count", scm_int2num (dur.dot_count ()));
81 d->set_parent (note, Y_AXIS);
86 SCM drum_type = ev->get_property ("drum-type");
90 if (scm_hash_table_p (tab) == SCM_BOOL_T)
91 defn = scm_hashq_ref (tab, drum_type, SCM_EOL);
93 if (ly_c_pair_p (defn))
95 SCM pos = ly_caddr (defn);
96 SCM style =ly_car (defn);
97 SCM script = ly_cadr (defn);
99 if (scm_integer_p (pos) == SCM_BOOL_T)
100 note->set_property ("staff-position", pos);
101 if (ly_c_symbol_p (style))
102 note->set_property ("style", style);
104 if (ly_c_string_p (script))
106 Item *p = make_item ("Script", ev->self_scm ());
108 make_script_from_event (p, &desc,
112 if (p->get_property ("follow-into-staff"))
113 p->set_property ("staff-padding", SCM_EOL);
116 p->set_parent (note, Y_AXIS);
117 Side_position_interface::add_support (p, note);
127 Drum_notes_engraver::acknowledge_grob (Grob_info inf)
129 if (Stem::has_interface (inf.grob_))
131 for (int i=0; i < scripts_.size (); i++)
133 Grob*e = scripts_[i];
135 if (to_dir (e->get_property ("side-relative-direction")))
136 e->set_property ("direction-source", inf.grob_->self_scm ());
141 e->add_dependency (inf.grob_);
142 Side_position_interface::add_support (e, inf.grob_);
145 else if (Note_column::has_interface (inf.grob_))
147 for (int i=0; i < scripts_.size (); i++)
149 Grob *e = scripts_[i];
151 if (!e->get_parent (X_AXIS) &&
152 Side_position_interface::get_axis (e) == Y_AXIS)
154 e->set_parent (inf.grob_, X_AXIS);
163 Drum_notes_engraver::stop_translation_timestep ()
174 ENTER_DESCRIPTION (Drum_notes_engraver,
175 /* descr */ "Generate noteheads.",
176 /* creats*/ "NoteHead Dots Script",
177 /* accepts */ "note-event busy-playing-event",
178 /* acks */ "stem-interface note-column-interface",
179 /* reads */ "drumStyleTable",