2 fretboard-engraver.cc -- part of GNU LilyPond
4 (c) 2006 Han-Wen Nienhuys
13 #include "engraver.hh"
15 #include "stream-event.hh"
18 #include "translator.icc"
21 make (guitar-like) tablature note
23 class Fretboard_engraver : public Engraver
27 vector<Stream_event*> note_events_;
28 vector<Stream_event*> tabstring_events_;
30 TRANSLATOR_DECLARATIONS (Fretboard_engraver);
33 DECLARE_TRANSLATOR_LISTENER (note);
34 DECLARE_TRANSLATOR_LISTENER (string_number);
35 void process_music ();
37 void stop_translation_timestep ();
40 Fretboard_engraver::Fretboard_engraver ()
45 IMPLEMENT_TRANSLATOR_LISTENER (Fretboard_engraver, note);
47 Fretboard_engraver::listen_note (Stream_event *ev)
49 note_events_.push_back (ev);
52 IMPLEMENT_TRANSLATOR_LISTENER (Fretboard_engraver, string_number);
54 Fretboard_engraver::listen_string_number (Stream_event *ev)
56 tabstring_events_.push_back (ev);
60 Fretboard_engraver::process_music ()
62 if (!note_events_.size ())
65 fret_board_ = make_item ("FretBoard", note_events_[0]->self_scm ());
67 SCM proc = get_property ("noteToFretFunction");
68 if (ly_is_procedure (proc))
71 context ()->self_scm (),
72 fret_board_->self_scm (),
74 ly_cxx_vector_to_list (note_events_),
75 ly_cxx_vector_to_list (tabstring_events_));
80 Fretboard_engraver::stop_translation_timestep ()
83 note_events_.clear ();
84 tabstring_events_.clear ();
87 ADD_TRANSLATOR (Fretboard_engraver,
89 "Generate one or more tablature noteheads from event of type"