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