From: fred Date: Sun, 24 Mar 2002 19:35:49 +0000 (+0000) Subject: lilypond-0.0.43 X-Git-Tag: release/1.5.59~5159 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ecf94868b657a8a5f90424e4f773866874273f1c;p=lilypond.git lilypond-0.0.43 --- diff --git a/lily/include/command-request.hh b/lily/include/command-request.hh index 3d5a1eb18d..f32dbea2fd 100644 --- a/lily/include/command-request.hh +++ b/lily/include/command-request.hh @@ -101,7 +101,7 @@ struct Group_feature_req : Command_req { struct Key_change_req : Command_req { Array melodic_p_arr_; - + virtual void transpose(Melodic_req const &)const; Key_change_req(); Key_change_req(Key_change_req const&); ~Key_change_req(); diff --git a/lily/include/input-music.hh b/lily/include/input-music.hh index 7a35bbfd19..36ca215f67 100644 --- a/lily/include/input-music.hh +++ b/lily/include/input-music.hh @@ -37,7 +37,7 @@ struct Input_music { virtual void set_default_group(String)=0; virtual bool find_plet_start_bo(char c, Moment& moment_r) = 0; virtual void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i) = 0; - // virtual void transpose(...) const =0; + virtual void transpose(Melodic_req const&) const =0; virtual Input_music *clone() const = 0; @@ -49,6 +49,8 @@ struct Simple_music : Input_music { Voice voice_; /* *** */ + virtual void transpose(Melodic_req const&) const ; + virtual Simple_music*simple() { return this; } void add(Voice_element*); virtual void set_default_group(String g) { voice_.set_default_group(g); } @@ -67,6 +69,7 @@ struct Simple_music : Input_music { struct Complex_music : Input_music { IPointerList elts; /* *************** */ + virtual void transpose(Melodic_req const&) const ; virtual void set_default_group(String g); void add(Input_music*); Complex_music(); diff --git a/lily/include/musical-request.hh b/lily/include/musical-request.hh index 6d96117ff2..761efce6bd 100644 --- a/lily/include/musical-request.hh +++ b/lily/include/musical-request.hh @@ -96,11 +96,11 @@ struct Melodic_req :virtual Musical_req /// 0 natural, 1 sharp, etc int accidental_i_; - /// force/supress printing of accidental. - bool forceacc_b_; - /// return height from central c (in halflines) - int height()const; + int height()const; + + /// transpose. #delta# is relative to central c. + void transpose(Melodic_req const &delta); /// return pitch from central c (in halfnotes) int pitch()const; Melodic_req(); @@ -111,7 +111,9 @@ struct Melodic_req :virtual Musical_req /// Put a note of specified type, height, and with accidental on the staff. struct Note_req : Rhythmic_req, virtual Melodic_req { - + /// force/supress printing of accidental. + bool forceacc_b_; + Note_req(); Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic(); } REQUESTMETHODS(Note_req, note); }; @@ -214,7 +216,7 @@ struct Subtle_req : virtual Musical_req { struct Dynamic_req : Subtle_req { /// for absolute dynamics enum Loudness { - FFF, FF, F, MF, MP, P, PP, PPP + FFF, FF, F, MF, MP, P, PP, PPP }; static String loudness_str(Loudness); REQUESTMETHODS(Dynamic_req, dynamic); diff --git a/lily/include/request.hh b/lily/include/request.hh index 1936d5a2ab..6e9bfd4df2 100644 --- a/lily/include/request.hh +++ b/lily/include/request.hh @@ -35,6 +35,7 @@ public: virtual Request* clone() const { return new Request(*this); } void print()const ; + virtual void transpose(Melodic_req const &){} virtual Moment duration() const { return 0; } /* accessors for children diff --git a/lily/include/voice-element.hh b/lily/include/voice-element.hh index 0c5b6b1328..cf398bc9b6 100644 --- a/lily/include/voice-element.hh +++ b/lily/include/voice-element.hh @@ -19,11 +19,11 @@ struct Voice_element { Moment duration; char const* defined_ch_c_l_; - const Voice *voice_l_; + Voice const *voice_l_; IPointerList reqs; /* *************** */ - + void transpose(Melodic_req const &)const; Voice_element(); Voice_element(Voice_element const & src ); diff --git a/lily/include/voice.hh b/lily/include/voice.hh index 06e6e1da27..4e7e615693 100644 --- a/lily/include/voice.hh +++ b/lily/include/voice.hh @@ -22,9 +22,9 @@ struct Voice { Voice(); Voice(Voice const&); - Moment when(const Voice_element*)const; + Moment when(Voice_element const *)const; Moment last() const; - + void transpose(Melodic_req const &)const; void add(Voice_element*); bool find_plet_start_bo(char c, Moment& moment_r); void print() const; diff --git a/lily/musical-request.cc b/lily/musical-request.cc index be9667c1a0..597a60ac76 100644 --- a/lily/musical-request.cc +++ b/lily/musical-request.cc @@ -36,9 +36,11 @@ void Request::do_print() const{} void Request::print() const { +#ifndef NPRINT mtor << name() << " {"; do_print(); mtor << "}\n"; +#endif } @@ -87,13 +89,30 @@ Melodic_req::Melodic_req() notename_i_ = 0; octave_i_ = 0; accidental_i_ = 0; - forceacc_b_ = false; +} + +void +Melodic_req::transpose(Melodic_req const & delta) +{ + octave_i_ += delta.octave_i_; + notename_i_ += delta.notename_i_; + while (notename_i_ >= 7 ) { + notename_i_ -= 7; + octave_i_ ++; + } + accidental_i_ += delta.accidental_i_; + if (abs(accidental_i_) > 2) { + warning("transposition makes accidental larger than 2", + delta.defined_ch_c_l_); + } } void Melodic_req::do_print() const { - mtor << "notename: " << notename_i_ << " acc: " <compare(*d2.scriptdef_p_); @@ -247,7 +278,7 @@ Script_req::~Script_req() } /* *************** */ int -Text_req:: compare(const Text_req &r1, const Text_req &r2) +Text_req:: compare(Text_req const &r1, Text_req const &r2) { bool b1 = (r1.dir_i_ == r2.dir_i_); bool b2 = (r1.tdef_p_ ->compare(*r2.tdef_p_)); @@ -274,8 +305,11 @@ Text_req::Text_req(int dir_i, Text_def* tdef_p) void Text_req::do_print() const { +#ifndef NPRINT + mtor << " dir " << dir_i_ ; tdef_p_->print(); +#endif } /* *************** */ @@ -289,7 +323,10 @@ Skip_req::duration() const void Skip_req::do_print() const { +#ifndef NPRINT + mtor << "duration: " << duration(); +#endif } Voice * @@ -305,7 +342,9 @@ Request::voice_l() void Subtle_req::do_print() const { - mtor << " subtime " << subtime_; +#ifndef NPRINT + mtor << " subtime " << subtime_; +#endif } void