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