]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tab-note-heads-engraver.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / tab-note-heads-engraver.cc
index d7e3f9bd66ebc0eb9a292793f954acfb9f89e1d9..be9fa38515c16e52348408b42d71ed2d11de8092 100644 (file)
 #include <cstdio>
 using namespace std;
 
-#include "dot-column.hh"
+#include "rhythmic-head.hh"
+#include "output-def.hh"
+#include "music.hh"
 #include "dots.hh"
-#include "duration.hh"
+#include "dot-column.hh"
+#include "staff-symbol-referencer.hh"
 #include "item.hh"
-#include "output-def.hh"
-#include "pitch.hh"
-#include "rhythmic-head.hh"
 #include "score-engraver.hh"
-#include "staff-symbol-referencer.hh"
-#include "stream-event.hh"
 #include "warn.hh"
-
-#include "translator.icc"
+#include "duration.hh"
 
 /**
    make (guitar-like) tablature note
@@ -31,14 +28,14 @@ class Tab_note_heads_engraver : public Engraver
 {
   vector<Item*> notes_;
 
-  vector<Stream_event*> note_events_;
-  vector<Stream_event*> tabstring_events_;
+  vector<Item*> dots_;
+  vector<Music*> note_events_;
+  vector<Music*> tabstring_events_;
 public:
   TRANSLATOR_DECLARATIONS (Tab_note_heads_engraver);
 
 protected:
-  DECLARE_TRANSLATOR_LISTENER (note);
-  DECLARE_TRANSLATOR_LISTENER (string_number);
+  virtual bool try_music (Music *event);
   void process_music ();
 
   void stop_translation_timestep ();
@@ -48,18 +45,23 @@ Tab_note_heads_engraver::Tab_note_heads_engraver ()
 {
 }
 
-IMPLEMENT_TRANSLATOR_LISTENER (Tab_note_heads_engraver, note);
-void
-Tab_note_heads_engraver::listen_note (Stream_event *ev)
+bool
+Tab_note_heads_engraver::try_music (Music *m)
 {
-  note_events_.push_back (ev);
-}
+  if (m->is_mus_type ("note-event"))
+    {
+      note_events_.push_back (m);
+      return true;
+    }
+  else if (m->is_mus_type ("string-number-event"))
+    {
+      tabstring_events_.push_back (m);
+      return true;
+    }
+  else if (m->is_mus_type ("busy-playing-event"))
+    return note_events_.size ();
 
-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);
+  return false;
 }
 
 void
@@ -72,17 +74,17 @@ Tab_note_heads_engraver::process_music ()
       int number_of_strings = ((int) ly_length (stringTunings));
       bool high_string_one = to_boolean (get_property ("highStringOne"));
 
-      Stream_event *event = note_events_[i];
+      Music *event = note_events_[i];
       Item *note = make_item ("TabNoteHead", event->self_scm ());
 
-      Stream_event *tabstring_event = 0;
+      Music *tabstring_event = 0;
 
       for (SCM s = event->get_property ("articulations");
           !tabstring_event && scm_is_pair (s); s = scm_cdr (s))
        {
-         Stream_event *art = unsmob_stream_event (scm_car (s));
+         Music *art = unsmob_music (scm_car (s));
 
-         if (art->in_event_class ("string-number-event"))
+         if (art->is_mus_type ("string-number-event"))
            tabstring_event = art;
        }
 
@@ -107,6 +109,22 @@ Tab_note_heads_engraver::process_music ()
        }
 
       Duration dur = *unsmob_duration (event->get_property ("duration"));
+      note->set_property ("duration-log",
+                         scm_from_int (dur.duration_log ()));
+
+      if (dur.dot_count ())
+       {
+         Item *d = make_item ("Dots", event->self_scm ());
+         Rhythmic_head::set_dots (note, d);
+
+         if (dur.dot_count ()
+             != scm_to_int (d->get_property ("dot-count")))
+           d->set_property ("dot-count", scm_from_int (dur.dot_count ()));
+
+         d->set_parent (note, Y_AXIS);
+
+         dots_.push_back (d);
+       }
 
       SCM scm_pitch = event->get_property ("pitch");
       SCM proc = get_property ("tablatureFormat");
@@ -140,27 +158,17 @@ void
 Tab_note_heads_engraver::stop_translation_timestep ()
 {
   notes_.clear ();
+  dots_.clear ();
   note_events_.clear ();
   tabstring_events_.clear ();
 }
 
-ADD_TRANSLATOR (Tab_note_heads_engraver,
-               /* doc */ "Generate one or more tablature noteheads from event of type NoteEvent.",
-               /* create */
-               "TabNoteHead "
-               ,
-
-               /* accept */
-               "note-event "
-               "string-number-event ",
-
-               /* read */
-               "middleCPosition "
-               "stringTunings "
-               "minimumFret "
-               "tablatureFormat "
-               "highStringOne "
-               "stringOneTopmost ",
+#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",
+               /* read */ "middleCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost",
                /* write */ "");