/*
drum-note-engraver.cc
- (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include <cctype>
+using namespace std;
#include "rhythmic-head.hh"
#include "engraver.hh"
#include "script-interface.hh"
#include "stem.hh"
#include "note-column.hh"
+#include "duration.hh"
class Drum_notes_engraver : public Engraver
{
- Link_array<Item> notes_;
- Link_array<Item> dots_;
- Link_array<Item> scripts_;
- Link_array<Music> events_;
+ vector<Item*> notes_;
+ vector<Item*> dots_;
+ vector<Item*> scripts_;
+ vector<Music*> events_;
public:
TRANSLATOR_DECLARATIONS (Drum_notes_engraver);
protected:
virtual bool try_music (Music *ev);
- virtual void process_music ();
- virtual void acknowledge_grob (Grob_info);
- virtual void stop_translation_timestep ();
+ void process_music ();
+ DECLARE_ACKNOWLEDGER (stem);
+ DECLARE_ACKNOWLEDGER (note_column);
+ void stop_translation_timestep ();
};
Drum_notes_engraver::Drum_notes_engraver ()
{
if (m->is_mus_type ("note-event"))
{
- events_.push (m);
+ events_.push_back (m);
return true;
}
else if (m->is_mus_type ("busy-playing-event"))
Drum_notes_engraver::process_music ()
{
SCM tab = 0;
- for (int i = 0; i < events_.size (); i++)
+ for (vsize i = 0; i < events_.size (); i++)
{
if (!tab)
tab = get_property ("drumStyleTable");
Duration dur = *unsmob_duration (ev->get_property ("duration"));
- note->set_property ("duration-log", scm_int2num (dur.duration_log ()));
+ note->set_property ("duration-log", scm_from_int (dur.duration_log ()));
if (dur.dot_count ())
{
if (dur.dot_count ()
!= robust_scm2int (d->get_property ("dot-count"), 0))
- d->set_property ("dot-count", scm_int2num (dur.dot_count ()));
+ d->set_property ("dot-count", scm_from_int (dur.dot_count ()));
d->set_parent (note, Y_AXIS);
- dots_.push (d);
+ dots_.push_back (d);
}
SCM drum_type = ev->get_property ("drum-type");
if (scm_is_string (script))
{
Item *p = make_item ("Script", ev->self_scm ());
- bool follow;
- make_script_from_event (p, &follow,
- context (), script,
+ make_script_from_event (p, context (), script,
0);
- if (p->get_property ("follow-into-staff"))
- p->set_property ("staff-padding", SCM_EOL);
-
p->set_parent (note, Y_AXIS);
Side_position_interface::add_support (p, note);
- scripts_.push (p);
+ scripts_.push_back (p);
}
}
- notes_.push (note);
+ notes_.push_back (note);
}
}
void
-Drum_notes_engraver::acknowledge_grob (Grob_info inf)
+Drum_notes_engraver::acknowledge_stem (Grob_info inf)
{
- if (Stem::has_interface (inf.grob ()))
+ for (vsize i = 0; i < scripts_.size (); i++)
{
- for (int i = 0; i < scripts_.size (); i++)
- {
- Grob *e = scripts_[i];
+ Grob *e = scripts_[i];
- if (to_dir (e->get_property ("side-relative-direction")))
- e->set_property ("direction-source", inf.grob ()->self_scm ());
+ if (to_dir (e->get_property ("side-relative-direction")))
+ e->set_object ("direction-source", inf.grob ()->self_scm ());
- /*
- add dep ?
- */
- e->add_dependency (inf.grob ());
- Side_position_interface::add_support (e, inf.grob ());
- }
+ Side_position_interface::add_support (e, inf.grob ());
}
- else if (Note_column::has_interface (inf.grob ()))
+}
+
+void
+Drum_notes_engraver::acknowledge_note_column (Grob_info inf)
+{
+ for (vsize i = 0; i < scripts_.size (); i++)
{
- for (int i = 0; i < scripts_.size (); i++)
- {
- Grob *e = scripts_[i];
+ Grob *e = scripts_[i];
- if (!e->get_parent (X_AXIS)
- && Side_position_interface::get_axis (e) == Y_AXIS)
- {
- e->set_parent (inf.grob (), X_AXIS);
- }
- }
+ if (!e->get_parent (X_AXIS)
+ && Side_position_interface::get_axis (e) == Y_AXIS)
+ e->set_parent (inf.grob (), X_AXIS);
}
}
events_.clear ();
}
+#include "translator.icc"
+
+ADD_ACKNOWLEDGER (Drum_notes_engraver, stem);
+ADD_ACKNOWLEDGER (Drum_notes_engraver, note_column);
ADD_TRANSLATOR (Drum_notes_engraver,
- /* descr */ "Generate noteheads.",
- /* creats*/ "NoteHead Dots Script",
- /* accepts */ "note-event busy-playing-event",
- /* acks */ "stem-interface note-column-interface",
- /* reads */ "drumStyleTable",
+ /* doc */ "Generate noteheads.",
+ /* create */ "NoteHead Dots Script",
+ /* accept */ "note-event busy-playing-event",
+ /* read */ "drumStyleTable",
/* write */ "");