summaryrefslogtreecommitdiff
path: root/voice.cc
blob: ac6d33166d6058b2638a5a94b99d6c1a5237ed50 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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;
}