#define KEYGRAV_HH
#include "engraver.hh"
-#include "key.hh"
+
#include "musical-pitch.hh"
+#include "protected-scm.hh"
+#include "newkey.hh"
+
/**
Make the key signature.
/*
TODO: move these into properties.
*/
- Key key_;
+ Newkey key_;
Key_change_req * keyreq_l_;
Key_item * item_p_;
- Array<Musical_pitch> accidental_idx_arr_;
- Array<Musical_pitch> old_accidental_idx_arr_;
-
+ Protected_scm old_accs_;
+ Protected_scm new_accs_;
bool key_changed_b() const;
--- /dev/null
+/*
+ newkey.hh -- declare Newkey
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+#ifndef NEWKEY_HH
+#define NEWKEY_HH
+
+#include "protected-scm.hh"
+
+class Newkey
+{
+ /*
+ alist mapping
+ (octave . notename) -> accidental and notename -> accidental
+ */
+ Protected_scm key_alist_;
+public:
+ void set (int name, int acc);
+ void set (int oct, int name, int acc);
+ void clear ();
+ void set_scm (SCM k, SCM v);
+ Newkey();
+ int get (int oct, int name);
+ int get (int name);
+};
+#endif /* NEWKEY_HH */
+
#include "staff-symbol-referencer.hh"
#include "side-position-interface.hh"
#include "engraver.hh"
-#include "key.hh"
+
#include "parray.hh"
virtual void do_removal_processing ();
public:
- Key local_key_;
+ Newkey local_key_;
Key_engraver *key_grav_l_;
Array<Note_req* > mel_l_arr_;
Array<Item*> support_l_arr_;
/* see if there's a tie that "changes" the accidental */
/* works because if there's a tie, the note to the left
is of the same pitch as the actual note */
- bool tie_changes = tied_l_arr_.find_l (support_l)
- && !local_key_.different_acc (note_l->pitch_);
+ int prev_acc =local_key_.get (note_l->pitch_.octave_i_,
+ note_l->pitch_.notename_i_);
+ bool different = prev_acc != note_l->pitch_.accidental_i_;
+
+ bool tie_changes = tied_l_arr_.find_l (support_l) && different;
if (!forget
-
- && ((note_l->forceacc_b_
- || !local_key_.different_acc (note_l->pitch_)
- || local_key_.internal_forceacc (note_l->pitch_)))
-
+ && (note_l->forceacc_b_
+ || !different)
&& !tie_changes)
{
if (!key_item_p_)
announce_element (Score_element_info (key_item_p_, 0));
}
+
+ bool extra_natural
+ = sign (prev_acc) * (prev_acc - note_l->pitch_.accidental_i_) == 1 ;
+
key_item_p_->add_pitch (note_l->pitch_,
note_l->cautionary_b_,
- local_key_.double_to_single_acc(note_l->pitch_));
+ extra_natural);
Side_position_interface (key_item_p_).add_support (support_l);
}
if (!forget)
{
- local_key_.set (note_l->pitch_);
+ local_key_.set (note_l->pitch_.octave_i_, note_l->pitch_.notename_i_,
+ note_l->pitch_.accidental_i_);
+#if 0
if (!tied_l_arr_.find_l (support_l))
{
local_key_.clear_internal_forceacc (note_l->pitch_);
{
local_key_.set_internal_forceacc (note_l->pitch_);
}
+#endif
}
}
}
--- /dev/null
+#include "newkey.hh"
+
+Newkey::Newkey ()
+{
+ clear();
+}
+
+void
+Newkey::clear()
+{
+ key_alist_ = SCM_EOL;
+}
+
+void
+Newkey::set (int n, int a)
+{
+ set_scm (gh_int2scm (n), gh_int2scm (a));
+}
+
+void
+Newkey::set (int o, int n, int a)
+{
+ set_scm (gh_cons (gh_int2scm (o),gh_int2scm(n)), gh_int2scm (a));
+}
+
+void
+Newkey::set_scm (SCM k, SCM v)
+{
+ key_alist_
+ = scm_assoc_set_x (key_alist_, k, v);
+}
+
+int
+Newkey::get (int o, int n)
+{
+ SCM r = scm_assoc (gh_cons (gh_int2scm (o), gh_int2scm (n)), key_alist_);
+ return r == SCM_BOOL_F ? get (n) : gh_cdr (r);
+}
+
+int
+Newkey::get (int n)
+{
+ SCM r = scm_assoc (gh_int2scm (n), key_alist_);
+ return r == SCM_BOOL_F ? 0: gh_cdr (r);
+}