2 chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "duration-convert.hh"
11 #include "timing-translator.hh"
12 #include "chord-tremolo-engraver.hh"
15 #include "musical-request.hh"
18 #include "score-engraver.hh"
20 ADD_THIS_TRANSLATOR (Chord_tremolo_engraver
);
22 Chord_tremolo_engraver::Chord_tremolo_engraver ()
24 reqs_drul_
[LEFT
] = reqs_drul_
[RIGHT
] = 0;
26 finished_abeam_p_
= 0;
31 Chord_tremolo_engraver::do_try_music (Music
* m
)
33 if (Chord_tremolo_req
* b
= dynamic_cast <Chord_tremolo_req
*> (m
))
35 Direction d
= b
->span_dir_
;
36 if (reqs_drul_
[d
] && !reqs_drul_
[d
]->equal_b (b
))
39 if ((d
== STOP
) && !abeam_p_
)
41 m
->warning (_ ("no tremolo beam to end"));
53 Chord_tremolo_engraver::do_process_requests ()
58 reqs_drul_
[STOP
]->warning (_ ("no tremolo beam to end"));
60 finished_abeam_p_
= abeam_p_
;
66 Score_engraver
* e
= 0;
67 Translator
* t
= daddy_grav_l ();
68 for (; !e
&& t
; t
= t
->daddy_trans_l_
)
70 e
= dynamic_cast<Score_engraver
*> (t
);
74 programming_error ("No score engraver!");
79 if (reqs_drul_
[START
])
83 reqs_drul_
[START
]->warning (_ ("Already have a tremolo beam"));
87 prev_start_req_
= reqs_drul_
[START
];
90 abeam_p_
->set_elt_property ("chord-tremolo", SCM_BOOL_T
);
92 announce_element (Score_element_info (abeam_p_
, reqs_drul_
[LEFT
]));
97 Chord_tremolo_engraver::do_post_move_processing ()
99 reqs_drul_
[START
] = 0;
103 Chord_tremolo_engraver::do_pre_move_processing ()
109 Chord_tremolo_engraver::typeset_beam ()
111 if (finished_abeam_p_
)
113 typeset_element (finished_abeam_p_
);
114 finished_abeam_p_
= 0;
116 reqs_drul_
[STOP
] = 0;
121 Chord_tremolo_engraver::do_removal_processing ()
126 prev_start_req_
->warning (_ ("unfinished tremolo beam"));
127 finished_abeam_p_
= abeam_p_
;
133 Chord_tremolo_engraver::acknowledge_element (Score_element_info i
)
137 if (Stem
* s
= dynamic_cast<Stem
*> (i
.elem_l_
))
139 int type_i
= prev_start_req_
->type_i_
;
140 s
->set_elt_property ("duration-log", gh_int2scm (intlog2 (type_i
) - 2));
142 s
->set_beaming (s
->flag_i (), LEFT
);
143 s
->set_beaming ( s
->flag_i (), RIGHT
);
147 if (s
->type_i () != 1)
149 int gap_i
=s
->flag_i () - ((s
->type_i () >? 2) - 2);
150 s
->set_elt_property ("beam-gap", gh_int2scm(gap_i
));
153 if (s
->type_i () != 1)
155 int gap_i
=s
->flag_i () - ((s
->type_i () >? 2) - 2);
156 abeam_p_
->set_elt_property ("beam-gap", gh_int2scm(gap_i
));
160 abeam_p_
->add_stem (s
);