]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.61
authorfred <fred>
Sun, 24 Mar 2002 19:40:29 +0000 (19:40 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:40:29 +0000 (19:40 +0000)
lily/include/musical-request.hh
lily/local-key-reg.cc
lily/musical-request.cc

index eaba302d2bb8d5a486f2e98080cdeb1f2c6f7c7a..721b2ff51cfee1a26cd69459f11d9f8dde7c3cec 100644 (file)
@@ -114,6 +114,7 @@ struct Melodic_req :virtual Musical_req
     /// return pitch from central c (in halfnotes)
     int pitch()const; 
     Melodic_req();
+    static int compare(Melodic_req const&, Melodic_req const&);
    
     REQUESTMETHODS(Melodic_req,melodic);
 };
index 84ec5baf690b34cf0684692b35cb0f18446a728d..2fac0d573d21c3ac2ca8a909adbea239c03868e0 100644 (file)
 #include "key-reg.hh"
 #include "debug.hh"
 #include "key-item.hh"
+#include "tie.hh"
+#include "notehead.hh"
 
 Local_key_register::Local_key_register()
 {
-    key_item_p_ = 0;
     key_C_ = 0;
 }
 
 void
 Local_key_register::pre_move_processing()
 {
-    if (key_item_p_) {
-       typeset_element(key_item_p_);
-       key_item_p_ = 0;
+    if (mel_l_arr_.size()) {
+       Local_key_item *key_item_p = 0;
+       for (int i=0; i  < mel_l_arr_.size(); i++) {
+           Item * support_l = support_l_arr_[i];
+
+           Note_req * note_l = mel_l_arr_[i];
+           if (tied_l_arr_.find_l(support_l) && !forced_l_arr_.find_l(support_l))
+               continue;
+           
+           if (!key_item_p)
+               key_item_p = new Local_key_item(*get_staff_info().c0_position_i_l_);
+           key_item_p->add(note_l);
+           key_item_p->add(support_l);
+           local_key_.oct(note_l->octave_i_)
+               .set(note_l->notename_i_, note_l->accidental_i_);
+       }
+       if (key_item_p)
+           typeset_element(key_item_p);
     }
+    mel_l_arr_.set_size(0);
+    tied_l_arr_.set_size(0);
+    support_l_arr_.set_size(0);
+    forced_l_arr_.set_size(0); 
 }
 
 void
 Local_key_register::acknowledge_element(Staff_elem_info info)
 {    
+    Staff_elem * elem_l = info.elem_l_;
     if (info.req_l_->note()) {
-       Note_req * note_l_ = info.req_l_->note();
+       Note_req * note_l = info.req_l_->note();
+       Item * item_l = info.elem_l_->item();
 
-       if( note_l_->forceacc_b_ ||
-           local_key_.oct(note_l_->octave_i_).acc(note_l_->notename_i_)
-           != note_l_->accidental_i_) {
-           Item * support_l_ = info.elem_l_->item();
-       
-
-           if (!key_item_p_) {
-               key_item_p_ = new Local_key_item(*get_staff_info().c0_position_i_l_);
-           }
-           
-           key_item_p_->add(note_l_);
-           key_item_p_->add(support_l_);
-           local_key_.oct(note_l_->octave_i_)
-               .set(note_l_->notename_i_, note_l_->accidental_i_);
+       if( note_l->forceacc_b_ ||
+           local_key_.oct(note_l->octave_i_).acc(note_l->notename_i_)
+           != note_l->accidental_i_) {
+           mel_l_arr_.push(note_l );
+           support_l_arr_.push(item_l);
+           if (note_l->forceacc_b_)
+               forced_l_arr_.push(item_l);
        }
-    } else if (info.req_l_->command()  && info.req_l_->command()->keychange()) { 
+    } else if (info.req_l_->command()
+              && info.req_l_->command()->keychange()) { 
        Key_register * key_reg_l =
            (Key_register*)info.origin_reg_l_arr_[0];
        key_C_ = &key_reg_l->key_;
        local_key_ = *key_C_;
-    } else if (info.elem_l_->name() == Key_item::static_name()) {
+    } else if (elem_l->name() == Key_item::static_name()) {
        Key_register * key_reg_l =
            (Key_register*)info.origin_reg_l_arr_[0];
        key_C_ = &key_reg_l->key_;
+    } else if (elem_l->name() == Tie::static_name()) {
+       Tie * tie_l = (Tie*)elem_l;
+       if (tie_l->same_pitch_b_)
+           tied_l_arr_.push(tie_l-> right_head_l_ );
     }
 }
 
@@ -69,7 +89,7 @@ Local_key_register::process_requests()
        if (key_C_)
            local_key_= *key_C_;
        else if( time_C_->when_ >Moment(0))
-           warning ("Help me! can't figure  current key");
+           warning ("Help me! can't figure out current key");
     }
 }
 
index 5ed08aa996b9b6efff759ad753bee4cb541ef1cf..9f65d8a88f88d0159ee450bb86bad6e46e12c121 100644 (file)
@@ -127,11 +127,23 @@ Melodic_req::transpose(Melodic_req const & delta)
 
 IMPLEMENT_STATIC_NAME(Melodic_req);
 
+int
+Melodic_req::compare(Melodic_req const&m1, Melodic_req const&m2)
+{
+    if (m1.octave_i_ != m2.octave_i_)
+       return m1.octave_i_ -m2.octave_i_;
+    else if (m1.notename_i_ != m2.notename_i_)
+       return m1.notename_i_ - m2.notename_i_;
+    else  if (m1.accidental_i_ != m2.accidental_i_)
+       return m1.accidental_i_ - m2.accidental_i_;
+    return 0;
+}
+
 void
 Melodic_req::do_print() const
 {
 #ifndef NPRINT
-       mtor << "notename: " << notename_i_ << " acc: " <<accidental_i_<<" oct: "<< octave_i_;
+    mtor << "notename: " << notename_i_ << " acc: " <<accidental_i_<<" oct: "<< octave_i_;
 #endif
 }