5 #include "my-lily-lexer.hh"
9 #include "musical-request.hh"
10 #include "command-request.hh"
13 #include "identifier.hh"
15 #include "text-def.hh"
16 #include "parseconstruct.hh"
17 #include "input-music.hh"
18 #include "voice-element.hh"
20 Lexer_prefs::plet_mom()
22 return Moment(default_plet_dur, default_plet_type);
24 Lexer_prefs::Lexer_prefs()
26 default_duration = 4, default_dots=0, default_octave_i_=0;
27 default_plet_type = 1, default_plet_dur = 1;
28 textstyle_str_="roman"; // in lexer?
30 last_duration_mode = false;
34 Lexer_prefs::set_duration_mode(String s)
37 last_duration_mode = (s== "LAST");
41 Lexer_prefs::set_last_duration(int n)
43 if (last_duration_mode)
47 /* triplet is '2/3' */
49 Lexer_prefs::set_plet(int num,int den)
51 assert(num >0&& den>0);
52 default_plet_dur = num;
53 default_plet_type = den;
57 get_text(String s) return t;
61 t->style_str_ = lexer->prefs.textstyle_str_;
62 t->defined_ch_c_l_ = defined_ch_c_l;
66 get_note_element(Note_req *rq, int * duration )
68 Voice_element*v = new Voice_element;
69 v->defined_ch_c_l_ = defined_ch_c_l;
71 int dur = duration[0];
72 int dots = duration[1];
75 Stem_req * stem_req_p = new Stem_req(dur,dots);
76 stem_req_p->plet_factor = lexer->prefs.plet_mom();
78 stem_req_p->defined_ch_c_l_ = defined_ch_c_l;
82 if ( !defined_ch_c_l )
83 defined_ch_c_l = lexer->here_ch_c_l();
87 rq->plet_factor = lexer->prefs.plet_mom();
89 rq->defined_ch_c_l_ = defined_ch_c_l;
97 get_word_element(Text_def* tdef_p, int* duration)
99 Voice_element* velt_p = new Voice_element;
100 velt_p->defined_ch_c_l_ = defined_ch_c_l;
102 int dur = duration[0];
103 int dots=duration[1];
105 tdef_p->defined_ch_c_l_ = defined_ch_c_l;
107 Lyric_req* lreq_p = new Lyric_req(tdef_p);
109 lreq_p->balltype = dur;
111 lreq_p->plet_factor = lexer->prefs.plet_mom();
113 lreq_p->defined_ch_c_l_ = defined_ch_c_l;
121 get_rest_element(String, int * duration )
123 Voice_element* velt_p = new Voice_element;
124 velt_p->defined_ch_c_l_ = defined_ch_c_l;
126 Rest_req * rest_req_p = new Rest_req;
127 rest_req_p->plet_factor = lexer->prefs.plet_mom();
128 rest_req_p->balltype = duration[0];
129 rest_req_p->dots = duration[1];
131 rest_req_p->defined_ch_c_l_ = defined_ch_c_l;
133 velt_p->add(rest_req_p);
139 Lexer_prefs::get_default_duration(int *p)
141 *p++ = default_duration;
146 Lexer_prefs::set_default_duration(int *p)
148 default_duration = *p++;
153 get_plet_request( char c, int dur_i, int type_i )
155 Plet_req* plet_req_p = new Plet_req;
156 plet_req_p->dur_i_ = dur_i;
157 plet_req_p->type_i_ = type_i;
158 plet_req_p->type_c_ = c;
168 req_p = new Barcheck_req;
174 Beam_req*b = new Beam_req;
175 int p_i=lexer->prefs.default_plet_type ;
185 req_p = new Slur_req;
195 req_p->span()->spantype = Span_req::START;
199 req_p->span()->spantype = Span_req::STOP;
206 req_p->defined_ch_c_l_ = req_defined_ch_c_l;
211 add_requests(Voice_element *v, Array<Request*> &req)
213 for (int i = 0; i < req.size(); i++) {
220 get_scriptdef(char c)
224 case '^' : s = "marcato";
226 case '+' : s = "stopped";
228 case '-' : s = "tenuto";
230 case '|': s = "staccatissimo";
234 case '>' : s = "accent";
238 case '.' : s = "staccato";
241 return lexer->lookup_identifier(s)->script(1);
245 get_script_req(int d , Script_def*def)
247 Script_req* script_req_p = new Script_req(d, def);
252 get_text_req(int d , Text_def*def)
254 Text_req* text_req_p = new Text_req(d, def);
259 get_stemdir_req(int d)
261 Group_feature_req * gfreq_p = new Group_feature_req;
262 gfreq_p->stemdir_i_ =d;
267 get_grouping_req(Array<int> i_arr)
269 Measure_grouping_req * mr_p = new Measure_grouping_req;
270 for (int i=0; i <i_arr.size(); ) {
271 mr_p->beat_i_arr_.push(i_arr[i++]);
272 mr_p->elt_length_arr_.push(Moment(1, i_arr[i++]));