2 chord-tremolo-engraver.cc -- implement Chord_tremolo_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "timing-translator.hh"
11 #include "chord-tremolo-engraver.hh"
14 #include "musical-request.hh"
17 #include "score-engraver.hh"
19 ADD_THIS_TRANSLATOR (Chord_tremolo_engraver
);
21 Chord_tremolo_engraver::Chord_tremolo_engraver ()
23 reqs_drul_
[LEFT
] = reqs_drul_
[RIGHT
] = 0;
25 finished_abeam_p_
= 0;
30 Chord_tremolo_engraver::do_try_music (Music
* m
)
32 if (Chord_tremolo_req
* b
= dynamic_cast <Chord_tremolo_req
*> (m
))
34 Direction d
= b
->span_dir_
;
35 if (reqs_drul_
[d
] && !reqs_drul_
[d
]->equal_b (b
))
38 if ((d
== STOP
) && !abeam_p_
)
40 m
->warning (_ ("no tremolo beam to end"));
52 Chord_tremolo_engraver::do_process_requests ()
57 reqs_drul_
[STOP
]->warning (_ ("no tremolo beam to end"));
59 finished_abeam_p_
= abeam_p_
;
65 Score_engraver
* e
= 0;
66 Translator
* t
= daddy_grav_l ();
67 for (; !e
&& t
; t
= t
->daddy_trans_l_
)
69 e
= dynamic_cast<Score_engraver
*> (t
);
73 programming_error ("No score engraver!");
78 if (reqs_drul_
[START
])
82 reqs_drul_
[START
]->warning (_ ("Already have a tremolo beam"));
86 prev_start_req_
= reqs_drul_
[START
];
89 abeam_p_
->set_elt_property ("chord-tremolo", SCM_BOOL_T
);
91 announce_element (Score_element_info (abeam_p_
, reqs_drul_
[LEFT
]));
96 Chord_tremolo_engraver::do_post_move_processing ()
98 reqs_drul_
[START
] = 0;
102 Chord_tremolo_engraver::do_pre_move_processing ()
108 Chord_tremolo_engraver::typeset_beam ()
110 if (finished_abeam_p_
)
112 typeset_element (finished_abeam_p_
);
113 finished_abeam_p_
= 0;
115 reqs_drul_
[STOP
] = 0;
120 Chord_tremolo_engraver::do_removal_processing ()
125 prev_start_req_
->warning (_ ("unfinished tremolo beam"));
126 finished_abeam_p_
= abeam_p_
;
132 Chord_tremolo_engraver::acknowledge_element (Score_element_info i
)
136 if (Stem
* s
= dynamic_cast<Stem
*> (i
.elem_l_
))
138 int type_i
= prev_start_req_
->type_i_
;
139 s
->set_elt_property ("duration-log", gh_int2scm (intlog2 (type_i
) - 2));
141 s
->set_beaming (s
->flag_i (), LEFT
);
142 s
->set_beaming ( s
->flag_i (), RIGHT
);
146 if (s
->type_i () != 1)
148 int gap_i
=s
->flag_i () - ((s
->type_i () >? 2) - 2);
149 s
->set_elt_property ("beam-gap", gh_int2scm(gap_i
));
152 if (s
->type_i () != 1)
154 int gap_i
=s
->flag_i () - ((s
->type_i () >? 2) - 2);
155 abeam_p_
->set_elt_property ("beam-gap", gh_int2scm(gap_i
));
159 abeam_p_
->add_stem (s
);