]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/musical-request.hh
release: 0.0.42.pre3
[lilypond.git] / lily / include / musical-request.hh
1 /*
2   musical-request.hh -- declare Musical requests
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9
10 #ifndef MUSICALREQUESTS_HH
11 #define MUSICALREQUESTS_HH
12
13 #include "request.hh"
14
15
16 /**
17   A request which is coupled to a #Voice_element# with nonzero duration.
18   Base class only
19  */
20 struct Musical_req : virtual Request {
21     
22     virtual Skip_req* skip() { return 0; }
23     virtual Dynamic_req* dynamic() { return 0; }
24     virtual Absolute_dynamic_req * absdynamic() { return 0; }
25     virtual Subtle_req * subtle() { return 0; }
26     virtual Span_dynamic_req * span_dynamic() { return 0; }
27     REQUESTMETHODS(Musical_req, musical);
28 };
29
30
31 struct Skip_req : Musical_req {
32     Moment duration_;
33     
34     virtual Moment duration() const;
35     REQUESTMETHODS(Skip_req, skip);
36 };
37 /** a request with a duration.
38   This request is used only a base class.
39  */
40 struct Rhythmic_req : virtual Musical_req {
41     int balltype;
42     int dots;
43     Moment plet_factor;
44     /* *************** */
45     static int compare(const Rhythmic_req &, const Rhythmic_req &);
46     virtual Moment duration() const;
47     Rhythmic_req();
48     Rhythmic_req(int,int);
49     REQUESTMETHODS(Rhythmic_req, rhythmic);
50 };
51
52 struct Spacing_req :virtual Request {
53     Moment next;
54     Real distance;
55     Real strength;
56     /* *************** */
57     Spacing_req();
58     REQUESTMETHODS(Spacing_req, spacing);
59 };
60
61 struct Blank_req : Spacing_req, Rhythmic_req {
62     REQUESTMETHODS(Spacing_req, spacing);
63     
64 };
65
66 /// Put a text above or below (?) this staff.
67 struct Text_req : virtual Musical_req {
68     /// preferred position (above/below)
69     int dir_i_;
70     /// the characteristics of the text
71     Text_def *tdef_p_;
72     /* *************** */
73     Text_req(int d, Text_def*);
74     ~Text_req();
75     Text_req(Text_req const&);
76     static int compare(const Text_req&,const Text_req&);
77     REQUESTMETHODS(Text_req,text);
78 };
79
80 /** Put a text in lyric_staff
81   @see Lyric_staff
82   */
83 struct Lyric_req : public Rhythmic_req, Text_req {
84     Lyric_req(Text_def* t_p);
85     REQUESTMETHODS(Lyric_req, lreq_l);
86 };
87
88 /// request which has some kind of pitch
89 struct Melodic_req :virtual Musical_req
90 {
91     /// 0 is c, 6 is b
92     int notename_i_;
93     /// 0 is central c
94     int octave_i_;
95
96     /// 0 natural, 1 sharp, etc
97     int accidental_i_;
98
99
100     /// return height from central c (in halflines)
101     int height()const; 
102     /// return pitch from central c (in halfnotes)
103     int pitch()const; 
104     Melodic_req();
105    
106     REQUESTMETHODS(Melodic_req,melodic);
107 };
108
109 /// Put a note of specified type, height, and with accidental on the staff.
110 struct Note_req : Rhythmic_req, virtual Melodic_req {
111     
112     /// force/supress printing of accidental.
113     bool forceacc_b_;
114     Note_req();
115     Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic(); }
116     REQUESTMETHODS(Note_req, note);
117  };
118
119 /**
120 Put a rest on the staff. Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded.
121 */
122 class Rest_req : public Rhythmic_req {
123 public:
124     REQUESTMETHODS(Rest_req,rest);
125 };
126
127 /**
128   attach a stem to the noteball.
129   Rhythmic_req parent needed to  determine if it will fit inside a beam.
130   */
131 struct Stem_req : Rhythmic_req {
132     /// preferred direction for the stem
133     int dir_i_;
134     Stem_req(int s, int dots);
135     REQUESTMETHODS(Stem_req,stem);
136 };
137
138 /**
139   Requests to start or stop something.
140  This type of request typically results in the creation of a #Spanner#
141 */
142 struct Span_req : virtual Musical_req {
143     /// should the spanner start or stop, or is it unwanted?
144     enum {
145         NOSPAN, START, STOP
146     } spantype ;
147     static int compare(const Span_req &r1, const Span_req &r2);
148     REQUESTMETHODS(Span_req,span);
149
150     Span_req();
151   
152 };
153
154 /** 
155  request for backward plet generation.
156
157  ugr. Place in hierarchy?
158  */
159 struct Plet_req : virtual Request {
160      char type_c_;
161      int dur_i_;
162      int type_i_;
163      Plet_req();
164  
165      REQUESTMETHODS(Plet_req,plet);
166 };
167
168 /** Start / stop a beam at this note.  if #nplet# is set, the staff will try to put an
169 appropriate number over the beam
170     */
171 struct Beam_req : Span_req {
172     int nplet;
173
174     /* *************** */
175      REQUESTMETHODS(Beam_req,beam);
176
177     Beam_req();
178 };
179
180 /// a slur
181 struct Slur_req : Span_req {
182  REQUESTMETHODS(Slur_req,slur);
183
184 };
185
186
187 /** Put a script above or below this ``note''. eg upbow, downbow. Why
188   a request? These symbols may conflict with slurs and brackets, so
189   this also a request */
190 struct Script_req : Musical_req {
191     int dir_i_;
192     Script_def *scriptdef_p_;
193
194     /* *************** */
195     static int compare(const Script_req &, const Script_req &);
196     Script_req(int d, Script_def*);
197     REQUESTMETHODS(Script_req,script);
198     ~Script_req();
199     Script_req(Script_req const&);
200 };
201
202 /** A helper in the hierarchy. Each dynamic is bound to one note ( a
203     crescendo spanning multiple notes is thought to be made of two
204     "dynamics": a start and a stop).  Dynamic changes can occur in a
205     smaller time than the length of its note, therefore fore each
206     Dynamic request carries a time, measured from the start of its
207     note.
208  */
209 struct Subtle_req : virtual Musical_req {
210     Moment subtime_;
211     REQUESTMETHODS(Subtle_req, subtle);
212 };
213
214 struct Dynamic_req : Subtle_req {
215     /// for absolute dynamics
216     enum Loudness {
217         FFF, FF, F, MF, MP, P, PP, PPP
218     };
219     static String loudness_str(Loudness);
220     REQUESTMETHODS(Dynamic_req, dynamic);
221 };
222
223 struct Absolute_dynamic_req : Dynamic_req {
224     Loudness loudness_;
225     Absolute_dynamic_req();
226     REQUESTMETHODS(Absolute_dynamic_req, absdynamic);
227 };
228
229 struct Span_dynamic_req : Dynamic_req, Span_req {
230     /// Grow or shrink the volume: 1=cresc, -1 = decresc 
231     int dynamic_dir_i_;
232     Span_dynamic_req();
233     REQUESTMETHODS(Span_dynamic_req, span_dynamic);
234 };
235
236 #endif // MUSICALREQUESTS_HH