X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftab-note-heads-engraver.cc;h=7870c0218a74b44fb3e64178c90124b66d0307b6;hb=730c54a571ab3b6c30e02be5f93c876abee0f9a7;hp=00b4ab156d8d93d858abf1b11f7905b453a0c85a;hpb=31568c504806f35aac420a394c9eab07abd9faa7;p=lilypond.git diff --git a/lily/tab-note-heads-engraver.cc b/lily/tab-note-heads-engraver.cc index 00b4ab156d..7870c0218a 100644 --- a/lily/tab-note-heads-engraver.cc +++ b/lily/tab-note-heads-engraver.cc @@ -8,18 +8,20 @@ #include #include + +#include "engraver.hh" + 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 "duration.hh" #include "item.hh" -#include "score-engraver.hh" +#include "output-def.hh" +#include "pitch.hh" +#include "rhythmic-head.hh" +#include "stream-event.hh" #include "warn.hh" -#include "duration.hh" + +#include "translator.icc" /** make (guitar-like) tablature note @@ -28,14 +30,14 @@ class Tab_note_heads_engraver : public Engraver { vector notes_; - vector dots_; - vector note_events_; - vector tabstring_events_; + vector note_events_; + vector 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,46 +47,41 @@ 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_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 (); + 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; + 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)); + int number_of_strings = scm_ilength (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)) { - Music *art = unsmob_music (scm_car (s)); + Stream_event *art = unsmob_stream_event (scm_car (s)); - if (art->is_mus_type ("string-number-event")) + if (art->in_event_class ("string-number-event")) tabstring_event = art; } @@ -109,22 +106,6 @@ 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"); @@ -158,17 +139,23 @@ void Tab_note_heads_engraver::stop_translation_timestep () { notes_.clear (); - dots_.clear (); note_events_.clear (); 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", - /* read */ "middleCPosition stringTunings minimumFret tablatureFormat highStringOne stringOneTopmost", + /* doc */ "Generate one or more tablature noteheads from event of type NoteEvent.", + /* create */ + "TabNoteHead " + , + + /* read */ + "middleCPosition " + "stringTunings " + "minimumFret " + "tablatureFormat " + "highStringOne " + "stringOneTopmost ", + /* write */ "");