From 36255564a7c76ca825b43ccc329605578bde0727 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 23:22:41 +0000 Subject: [PATCH] lilypond-1.3.58 --- lily/include/key-engraver.hh | 12 ++++++---- lily/include/newkey.hh | 32 +++++++++++++++++++++++++ lily/local-key-engraver.cc | 29 ++++++++++++++--------- lily/newkey.cc | 45 ++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 16 deletions(-) create mode 100644 lily/include/newkey.hh create mode 100644 lily/newkey.cc diff --git a/lily/include/key-engraver.hh b/lily/include/key-engraver.hh index 171ef13e9e..408f961d67 100644 --- a/lily/include/key-engraver.hh +++ b/lily/include/key-engraver.hh @@ -11,8 +11,11 @@ #define KEYGRAV_HH #include "engraver.hh" -#include "key.hh" + #include "musical-pitch.hh" +#include "protected-scm.hh" +#include "newkey.hh" + /** Make the key signature. @@ -29,13 +32,12 @@ public: /* TODO: move these into properties. */ - Key key_; + Newkey key_; Key_change_req * keyreq_l_; Key_item * item_p_; - Array accidental_idx_arr_; - Array old_accidental_idx_arr_; - + Protected_scm old_accs_; + Protected_scm new_accs_; bool key_changed_b() const; diff --git a/lily/include/newkey.hh b/lily/include/newkey.hh new file mode 100644 index 0000000000..32c3ad7f66 --- /dev/null +++ b/lily/include/newkey.hh @@ -0,0 +1,32 @@ +/* + newkey.hh -- declare Newkey + + source file of the GNU LilyPond music typesetter + + (c) 2000 Han-Wen Nienhuys + + */ + +#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 */ + diff --git a/lily/local-key-engraver.cc b/lily/local-key-engraver.cc index 192baaee47..d8350f1c7a 100644 --- a/lily/local-key-engraver.cc +++ b/lily/local-key-engraver.cc @@ -20,7 +20,7 @@ #include "staff-symbol-referencer.hh" #include "side-position-interface.hh" #include "engraver.hh" -#include "key.hh" + #include "parray.hh" @@ -42,7 +42,7 @@ protected: virtual void do_removal_processing (); public: - Key local_key_; + Newkey local_key_; Key_engraver *key_grav_l_; Array mel_l_arr_; Array support_l_arr_; @@ -111,15 +111,15 @@ Local_key_engraver::process_acknowledged () /* 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_) @@ -132,15 +132,21 @@ Local_key_engraver::process_acknowledged () 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_); @@ -149,6 +155,7 @@ Local_key_engraver::process_acknowledged () { local_key_.set_internal_forceacc (note_l->pitch_); } +#endif } } } diff --git a/lily/newkey.cc b/lily/newkey.cc new file mode 100644 index 0000000000..31bd1c913c --- /dev/null +++ b/lily/newkey.cc @@ -0,0 +1,45 @@ +#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); +} -- 2.39.5