2 chord-name-engraver.cc -- implement Chord_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "chord-name.hh"
12 #include "musical-request.hh"
13 #include "paper-def.hh"
14 #include "font-interface.hh"
15 #include "paper-def.hh"
17 #include "dimensions.hh"
19 #include "musical-pitch.hh"
21 class Chord_name_engraver : public Engraver
24 Chord_name_engraver ();
25 VIRTUAL_COPY_CONS (Translator);
28 virtual void do_pre_move_processing ();
29 virtual void acknowledge_element (Score_element_info i);
30 virtual void do_process_music ();
31 virtual bool do_try_music (Music* m);
34 void create_chord_name ();
36 Array<Musical_pitch> pitch_arr_;
40 Tonic_req* tonic_req_;
41 Inversion_req* inversion_req_;
45 ADD_THIS_TRANSLATOR (Chord_name_engraver);
47 Chord_name_engraver::Chord_name_engraver ()
58 Chord_name_engraver::acknowledge_element (Score_element_info i)
60 if (Note_req* n = dynamic_cast<Note_req*> (i.req_l_))
61 pitch_arr_.push (* unsmob_pitch (n->get_mus_property ("pitch")));
65 Chord_name_engraver::do_try_music (Music* m)
67 if (Note_req* n = dynamic_cast<Note_req*> (m))
69 pitch_arr_.push (* unsmob_pitch (n->get_mus_property ("pitch")));
72 if (Tonic_req* t = dynamic_cast<Tonic_req*> (m))
77 if (Inversion_req* i = dynamic_cast<Inversion_req*> (m))
82 if (Bass_req* b = dynamic_cast<Bass_req*> (m))
91 Chord_name_engraver::do_process_music ()
96 if (!pitch_arr_.size ())
99 bool find_inversion_b = false;
100 SCM chord_inversion = get_property ("chordInversion");
101 if (gh_boolean_p (chord_inversion))
102 find_inversion_b = gh_scm2bool (chord_inversion);
104 chord_p_ = new Chord (to_chord (pitch_arr_,
105 tonic_req_, inversion_req_, bass_req_,
108 create_chord_name ();
109 announce_element (chord_name_p_, 0);
110 SCM s = get_property ("drarnChords"); //FIXME!
111 if (to_boolean (s) && last_chord_p_ && !compare (chord_p_, last_chord_p_))
112 chord_name_p_->set_elt_property ("begin-of-line-visible", SCM_BOOL_T);
116 Chord_name_engraver::create_chord_name ()
119 chord_name_p_ = new Item (get_property ("ChordName"));
121 Hmm, why not represent complete chord as list?
122 ((tonic third fifth) (inversion bass))
125 for (int i= chord_p_->pitch_arr_.size (); i--; )
126 plist = gh_cons (chord_p_->pitch_arr_[i].smobbed_copy (), plist);
128 chord_name_p_->set_elt_property ("pitches", plist);
129 if (chord_p_->inversion_b_)
130 chord_name_p_->set_elt_property ("inversion",
131 chord_p_->inversion_pitch_.smobbed_copy ());
132 if (chord_p_->bass_b_)
133 chord_name_p_->set_elt_property ("bass", chord_p_->bass_pitch_.smobbed_copy ());
137 Chord_name_engraver::do_pre_move_processing ()
141 typeset_element (chord_name_p_);
148 delete last_chord_p_;
149 last_chord_p_ = chord_p_;