summaryrefslogtreecommitdiff
path: root/request.cc
blob: 35a9ae9718a156fe594240cae35327a6e1bfd951 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "request.hh"
#include "debug.hh"

#define VIRTUALCONS(T,R) R *T::clone() const { return  new T(*this); } struct T
#define RCONS(T) VIRTUALCONS(T, Request)

RCONS(Rest_req);
RCONS(Rhythmic_req);
RCONS(Stem_req);
RCONS(Note_req);


void
Request::print() const    
{
#ifndef NPRINT
    mtor << "Req{ unknown }\n";
#endif
}

Request::Request(Voice_element*v)
{
    elt = v;
}

Note_req::Note_req(Voice_element*v)
    : Rhythmic_req(v)
{
    name = 'c';
    octave = 0;
    accidental = 0;
    forceacc = false;
}

int
Note_req::height() const
{
    int s = name -'c';
    if (s < 0)
	s+=7;
    return  s + octave*7;
}

Rhythmic_req::Rhythmic_req(Voice_element*v)
     :Request(v)
{
    balltype = 1;
    dots = 0;
}

void
Rhythmic_req::print() const
{
    mtor << "rhythmic: " << balltype ;
    int d =dots;
    while (d--)
	mtor << '.';
    mtor<<"\n";
}

void
Note_req::print() const
{
    mtor << "note: " << name << " oct: "<< octave;
    Rhythmic_req::print();
}

Request::Request()
{
    elt = 0;
}

void
Rest_req::print() const
{
    mtor << "rest, " ;
    Rhythmic_req::print();
}

Real
wholes(int dur, int dots)
{
    Real f = 1.0/Real(dur);
    Real delta = f;

    while (dots--) {
	delta /= 2.0;
	f += delta;
    }
    return f;    
}

Real
Rhythmic_req::duration() const {    
    return wholes( balltype,dots);
}