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 void stop_translation_timestep ();
34 void process_music ();
35 virtual void derived_mark() const;
36 DECLARE_TRANSLATOR_LISTENER (note
);
37 DECLARE_TRANSLATOR_LISTENER (string_number
);
45 Fretboard_engraver::derived_mark () const
47 scm_gc_mark (last_fret_notes_
);
50 Fretboard_engraver::Fretboard_engraver ()
53 last_fret_notes_
= SCM_EOL
;
56 IMPLEMENT_TRANSLATOR_LISTENER (Fretboard_engraver
, note
);
58 Fretboard_engraver::listen_note (Stream_event
*ev
)
60 note_events_
.push_back (ev
);
63 IMPLEMENT_TRANSLATOR_LISTENER (Fretboard_engraver
, string_number
);
65 Fretboard_engraver::listen_string_number (Stream_event
*ev
)
67 tabstring_events_
.push_back (ev
);
71 Fretboard_engraver::process_music ()
73 if (!note_events_
.size ())
76 fret_board_
= make_item ("FretBoard", note_events_
[0]->self_scm ());
77 SCM fret_notes
= ly_cxx_vector_to_list (note_events_
);
78 SCM proc
= get_property ("noteToFretFunction");
79 if (ly_is_procedure (proc
))
82 context ()->self_scm (),
83 fret_board_
->self_scm (),
85 ly_cxx_vector_to_list (tabstring_events_
));
87 SCM changes
= get_property("chordChanges");
88 if (to_boolean (changes
) && scm_is_pair(last_fret_notes_
)
89 && ly_is_equal (last_fret_notes_
, fret_notes
))
90 fret_board_
->set_property ("begin-of-line-visible", SCM_BOOL_T
);
92 last_fret_notes_
= fret_notes
;
96 Fretboard_engraver::stop_translation_timestep ()
99 note_events_
.clear ();
100 tabstring_events_
.clear ();
103 ADD_TRANSLATOR (Fretboard_engraver
,
105 "Generate one or more tablature noteheads from event of type"
106 " @code{NoteEvent}.",
115 "maximumFretStretch "
118 "predefinedDiagramTable",