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