int main (int argc, char * argv []) { Gtk::Main kit(argc, argv); /* strip GTK+ parameters */ int c; g_rc_settings.set_defaults(); /* start out with normal values */ g_user_settings.set_defaults(); /* start out with normal values */ /* * Set up objects that are specific to the Gtk-2 GUI. Pass them to * the perform constructor. Create a font-render object. * * ISSUE: We really need to create the perform object after reading * the configuration, but we also need to fill it in from the * configuration, I believe. */ seq64::gui_assistant_gtk2 gui; /* GUI-specific objects */ seq64::perform p(gui); /* main performance object */ seq64::p_font_renderer = new seq64::font(); /* set the font renderer */ /* * Instead of the Seq24 names, use the new configuration file-names, * located in ~/.config/sequencer64. However, if they aren't found, * we no longer fall back to the legacy configuration file-names. If * the --legacy option is in force, use only the legacy configuration * file-name. The code also ensures the directory exists. CURRENTLY * LINUX-SPECIFIC. See the rc_settings class for how this works. */ std::string cfg_dir = g_rc_settings.home_config_directory(); if (cfg_dir.empty()) return EXIT_FAILURE; std::string rcname = g_rc_settings.user_filespec(); if (Glib::file_test(rcname, Glib::FILE_TEST_EXISTS)) { printf("[Reading user configuration %s]\n", rcname.c_str()); seq64::userfile user(rcname); if (user.parse(p)) { // Nothing to do, and no exit needed here if it fails } } rcname = g_rc_settings.config_filespec(); if (Glib::file_test(rcname, Glib::FILE_TEST_EXISTS)) { printf("[Reading rc configuration %s]\n", rcname.c_str()); seq64::optionsfile options(rcname); if (options.parse(p)) { /* * Not necessary, and it resets the last-used-directory * obtained from the "rc" configuration file. * * g_rc_settings.last_used_dir(cfg_dir); */ } else return EXIT_FAILURE; } for (;;) /* parse all command parameters */ { int option_index = 0; /* getopt_long index storage */ c = getopt_long ( argc, argv, "ChlLi:jJmM:pPsSU:Vx:", /* wrong: "C:hi:jJmM:pPsSU:Vx:" */ long_options, &option_index ); if (c == -1) /* detect the end of options */ break; switch (c) { case '?': case 'h': printf(g_help_1a); printf(g_help_1b); printf(g_help_2); return EXIT_SUCCESS; break; case 'l': g_rc_settings.legacy_format(true); printf("Setting legacy seq24 file format.\n"); break; case 'L': g_rc_settings.lash_support(true); printf("Activating LASH support.\n"); break; case 'S': g_rc_settings.stats(true); break; case 's': g_rc_settings.show_midi(true); break; case 'p': g_rc_settings.priority(true); break; case 'P': g_rc_settings.pass_sysex(true); break; case 'k': g_rc_settings.print_keys(true); break; case 'j': g_rc_settings.with_jack_transport(true); break; case 'J': g_rc_settings.with_jack_master(true); break; case 'C': g_rc_settings.with_jack_master_cond(true); break; case 'M': if (atoi(optarg) > 0) { g_rc_settings.jack_start_mode(true); } else { g_rc_settings.jack_start_mode(false); } break; case 'm': g_rc_settings.manual_alsa_ports(true); break; case 'i': /* ignore ALSA device */ g_rc_settings.device_ignore(true); g_rc_settings.device_ignore_num(atoi(optarg)); break; case 'V': printf("%s", versiontext.c_str()); return EXIT_SUCCESS; break; case 'U': g_rc_settings.jack_session_uuid(std::string(optarg)); break; case 'x': g_rc_settings.interaction_method ( interaction_method_t(atoi(optarg)) ); break; default: break; } } std::size_t applen = strlen("seq24"); std::string appname(argv[0]); /* "seq24", "./seq24", etc. */ appname = appname.substr(appname.size()-applen, applen); if (appname == "seq24") { g_rc_settings.legacy_format(true); printf("Setting legacy seq24 file format.\n"); } g_rc_settings.set_globals(); /* copy to legacy globals */ g_user_settings.set_globals(); /* copy to legacy globals */ #ifdef USE_THIS_INSTANCE_OF_CODE /* * Set up objects that are specific to the Gtk-2 GUI. Pass them to * the perform constructor. Create a font-render object. */ seq64::gui_assistant_gtk2 gui; /* GUI-specific objects */ seq64::perform p(gui); /* main performance object */ seq64::p_font_renderer = new seq64::font(); /* set the font renderer */ #endif // USE_THIS_INSTANCE_OF_CODE p.init(); p.launch_input_thread(); p.launch_output_thread(); p.init_jack(); seq64::mainwnd seq24_window(p); /* push mainwnd onto stack */ if (optind < argc) { if (Glib::file_test(argv[optind], Glib::FILE_TEST_EXISTS)) seq24_window.open_file(argv[optind]); else printf("? file not found: %s\n", argv[optind]); } #ifdef SEQ64_LASH_SUPPORT if (global_lash_support) { /* * Initialize the lash driver (strips lash-specific command line * arguments), then connect to LASH daemon and poll events. */ seq64::global_lash_driver = new seq64::lash(p, argc, argv); // seq64::global_lash_driver->init(); seq64::global_lash_driver->start(); } else seq64::global_lash_driver = nullptr; #endif kit.run(seq24_window); p.deinit_jack(); /* * Write the configuration file to the new name, unless the * --legacy option is in force. */ g_rc_settings.get_globals(); /* copy from legacy globals */ rcname = g_rc_settings.config_filespec(); printf("[Writing rc configuration %s]\n", rcname.c_str()); seq64::optionsfile options(rcname); if (options.write(p)) { // Anything to do? } g_user_settings.dump_summary(); g_user_settings.get_globals(); /* copy from legacy globals */ g_user_settings.dump_summary(); rcname = g_rc_settings.user_filespec(); printf("[Writing user configuration %s]\n", rcname.c_str()); seq64::userfile userstuff(rcname); if (userstuff.write(p)) { // Anything to do? } #ifdef SEQ64_LASH_SUPPORT if (not_nullptr(seq64::global_lash_driver)) delete seq64::global_lash_driver; #endif return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { /* Scan the argument vector and strip off all parameters known to * GTK+. */ Gtk::Main kit(argc, argv); /*prepare global MIDI definitions*/ for ( int i=0; i<c_maxBuses; i++ ) { for ( int j=0; j<16; j++ ) global_user_midi_bus_definitions[i].instrument[j] = -1; } for ( int i=0; i<c_max_instruments; i++ ) { for ( int j=0; j<128; j++ ) global_user_instrument_definitions[i].controllers_active[j] = false; } /* Init the lash driver (strip lash specific command line * arguments and connect to daemon) */ #ifdef LASH_SUPPORT lash_driver = new lash(&argc, &argv); #endif /* the main performance object */ /* lash must be initialized here because mastermidibus uses the global * lash_driver variable*/ perform p; /* read user preferences files */ if ( getenv( HOME ) != NULL ) { Glib::ustring home( getenv( HOME )); last_used_dir = home; Glib::ustring total_file = home + SLASH + config_filename; if (Glib::file_test(total_file, Glib::FILE_TEST_EXISTS)) { printf( "Reading [%s]\n", total_file.c_str()); optionsfile options( total_file ); if ( !options.parse( &p ) ) { printf( "Error Reading [%s]\n", total_file.c_str()); } } total_file = home + SLASH + user_filename; if (Glib::file_test(total_file, Glib::FILE_TEST_EXISTS)) { printf( "Reading [%s]\n", total_file.c_str()); userfile user( total_file ); if ( !user.parse( &p ) ) { printf( "Error Reading [%s]\n", total_file.c_str()); } } } else printf( "Error calling getenv( \"%s\" )\n", HOME ); /* parse parameters */ int c; while (true) { /* getopt_long stores the option index here. */ int option_index = 0; c = getopt_long(argc, argv, "Chi:jJkmM:pPsSU:vx:", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case '?': case 'h': printf( "Usage: seq24 [OPTIONS] [FILENAME]\n\n" ); printf( "Options:\n" ); printf( " -h, --help: show this message\n" ); printf( " -v, --version: show program version information\n" ); printf( " -m, --manual_alsa_ports: seq24 won't attach alsa ports\n" ); printf( " -s, --showmidi: dumps incoming midi events to screen\n" ); printf( " -p, --priority: runs higher priority with FIFO scheduler (must be root)\n" ); printf( " -P, --pass_sysex: passes any incoming sysex messages to all outputs \n" ); printf( " -i, --ignore <number>: ignore ALSA device\n" ); printf( " -k, --show_keys: prints pressed key value\n" ); printf( " -x, --interaction_method <number>: see .seq24rc for methods to use\n" ); printf( " -j, --jack_transport: seq24 will sync to jack transport\n" ); printf( " -J, --jack_master: seq24 will try to be jack master\n" ); printf( " -C, --jack_master_cond: jack master will fail if there is already a master\n" ); printf( " -M, --song_start_mode <mode>: The following play\n" ); printf( " modes are available (0 = live mode)\n"); printf( " (1 = song mode) (default)\n" ); printf( " -S, --stats: show statistics\n" ); printf( " -U, --jack_session_uuid <uuid>: set uuid for jack session\n" ); printf( "\n\n\n" ); return EXIT_SUCCESS; break; case 'S': global_stats = true; break; case 's': global_showmidi = true; break; case 'p': global_priority = true; break; case 'P': global_pass_sysex = true; break; case 'k': global_print_keys = true; break; case 'j': global_with_jack_transport = true; break; case 'J': global_with_jack_master = true; break; case 'C': global_with_jack_master_cond = true; break; case 'M': if (atoi( optarg ) > 0) { global_song_start_mode = true; } else { global_song_start_mode = false; } break; case 'm': global_manual_alsa_ports = true; break; case 'i': /* ignore alsa device */ global_device_ignore = true; global_device_ignore_num = atoi( optarg ); break; case 'v': printf("%s", versiontext); return EXIT_SUCCESS; break; case 'U': global_jack_session_uuid = Glib::ustring(optarg); break; case 'x': global_interactionmethod = (interaction_method_e)atoi(optarg); break; default: break; } } /* end while */ p.init(); p.launch_input_thread(); p.launch_output_thread(); p.init_jack(); p_font_renderer = new font(); mainwnd seq24_window( &p ); if (optind < argc) { if (Glib::file_test(argv[optind], Glib::FILE_TEST_EXISTS)) seq24_window.open_file(argv[optind]); else printf("File not found: %s\n", argv[optind]); } /* connect to lash daemon and poll events*/ #ifdef LASH_SUPPORT lash_driver->start(&p); #endif kit.run(seq24_window); p.deinit_jack(); if ( getenv( HOME ) != NULL ) { string home( getenv( HOME )); Glib::ustring total_file = home + SLASH + config_filename; printf( "Writing [%s]\n", total_file.c_str()); optionsfile options( total_file ); if (!options.write( &p)) printf( "Error writing [%s]\n", total_file.c_str()); } else { printf( "Error calling getenv( \"%s\" )\n", HOME ); } #ifdef LASH_SUPPORT delete lash_driver; #endif return EXIT_SUCCESS; }
int main (int argc, char *argv[]) { for ( int i=0; i<c_maxBuses; i++ ) { for ( int j=0; j<16; j++ ) global_user_midi_bus_definitions[i].instrument[j] = -1; } for ( int i=0; i<c_max_instruments; i++ ) { for ( int j=0; j<128; j++ ) global_user_instrument_definitions[i].controllers_active[j] = false; } /* init the lash driver (strips lash specific cmdline arguments */ #ifdef LASH_SUPPORT lash_driver = new lash(&argc, &argv); #endif /* the main performance object */ perform p; /* all GTK applications must have a gtk_main(). Control ends here and waits for an event to occur (like a key press or mouse event). */ Gtk::Main kit(argc, argv); p_font_renderer = new font(); if ( getenv( HOME ) != NULL ){ Glib::ustring home( getenv( HOME )); last_used_dir = home; Glib::ustring total_file = home + SLASH + config_filename; printf( "Reading [%s]\n", total_file.c_str()); optionsfile options( total_file ); if ( !options.parse( &p ) ){ printf( "Error Reading [%s]\n", total_file.c_str()); } total_file = home + SLASH + user_filename; printf( "Reading [%s]\n", total_file.c_str()); userfile user( total_file ); if ( !user.parse( &p ) ){ printf( "Error Reading [%s]\n", total_file.c_str()); } } else { printf( "Error calling getenv( \"%s\" )\n", HOME ); } /* parse parameters */ int c; while (1){ /* getopt_long stores the option index here. */ int option_index = 0; c = getopt_long (argc, argv, "p:f:v", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c){ case '?': case 'h': printf( "usage: seq24 [options]\n\n" ); printf( "options:\n" ); printf( " --help : show this message\n" ); printf( " --file <filename> : load midi file on startup\n" ); printf( " --manual_alsa_ports : seq24 won't attach alsa ports\n" ); printf( " --showmidi : dumps incoming midi to screen\n" ); printf( " --priority : runs higher priority with FIFO scheduler (must be root)\n" ); printf( " --pass_sysex : passes any incoming sysex messages to all outputs \n" ); printf( " --show_keys : prints pressed key value\n" ); printf( " --interaction_method <number>: see .seq24rc for methods to use\n" ); printf( " --jack_transport : seq24 will sync to jack transport\n" ); printf( " --jack_master : seq24 will try to be jack master\n" ); printf( " --jack_master_cond : jack master will fail if there is already a master\n" ); printf( " --jack_start_mode <x> : when seq24 is synced to jack, the following play\n" ); printf( " modes are available (0 = live mode)\n"); printf( " (1 = song mode) (default)\n" ); printf( "\n\n\n" ); return 0; break; case 'S': global_stats = true; break; case 's': global_showmidi = true; break; case 'p': global_priority = true; break; case 'P': global_pass_sysex = true; break; case 'k': global_print_keys = true; break; case 'j': global_with_jack_transport = true; break; case 'J': global_with_jack_master = true; break; case 'C': global_with_jack_master_cond = true; break; case 'M': if (atoi( optarg ) > 0) { global_jack_start_mode = true; } else { global_jack_start_mode = false; } break; case 'm': global_manual_alsa_ports = true; break; case 'f': global_filename = Glib::ustring(optarg); break; case 'i': /* ignore alsa device */ global_device_ignore = true; global_device_ignore_num = atoi( optarg ); break; case 'x': global_interactionmethod = (interaction_method_e)atoi( optarg ); break; default: break; } } /* end while */ p.init(); p.launch_input_thread(); p.launch_output_thread(); p.init_jack(); if (global_filename != "") { /* import that midi file */ midifile *f = new midifile(global_filename); f->parse( &p, 0 ); delete f; } mainwnd seq24_window( &p ); #ifdef LASH_SUPPORT lash_driver->start( &p ); #endif kit.run(seq24_window); p.deinit_jack(); if ( getenv( HOME ) != NULL ){ string home( getenv( HOME )); Glib::ustring total_file = home + SLASH + config_filename; printf( "Writing [%s]\n", total_file.c_str()); optionsfile options( total_file ); if ( !options.write( &p ) ){ printf( "Error writing [%s]\n", total_file.c_str()); } } else { printf( "Error calling getenv( \"%s\" )\n", HOME ); } #ifdef LASH_SUPPORT delete lash_driver; #endif return 0; }