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