]> git.donarmstrong.com Git - lilypond.git/blobdiff - src/voice.cc
partial: 0.0.39-1.jcn
[lilypond.git] / src / voice.cc
index 8a1c136d04b32389fef812191696ca85a5c559d0..6301f299451916d676a84c934e8ecf4d74dda6c3 100644 (file)
@@ -1,22 +1,62 @@
+/*
+  voice.cc -- implement Voice
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
 #include "debug.hh"
 #include "voice.hh"
-#include "request.hh"
+#include "musicalrequest.hh"
+#include "commandrequest.hh"
+#include "midi-item.hh"
+#include "midi-stream.hh"
+#include "voice-element.hh"
+
+void
+Voice::set_default_group(String s)
+{
+    elts.top()->set_default_group(s);
+}
+
+bool
+Voice::find_plet_start_bo(char c, Moment& moment_r)
+{
+    for (iter_bot(elts, i); i.ok(); i--)
+       if ( i->find_plet_start_bo(c, moment_r) )
+           return true;
+    return false;
+}
+
+void 
+Voice::set_plet_backwards(Moment& now_moment_r, Moment until_moment,
+                         int num_i, int den_i)
+{
+    for (iter_bot(elts, i); i.ok(); i--) 
+       if ( now_moment_r <= until_moment ) 
+           i->set_plet_backwards(now_moment_r, until_moment, num_i, den_i);
+       else
+           return;
+}
 
 Voice::Voice(Voice const&src)
 {
-    PL_copy(elts, src.elts);
+    for (iter_top(src.elts, i); i.ok(); i++)
+       add(new Voice_element(**i));
+
     start = src.start;
 }
 
 Voice::Voice()
 {
-    start = 0.0;
+    start = 0;
 }
 
 void
 Voice::add(Voice_element*v)
 {
-    v->voice_ = this;
+    v->voice_l_ = this;
     elts.bottom().add(v);
 }
 
@@ -24,56 +64,22 @@ void
 Voice::print() const
 {
 #ifndef NPRINT
-    mtor << "start: "<< start<<eol;
-    for (PCursor<Voice_element*> vec(elts); vec.ok(); vec++)
-       vec->print();
+    mtor << "Voice { start: "<< start<<eol;
+    for (iter_top(elts,i); i.ok(); i++)
+       i->print();
+    mtor << "}\n";
 #endif
 }
 
-Real
+Moment
 Voice::last() const
 {
-    Real l =start;
-    for (PCursor<Voice_element*> vec(elts); vec.ok(); vec++)
-       l  += vec->duration;
+    Moment l =0;
+    if (elts.size())
+       l = start;
+    
+    for (iter_top(elts,i); i.ok(); i++)
+       l  += i->duration;
     return l;
 }
-/****************************************************************/
-void
-Voice_element::print() const
-{
-#ifndef NPRINT
-    mtor << "voice_element { dur :"<< duration <<"\n";
-    for (PCursor<Request*> rc(reqs); rc.ok(); rc++) {
-       rc->print();
-    }
-    mtor << "}\n";
-#endif
-}
-void
-Voice_element::add(Request*r)
-{
-    if (r->rhythmic()) {
-       assert (!duration);         
-       duration = r->duration();
-    }
-    r->elt = this;
-    reqs.bottom().add(r);
-}
-
 
-Voice_element::Voice_element()
-{
-    voice_ = 0;
-    group = 0;
-    duration = 0.0;
-}
-
-Voice_element::Voice_element(Voice_element const&src)
-{
-    duration=src.duration;
-    voice_=src.voice_;
-    IPointerList__copy(Request*, reqs, src.reqs, clone());
-    group=src.group;
-//    assert(!granted_items.size() && !granted_spanners.size());
-}