]> git.donarmstrong.com Git - lilypond.git/blob - src/request.cc
release: 0.0.9
[lilypond.git] / src / request.cc
1 #include "request.hh"
2 #include "debug.hh"
3
4 #define VIRTUALCONS(T,R) R *T::clone() const { return  new T(*this); } struct T
5 #define RCONS(T) VIRTUALCONS(T, Request)
6
7 RCONS(Rest_req);
8 RCONS(Rhythmic_req);
9 RCONS(Stem_req);
10 RCONS(Note_req);
11 RCONS(Span_req);
12 RCONS(Slur_req);
13 RCONS(Beam_req);
14
15 void
16 Request::print() const    
17 {
18 #ifndef NPRINT
19     mtor << "Req{ unknown }\n";
20 #endif
21 }
22
23 Request::Request()
24 {
25     elt = 0;
26 }
27
28 Note_req::Note_req()
29 {
30     name = 'c';
31     octave = 0;
32     accidental = 0;
33     forceacc = false;
34 }
35
36 int
37 Note_req::height() const
38 {
39     int s = name -'c';
40     if (s < 0)
41         s+=7;
42     return  s + octave*7;
43 }
44
45 Rhythmic_req::Rhythmic_req()
46 {
47     balltype = 1;
48     dots = 0;
49 }
50
51 void
52 Rhythmic_req::print() const
53 {
54     mtor << "rhythmic: " << balltype ;
55     int d =dots;
56     while (d--)
57         mtor << '.';
58     mtor<<"\n";
59 }
60
61 void
62 Note_req::print() const
63 {
64     mtor << "note: " << name << " oct: "<< octave;
65     Rhythmic_req::print();
66 }
67
68 void
69 Rest_req::print() const
70 {
71     mtor << "rest, " ;
72     Rhythmic_req::print();
73 }
74
75 Real
76 wholes(int dur, int dots)
77 {
78     Real f = 1.0/Real(dur);
79     Real delta = f;
80
81     while (dots--) {
82         delta /= 2.0;
83         f += delta;
84     }
85     return f;    
86 }
87
88 Real
89 Rhythmic_req::duration() const {    
90     return wholes( balltype,dots);
91 }
92
93 Beam_req::Beam_req()
94 {
95     nplet = 0;
96 }
97
98 Span_req::Span_req()
99 {
100     spantype = NOSPAN;
101 }