X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fdrum-note-engraver.cc;h=3fc91edb7acc49d9276f8af6fda659280e0f7a35;hb=2cf1c2005c4a09e23a554b41f533453bf595c2be;hp=1b95c519ad29b2e8d5c7d99e6799d251e617b468;hpb=75eebcb49e52d296b1da3e1074e0825d2c780db4;p=lilypond.git diff --git a/lily/drum-note-engraver.cc b/lily/drum-note-engraver.cc index 1b95c519ad..3fc91edb7a 100644 --- a/lily/drum-note-engraver.cc +++ b/lily/drum-note-engraver.cc @@ -1,36 +1,52 @@ /* - drum-note-engraver.cc + This file is part of LilyPond, the GNU music typesetter. - (c) 1997--2006 Han-Wen Nienhuys + Copyright (C) 1997--2010 Han-Wen Nienhuys + + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include using namespace std; -#include "rhythmic-head.hh" +#include "item.hh" +#include "duration.hh" #include "engraver.hh" -#include "warn.hh" +#include "note-column.hh" +#include "rhythmic-head.hh" #include "side-position-interface.hh" #include "script-interface.hh" #include "stem.hh" -#include "note-column.hh" -#include "duration.hh" +#include "stream-event.hh" +#include "warn.hh" + +#include "translator.icc" class Drum_notes_engraver : public Engraver { - Link_array notes_; - Link_array dots_; - Link_array scripts_; - Link_array events_; + vector notes_; + vector scripts_; + vector events_; public: TRANSLATOR_DECLARATIONS (Drum_notes_engraver); protected: - virtual bool try_music (Music *ev); void process_music (); DECLARE_ACKNOWLEDGER (stem); DECLARE_ACKNOWLEDGER (note_column); + DECLARE_TRANSLATOR_LISTENER (note); void stop_translation_timestep (); }; @@ -38,50 +54,25 @@ Drum_notes_engraver::Drum_notes_engraver () { } -bool -Drum_notes_engraver::try_music (Music *m) +IMPLEMENT_TRANSLATOR_LISTENER (Drum_notes_engraver, note); +void +Drum_notes_engraver::listen_note (Stream_event *ev) { - if (m->is_mus_type ("note-event")) - { - events_.push (m); - return true; - } - else if (m->is_mus_type ("busy-playing-event")) - return events_.size (); - - return false; + events_.push_back (ev); } void 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"); - Music *ev = events_[i]; + Stream_event *ev = events_[i]; Item *note = make_item ("NoteHead", ev->self_scm ()); - Duration dur = *unsmob_duration (ev->get_property ("duration")); - - note->set_property ("duration-log", scm_from_int (dur.duration_log ())); - - if (dur.dot_count ()) - { - Item *d = make_item ("Dots", ev->self_scm ()); - Rhythmic_head::set_dots (note, d); - - if (dur.dot_count () - != robust_scm2int (d->get_property ("dot-count"), 0)) - d->set_property ("dot-count", scm_from_int (dur.dot_count ())); - - d->set_parent (note, Y_AXIS); - - dots_.push (d); - } - SCM drum_type = ev->get_property ("drum-type"); SCM defn = SCM_EOL; @@ -108,18 +99,18 @@ Drum_notes_engraver::process_music () 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_stem (Grob_info inf) { - for (int i = 0; i < scripts_.size (); i++) + for (vsize i = 0; i < scripts_.size (); i++) { Grob *e = scripts_[i]; @@ -133,7 +124,7 @@ Drum_notes_engraver::acknowledge_stem (Grob_info inf) void Drum_notes_engraver::acknowledge_note_column (Grob_info inf) { - for (int i = 0; i < scripts_.size (); i++) + for (vsize i = 0; i < scripts_.size (); i++) { Grob *e = scripts_[i]; @@ -147,20 +138,27 @@ void Drum_notes_engraver::stop_translation_timestep () { notes_.clear (); - dots_.clear (); scripts_.clear (); events_.clear (); } -#include "translator.icc" - ADD_ACKNOWLEDGER (Drum_notes_engraver, stem); ADD_ACKNOWLEDGER (Drum_notes_engraver, note_column); + + ADD_TRANSLATOR (Drum_notes_engraver, - /* doc */ "Generate noteheads.", - /* create */ "NoteHead Dots Script", - /* accept */ "note-event busy-playing-event", - /* read */ "drumStyleTable", - /* write */ ""); + /* doc */ + "Generate drum note heads.", + + /* create */ + "NoteHead " + "Script ", + + /* read */ + "drumStyleTable ", + + /* write */ + "" + );