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