Update from Andrew: tweaks for cross-staff chords snippet.
[lilypond.git] / lily / fretboard-engraver.cc
blobf284161a801cb86f4cb73635b6fee4e6f331ac82
1 /*
2 fretboard-engraver.cc -- part of GNU LilyPond
4 (c) 2006 Han-Wen Nienhuys
5 */
7 #include <cctype>
8 #include <cstdio>
9 using namespace std;
11 #include "context.hh"
12 #include "item.hh"
13 #include "engraver.hh"
14 #include "pitch.hh"
15 #include "stream-event.hh"
16 #include "warn.hh"
18 #include "translator.icc"
20 /**
21 make (guitar-like) tablature note
23 class Fretboard_engraver : public Engraver
25 Item *fret_board_;
27 vector<Stream_event*> note_events_;
28 vector<Stream_event*> tabstring_events_;
29 public:
30 TRANSLATOR_DECLARATIONS (Fretboard_engraver);
32 protected:
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 ()
42 fret_board_ = 0;
45 IMPLEMENT_TRANSLATOR_LISTENER (Fretboard_engraver, note);
46 void
47 Fretboard_engraver::listen_note (Stream_event *ev)
49 note_events_.push_back (ev);
52 IMPLEMENT_TRANSLATOR_LISTENER (Fretboard_engraver, string_number);
53 void
54 Fretboard_engraver::listen_string_number (Stream_event *ev)
56 tabstring_events_.push_back (ev);
59 void
60 Fretboard_engraver::process_music ()
62 if (!note_events_.size ())
63 return ;
65 fret_board_ = make_item ("FretBoard", note_events_[0]->self_scm ());
67 SCM proc = get_property ("noteToFretFunction");
68 if (ly_is_procedure (proc))
70 scm_call_4 (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_));
79 void
80 Fretboard_engraver::stop_translation_timestep ()
82 fret_board_ = 0;
83 note_events_.clear ();
84 tabstring_events_.clear ();
87 ADD_TRANSLATOR (Fretboard_engraver,
88 /* doc */
89 "Generate one or more tablature noteheads from event of type"
90 " @code{NoteEvent}.",
92 /* create */
93 "FretBoard ",
95 /* read */
96 "stringTunings "
97 "minimumFret "
98 "maximumFretStretch "
99 "tablatureFormat "
100 "highStringOne "
101 "predefinedDiagramTable",
103 /* write */