]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.43
authorfred <fred>
Sun, 24 Mar 2002 19:35:49 +0000 (19:35 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:35:49 +0000 (19:35 +0000)
lily/include/command-request.hh
lily/include/input-music.hh
lily/include/musical-request.hh
lily/include/request.hh
lily/include/voice-element.hh
lily/include/voice.hh
lily/musical-request.cc

index 3d5a1eb18d496d336700c1e2c873acad06d60060..f32dbea2fdb35f1146f191c2cffa666cd0e40d91 100644 (file)
@@ -101,7 +101,7 @@ struct Group_feature_req : Command_req {
 
 struct Key_change_req : Command_req {
     Array<Melodic_req*> melodic_p_arr_;
-
+    virtual void transpose(Melodic_req const &)const;
     Key_change_req();
     Key_change_req(Key_change_req const&);
     ~Key_change_req();
index 7a35bbfd19b037827ac59d040b8a7f097d5460d7..36ca215f67521d1852e0a45d66b69f9a3a96c679 100644 (file)
@@ -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<Input_music*> elts;
     /* *************** */
+    virtual void transpose(Melodic_req const&) const ;
     virtual void set_default_group(String g);
     void add(Input_music*);
     Complex_music();
index 6d96117ff2f2a9d5bdc237dfa94c1e2156cc06b9..761efce6bd37e0061e75a2f22963c1d752113434 100644 (file)
@@ -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);
index 1936d5a2abf0fe3e7972859874b27508c99cf908..6e9bfd4df2c95f87f875fc52a8fbb48e9315abc0 100644 (file)
@@ -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
index 0c5b6b132882dcae69db69c2de8acb0c02bddaee..cf398bc9b676dffe87e9df87088991edf42a60f2 100644 (file)
 struct Voice_element {
     Moment duration;
     char const* defined_ch_c_l_;
-    const Voice *voice_l_;
+    Voice const *voice_l_;
     IPointerList<Request*> reqs;
 
     /* *************** */
-    
+    void transpose(Melodic_req const &)const;
     Voice_element();
     Voice_element(Voice_element const & src );
 
index 06e6e1da279006f08aa94113d2365c3840dcb996..4e7e615693e7ed4bf8ca9010b95c7b55883feed0 100644 (file)
@@ -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;
index be9667c1a0e893cebe9d1b5d26e8ed15b9f2ab76..597a60ac7608536d5a872cc22948d4e66d99acf0 100644 (file)
@@ -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: " <<accidental_i_<<" oct: "<< octave_i_;
+#ifndef NPRINT
+       mtor << "notename: " << notename_i_ << " acc: " <<accidental_i_<<" oct: "<< octave_i_;
+#endif
 }
 
 int
@@ -123,12 +142,14 @@ Plet_req::Plet_req()
 void
 Plet_req::do_print() const
 {
+#ifndef NPRINT
     mtor << "plet: " << type_c_ << ": " << dur_i_ << "/" << type_i_;
+#endif
 }
 
 /* *************** */
 int
-Rhythmic_req::compare(const Rhythmic_req &r1, const Rhythmic_req &r2)
+Rhythmic_req::compare(Rhythmic_req const &r1, Rhythmic_req const &r2)
 {
     return sign(r1.duration() - r2.duration());
 }
@@ -149,12 +170,14 @@ Rhythmic_req::Rhythmic_req()
 void
 Rhythmic_req::do_print() const
 {
+#ifndef NPRINT
     mtor << "ball: " << balltype ;
     int d =dots;
     while (d--)
        mtor << '.';
     
     mtor<<", plet factor"<<plet_factor<<"\n";
+#endif
 }
 
 
@@ -177,12 +200,20 @@ Lyric_req::do_print() const
     Rhythmic_req::do_print();
     Text_req::do_print();
 }
+
 /* *************** */
+Note_req::Note_req()
+{
+    forceacc_b_ = false;
+}
 void
 Note_req::do_print() const
 {
+#ifndef NPRINT
+    mtor << " forceacc_b_ " << forceacc_b_ << '\n';
     Melodic_req::do_print();
     Rhythmic_req::do_print();
+#endif
 }
 /* *************** */
 void
@@ -202,7 +233,7 @@ void Beam_req::do_print()const{}
 void Slur_req::do_print()const{}
 /* *************** */
 int
-Span_req:: compare(const Span_req &r1, const Span_req &r2)
+Span_req:: compare(Span_req const &r1, Span_req const &r2)
 {
      return r1.spantype - r2.spantype;
 }
@@ -220,7 +251,7 @@ Script_req::Script_req(int d , Script_def*def)
 }
 
 int
-Script_req::compare(const Script_req &d1, const Script_req &d2)
+Script_req::compare(Script_req const &d1, Script_req const &d2)
 {
     return d1.dir_i_ == d2.dir_i_ &&
        d1.scriptdef_p_->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