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