]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/musical-request.hh
release: 0.1.52
[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 #Request_chord#
20   Base class only
21  */
22 class Musical_req  : public virtual Request  {
23 public:
24     
25   virtual Lyric_req* lreq_l() { return 0; }
26   virtual Note_req *note() { return 0;}
27   virtual Stem_req *stem() { return 0;}
28   virtual Melodic_req *melodic() { return 0; }
29   virtual Slur_req *slur() { return 0 ; }
30   virtual Beam_req *beam() { return 0 ; }
31   virtual Abbreviation_beam_req* abbrev_beam() { return 0 ; }
32   virtual Rhythmic_req*rhythmic() { return 0; }
33   virtual Musical_script_req*musicalscript() { return 0; }
34   virtual Text_req*text() { return 0; }
35   virtual Rest_req *rest() { return 0; }
36   virtual Skip_req* skip() { return 0; }
37   virtual Dynamic_req* dynamic() { return 0; }
38   virtual Absolute_dynamic_req * absdynamic() { return 0; }
39   virtual Tie_req * tie() { return 0; }
40   virtual Plet_req* plet() { return 0; }
41   virtual Span_dynamic_req * span_dynamic() { return 0; }
42   virtual Abbreviation_req* abbrev() { return 0; }
43   REQUESTMETHODS(Musical_req, musical);
44 };
45
46
47
48 /** a request with a duration.
49   This request is used only a base class.
50  */
51 class Rhythmic_req  : public virtual Musical_req  {
52 public:
53   Duration duration_;
54     
55   /* *************** */
56   void set_duration (Duration);
57   bool do_equal_b (Request*) const;
58   virtual Moment duration() const;
59   Rhythmic_req();
60   static int compare (Rhythmic_req const&,Rhythmic_req const&);
61   REQUESTMETHODS(Rhythmic_req, rhythmic);
62 };
63
64 class Skip_req  : public Rhythmic_req  {
65 public:
66   REQUESTMETHODS(Skip_req, skip);
67 };
68
69 struct Spacing_req :virtual Request {
70   Moment next;
71   Real distance;
72   Real strength;
73   /* *************** */
74   Spacing_req();
75   REQUESTMETHODS(Spacing_req, spacing);
76 };
77
78 struct Abbreviation_req : public Musical_req {
79   REQUESTMETHODS (Abbreviation_req, abbrev);
80   Abbreviation_req ();
81   int type_i_;
82 };
83
84 class Blank_req  : public Spacing_req, Rhythmic_req  {
85 public:
86   REQUESTMETHODS(Spacing_req, spacing);
87     
88 };
89
90 /// Put a text above or below (?) this staff.
91 class Text_req  : public virtual Musical_req  {
92 public:
93   /// preferred position (above/below)
94   Direction dir_;
95   /// the characteristics of the text
96   Text_def *tdef_p_;
97
98   /* *************** */
99   Text_req (int d, Text_def*);
100   ~Text_req();
101   Text_req (Text_req const&);
102
103   REQUESTMETHODS(Text_req,text);
104 };
105
106 /** Put a text in lyric_staff
107   @see Lyric_staff
108   */
109 class Lyric_req  : public  Rhythmic_req, public Text_req  {
110 public:
111   Lyric_req (Text_def* t_p);
112   REQUESTMETHODS(Lyric_req, lreq_l);
113 };
114
115 /// request which has some kind of pitch
116 struct Melodic_req :virtual Musical_req
117 {
118   /// 0 is c, 6 is b
119   int notename_i_;
120   /// 0 is central c
121   int octave_i_;
122
123     /// 0 natural, 1 sharp, etc
124   int accidental_i_;
125
126   /// return height from central c (in halflines)
127   int height() const;
128
129   /// transpose. #delta# is relative to central c.
130   virtual void transpose (Melodic_req const *delta);
131   /// return pitch from central c (in halfnotes)
132   int pitch() const; 
133   Melodic_req();
134   bool do_equal_b (Request*) const;
135   static int compare (Melodic_req const&,Melodic_req const&);
136   REQUESTMETHODS(Melodic_req,melodic);
137 };
138
139 /// Put a note of specified type, height, and with accidental on the staff.
140 class Note_req  : public Rhythmic_req, virtual public Melodic_req  {
141 public:
142     
143   /// force/supress printing of accidental.
144   bool forceacc_b_;
145   Note_req();
146   bool do_equal_b (Request*) const;
147   Rhythmic_req* rhythmic() { return Rhythmic_req::rhythmic (); }
148   REQUESTMETHODS(Note_req, note);
149 };
150
151 /**
152 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.
153 */
154 class Rest_req : public Rhythmic_req {
155 public:
156   REQUESTMETHODS(Rest_req,rest);
157 };
158
159
160
161 /**
162   Requests to start or stop something.
163  This type of request typically results in the creation of a #Spanner#
164 */
165 class Span_req  : public virtual Musical_req  {
166 public:
167   /// should the spanner start or stop, or is it unwanted?
168   enum Spantype {
169     NOSPAN, START, STOP
170   } spantype;
171   bool do_equal_b (Request*) const;
172   REQUESTMETHODS(Span_req,span);
173
174   Span_req();
175   
176 };
177
178 /** Start / stop a beam at this note */
179 class Beam_req  : public Span_req  {
180 public:
181   /* *************** */
182   REQUESTMETHODS(Beam_req,beam);
183
184   Beam_req();
185 };
186
187 /** 
188  Start / stop an abbreviation beam at this note. 
189  */
190 class Abbreviation_beam_req : public Span_req  {
191 public:
192   REQUESTMETHODS (Abbreviation_beam_req, abbrev_beam);
193
194   Abbreviation_beam_req ();
195
196   int type_i_;
197 };
198
199 /**
200   Start a tie at this voice element, end it at the next
201  */
202 class Tie_req : public Musical_req {
203 public:
204   REQUESTMETHODS(Tie_req, tie);
205 };
206
207 /// a slur
208 class Slur_req  : public Span_req  {
209 public:
210   REQUESTMETHODS(Slur_req,slur);
211
212 };
213
214 /// a plet (bracket with) number
215 class Plet_req : public Span_req  {
216 public:
217   int plet_i_;
218
219   REQUESTMETHODS(Plet_req,plet);
220
221   Plet_req ();
222 };
223
224 class Musical_script_req : public Musical_req,  public Script_req {
225 public:
226   REQUESTMETHODS(Musical_script_req, musicalscript);
227 };
228
229
230 class Dynamic_req  : public virtual Musical_req  {
231 public:
232   /**
233     for absolute dynamics
234
235     This sux. We'd want increasing numbers for FFF till PPP, but not 
236     for FP, SF, SFZ (FP is *not* louder than FFF)
237    */
238   enum Loudness {
239     FFF, FF, F, MF, MP, P, PP, PPP, FP, SF, SFZ
240   };
241   static String loudness_static_str (Loudness);
242   REQUESTMETHODS(Dynamic_req, dynamic);
243 };
244
245 class Absolute_dynamic_req  : public Dynamic_req  {
246 public:
247   Loudness loudness_;
248   String loudness_str () const;
249   Absolute_dynamic_req();
250   REQUESTMETHODS(Absolute_dynamic_req, absdynamic);
251 };
252
253 class Span_dynamic_req  : public Dynamic_req, public Span_req  {
254 public:
255   /// Grow or shrink the volume: 1=cresc, -1 = decresc 
256   Direction dynamic_dir_;
257   Span_dynamic_req();
258   REQUESTMETHODS(Span_dynamic_req, span_dynamic);
259 };
260
261 #endif // MUSICALREQUESTS_HH