lilypond-1.3.21
[lilypond.git] / src / inputcommand.cc
blobaab0ea4a8b8a69ec599ce3da8a52c16611806abb
1 #include "inputcommand.hh"
2 #include "debug.hh"
3 #include "command.hh"
5 Input_command::Input_command()
10 Input_command::operator Command()
12 Command c;
13 if (!args.size())
14 return c;
16 c.code = INTERPRET;
17 String s = args[0];
19 int p=0;
20 if (s == "KEY")
21 p = 200;
22 else if (s=="CLEF")
23 p = 190;
24 else if (s == "METER")
25 p = 180;
26 else if (s == "BAR")
27 p = 170;
28 else if (s == "GROUPING")
29 p = 160;
31 c.priority = p;
32 c.args = args;
34 return c;
38 Input_command*
39 get_partial_command(Moment u)
41 Input_command*c = new Input_command;
42 c->args.push("PARTIAL");
43 c->args.push(u);
44 return c;
47 Input_command*
48 get_goto_command(String s)
50 Input_command*c = new Input_command;
51 c->args.push("GOTO");
52 c->args.push(s);
53 return c;
56 Input_command*
57 get_cadenza_toggle(int i)
60 Input_command*c = new Input_command;
61 c->args.push("CADENZA");
62 c->args.push(i);
63 return c;
65 Input_command*
66 get_grouping_command(Array<int>a )
68 Input_command*c = new Input_command;
69 c->args.push("GROUPING");
70 for (int i=0; i < a.size(); i ++)
71 c->args.push(a[i]);
73 return c;
76 Input_command*
77 get_key_interpret_command(Array<int >a )
79 Input_command*c = new Input_command;
80 c->args.push("KEY");
81 for (int i=0; i < a.size(); i ++) {
82 c->args.push(a[i]);
84 return c;
87 Input_command*
88 get_reset_command()
90 Input_command*c = new Input_command;
91 c->args.push("RESET");
92 return c;
95 Input_command *
96 get_meterchange_command(int n, int m)
98 Input_command*c = new Input_command;
100 c->args.push( "METER");
101 c->args.push( n );
102 c->args.push( m );
104 return c;
107 Input_command *
108 get_newmeasure_command()
110 Input_command*c = new Input_command;
111 c->args.push( "NEWMEASURE");
112 return c;
115 Input_command *
116 get_skip_command(int n, Moment m)
118 Input_command*c = new Input_command;
120 c->args.push( "SKIP");
121 c->args.push( n );
122 c->args.push( m );
124 return c;
128 void
129 Input_command::print()const
131 #ifndef NPRINT
132 mtor << "{ ";
133 if (args.size()) {
134 mtor<< " args: ";
135 for (int i = 0; i<args.size(); i++)
136 mtor << "`"<<args[i] <<"',";
138 mtor << "}\n";
139 #endif
142 Input_command*
143 get_clef_interpret_command(String w)
145 Input_command*c = new Input_command;
146 c->args.push("CLEF");
147 c->args.push(w);
148 return c;
151 Input_command*
152 get_bar_command(String w)
154 Input_command*c = new Input_command;
155 c->args.push("BAR");
156 c->args.push(w);
157 return c;
160 Array<int>
161 get_default_grouping(int count, int one_beat_note)
163 Array<int> s;
164 if (!(count % 3 )) {
165 for (int i=0; i < count/3; i++) {
166 s.push(3);
167 s.push(one_beat_note);
169 } else if (!(count %2)) {
170 for (int i=0; i < count/2; i++) {
171 s.push(2);
172 s.push(one_beat_note);
175 }else {
176 s.push(2);
177 s.push(one_beat_note);
178 s.concat(get_default_grouping(count-2, one_beat_note));
180 return s;