]> git.donarmstrong.com Git - lilypond.git/blob - src/request.cc
release: 0.0.10
[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 = 0;
31     octave = 0;
32     accidental = 0;
33     forceacc = false;
34 }
35
36 int
37 Note_req::height() const
38 {
39     return  name + octave*7;
40 }
41
42 Rhythmic_req::Rhythmic_req()
43 {
44     balltype = 1;
45     dots = 0;
46 }
47
48 void
49 Rhythmic_req::print() const
50 {
51     mtor << "rhythmic: " << balltype ;
52     int d =dots;
53     while (d--)
54         mtor << '.';
55     mtor<<"\n";
56 }
57
58 void
59 Note_req::print() const
60 {
61     mtor << "note: " << name << " oct: "<< octave;
62     Rhythmic_req::print();
63 }
64
65 void
66 Rest_req::print() const
67 {
68     mtor << "rest, " ;
69     Rhythmic_req::print();
70 }
71
72 Real
73 wholes(int dur, int dots)
74 {
75     Real f = 1.0/Real(dur);
76     Real delta = f;
77
78     while (dots--) {
79         delta /= 2.0;
80         f += delta;
81     }
82     return f;    
83 }
84
85 Real
86 Rhythmic_req::duration() const {    
87     return wholes( balltype,dots);
88 }
89
90 Beam_req::Beam_req()
91 {
92     nplet = 0;
93 }
94
95 Span_req::Span_req()
96 {
97     spantype = NOSPAN;
98 }