]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.45
authorfred <fred>
Sun, 24 Mar 2002 19:36:36 +0000 (19:36 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:36:36 +0000 (19:36 +0000)
lily/include/input-music.hh
lily/include/voice-element.hh
lily/include/voice.hh
lily/input-music.cc
lily/voice-elt.cc
lily/voice.cc

index 36ca215f67521d1852e0a45d66b69f9a3a96c679..49e41d572956a50575e22a9a8252fc12920b5f47 100644 (file)
@@ -35,7 +35,7 @@ struct Input_music {
     virtual ~Input_music(){}
     virtual void print() const =0;
     virtual void set_default_group(String)=0;
-    virtual bool find_plet_start_bo(char c, Moment& moment_r) = 0;
+    virtual bool find_plet_start_b(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(Melodic_req const&) const =0;
     
@@ -58,7 +58,7 @@ struct Simple_music : Input_music {
     virtual Voice_list convert()const;
     virtual void translate_time(Moment dt);
     virtual void print() const;
-    virtual bool find_plet_start_bo(char c, Moment& moment_r);
+    virtual bool find_plet_start_b(char c, Moment& moment_r);
     virtual void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i);
     virtual Input_music *clone() const {
        return new Simple_music(*this);
@@ -76,7 +76,7 @@ struct Complex_music : Input_music {
     Complex_music(Complex_music const &);
     virtual void print() const ;
     void concatenate(Complex_music*);
-    virtual bool find_plet_start_bo(char c, Moment& moment_r);
+    virtual bool find_plet_start_b(char c, Moment& moment_r);
     virtual void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i);
 };
 
index 0b606f1301a0a31c7d58294916f22068c793b979..aa72fb8122db55fd57cec9e8cffa004f7487fd36 100644 (file)
 /** one horizontal bit.  Voice_element is nothing but a container for
     *the requests, */
 struct Voice_element {
-    Moment duration;
+    /** the duration of the element.  This can be 0; The duration is
+      determined from rhythmical requests contained in this
+      Voice_element */
+    Moment duration_;
     char const* defined_ch_C_;
     Voice const *voice_l_;
     IPointerList<Request*> reqs;
@@ -28,7 +31,7 @@ struct Voice_element {
     Voice_element(Voice_element const & src );
 
     void add(Request*);
-    bool find_plet_start_bo(char c, Moment& moment_r);
+    bool find_plet_start_b(char c, Moment& moment_r);
     void print ()const;
     void set_default_group(String id);
     void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i);
index 4e7e615693e7ed4bf8ca9010b95c7b55883feed0..f5a950a2c9f024fb2127c0b105a7c953a9446613 100644 (file)
@@ -15,6 +15,9 @@
     */
 
 struct Voice {
+    /** the elements, earliest first.
+      Please use the member #add()# to add a new element
+      */
     IPointerList<Voice_element *> elts;
     Moment start;
 
@@ -26,7 +29,7 @@ struct Voice {
     Moment last() const;
     void transpose(Melodic_req const &)const;
     void add(Voice_element*);
-    bool find_plet_start_bo(char c, Moment& moment_r);
+    bool find_plet_start_b(char c, Moment& moment_r);
     void print() const;
     void set_default_group(String id);
     void set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i);
index 26377e7f531893569fc44e704fcee20a5ea4e78c..e407c87dd567b4711a10c00e72977e6040b9eac5 100644 (file)
@@ -2,6 +2,7 @@
 #include "input-music.hh"
 #include "voice.hh"
 #include "musical-request.hh"
+#include "command-request.hh"
 #include "voice-element.hh"
 
 void
@@ -10,7 +11,7 @@ Input_music::check_plet(Voice_element* velt_l)
     for (iter_top(velt_l->reqs,i); i.ok(); i++)
        if ( i->plet() ) {
            Moment start_moment = 0;
-           if ( !find_plet_start_bo( i->plet()->type_c_, start_moment ) ) {
+           if ( !find_plet_start_b( i->plet()->type_c_, start_moment ) ) {
                error( "begin of plet not found", i->defined_ch_C_ );
                break;
            }
@@ -48,7 +49,15 @@ Voice_list
 Simple_music::convert()const
 {
     Voice_list l;
-    l.bottom().add(new Voice(voice_));
+    Voice * v_p = new Voice(voice_);
+    PCursor<Voice_element*> i= v_p->elts.bottom();
+       // need-to-have, otherwise memory will be filled up with regs. 
+    if (!i.ok() || i->duration_) {
+       v_p->add ( new Voice_element);
+       i=v_p->elts.bottom();
+    }
+    i->add(new Terminate_voice_req); 
+    l.bottom().add(v_p);
     return l;
 }
 
@@ -56,17 +65,20 @@ Simple_music::convert()const
 void
 Simple_music::print() const
 {
+#ifndef NPRINT
     mtor << "Simple_music {";
     voice_.print();
     mtor << "}\n";
+#endif
 }
 bool
-Simple_music::find_plet_start_bo(char c, Moment& moment_r)
+Simple_music::find_plet_start_b(char c, Moment& moment_r)
 {
-    return voice_.find_plet_start_bo(c, moment_r);
+    return voice_.find_plet_start_b(c, moment_r);
 }
 void 
-Simple_music::set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i)
+Simple_music::set_plet_backwards(Moment& now_moment_r, Moment until_moment, 
+                                int num_i, int den_i)
 {
     voice_.set_plet_backwards(now_moment_r, until_moment, num_i, den_i);
 }
@@ -115,10 +127,10 @@ Complex_music::set_default_group(String g)
            i->set_default_group(g);
 }
 bool
-Complex_music::find_plet_start_bo(char c, Moment& moment_r)
+Complex_music::find_plet_start_b(char c, Moment& moment_r)
 {
     for (iter_bot(elts,i); i.ok(); i--) {
-        if ( i->find_plet_start_bo(c, moment_r) )
+        if ( i->find_plet_start_b(c, moment_r) )
            return true;
     }
     return false;
index 4c1249b14072d7fb54f874b8f447ce84288a7057..4e334378864b6768ba164cb7f8ffa5d916cdc5ad 100644 (file)
@@ -27,7 +27,7 @@ void
 Voice_element::print() const
 {
 #ifndef NPRINT
-    mtor << "voice_element { dur :"<< duration <<"\n";
+    mtor << "voice_element { dur :"<< duration_ <<"\n";
     for (iter_top(reqs,rc); rc.ok(); rc++) {
        rc->print();
     }
@@ -39,8 +39,8 @@ void
 Voice_element::add(Request*r)
 {
     if (r->duration()) {
-       assert (!duration  || duration == r->duration());
-       duration = r->duration();
+       assert (!duration_  || duration_ == r->duration());
+       duration_ = r->duration();
     }
     
     r->elt_l_ = this;
@@ -51,7 +51,7 @@ Voice_element::add(Request*r)
 Voice_element::Voice_element()
 {
     voice_l_ = 0;
-    duration = 0;
+    duration_ = 0;
     defined_ch_C_ = 0;
 }
 
@@ -65,10 +65,10 @@ Voice_element::Voice_element(Voice_element const&src)
 
 }
 bool
-Voice_element::find_plet_start_bo(char c, Moment& moment_r)
+Voice_element::find_plet_start_b(char c, Moment& moment_r)
 {
     assert( c == ']' );
-    moment_r += duration;
+    moment_r += duration_;
     for ( PCursor<Request*> i( reqs.top() ); i.ok(); i++ ) {
        if (i->beam() && i->beam()->spantype == Span_req::START )
            return true;
@@ -91,7 +91,7 @@ void
 Voice_element::set_plet_backwards(Moment& now_moment_r,
                                  Moment until_moment, int num_i, int den_i)
 {
-    now_moment_r += duration;
+    now_moment_r += duration_;
     if ( now_moment_r > until_moment )
        return;
     for ( PCursor<Request*> i( reqs.top() ); i.ok(); i++ ) {
index 2294d57b2ecb0d8f87ab4fb75c3eca91a3a9e4f7..d76b3ebe83f975e7f3e49e21ef8ccef1e9ae7b01 100644 (file)
@@ -30,10 +30,10 @@ Voice::set_default_group(String s)
 }
 
 bool
-Voice::find_plet_start_bo(char c, Moment& moment_r)
+Voice::find_plet_start_b(char c, Moment& moment_r)
 {
     for (iter_bot(elts, i); i.ok(); i--)
-       if ( i->find_plet_start_bo(c, moment_r) )
+       if ( i->find_plet_start_b(c, moment_r) )
            return true;
     return false;
 }
@@ -88,7 +88,7 @@ Voice::last() const
        l = start;
     
     for (iter_top(elts,i); i.ok(); i++)
-       l  += i->duration;
+       l  += i->duration_;
     return l;
 }