Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / note-name-engraver.cc
blob1e1e01acb15db4eac0a86cfd6dee02333192f2e5
1 /*
2 note-name-engraver.cc -- implement Note_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "engraver.hh"
10 #include "item.hh"
11 #include "pitch.hh"
12 #include "stream-event.hh"
14 #include "translator.icc"
16 class Note_name_engraver : public Engraver
18 public:
19 TRANSLATOR_DECLARATIONS (Note_name_engraver);
21 vector<Stream_event*> events_;
22 vector<Item*> texts_;
23 DECLARE_TRANSLATOR_LISTENER (note);
24 void process_music ();
25 void stop_translation_timestep ();
28 IMPLEMENT_TRANSLATOR_LISTENER (Note_name_engraver, note);
29 void
30 Note_name_engraver::listen_note (Stream_event *ev)
32 events_.push_back (ev);
35 void
36 Note_name_engraver::process_music ()
38 string s;
39 for (vsize i = 0; i < events_.size (); i++)
41 if (i)
42 s += " ";
43 Pitch p = *unsmob_pitch (events_[i]->get_property ("pitch"));
45 if (!to_boolean (get_property ("printOctaveNames")))
46 p = Pitch (-1, p.get_notename (), p.get_alteration ());
48 s += p.to_string ();
50 if (s.length ())
52 Item *t = make_item ("NoteName", events_[0]->self_scm ());
53 t->set_property ("text", ly_string2scm (s));
54 texts_.push_back (t);
58 void
59 Note_name_engraver::stop_translation_timestep ()
61 texts_.clear ();
62 events_.clear ();
65 Note_name_engraver::Note_name_engraver ()
69 ADD_TRANSLATOR (Note_name_engraver,
70 /* doc */
71 "Print pitches as words.",
73 /* create */
74 "NoteName ",
76 /* read */
77 "printOctaveNames ",
79 /* write */