2 // main.cc -- implement silly main() entry point
3 // should have Root class.
5 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
10 Sources* source_l_g = &source;
12 Verbose level_ver = NORMAL_ver;
15 char const* defined_ch_C = 0;
17 // ugh, another global
19 find_file( String str )
24 // ugh, copied from warn.cc, cannot use
26 message( String message_str, char const* context_ch_C )
28 String str = "mi2mu: ";
29 Source_file* sourcefile_l = source_l_g->sourcefile_l( context_ch_C );
31 str += sourcefile_l->file_line_no_str(context_ch_C) + String(": ");
36 str += sourcefile_l->error_str( context_ch_C );
38 // if ( busy_parsing() )
39 cerr << endl; // until we have fine output manager...
44 warning( String message_str, char const* context_ch_C )
46 message( "warning: " + message_str, context_ch_C );
50 error( String message_str, char const* context_ch_C )
52 message( message_str, context_ch_C );
53 // since when exits error again?
54 // i-d say: error: errorlevel |= 1; -> no output upon error
55 // warning: recovery -> output (possibly wrong)
57 midi_lexer_l_g->errorlevel_i_ |= 1;
64 "Usage: mi2mu [options] midi-file\n"
65 "Translate midi-file to mudela\n"
68 " -b, --no-quantify write exact durations, e.g.: a4*385/384\n"
69 " -d, --debug print lots of debugging stuff\n"
70 " -h, --help this help\n"
71 " -I, --include=DIR add DIR to search path\n"
72 " -n, --no-silly assume no plets or double dots, smallest is 16\n"
73 " -o, --output=FILE set FILE as default output\n"
74 " -p, --no-plets assume no plets\n"
75 " -q, --quiet be quiet\n"
76 " -s, --smallest=N assume no shorter (reciprocal) durations than N\n"
77 " -v, --verbose be verbose\n"
78 " -w, --warranty show warranty and copyright\n"
79 " -x, --no-double-dots assume no double dotted notes\n"
86 tor( NORMAL_ver ) << mi2mu_version_str() << endl;
94 "Mi2mu, translate midi to mudela.\n"
95 "Copyright (C) 1997 by\n"
96 " Han-Wen Nienhuys <hanwen@stack.nl>\n"
98 " Jan Nieuwenhuizen <jan@digicash.com>\n"
100 " This program is free software; you can redistribute it and/or\n"
101 "modify it under the terms of the GNU General Public License version 2\n"
102 "as published by the Free Software Foundation.\n"
104 " This program is distributed in the hope that it will be useful,\n"
105 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
106 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
107 "General Public License for more details.\n"
109 " You should have received a copy (refer to the file COPYING) of the\n"
110 "GNU General Public License along with this program; if not, write to\n"
111 "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
116 main( int argc_i, char* argv_sz_a[] )
118 Long_option_init long_option_init_a[] = {
129 0, "no-double-dots", 'x',
132 Getopt_long getopt_long( argc_i, argv_sz_a, long_option_init_a );
136 while ( Long_option_init* long_option_init_p = getopt_long() )
137 switch ( long_option_init_p->shortname ) {
139 Duration_convert::no_quantify_b_s = true;
142 level_ver = DEBUG_ver;
149 // path->push( getopt_long.optarg );
152 Duration_convert::no_double_dots_b_s = true;
153 Duration_convert::no_triplets_b_s = true;
154 Duration_convert::no_smaller_than_i_s = 16;
157 output_str = getopt_long.optarg;
160 Duration_convert::no_triplets_b_s = true;
163 level_ver = QUIET_ver;
166 int i = String_convert::dec2_i( getopt_long.optarg );
171 Duration_convert::no_smaller_than_i_s = i;
175 level_ver = VERBOSE_ver;
182 Duration_convert::no_double_dots_b_s = false;
190 while ( ( arg_sz = getopt_long.get_next_arg() ) ) {
191 My_midi_parser midi_parser( arg_sz, & source );
192 midi_parser_l_g = &midi_parser;
194 int error_i = midi_parser.parse();
197 if ( !output_str.length_i() ) {
198 String d, dir, base, ext;
200 split_path(arg_sz, d, dir, base, ext);
202 output_str = base + ext + ".ly";
204 error_i = midi_parser.output_mudela( output_str );