//----------------------------------------------------------------------------- // Name: Main // Desc: ... //----------------------------------------------------------------------------- int main( int argc, char *argv[] ) { /* Check Arguments */ if ( argc != 2 ) { printf("Usage: %s: Input Audio\n", argv[0]); return EXIT_FAILURE; } /* Initialize SRC Algorithm */ initialize_src_type(); /* Initialize Glut */ initialize_glut(argc, argv); /* Initialize PortAudio */ initialize_audio(argv[1]); /* Start Curses Mode */ initscr(); cbreak(); // Line Buffering Disabled noecho(); // Comment This Out if You Want to Show Characters When They Are Typed curs_set(0); // Make ncurses Cursor Invisible /* Print Help Menu and GUI */ help(); printGUI(); /* Main Interactive Loop, Quits With 'q' */ glutMainLoop(); return EXIT_SUCCESS; }
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ bool initialize(int argc, char **argv) { return initialize_goal_image(argc,argv) && initialize_cuda(1,argv) && // xxx hack cuda init initialize_glut(argc,argv) && initialize_population(argc,argv); // population needs GL up-n-running }
int main(int argc, char **argv) { paData data; PaStream *stream; PaError err; PaStreamParameters outputParams; if (argc != 2) { printf ("\nAudio file name required as argument: \n"); printf (" Usage : hv <stereofilename>\n"); exit (1); } /* clear structures - set everything to zero */ memset(&data.sfinfo1, 0, sizeof(data.sfinfo1)); /**************************************************************************/ /* Open audio file */ /**************************************************************************/ data.infile1 = sf_open(argv[1], SFM_READ, &data.sfinfo1); if (data.infile1 == NULL) { printf ("Error: could not open file: %s\n", argv[1]) ; puts(sf_strerror (NULL)) ; exit(1); } printf("Audio file: Frames: %d Channels: %d Samplerate: %d\n", (int)data.sfinfo1.frames, data.sfinfo1.channels, data.sfinfo1.samplerate); /* If file is not stereo, exit */ if (data.sfinfo1.channels != STEREO) { printf("Error: audio file must be stereo.\n"); exit(1); } data.sampleRate = data.sfinfo1.samplerate; /* Initialize volume for audio */ data.amplitude1 = INITIAL_VOLUME; /**************************************************************************/ /* Init and start PortAudio */ /**************************************************************************/ /* Initializing PortAudio */ err = Pa_Initialize(); if (err != paNoError ) { printf("PortAudio error: %s\n", Pa_GetErrorText(err)); printf("\nExiting.\n"); exit(1); } /* Ouput stream parameters */ outputParams.device = Pa_GetDefaultOutputDevice(); outputParams.channelCount = STEREO; outputParams.sampleFormat = paFloat32; outputParams.suggestedLatency = Pa_GetDeviceInfo(outputParams.device)->defaultLowOutputLatency; outputParams.hostApiSpecificStreamInfo = NULL; /* Open audio stream */ err = Pa_OpenStream(&stream, NULL, /* no input */ &outputParams, data.sampleRate, FRAMES_PER_BUFFER, paNoFlag, /* flags */ paCallback, &data); printf("Sample rate: %f\n", data.sampleRate); if (err != paNoError) { printf("PortAudio error: open stream: %s\n", Pa_GetErrorText(err)); exit(2); } /* Start audio stream */ err = Pa_StartStream(stream); if (err != paNoError) { printf( "PortAudio error: start stream: %s\n", Pa_GetErrorText(err)); exit(3); } printf("Ratio: %f to %f\n", ratio, ratio2); initialize_glut(argc, argv); glutMainLoop(); /**************************************************************************/ /* Clean up: close PortAudio and sound files */ /**************************************************************************/ /* Close files */ sf_close(data.infile1); /* Stop stream */ err = Pa_StopStream(stream ); if (err != paNoError) { printf( "PortAudio error: stop stream: %s\n", Pa_GetErrorText(err)); } /* Close stream */ err = Pa_CloseStream(stream ); if (err != paNoError) { printf( "PortAudio error: close stream: %s\n", Pa_GetErrorText(err)); } /* Terminate PortAudio */ err = Pa_Terminate(); if (err != paNoError) { printf("PortAudio error: terminate: %s\n", Pa_GetErrorText(err)); } }
int main(int argc, char** argv) { namespace po = boost::program_options; namespace fs = boost::filesystem; const std::string exec_name = (argc > 0) ? fs::basename(argv[0]) : ""; scm::shared_ptr<scm::core> scm_core(new scm::core(1, argv)); putenv((char *)"__GL_SYNC_TO_VBLANK=0"); int window_width; int window_height; unsigned int main_memory_budget; unsigned int video_memory_budget ; unsigned int max_upload_budget; std::string resource_file_path = ""; std::string measurement_file_path = ""; bool measurement_file_interpolation = false; float measurement_interpolation_stepsize = 1.0f; std::string pvs_file_path = ""; bool pvs_culling = true; po::options_description desc("Usage: " + exec_name + " [OPTION]... INPUT\n\n" "Allowed Options"); desc.add_options() ("help", "print help message") ("width,w", po::value<int>(&window_width)->default_value(1920), "specify window width (default=1920)") ("height,h", po::value<int>(&window_height)->default_value(1080), "specify window height (default=1080)") ("resource-file,f", po::value<std::string>(&resource_file_path), "specify resource input-file") ("vram,v", po::value<unsigned>(&video_memory_budget)->default_value(2048), "specify graphics memory budget in MB (default=2048)") ("mem,m", po::value<unsigned>(&main_memory_budget)->default_value(4096), "specify main memory budget in MB (default=4096)") ("upload,u", po::value<unsigned>(&max_upload_budget)->default_value(64), "specify maximum video memory upload budget per frame in MB (default=64)") ("measurement-file", po::value<std::string>(&measurement_file_path)->default_value(""), "specify camera session for quality measurement_file (default = \"\")") ("measurement-interpolate", po::value<bool>(&measurement_file_interpolation)->default_value(false), "allow interpolation between measurement transformations (default=false)") ("measurement-stepsize", po::value<float>(&measurement_interpolation_stepsize)->default_value(1.0f), "if interpolation is activated, this will be the stepsize in spatial units between interpolation points") ("pvs-file,p", po::value<std::string>(&pvs_file_path), "specify potentially visible set file.") ("pvs-culling", po::value<bool>(&pvs_culling)->default_value(true), "pvs will optimize drawn level of detail, yet if pvs culling is set to true, potentially occluded geometry will not be renderer"); ; po::positional_options_description p; po::variables_map vm; try { auto parsed_options = po::command_line_parser(argc, argv).options(desc).allow_unregistered().run(); po::store(parsed_options, vm); po::notify(vm); std::vector<std::string> to_pass_further = po::collect_unrecognized(parsed_options.options, po::include_positional); bool no_input = !vm.count("input") && to_pass_further.empty(); if (resource_file_path == "") { if (vm.count("help") || no_input) { std::cout << desc; return 0; } } // no explicit input -> use unknown options if (!vm.count("input") && resource_file_path == "") { resource_file_path = "auto_generated.rsc"; std::fstream ofstr(resource_file_path, std::ios::out); if (ofstr.good()) { for (auto argument : to_pass_further) { ofstr << argument << std::endl; } } else { throw std::runtime_error("Cannot open file"); } ofstr.close(); } } catch (std::exception& e) { std::cout << "Warning: No input file specified. \n" << desc; return 0; } // set min and max window_width = std::max(std::min(window_width, 4096), 1); window_height = std::max(std::min(window_height, 2160), 1); main_memory_budget = std::max(int(main_memory_budget), 1); video_memory_budget = std::max(int(video_memory_budget), 1); max_upload_budget = std::max(int(max_upload_budget), 64); initialize_glut(argc, argv, window_width, window_height); std::pair< std::vector<std::string>, std::vector<scm::math::mat4f> > model_attributes; std::set<lamure::model_t> visible_set; std::set<lamure::model_t> invisible_set; model_attributes = read_model_string(resource_file_path, &visible_set, &invisible_set); //std::string scene_name; //create_scene_name_from_vector(model_attributes.first, scene_name); std::vector<scm::math::mat4f> & model_transformations = model_attributes.second; std::vector<std::string> const& model_filenames = model_attributes.first; lamure::ren::policy* policy = lamure::ren::policy::get_instance(); policy->set_max_upload_budget_in_mb(max_upload_budget); //8 policy->set_render_budget_in_mb(video_memory_budget); //2048 policy->set_out_of_core_budget_in_mb(main_memory_budget); //4096, 8192 policy->set_window_width(window_width); policy->set_window_height(window_height); lamure::ren::model_database* database = lamure::ren::model_database::get_instance(); std::vector<scm::math::mat4d> parsed_views = std::vector<scm::math::mat4d>(); std::string measurement_filename = ""; snapshot_session_descriptor measurement_descriptor; if( ! measurement_file_path.empty() ) { measurement_descriptor.recorded_view_vector_ = parse_camera_session_file(measurement_file_path); measurement_descriptor.snapshot_resolution_ = scm::math::vec2ui(window_width, window_height); size_t last_dot_in_filename_pos = measurement_file_path.find_last_of('.'); size_t first_slash_before_filename_pos = measurement_file_path.find_last_of("/\\", last_dot_in_filename_pos); measurement_descriptor.session_filename_ = measurement_file_path.substr(first_slash_before_filename_pos+1, last_dot_in_filename_pos); quality_measurement_mode_enabled_ = true; measurement_descriptor.snapshot_session_enabled_ = true; glutFullScreenToggle(); } management_ = new management(model_filenames, model_transformations, visible_set, invisible_set, measurement_descriptor); management_->interpolate_between_measurement_transforms(measurement_file_interpolation); management_->set_interpolation_step_size(measurement_interpolation_stepsize); management_->enable_culling(pvs_culling); // PVS basic setup. If no path is given, runtime access to the PVS will always return true (visible). if(pvs_file_path != "") { std::string pvs_grid_file_path = pvs_file_path; pvs_grid_file_path.resize(pvs_grid_file_path.length() - 3); pvs_grid_file_path = pvs_grid_file_path + "grid"; lamure::pvs::pvs_database* pvs = lamure::pvs::pvs_database::get_instance(); pvs->load_pvs_from_file(pvs_grid_file_path, pvs_file_path, false); } // Start rendering main loop. glutMainLoop(); if (management_ != nullptr) { delete lamure::ren::cut_database::get_instance(); delete lamure::ren::controller::get_instance(); delete lamure::ren::model_database::get_instance(); delete lamure::ren::policy::get_instance(); delete lamure::ren::ooc_cache::get_instance(); } return 0; }