2 local-key-reg.cc -- implement Local_key_register
4 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 #include "musical-request.hh"
8 #include "command-request.hh"
9 #include "local-key-reg.hh"
10 #include "local-key-item.hh"
13 #include "key-item.hh"
15 #include "note-head.hh"
16 #include "time-description.hh"
18 Local_key_register::Local_key_register()
24 Local_key_register::do_pre_move_processing()
26 Local_key_item
*key_item_p
= 0;
27 if (mel_l_arr_
.size()) {
28 for (int i
=0; i
< mel_l_arr_
.size(); i
++) {
29 Item
* support_l
= support_l_arr_
[i
];
30 Note_req
* note_l
= mel_l_arr_
[i
];
32 if (tied_l_arr_
.find_l(support_l
) &&
36 if( !note_l
->forceacc_b_
&&
37 local_key_
.oct(note_l
->octave_i_
).acc(note_l
->notename_i_
)
38 == note_l
->accidental_i_
)
44 key_item_p
= new Local_key_item(*get_staff_info().c0_position_i_l_
);
45 key_item_p
->add(note_l
);
46 key_item_p
->add_support(support_l
);
47 local_key_
.oct(note_l
->octave_i_
)
48 .set(note_l
->notename_i_
, note_l
->accidental_i_
);
53 for(int i
=0; i
< support_l_arr_
.size(); i
++)
54 key_item_p
->add_support(support_l_arr_
[i
]);
56 typeset_element(key_item_p
);
59 mel_l_arr_
.set_size(0);
60 tied_l_arr_
.set_size(0);
61 support_l_arr_
.set_size(0);
62 forced_l_arr_
.set_size(0);
66 Local_key_register::acknowledge_element(Score_elem_info info
)
68 Score_elem
* elem_l
= info
.elem_l_
;
69 if (info
.req_l_
->musical() && info
.req_l_
->musical()->note()) {
70 Note_req
* note_l
= info
.req_l_
->musical()->note();
71 Item
* item_l
= info
.elem_l_
->item();
73 mel_l_arr_
.push(note_l
);
74 support_l_arr_
.push(item_l
);
76 } else if (info
.req_l_
->command()
77 && info
.req_l_
->command()->keychange()) {
78 Key_register
* key_reg_l
=
79 (Key_register
*)info
.origin_reg_l_arr_
[0];
80 key_C_
= &key_reg_l
->key_
;
82 } else if (elem_l
->name() == Key_item::static_name()) {
83 Key_register
* key_reg_l
=
84 (Key_register
*)info
.origin_reg_l_arr_
[0];
85 key_C_
= &key_reg_l
->key_
;
86 } else if (elem_l
->name() == Tie::static_name()) {
87 Tie
* tie_l
= (Tie
*)elem_l
->spanner();
88 if (tie_l
->same_pitch_b_
)
89 tied_l_arr_
.push(tie_l
-> right_head_l_
);
94 Local_key_register::do_process_requests()
96 Time_description
const * time_C_
= get_staff_info().time_C_
;
97 if (! time_C_
->whole_in_measure_
){
100 else if(0&& time_C_
->when_
>Moment(0))
101 warning ("Help me! can't figure out current key");
105 IMPLEMENT_STATIC_NAME(Local_key_register
);
106 IMPLEMENT_IS_TYPE_B1(Local_key_register
,Request_register
);
107 ADD_THIS_REGISTER(Local_key_register
);