]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tab-note-heads-engraver.cc
* ly/engraver-init.ly: Make FiguredBass accepted in GrandStaff and
[lilypond.git] / lily / tab-note-heads-engraver.cc
index acb553c827841c303d272410ab5b11e443a73b72..1ddabdd6971a87d77f4647b7198b99076510d7ec 100644 (file)
@@ -3,39 +3,43 @@
 
   based on note-heads-engraver.cc, by Jean-Baptiste Lamy <jiba@tuxfamily.org>,
 
-  (c) 2002--2005
+  (c) 2002--2006
 */
 
 #include <cctype>
 #include <cstdio>
+using namespace std;
 
-#include "rhythmic-head.hh"
-#include "output-def.hh"
-#include "music.hh"
-#include "dots.hh"
 #include "dot-column.hh"
-#include "staff-symbol-referencer.hh"
+#include "dots.hh"
+#include "duration.hh"
 #include "item.hh"
+#include "music.hh"
+#include "output-def.hh"
+#include "rhythmic-head.hh"
 #include "score-engraver.hh"
+#include "staff-symbol-referencer.hh"
+#include "stream-event.hh"
 #include "warn.hh"
-#include "duration.hh"
 
+#include "translator.icc"
 
 /**
    make (guitar-like) tablature note
 */
 class Tab_note_heads_engraver : public Engraver
 {
-  Link_array<Item> notes_;
+  vector<Item*> notes_;
 
-  Link_array<Item> dots_;
-  Link_array<Music> note_events_;
-  Link_array<Music> tabstring_events_;
+  vector<Item*> dots_;
+  vector<Stream_event*> note_events_;
+  vector<Stream_event*> tabstring_events_;
 public:
   TRANSLATOR_DECLARATIONS (Tab_note_heads_engraver);
 
 protected:
-  virtual bool try_music (Music *event);
+  DECLARE_TRANSLATOR_LISTENER (note);
+  DECLARE_TRANSLATOR_LISTENER (string_number);
   void process_music ();
 
   void stop_translation_timestep ();
@@ -45,41 +49,34 @@ Tab_note_heads_engraver::Tab_note_heads_engraver ()
 {
 }
 
-bool
-Tab_note_heads_engraver::try_music (Music *m)
+IMPLEMENT_TRANSLATOR_LISTENER (Tab_note_heads_engraver, note);
+void
+Tab_note_heads_engraver::listen_note (Stream_event *ev)
 {
-  if (m->is_mus_type ("note-event"))
-    {
-      note_events_.push (m);
-      return true;
-    }
-  else if (m->is_mus_type ("string-number-event"))
-    {
-      tabstring_events_.push (m);
-      return true;
-    }
-  else if (m->is_mus_type ("busy-playing-event"))
-    {
-      return note_events_.size ();
-    }
+  note_events_.push_back (ev);
+}
 
-  return false;
+IMPLEMENT_TRANSLATOR_LISTENER (Tab_note_heads_engraver, string_number);
+void
+Tab_note_heads_engraver::listen_string_number (Stream_event *ev)
+{
+  tabstring_events_.push_back (ev);
 }
 
 void
 Tab_note_heads_engraver::process_music ()
 {
-  int j = 0;
-  for (int i = 0; i < note_events_.size (); i++)
+  vsize j = 0;
+  for (vsize i = 0; i < note_events_.size (); i++)
     {
       SCM stringTunings = get_property ("stringTunings");
       int number_of_strings = ((int) ly_length (stringTunings));
       bool high_string_one = to_boolean (get_property ("highStringOne"));
 
-      Music *event = note_events_[i];
+      Stream_event *event = note_events_[i];
       Item *note = make_item ("TabNoteHead", event->self_scm ());
 
-      Music *tabstring_event = 0;
+      Stream_event *tabstring_event = 0;
 
       for (SCM s = event->get_property ("articulations");
           !tabstring_event && scm_is_pair (s); s = scm_cdr (s))
@@ -87,13 +84,13 @@ Tab_note_heads_engraver::process_music ()
          Music *art = unsmob_music (scm_car (s));
 
          if (art->is_mus_type ("string-number-event"))
-           tabstring_event = art;
+           tabstring_event = art->to_event ();
        }
 
       if (!tabstring_event && j < tabstring_events_.size ())
        {
          tabstring_event = tabstring_events_[j];
-         if (j +1 < tabstring_events_.size ())
+         if (j + 1 < tabstring_events_.size ())
            j++;
        }
 
@@ -125,7 +122,7 @@ Tab_note_heads_engraver::process_music ()
 
          d->set_parent (note, Y_AXIS);
 
-         dots_.push (d);
+         dots_.push_back (d);
        }
 
       SCM scm_pitch = event->get_property ("pitch");
@@ -152,7 +149,7 @@ Tab_note_heads_engraver::process_music ()
       note->set_property ("text", text);
 
       note->set_property ("staff-position", scm_from_int (pos));
-      notes_.push (note);
+      notes_.push_back (note);
     }
 }
 
@@ -165,12 +162,10 @@ Tab_note_heads_engraver::stop_translation_timestep ()
   tabstring_events_.clear ();
 }
 
-#include "translator.icc"
-
 ADD_TRANSLATOR (Tab_note_heads_engraver,
                /* doc */ "Generate one or more tablature noteheads from Music of type NoteEvent.",
                /* create */ "TabNoteHead Dots",
-               /* accept */ "note-event string-number-event busy-playing-event",
+               /* accept */ "note-event string-number-event",
                /* read */ "middleCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost",
                /* write */ "");