2 chord-name-engraver.cc -- implement Chord_name_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "chord-name-engraver.hh"
11 #include "musical-request.hh"
12 #include "paper-def.hh"
14 #include "paper-def.hh"
16 #include "dimensions.hh"
17 #include "g-text-item.hh"
19 ADD_THIS_TRANSLATOR (Chord_name_engraver);
21 Chord_name_engraver::Chord_name_engraver ()
26 Chord_name_engraver::acknowledge_element (Score_element_info i)
28 if (Note_req* n = dynamic_cast<Note_req*> (i.req_l_))
29 pitch_arr_.push (n->pitch_);
33 Chord_name_engraver::do_try_music (Music* m)
35 if (Note_req* n = dynamic_cast<Note_req*> (m))
37 pitch_arr_.push (n->pitch_);
44 Chord_name_engraver::do_process_requests ()
46 if (text_p_arr_.size ())
48 if (!pitch_arr_.size ())
52 Banter style chord names (almost).
54 - move this stuff to new Item class Chord_name
55 - switch on property, add american (?) chordNameStyle
57 Scalar chordNameStyle = get_property ("chordNameStyle", 0);
58 if (chordNameStyle == "Banter")
59 chord = pitches_to_banter (pitch_arr_));
63 Chord chord (pitch_arr_);
64 Musical_pitch* inversion = 0;
65 Scalar chord_inversion = get_property ("chordInversion", 0);
66 if (chord_inversion.to_bool ())
68 int tonic_i = chord.find_tonic_i ();
71 inversion = &pitch_arr_[0];
72 Scalar preserve = get_property ("chordInversionPreserve", 0);
73 if (preserve.to_bool ())
74 chord.rebuild_from_base (tonic_i);
76 chord.rebuild_insert_inversion (tonic_i);
80 G_text_item* item_p = new G_text_item;
82 item_p->text_str_ = chord.banter_str (inversion);
84 Scalar style = get_property ("textstyle", 0);
85 if (style.length_i ())
86 item_p->style_str_ = style;
88 text_p_arr_.push (item_p);
89 announce_element (Score_element_info (item_p, 0));
93 Chord_name_engraver::do_pre_move_processing ()
95 for (int i=0; i < text_p_arr_.size (); i++)
97 typeset_element (text_p_arr_[i]);