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