]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/musical-request.hh
release: 0.0.59
[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 "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    
118     REQUESTMETHODS(Melodic_req,melodic);
119 };
120
121 /// Put a note of specified type, height, and with accidental on the staff.
122 class Note_req  : public Rhythmic_req, virtual public Melodic_req  {
123 public:
124     
125     /// force/supress printing of accidental.
126     bool forceacc_b_;
127     Note_req();
128     Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic(); }
129     REQUESTMETHODS(Note_req, note);
130  };
131
132 /**
133 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.
134 */
135 class Rest_req : public Rhythmic_req {
136 public:
137     REQUESTMETHODS(Rest_req,rest);
138 };
139
140 /**
141   attach a stem to the noteball.
142   Rhythmic_req parent needed to  determine if it will fit inside a beam.
143   */
144 class Stem_req  : public Rhythmic_req  {
145 public:
146     /// preferred direction for the stem
147     int dir_i_;
148     Stem_req();
149     REQUESTMETHODS(Stem_req,stem);
150 };
151
152 /**
153   Requests to start or stop something.
154  This type of request typically results in the creation of a #Spanner#
155 */
156 class Span_req  : public virtual Musical_req  {
157 public:
158     /// should the spanner start or stop, or is it unwanted?
159     enum {
160         NOSPAN, START, STOP
161     } spantype ;
162     static int compare(const Span_req &r1, const Span_req &r2);
163     REQUESTMETHODS(Span_req,span);
164
165     Span_req();
166   
167 };
168
169 /** 
170  request for backward plet generation.
171
172  ugr. Place in hierarchy?
173  */
174 class Plet_req  : public virtual Request  {
175 public:
176      char type_c_;
177      int dur_i_;
178      int type_i_;
179      Plet_req();
180  
181      REQUESTMETHODS(Plet_req,plet);
182 };
183
184 /** Start / stop a beam at this note.  if #nplet# is set, the staff
185 will try to put an appropriate number over the beam */
186 class Beam_req  : public Span_req  {
187 public:
188     int nplet;
189
190     /* *************** */
191      REQUESTMETHODS(Beam_req,beam);
192
193     Beam_req();
194 };
195
196 /**
197   Start a tie at this voice element, end it at the next
198  */
199 class Tie_req : public Musical_req {
200 public:
201     REQUESTMETHODS(Tie_req, tie);
202 };
203
204 /// a slur
205 class Slur_req  : public Span_req  {
206 public:
207  REQUESTMETHODS(Slur_req,slur);
208
209 };
210
211
212 /** Put a script above or below this ``note''. eg upbow, downbow. Why
213   a request? These symbols may conflict with slurs and brackets, so
214   this also a request */
215 class Script_req  : public Musical_req  {
216 public:
217     int dir_i_;
218     Script_def *scriptdef_p_;
219
220     /* *************** */
221     static int compare(const Script_req &, const Script_req &);
222     Script_req(int d, Script_def*);
223     REQUESTMETHODS(Script_req,script);
224     ~Script_req();
225     Script_req(Script_req const&);
226 };
227
228 /** A helper in the hierarchy. Each dynamic is bound to one note ( a
229     crescendo spanning multiple notes is thought to be made of two
230     "dynamics": a start and a stop).  Dynamic changes can occur in a
231     smaller time than the length of its note, therefore fore each
232     Dynamic request carries a time, measured from the start of its
233     note.
234  */
235 class Subtle_req  : public virtual Musical_req  {
236 public:
237     /// the time relative to Voice_element start.
238     Moment subtime_;
239     REQUESTMETHODS(Subtle_req, subtle);
240 };
241
242 class Dynamic_req  : public Subtle_req  {
243 public:
244     /// for absolute dynamics
245     enum Loudness {
246         FFF, FF, F, MF, MP, P, PP, PPP
247     };
248     static String loudness_str(Loudness);
249     REQUESTMETHODS(Dynamic_req, dynamic);
250 };
251
252 class Absolute_dynamic_req  : public Dynamic_req  {
253 public:
254     Loudness loudness_;
255     Absolute_dynamic_req();
256     REQUESTMETHODS(Absolute_dynamic_req, absdynamic);
257 };
258
259 class Span_dynamic_req  : public Dynamic_req, public Span_req  {
260 public:
261     /// Grow or shrink the volume: 1=cresc, -1 = decresc 
262     int dynamic_dir_i_;
263     Span_dynamic_req();
264     REQUESTMETHODS(Span_dynamic_req, span_dynamic);
265 };
266
267 #endif // MUSICALREQUESTS_HH