From: fred Date: Sun, 24 Mar 2002 19:38:20 +0000 (+0000) Subject: lilypond-0.0.49 X-Git-Tag: release/1.5.59~5013 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0ec722ecd961b64b25860b0ee6d2f8ef5fb9848d;p=lilypond.git lilypond-0.0.49 --- diff --git a/lily/command-request.cc b/lily/command-request.cc index dfa448f41f..55ccf54c27 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -173,6 +173,13 @@ Key_change_req::transpose(Melodic_req const & d)const } IMPLEMENT_STATIC_NAME(Key_change_req); +void +Key_change_req::squash_octaves() +{ + for (int i=0; i < melodic_p_arr_.size(); i++) { + melodic_p_arr_[i]->octave_i_ = 0; + } +} void Key_change_req::do_print() const @@ -185,6 +192,7 @@ Key_change_req::do_print() const Key_change_req::Key_change_req() { minor_b_ = false; + multi_octave_b_= false; } Key_change_req::Key_change_req(Key_change_req const&c) @@ -192,6 +200,7 @@ Key_change_req::Key_change_req(Key_change_req const&c) for (int i=0; i < c.melodic_p_arr_.size(); i++) melodic_p_arr_.push( c.melodic_p_arr_[i]->clone()->melodic() ); minor_b_ = c.minor_b_; + multi_octave_b_ = c.multi_octave_b_; } Key_change_req::~Key_change_req() @@ -208,7 +217,7 @@ Key_change_req::flats_i() Melodic_req* mel_l = melodic_p_arr_[i]->melodic(); assert( mel_l ); if ( mel_l->accidental_i_ < 0 ) - flats_i++; + flats_i -= mel_l->accidental_i_; } return flats_i; } @@ -227,7 +236,7 @@ Key_change_req::sharps_i() Melodic_req* mel_l = melodic_p_arr_[i]->melodic(); assert( mel_l ); if ( mel_l->accidental_i_ > 0 ) - sharps_i++; + sharps_i+= mel_l->accidental_i_; } return sharps_i; } diff --git a/lily/include/key.hh b/lily/include/key.hh index 3d58629d5d..cbffa1e8f7 100644 --- a/lily/include/key.hh +++ b/lily/include/key.hh @@ -1,5 +1,5 @@ /* - key.hh -- declare Key + key.hh -- declare Key, Octave_key (c) 1996,97 Han-Wen Nienhuys */ @@ -10,13 +10,11 @@ #include "varray.hh" #include "scalar.hh" -/// administration of current key -class Key { - Array accidental_i_arr_; - - /* *************** */ +/// administration of current key in one octave. +class Octave_key { public: + Array accidental_i_arr_; Key(); void set(int i, int acc); @@ -24,14 +22,19 @@ public: }; /// administration of accidentals -struct Local_key +class Key { - void reset(Key); - Key& oct(int); - Local_key(); - -private: - Array octaves; + /** for each octave a key. Has to be private since octave 0 isn't member 0. + */ + Array octaves; +public: + bool multi_octave_b_; + + Octave_key&oct(int); + Octave_key oct(int) const; + void set(int name, int acc); + void set(int oct, int name, int acc); + Key(); }; #endif // KEY_HH diff --git a/lily/include/staff-info.hh b/lily/include/staff-info.hh index 4873da6b49..2229c99ab0 100644 --- a/lily/include/staff-info.hh +++ b/lily/include/staff-info.hh @@ -1,5 +1,5 @@ /* - staff-info.hh -- declare + staff-info.hh -- declare Staff_info source file of the LilyPond music typesetter @@ -19,6 +19,8 @@ struct Staff_info { /// when is now? Time_description const *time_C_; Rhythmic_grouping const *rhythmic_C_; + + /// bool break_allowed_b_; Moment when(); diff --git a/lily/key-item.cc b/lily/key-item.cc index 7cc9fcbfa9..1054fc2c73 100644 --- a/lily/key-item.cc +++ b/lily/key-item.cc @@ -20,10 +20,11 @@ Key_item::Key_item(int c) void Key_item::read(Key_register const & key_reg_r) { + assert(!key_reg_r.key_.multi_octave_b_); const Array &idx_arr =key_reg_r.accidental_idx_arr_; for (int i = 0 ; i< idx_arr.size(); i++) { int note = idx_arr[i]; - int acc = key_reg_r.key_.acc(note); + int acc = key_reg_r.key_.oct(0).acc(note); add(note, acc); } diff --git a/lily/key.cc b/lily/key.cc index 7e23464ccf..0f02ef845d 100644 --- a/lily/key.cc +++ b/lily/key.cc @@ -3,36 +3,47 @@ const int OCTAVES=14; // ugh.. const int ZEROOCTAVE=7; -Key::Key() +Octave_key::Octave_key() { accidental_i_arr_.set_size(7); for (int i= 0; i < 7 ; i++) accidental_i_arr_[i] = 0; } -Local_key::Local_key() +Key::Key() { + multi_octave_b_ = false; octaves.set_size(OCTAVES); } -Key& -Local_key::oct(int i) +Octave_key& +Key::oct(int i) +{ + return octaves[i+ZEROOCTAVE]; +} + +Octave_key +Key::oct(int i)const { return octaves[i+ZEROOCTAVE]; } void -Key::set(int i, int a) +Octave_key::set(int i, int a) { assert(a > -3 && a < 3); accidental_i_arr_[i]=a; } +void +Key::set(int o, int n , int a) +{ + octaves[o + ZEROOCTAVE].set(n,a); +} void -Local_key::reset(Key k) +Key::set (int n, int a) { for (int i= 0; i < OCTAVES ; i++) - octaves[i] = k; + octaves[i].set(n,a); } - diff --git a/lily/local-key-reg.cc b/lily/local-key-reg.cc index 308a7ac432..caf3e524a6 100644 --- a/lily/local-key-reg.cc +++ b/lily/local-key-reg.cc @@ -52,7 +52,7 @@ Local_key_register::acknowledge_element(Staff_elem_info info) Key_register * key_reg_l = (Key_register*)info.origin_reg_l_arr_[0]; key_C_ = &key_reg_l->key_; - local_key_.reset(*key_C_); + local_key_ = *key_C_; } } @@ -62,7 +62,7 @@ Local_key_register::process_requests() Time_description const * time_C_ = get_staff_info().time_C_; if (! time_C_->whole_in_measure_){ if (key_C_) - local_key_.reset(*key_C_); + local_key_= *key_C_; else if( time_C_->when_ >Moment(0)) warning ("Help me! can't figure current key"); }