2 chord-name-engraver.cc -- implement New_chord_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2003 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "chord-name.hh"
12 #include "paper-def.hh"
13 #include "font-interface.hh"
14 #include "paper-def.hh"
16 #include "dimensions.hh"
19 #include "protected-scm.hh"
20 #include "translator-group.hh"
22 class New_chord_name_engraver : public Engraver
24 TRANSLATOR_DECLARATIONS( New_chord_name_engraver);
26 virtual void stop_translation_timestep ();
27 virtual void process_music ();
28 virtual bool try_music (Music *);
31 void add_note (Music *);
34 Link_array<Music> notes_;
36 Protected_scm last_chord_;
41 New_chord_name_engraver::New_chord_name_engraver ()
44 last_chord_ = SCM_EOL;
48 New_chord_name_engraver::add_note (Music * n)
54 New_chord_name_engraver::process_music ()
60 SCM inversion = SCM_EOL;
61 SCM pitches = SCM_EOL;
63 for (int i =0 ; i < notes_.size (); i++)
66 SCM p = n->get_mus_property ("pitch");;
67 if (n->get_mus_property ("inversion") == SCM_BOOL_T)
69 else if (n->get_mus_property ("bass") == SCM_BOOL_T)
72 pitches = gh_cons (p, pitches);
75 pitches = scm_sort_list (pitches, Pitch::less_p_proc);
77 SCM name_proc = get_property ("chordNameFunction");
78 SCM markup = scm_call_4 (name_proc, pitches, bass, inversion,
79 daddy_trans_->self_scm());
84 SCM chord_as_scm = gh_cons (pitches, gh_cons (bass, inversion));
86 chord_name_ = new Item (get_property ("ChordName"));
87 chord_name_->set_grob_property("text", markup);
88 announce_grob(chord_name_, SCM_EOL);
89 SCM s = get_property ("chordChanges");
90 if (to_boolean (s) && gh_pair_p (last_chord_)
91 && gh_equal_p (chord_as_scm, last_chord_))
92 chord_name_->set_grob_property ("begin-of-line-visible", SCM_BOOL_T);
94 last_chord_ = chord_as_scm;
98 New_chord_name_engraver::try_music (Music* m)
103 if (m->is_mus_type ("note-event"))
112 New_chord_name_engraver::stop_translation_timestep ()
116 typeset_grob (chord_name_);
122 ENTER_DESCRIPTION(New_chord_name_engraver,
123 /* descr */ "Catch note-events "
124 "and generate the appropriate chordname.",
125 /* creats*/ "ChordName",
126 /* accepts */ "note-event",
128 /* reads */ "chordChanges chordNameExceptions chordNameFunction",