]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.1
authorfred <fred>
Tue, 17 Sep 1996 12:21:18 +0000 (12:21 +0000)
committerfred <fred>
Tue, 17 Sep 1996 12:21:18 +0000 (12:21 +0000)
voice.cc [new file with mode: 0644]
voice.hh [new file with mode: 0644]

diff --git a/voice.cc b/voice.cc
new file mode 100644 (file)
index 0000000..ac6d331
--- /dev/null
+++ b/voice.cc
@@ -0,0 +1,56 @@
+#include "debug.hh"
+#include "voice.hh"
+
+void
+Voice_element::add(Request*r)
+{
+    if (r->tag == Request::NOTE ||r->tag == Request::REST) {
+       assert (!duration);         
+       duration = r->duration();
+    }
+    reqs.bottom().add(r);
+}
+
+Voice::Voice()
+{
+    start = 0.0;
+}
+
+void
+Voice::add(Voice_element*v)
+{
+    elts.bottom().add(v);
+}
+
+Voice_element::Voice_element()
+{
+    voice = 0;
+    group = 0;
+    duration = 0.0;
+}
+
+void
+Voice::print() const
+{
+    mtor << "start: "<< start<<eol;
+    for (PCursor<Voice_element*> vec(elts); vec.ok(); vec++)
+       vec->print();
+}
+void
+Voice_element::print() const
+{
+    mtor << "voice_element { dur :"<< duration <<"\n";
+    for (PCursor<Request*> rc(reqs); rc.ok(); rc++) {
+       mtor << "reqtag: " << rc->tag<<eol;
+    }
+    mtor << "}\n";
+}
+
+Mtime
+Voice::last() const
+{
+    Mtime l =start;
+    for (PCursor<Voice_element*> vec(elts); vec.ok(); vec++)
+       l  += vec->duration;
+    return l;
+}
diff --git a/voice.hh b/voice.hh
new file mode 100644 (file)
index 0000000..3553752
--- /dev/null
+++ b/voice.hh
@@ -0,0 +1,49 @@
+#ifndef VOICE_HH
+#define VOICE_HH
+
+#include "mtime.hh"
+#include "list.hh"
+#include "request.hh"
+
+/// class for  horizontal stuff.
+struct Voice {
+    PointerList<Voice_element *> elts;
+    Mtime start;
+
+    /****************/
+    Mtime when(const Voice_element*)const;
+    Mtime last() const;
+    Voice();
+    void add(Voice_element*);
+    void print() const;
+};
+/**
+
+    Voice is a ordered row of Voice_elements. It is strictly horizontal:
+    you cannot have two rhythmic elements running parallel in a Voice
+
+    */
+
+struct Voicegroup {
+    /// don't know how to identify these.
+};
+
+/// 
+struct Voice_element {
+    Mtime duration;
+    const Voicegroup *group;
+    const Voice *voice;
+    PointerList<Request*> reqs;
+
+    List<const Item *> granted_items;
+    List<const Spanner *> granted_spanners;
+    void add(Request*);
+    Voice_element();
+
+    void print ()const;
+};
+/** Apart from being a container for the requests, Voice_element is
+    glue between related items and spanners, between requests and
+    (voice)groups
+    */
+#endif