summaryrefslogtreecommitdiff
path: root/src/voice.cc
blob: 14883e149966d9997b6029168cd9e297cfb1c1ec (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "debug.hh"
#include "voice.hh"

Voice::Voice(Voice const&src)
{
    PL_copy(elts, src.elts);
    start = src.start;
}

Voice::Voice()
{
    start = 0.0;
}

void
Voice::add(Voice_element*v)
{
    elts.bottom().add(v);
}

void
Voice::print() const
{
        #ifndef NPRINT

    mtor << "start: "<< start<<eol;
    for (PCursor<Voice_element*> vec(elts); vec.ok(); vec++)
	vec->print();
#endif
}

Real
Voice::last() const
{
    Real l =start;
    for (PCursor<Voice_element*> vec(elts); vec.ok(); vec++)
	l  += vec->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;
    PointerList__copy(Request*, reqs, src.reqs, clone());
    group=src.group;
    assert(!granted_items.size() && !granted_spanners.size());
}