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