]> git.donarmstrong.com Git - lilypond.git/blob - request.hh
release: 0.0.6
[lilypond.git] / request.hh
1 // mpp96's second egg of columbus!
2 #ifndef REQUEST_HH
3 #define REQUEST_HH
4
5 #include "glob.hh"
6 #include "string.hh"
7
8 /// a voice element wants something printed
9 struct Request {
10     Voice_element*elt;
11     
12     /****************/
13
14     virtual void print()const ;
15     virtual Note_req *note() {return 0;}
16     virtual Rest_req *rest() {return 0;}
17     virtual  Rhythmic_req*rhythmic() { return 0;}
18     Request(Voice_element*);
19     Request();
20     virtual Real duration() const { return 0.0; }
21 };
22
23 /**
24     Any Voice_element can do a number of requests. A request is done
25     to the #Staff# which contains the #Voice_element#. The staff decides
26     whether to to honor the request, ignore it, or merge it with other
27     requests. Merging of requests is preferably done with other
28     requests done by members of the same voicegroups (beams, brackets, stems) 
29
30     Please refer to the documentation of the Child classes of
31     #Request# for explanation of each request type.
32
33     The result of a request will be an #Item# or a #Spanner#, which
34     will be put on a #PStaff#. Note that the #PStaff# and the original
35     #Staff# need not have anything in common. For example, the
36     ``double'' piano Staff could interpret commands which juggle
37     melodies across the left and right hand, and may put the result in
38     two five-line PStaffs (maybe with extra PStaffs to carry the dynamic
39     signs and any lyric.
40
41     The class #Staff# should be thought as a container for the
42     #Voice#s, and an interpreter for #Request#s and #Command#s.
43     Different staffs can produce different outputs; a melodious voice
44     which is put into a percussion-Staff, will be typeset as the rythm of
45     that voice.
46
47     After #Staff# made up her mind (Would #Staff# be a smart
48     name? How about #struct Lily {}# :-), the resultant items and
49     spanners are put on the PScore, and pointers to these items are
50     stored in the #Voice_element#. This construction enables the
51     beams/stems to look up the balls it has to connect to.  */
52         
53
54 /// a request with a duration
55 struct Rhythmic_req : Request {
56     int balltype;
57     int dots;
58     
59     /****************/
60
61     Real duration() const;
62     Rhythmic_req(Voice_element*);
63     Rhythmic_req*rhythmic() { return this;}
64     void print ()const;
65 };
66
67 /// Put a note of specified type, height, and with accidental on the staff.
68 struct Note_req : Rhythmic_req {
69     char name;
70     int octave;
71     int accidental;
72     bool forceacc;
73     
74     /****************/
75
76     // return height from central c (in halflines)
77     int height()const; 
78     Note_req(Voice_element*v);
79     Note_req*note() { return this;}
80     virtual void print() const;
81 };
82 /**
83 Staff has to decide if the ball should be hanging left or right. This
84 influences the horizontal dimensions of a column, and this  is why
85 request processing should be done before horizontal spacing.
86
87 Other voices' frivolities may cause the need for accidentals, so this
88 is also for the Staff to decide. The Staff can decide on positioning
89 based on ottava commands and the appropriate clef.
90 */
91
92
93 ///Put a rest on the staff.
94 struct Rest_req : Rhythmic_req {
95     void print()const;
96     Rest_req(Voice_element*v) : Rhythmic_req(v) {  }
97     Rest_req * rest() { return this;}
98 };
99 /**
100 Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded.
101 */
102
103 #if 0
104
105 ///Put a lyric above or below (?) this staff.
106 struct Lyric_req : Request {
107     String text;
108 };
109
110
111 ///Put a script above or below this ``note''    
112 struct Script_req : Request {
113     int orientation;
114     Symbol sym;
115 };
116 /**
117 eg upbow, downbow. Why a request? These symbols may conflict with slurs and brackets, so this
118 also a request
119 */
120
121
122
123
124 ///Draw a (Guitar) chord above or below this ``note''
125 struct Chord : Request {
126         // don't know how this looks.
127 };
128 /**
129 Why a request?
130 Because everything else is done in requests.
131 */
132
133
134 /// for absolute dynamics
135 enum Loudness {
136     FFF, FF, F, MF, MP, P, PP, PPP
137 } ;
138
139 /// attach a stem to the noteball
140 struct Stem_req : Request {
141     /// 4,8,16, ..
142     int stem_number ;
143 };
144 /// requests to start or stop something.
145 struct Span_req : Request {
146     /// should the spanner start or stop, or is it unwanted?
147     enum {
148         NOSPAN, START, STOP
149     } spantype ;
150 };
151 /**
152  This type of request typically results in the creation of a #Spanner#
153 */
154
155
156 ///Start / stop a beam at this note.
157 struct Beam_req : Span_req {
158     int nplet;
159 };
160 /** Staff will have to combine this with the stem_request, since the
161     number of flags that a stem wants to carry will determine the
162     number of beams.  if #nplet# is set, the staff will try to put an
163     appropriate number over the beam
164
165     [what to do  if the nplet fields of start and stop conflict?]
166     */
167
168 ///Start / stop a slur or a bracket.
169 struct Bracket_req : Span_req {
170     int nplet;
171 };
172 /**
173 Start/stop a bracket at this note. if #nplet# is set, the staff will
174 try to put an appropriate number over the bracket
175 */
176
177 /// a slur
178 struct Slur_req : Span_req {
179     
180 };
181
182 /// helper in the hierarchy
183 struct Dynamic {
184     Real subtime;
185 };
186 /** Each dynamic is bound to one note ( a crescendo spanning multiple
187     notes is thought to be made of two "dynamics": a start and a stop).
188     Dynamic changes can occur in a smaller time than the length of its
189     note, therefore fore each Dynamic request carries a time, measured
190     from the start of its note.
191
192     This subfield would come in handy, if mpp96 was adapted for midi
193     support.
194     
195     Dynamic should have been derived from request, but I don't want to
196     fuss with virtual baseclasses.  */
197
198 /// do a crescendo
199 struct Cresc_req : Span_req, Dynamic {
200     
201 };
202
203 /// do a decrescendo
204 struct Decresc_req : Span_req, Dynamic {
205     
206 };
207
208 /// do a dynamic like "fff" or "mp"
209 struct Absdynamic_req : Request, Dynamic {
210         Loudness loudness;
211 };
212 #endif
213 #endif