4 (c) 1997--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "rhythmic-head.hh"
11 #include "engraver.hh"
13 #include "side-position-interface.hh"
14 #include "script-interface.hh"
16 #include "note-column.hh"
17 #include "duration.hh"
19 class Drum_notes_engraver : public Engraver
21 Link_array<Item> notes_;
22 Link_array<Item> dots_;
23 Link_array<Item> scripts_;
24 Link_array<Music> events_;
27 TRANSLATOR_DECLARATIONS (Drum_notes_engraver);
30 virtual bool try_music (Music *ev);
31 void process_music ();
32 DECLARE_ACKNOWLEDGER (stem);
33 DECLARE_ACKNOWLEDGER (note_column);
34 void stop_translation_timestep ();
37 Drum_notes_engraver::Drum_notes_engraver ()
42 Drum_notes_engraver::try_music (Music *m)
44 if (m->is_mus_type ("note-event"))
49 else if (m->is_mus_type ("busy-playing-event"))
50 return events_.size ();
56 Drum_notes_engraver::process_music ()
59 for (int i = 0; i < events_.size (); i++)
62 tab = get_property ("drumStyleTable");
64 Music *ev = events_[i];
65 Item *note = make_item ("NoteHead", ev->self_scm ());
67 Duration dur = *unsmob_duration (ev->get_property ("duration"));
69 note->set_property ("duration-log", scm_from_int (dur.duration_log ()));
73 Item *d = make_item ("Dots", ev->self_scm ());
74 Rhythmic_head::set_dots (note, d);
77 != robust_scm2int (d->get_property ("dot-count"), 0))
78 d->set_property ("dot-count", scm_from_int (dur.dot_count ()));
80 d->set_parent (note, Y_AXIS);
85 SCM drum_type = ev->get_property ("drum-type");
89 if (scm_hash_table_p (tab) == SCM_BOOL_T)
90 defn = scm_hashq_ref (tab, drum_type, SCM_EOL);
92 if (scm_is_pair (defn))
94 SCM pos = scm_caddr (defn);
95 SCM style = scm_car (defn);
96 SCM script = scm_cadr (defn);
98 if (scm_integer_p (pos) == SCM_BOOL_T)
99 note->set_property ("staff-position", pos);
100 if (scm_is_symbol (style))
101 note->set_property ("style", style);
103 if (scm_is_string (script))
105 Item *p = make_item ("Script", ev->self_scm ());
106 make_script_from_event (p, context (), script,
109 p->set_parent (note, Y_AXIS);
110 Side_position_interface::add_support (p, note);
120 Drum_notes_engraver::acknowledge_stem (Grob_info inf)
122 for (int i = 0; i < scripts_.size (); i++)
124 Grob *e = scripts_[i];
126 if (to_dir (e->get_property ("side-relative-direction")))
127 e->set_object ("direction-source", inf.grob ()->self_scm ());
129 Side_position_interface::add_support (e, inf.grob ());
134 Drum_notes_engraver::acknowledge_note_column (Grob_info inf)
136 for (int i = 0; i < scripts_.size (); i++)
138 Grob *e = scripts_[i];
140 if (!e->get_parent (X_AXIS)
141 && Side_position_interface::get_axis (e) == Y_AXIS)
142 e->set_parent (inf.grob (), X_AXIS);
147 Drum_notes_engraver::stop_translation_timestep ()
156 #include "translator.icc"
158 ADD_ACKNOWLEDGER (Drum_notes_engraver, stem);
159 ADD_ACKNOWLEDGER (Drum_notes_engraver, note_column);
160 ADD_TRANSLATOR (Drum_notes_engraver,
161 /* doc */ "Generate noteheads.",
162 /* create */ "NoteHead Dots Script",
163 /* accept */ "note-event busy-playing-event",
164 /* read */ "drumStyleTable",