Add FiguredBass to ChoirStaff's accepts list.
[lilypond/mpolesky.git] / lily / fretboard-engraver.cc
blob4a1e8ba136aea7d8a49addf8595f7091b7c11f05
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2006--2009 Han-Wen Nienhuys
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include <cctype>
21 #include <cstdio>
22 using namespace std;
24 #include "context.hh"
25 #include "item.hh"
26 #include "engraver.hh"
27 #include "pitch.hh"
28 #include "stream-event.hh"
29 #include "warn.hh"
31 #include "translator.icc"
33 /**
34 make (guitar-like) tablature note
36 class Fretboard_engraver : public Engraver
38 Item *fret_board_;
40 vector<Stream_event*> note_events_;
41 vector<Stream_event*> tabstring_events_;
42 public:
43 TRANSLATOR_DECLARATIONS (Fretboard_engraver);
45 protected:
46 void stop_translation_timestep ();
47 void process_music ();
48 virtual void derived_mark() const;
49 DECLARE_TRANSLATOR_LISTENER (note);
50 DECLARE_TRANSLATOR_LISTENER (string_number);
52 private:
53 SCM last_fret_notes_;
57 void
58 Fretboard_engraver::derived_mark () const
60 scm_gc_mark (last_fret_notes_);
63 Fretboard_engraver::Fretboard_engraver ()
65 fret_board_ = 0;
66 last_fret_notes_ = SCM_EOL;
69 IMPLEMENT_TRANSLATOR_LISTENER (Fretboard_engraver, note);
70 void
71 Fretboard_engraver::listen_note (Stream_event *ev)
73 note_events_.push_back (ev);
76 IMPLEMENT_TRANSLATOR_LISTENER (Fretboard_engraver, string_number);
77 void
78 Fretboard_engraver::listen_string_number (Stream_event *ev)
80 tabstring_events_.push_back (ev);
83 void
84 Fretboard_engraver::process_music ()
86 if (!note_events_.size ())
87 return ;
89 fret_board_ = make_item ("FretBoard", note_events_[0]->self_scm ());
90 SCM fret_notes = ly_cxx_vector_to_list (note_events_);
91 SCM proc = get_property ("noteToFretFunction");
92 if (ly_is_procedure (proc))
94 scm_call_4 (proc,
95 context ()->self_scm (),
96 fret_board_->self_scm (),
97 fret_notes,
98 ly_cxx_vector_to_list (tabstring_events_));
100 SCM changes = get_property("chordChanges");
101 if (to_boolean (changes) && scm_is_pair(last_fret_notes_)
102 && ly_is_equal (last_fret_notes_, fret_notes))
103 fret_board_->set_property ("begin-of-line-visible", SCM_BOOL_T);
105 last_fret_notes_ = fret_notes;
108 void
109 Fretboard_engraver::stop_translation_timestep ()
111 fret_board_ = 0;
112 note_events_.clear ();
113 tabstring_events_.clear ();
116 ADD_TRANSLATOR (Fretboard_engraver,
117 /* doc */
118 "Generate one or more tablature noteheads from event of type"
119 " @code{NoteEvent}.",
121 /* create */
122 "FretBoard ",
124 /* read */
125 "chordChanges "
126 "stringTunings "
127 "minimumFret "
128 "maximumFretStretch "
129 "tablatureFormat "
130 "highStringOne "
131 "predefinedDiagramTable",
133 /* write */