9 #include "musicalrequest.hh"
10 #include "commandrequest.hh"
12 #include "notename.hh"
13 #include "identparent.hh"
15 #include "text-def.hh"
16 #include "parseconstruct.hh"
17 #include "input-music.hh"
18 #include "voice-element.hh"
20 int default_duration
= 4, default_dots
=0, default_octave
=0;
21 int default_plet_type
= 1, default_plet_dur
= 1;
22 String textstyle
="roman"; // in lexer?
24 bool last_duration_mode
= false;
27 set_duration_mode(String s
)
30 last_duration_mode
= (s
== "LAST");
36 if (last_duration_mode
)
40 /* triplet is '2/3' */
42 set_plet(int num
,int den
)
44 assert(num
>0&& den
>0);
45 default_plet_dur
= num
;
46 default_plet_type
= den
;
50 get_text(String s
) return t
;
54 t
->style_str_
= textstyle
;
55 t
->defined_ch_c_l_
= defined_ch_c_l
;
60 set_text_style(String s
)
66 parse_octave (const char *a
, int &j
, int &oct
)
81 parse_pitch( const char *a
, Melodic_req
* mel_l
)
86 mel_l
->octave_i_
= default_octave
;
87 parse_octave(a
,j
,mel_l
->octave_i_
);
90 mel_l
->forceacc_b_
= false;
93 mel_l
->forceacc_b_
= true;
99 get_note_element(String pitch
, int * notename
, int * duration
)
101 Voice_element
*v
= new Voice_element
;
102 v
->defined_ch_c_l_
= defined_ch_c_l
;
105 int dur
= duration
[0];
106 int dots
= duration
[1];
109 Stem_req
* stem_req_p
= new Stem_req(dur
,dots
);
110 stem_req_p
->plet_factor
= Moment(default_plet_dur
, default_plet_type
);
111 stem_req_p
->defined_ch_c_l_
= defined_ch_c_l
;
115 if ( !defined_ch_c_l
)
116 defined_ch_c_l
= lexer
->here_ch_c_l();
118 Note_req
* rq
= new Note_req
;
119 rq
->notename_i_
=notename
[0];
120 rq
->accidental_i_
= notename
[1];
121 parse_pitch(pitch
, rq
);
122 rq
->octave_i_
+= notename
[2];
126 rq
->plet_factor
= Moment(default_plet_dur
, default_plet_type
);
127 rq
->defined_ch_c_l_
= defined_ch_c_l
;
135 get_word_element(Text_def
* tdef_p
, int* duration
)
137 Voice_element
* velt_p
= new Voice_element
;
138 velt_p
->defined_ch_c_l_
= defined_ch_c_l
;
140 int dur
= duration
[0];
141 int dots
=duration
[1];
143 tdef_p
->defined_ch_c_l_
= defined_ch_c_l
;
145 Lyric_req
* lreq_p
= new Lyric_req(tdef_p
);
147 lreq_p
->balltype
= dur
;
149 lreq_p
->plet_factor
= Moment(default_plet_dur
, default_plet_type
);
151 lreq_p
->defined_ch_c_l_
= defined_ch_c_l
;
159 get_rest_element(String
, int * duration
)
161 Voice_element
* velt_p
= new Voice_element
;
162 velt_p
->defined_ch_c_l_
= defined_ch_c_l
;
164 Rest_req
* rest_req_p
= new Rest_req
;
165 rest_req_p
->plet_factor
= Moment(default_plet_dur
, default_plet_type
);
166 rest_req_p
->balltype
= duration
[0];
167 rest_req_p
->dots
= duration
[1];
169 rest_req_p
->defined_ch_c_l_
= defined_ch_c_l
;
171 velt_p
->add(rest_req_p
);
177 get_default_duration(int *p
)
179 *p
++ = default_duration
;
184 set_default_duration(int *p
)
186 default_duration
= *p
++;
192 set_default_octave(String d
)
196 parse_octave(d
, i
, default_octave
);
200 get_plet_request( char c
, int dur_i
, int type_i
)
202 Plet_req
* plet_req_p
= new Plet_req
;
203 plet_req_p
->dur_i_
= dur_i
;
204 plet_req_p
->type_i_
= type_i
;
205 plet_req_p
->type_c_
= c
;
215 req_p
= new Barcheck_req
;
221 Beam_req
*b
= new Beam_req
;
222 if (default_plet_type
!= 1)
223 b
->nplet
= default_plet_type
;
231 req_p
= new Slur_req
;
241 req_p
->span()->spantype
= Span_req::START
;
245 req_p
->span()->spantype
= Span_req::STOP
;
252 req_p
->defined_ch_c_l_
= req_defined_ch_c_l
;
257 add_requests(Voice_element
*v
, Array
<Request
*> &req
)
259 for (int i
= 0; i
< req
.size(); i
++) {
266 get_scriptdef(char c
)
270 case '^' : s
= "marcato";
272 case '+' : s
= "stopped";
274 case '-' : s
= "tenuto";
276 case '|': s
= "staccatissimo";
280 case '>' : s
= "accent";
284 case '.' : s
= "staccato";
287 return lexer
->lookup_identifier(s
)->script(1);
291 get_script_req(int d
, Script_def
*def
)
293 Script_req
* script_req_p
= new Script_req(d
, def
);
298 get_text_req(int d
, Text_def
*def
)
300 Text_req
* text_req_p
= new Text_req(d
, def
);
305 get_stemdir_req(int d
)
307 Group_feature_req
* gfreq_p
= new Group_feature_req
;
308 gfreq_p
->stemdir_i_
=d
;
313 get_grouping_req(Array
<int> i_arr
)
315 Measure_grouping_req
* mr_p
= new Measure_grouping_req
;
316 for (int i
=0; i
<i_arr
.size(); ) {
317 mr_p
->beat_i_arr_
.push(i_arr
[i
++]);
318 mr_p
->elt_length_arr_
.push(Moment(1, i_arr
[i
++]));