2 // main.cc -- implement silly main() entry point
3 // should have Root class.
5 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
8 #include "string-convert.hh"
11 #include "duration-convert.hh"
14 #include "mi2mu-global.hh"
15 #include "midi-score-parser.hh"
16 #include "mudela-score.hh"
20 String filename_str_g;
23 Mudela_score* mudela_score_l_g = 0;
27 static File_path path;
29 Verbose level_ver = NORMAL_ver;
31 /// just to make sure print_rat is linked in
32 static void (*rat_printer)(Moment const&);
38 "Usage: mi2mu [options] midi-file\n"
39 "Translate midi-file to mudela\n"
42 " -b, --no-quantify write exact durations, e.g.: a4*385/384\n"
43 " -d, --debug print lots of debugging stuff\n"
44 " -h, --help this help\n"
45 " -I, --include=DIR add DIR to search path\n"
46 " -n, --no-silly assume no plets or double dots, smallest is 32\n"
47 " -o, --output=FILE set FILE as default output\n"
48 " -p, --no-plets assume no plets\n"
49 " -q, --quiet be quiet\n"
50 " -s, --smallest=N assume no shorter (reciprocal) durations than N\n"
51 " -v, --verbose be verbose\n"
52 " -w, --warranty show warranty and copyright\n"
53 " -x, --no-double-dots assume no double dotted notes\n"
60 LOGOUT(NORMAL_ver) << mi2mu_version_str() << endl;
68 "Mi2mu, translate midi to mudela.\n"
69 "Copyright (C) 1997 by\n"
70 " Jan Nieuwenhuizen <jan@digicash.com>\n"
71 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
73 " This program is free software; you can redistribute it and/or\n"
74 "modify it under the terms of the GNU General Public License version 2\n"
75 "as published by the Free Software Foundation.\n"
77 " This program is distributed in the hope that it will be useful,\n"
78 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
79 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
80 "General Public License for more details.\n"
82 " You should have received a copy (refer to the file COPYING) of the\n"
83 "GNU General Public License along with this program; if not, write to\n"
84 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
89 main (int argc_i, char* argv_sz_a[])
91 rat_printer = print_rat;
93 Long_option_init long_option_init_a[] =
95 {0, "no-quantify", 'b'},
100 {0, "no-plets", 'p'},
102 {1, "smallest", 's'},
104 {0, "warranty", 'w'},
105 {0, "no-double-dots", 'x'},
108 Getopt_long getopt_long (argc_i, argv_sz_a, long_option_init_a);
111 while (Long_option_init const* long_option_init_p = getopt_long())
112 switch (long_option_init_p->shortname)
115 Duration_convert::no_quantify_b_s = true;
118 level_ver = DEBUG_ver;
126 // path->push (getopt_long.optional_argument_ch_C_);
129 Duration_convert::no_double_dots_b_s = true;
130 Duration_convert::no_triplets_b_s = true;
131 Duration_convert::no_smaller_than_i_s = 5;
134 output_str = getopt_long.optional_argument_ch_C_;
137 Duration_convert::no_triplets_b_s = true;
140 level_ver = QUIET_ver;
144 int i = String_convert::dec2_i (getopt_long.optional_argument_ch_C_);
151 Duration_convert::no_smaller_than_i_s =
152 Duration_convert::i2_type(i);
156 level_ver = VERBOSE_ver;
164 Duration_convert::no_double_dots_b_s = true;
171 // flag -q must be checked first
175 source.set_binary (true);
176 source.set_path (&path);
178 char const* arg_sz = 0;
179 while ( (arg_sz = getopt_long.get_next_arg ()))
181 filename_str_g = arg_sz;
182 Midi_score_parser midi_parser;
183 Mudela_score* score_p = midi_parser.parse (arg_sz, &source);
188 mudela_score_l_g = score_p;
191 if (!output_str.length_i ())
193 String d, dir, base, ext;
194 split_path (arg_sz, d, dir, base, ext);
195 output_str = base + ext + ".ly";
198 score_p->output (output_str);