]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/musical-request.hh
e03a3e86463a06045473b00ae83de5feef526801
[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--1998 Han-Wen Nienhuys <hanwen@cs.uu.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 #include "musical-pitch.hh"
17
18 /**
19   A request which is coupled to a note (that has duration).
20   Base class only
21  */
22 class Musical_req  : public virtual Request  {
23 public:
24
25   DEFAULTACCESSOR(Lyric_req)
26   DEFAULTACCESSOR(Note_req )
27   DEFAULTACCESSOR(Stem_req )
28   DEFAULTACCESSOR(Melodic_req )
29   DEFAULTACCESSOR(Slur_req )
30   DEFAULTACCESSOR(Beam_req )
31   DEFAULTACCESSOR(Abbreviation_beam_req)
32   DEFAULTACCESSOR(Rhythmic_req)
33   DEFAULTACCESSOR(Musical_script_req)
34   DEFAULTACCESSOR(Text_req)
35   DEFAULTACCESSOR(Rest_req )
36   DEFAULTACCESSOR(Skip_req)
37   DEFAULTACCESSOR(Dynamic_req)
38   DEFAULTACCESSOR(Absolute_dynamic_req )
39   DEFAULTACCESSOR(Tie_req)
40   DEFAULTACCESSOR(Musical_span_req)
41   DEFAULTACCESSOR(Plet_req)
42   DEFAULTACCESSOR(Span_dynamic_req )
43   DEFAULTACCESSOR(Abbreviation_req)
44   DEFAULTACCESSOR(Multi_measure_rest_req)
45   REQUESTMETHODS(Musical_req);
46 };
47
48
49
50 /** a request with a duration.
51   This request is used only used as a base class.
52  */
53 class Rhythmic_req  : public virtual Musical_req  {
54 public:
55   Duration duration_;
56     
57   bool do_equal_b (Request*) const;
58   void compress (Moment);
59   virtual Moment duration() const;
60   Rhythmic_req();
61   static int compare (Rhythmic_req const&,Rhythmic_req const&);
62   REQUESTMETHODS(Rhythmic_req);
63 };
64
65 class Skip_req  : public Rhythmic_req  {
66 public:
67   REQUESTMETHODS(Skip_req);
68 };
69
70 struct Spacing_req :virtual Request {
71   Moment next;
72   Real distance;
73   Real strength;
74   Spacing_req();
75   REQUESTMETHODS(Spacing_req);
76 };
77
78 struct Abbreviation_req : public Musical_req {
79   REQUESTMETHODS (Abbreviation_req);
80   Abbreviation_req ();
81   int type_i_;
82 };
83
84 class Blank_req  : public Spacing_req, Rhythmic_req  {
85 public:
86   REQUESTMETHODS(Spacing_req);
87 };
88
89 /// Put a text above or below (?) this staff.
90 class Text_req  : public virtual Musical_req  {
91 public:
92   /// preferred position (above/below)
93   Direction dir_;
94   /// the characteristics of the text
95   Text_def *tdef_p_;
96
97   Text_req (int d, Text_def*);
98   ~Text_req();
99   Text_req (Text_req const&);
100
101   REQUESTMETHODS(Text_req);
102 };
103
104 /** a syllable  or lyric is a string with rhythm.
105   */
106 class Lyric_req  : public  Rhythmic_req  {
107 public:
108   String text_str_;
109   REQUESTMETHODS(Lyric_req);
110 };
111
112
113
114 /// request which has some kind of pitch
115 struct Melodic_req :virtual Musical_req
116 {
117   Musical_pitch pitch_;
118   /// transpose. #delta# is relative to central c.
119   virtual void transpose (Musical_pitch delta);
120   Melodic_req();
121   bool do_equal_b (Request*) const;
122   static int compare (Melodic_req const&,Melodic_req const&);
123   REQUESTMETHODS(Melodic_req);
124 };
125
126 /// Put a note of specified type, height, and with accidental on the staff.
127 class Note_req  : public Rhythmic_req, virtual public Melodic_req  {
128 public:
129     
130   /// force/supress printing of accidental.
131   bool forceacc_b_;
132   /// Cautionary, i.e. parenthesized accidental.
133   bool cautionary_b_;
134   Note_req();
135   bool do_equal_b (Request*) const;
136   Rhythmic_req* access_Rhythmic_req () { return Rhythmic_req::access_Rhythmic_req (); }
137   REQUESTMETHODS(Note_req);
138 };
139
140 /**
141 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.
142 */
143 class Rest_req : public Rhythmic_req {
144 public:
145   REQUESTMETHODS(Rest_req);
146 };
147
148 /**
149  Part: typeset a measure with the number of measures rest
150  Score: typeset all individual measures ass full rests
151  */
152 class Multi_measure_rest_req : public Rhythmic_req  {
153 public:
154   REQUESTMETHODS(Multi_measure_rest_req);
155
156 };
157
158 class Musical_span_req : public Span_req, public virtual Musical_req
159 {
160 public:
161   REQUESTMETHODS(Musical_span_req);
162   
163 };
164
165 /** Start / stop a beam at this note */
166 class Beam_req  : public Musical_span_req  {
167 public:
168   REQUESTMETHODS(Beam_req);
169
170   Beam_req();
171 };
172
173 /** 
174  Start / stop an abbreviation beam at this note. 
175  */
176 class Abbreviation_beam_req : public Musical_span_req  {
177 public:
178   REQUESTMETHODS (Abbreviation_beam_req);
179
180   Abbreviation_beam_req ();
181
182   int type_i_;
183 };
184
185 /**
186   Start a tie at this note, end it at the next
187  */
188 class Tie_req : public Musical_req {
189 public:
190   REQUESTMETHODS(Tie_req);
191 };
192
193 /// a slur
194 class Slur_req  : public Musical_span_req  {
195 public:
196   REQUESTMETHODS(Slur_req);
197
198 };
199
200 /// a plet (bracket with) number
201 class Plet_req : public Musical_span_req  {
202 public:
203   int plet_i_;
204
205   REQUESTMETHODS(Plet_req);
206   Plet_req ();
207 };
208
209 class Musical_script_req : public Musical_req,  public Script_req {
210 public:
211   REQUESTMETHODS(Musical_script_req);
212 };
213
214
215 class Dynamic_req  : public virtual Musical_req  {
216 public:
217   /**
218     for absolute dynamics
219
220     This sux. We'd want increasing numbers for FFF till PPP, but not 
221     for FP, SF, SFZ (FP is *not* louder than FFF)
222    */
223   enum Loudness {
224     FFF, FF, F, MF, MP, P, PP, PPP, FP, SF, SFZ
225   };
226   static String loudness_static_str (Loudness);
227   REQUESTMETHODS(Dynamic_req);
228 };
229
230 class Absolute_dynamic_req  : public Dynamic_req  {
231 public:
232   Loudness loudness_;
233   virtual bool do_equal_b (Request*) const;
234   String loudness_str () const;
235   Absolute_dynamic_req();
236   REQUESTMETHODS(Absolute_dynamic_req);
237 };
238
239 class Span_dynamic_req  : public Dynamic_req, public Musical_span_req  {
240 public:
241   virtual bool do_equal_b (Request*) const;
242   /// Grow or shrink the volume: 1=cresc, -1 = decresc 
243   Direction dynamic_dir_;
244   Span_dynamic_req();
245   REQUESTMETHODS(Span_dynamic_req);
246 };
247
248 #endif // MUSICALREQUESTS_HH