2 pitched-trill-engraver.cc -- implement Pitched_trill_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "engraver.hh"
13 #include "pointer-group-interface.hh"
14 #include "axis-group-interface.hh"
16 #include "note-head.hh"
18 #include "side-position-interface.hh"
22 class Pitched_trill_engraver : public Engraver
26 TRANSLATOR_DECLARATIONS(Pitched_trill_engraver);
30 DECLARE_ACKNOWLEDGER ( note_head);
31 DECLARE_ACKNOWLEDGER ( dots);
32 DECLARE_ACKNOWLEDGER ( text_spanner);
33 void process_music ();
34 virtual bool try_music (Music*);
35 void stop_translation_timestep ();
39 Item *trill_accidental_;
41 Link_array<Grob> heads_;
43 void make_trill (Music *);
47 Pitched_trill_engraver::Pitched_trill_engraver ()
51 trill_accidental_ = 0;
55 Pitched_trill_engraver::acknowledge_dots (Grob_info info)
57 heads_.push (info.grob ());
60 Pitched_trill_engraver::acknowledge_note_head (Grob_info info)
62 heads_.push (info.grob ());
66 Pitched_trill_engraver::acknowledge_text_spanner (Grob_info info)
68 Music *mus = info.music_cause ();
70 && mus->is_mus_type ("trill-span-event")
71 && to_dir (mus->get_property ("span-direction")) == START
72 && unsmob_pitch (mus->get_property ("trill-pitch")))
79 Pitched_trill_engraver::make_trill (Music *mus)
81 SCM scm_pitch = mus->get_property ("trill-pitch");
82 Pitch * p = unsmob_pitch (scm_pitch);
84 SCM keysig = get_property ("localKeySignature");
86 SCM key = scm_cons (scm_from_int (p->get_octave ()),
87 scm_from_int (p->get_notename ()));
89 SCM handle = scm_assoc (key, keysig);
91 (handle == SCM_BOOL_F)
92 || p->get_alteration () == 0;
96 programming_error ("already have a trill head.");
100 trill_head_ = make_item ("TrillPitchHead", mus->self_scm ());
101 SCM c0scm = get_property ("middleCPosition");
103 int c0 = scm_is_number (c0scm) ? scm_to_int (c0scm) : 0;
105 trill_head_->set_property ("staff-position",
106 scm_from_int (unsmob_pitch (scm_pitch)->steps ()
109 trill_group_ = make_item ("TrillPitchGroup", mus->self_scm());
111 Axis_group_interface::add_element (trill_group_, trill_head_);
115 trill_accidental_ = make_item ("TrillPitchAccidental", mus->self_scm ());
117 // fixme: naming -> alterations
118 trill_accidental_->set_property ("accidentals", scm_list_1 (scm_from_int (p->get_alteration ())));
119 Side_position_interface::add_support (trill_accidental_, trill_head_);
120 trill_head_->set_object ("accidental-grob", trill_accidental_->self_scm ());
121 trill_group_->set_parent (trill_head_, Y_AXIS);
122 Axis_group_interface::add_element (trill_group_, trill_accidental_);
123 trill_accidental_->set_parent (trill_head_, Y_AXIS);
128 Pitched_trill_engraver::stop_translation_timestep ()
131 for (int i = 0; i < heads_.size (); i++)
133 Side_position_interface::add_support (trill_group_, heads_[i]);
139 trill_accidental_ = 0;
143 Pitched_trill_engraver::process_music ()
148 Pitched_trill_engraver::try_music (Music *)
153 #include "translator.icc"
154 ADD_ACKNOWLEDGER (Pitched_trill_engraver, note_head);
155 ADD_ACKNOWLEDGER (Pitched_trill_engraver, dots);
156 ADD_ACKNOWLEDGER (Pitched_trill_engraver, text_spanner);
157 ADD_TRANSLATOR (Pitched_trill_engraver,
158 /* descr */ "Print the bracketed notehead after a notehead with trill.",
159 /* creats*/ "TrillPitchHead TrillPitchAccidental TrillPitchGroup",