2 local-key-reg.cc -- implement Local_key_engraver
4 (c) 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
7 #include "musical-request.hh"
8 #include "command-request.hh"
9 #include "local-key-grav.hh"
10 #include "local-key-item.hh"
11 #include "key-grav.hh"
13 #include "key-item.hh"
15 #include "note-head.hh"
16 #include "time-description.hh"
17 #include "engraver-group.hh"
20 Local_key_engraver::Local_key_engraver()
27 Local_key_engraver::do_creation_processing ()
30 daddy_grav_l()->get_simple_translator (Key_engraver::static_name());
34 warning ("Out of tune! Can't find key engraver");
38 key_C_
= &((Key_engraver
*)result
->engraver_l ())->key_
;
44 Local_key_engraver::process_acknowledged ()
46 if (!key_item_p_
&& mel_l_arr_
.size())
48 for (int i
=0; i
< mel_l_arr_
.size(); i
++)
50 Item
* support_l
= support_l_arr_
[i
];
51 Note_req
* note_l
= mel_l_arr_
[i
];
53 if (tied_l_arr_
.find_l (support_l
) &&
57 if (!note_l
->forceacc_b_
58 && local_key_
.different_acc (note_l
->pitch_
))
64 Staff_info inf
= get_staff_info();
65 if (inf
.c0_position_i_l_
)
66 c0_i
= *get_staff_info().c0_position_i_l_
;
68 key_item_p_
= new Local_key_item (c0_i
);
69 announce_element (Score_elem_info (key_item_p_
, 0));
71 key_item_p_
->add (note_l
->pitch_
);
72 key_item_p_
->add_support (support_l
);
73 local_key_
.set (note_l
->pitch_
);
80 Local_key_engraver::do_pre_move_processing()
84 for (int i
=0; i
< support_l_arr_
.size(); i
++)
85 key_item_p_
->add_support (support_l_arr_
[i
]);
87 typeset_element (key_item_p_
);
93 support_l_arr_
.clear();
94 forced_l_arr_
.clear();
98 Local_key_engraver::acknowledge_element (Score_elem_info info
)
100 Score_elem
* elem_l
= info
.elem_l_
;
101 if (info
.req_l_
->musical() && info
.req_l_
->musical ()->note ())
103 Note_req
* note_l
= info
.req_l_
->musical()->note ();
104 Item
* item_l
= info
.elem_l_
->item();
106 mel_l_arr_
.push (note_l
);
107 support_l_arr_
.push (item_l
);
109 else if (info
.req_l_
->command()
110 && info
.req_l_
->command()->keychange () && key_C_
)
112 local_key_
= *key_C_
;
114 else if (elem_l
->is_type_b (Tie::static_name ()))
116 Tie
* tie_l
= (Tie
*)elem_l
->spanner();
117 if (tie_l
->same_pitch_b_
)
118 tied_l_arr_
.push (tie_l
-> head_l_drul_
[RIGHT
]);
123 Local_key_engraver::do_process_requests()
125 Time_description
const * time_C_
= get_staff_info().time_C_
;
126 if (time_C_
&& !time_C_
->whole_in_measure_
)
134 IMPLEMENT_IS_TYPE_B1(Local_key_engraver
,Engraver
);
135 ADD_THIS_TRANSLATOR(Local_key_engraver
);