// file: $ECE_8993/util/calculate_lpc/v1.0/clpc_gp_0.cc // // a simple command line parser // // system include files // #include // isip include files // #include #include // local include files // #include "calculate_lpc.h" #include "calculate_lpc_constants.h" // function: get_parameters_cc // // arguments: // // int argc: (input) argc from the main program // char** argv: (input) argv from the main program // logical_1& use_hamming: (output) whether or not to use a hamming window // logical_1& apply_pre_emphasis: (output) whether or not to pre-emphasize // float_4& pre_emph_coeff: (output) coefficient for the pre-emphasis filter // float_4& window_dur: (output) the window duration in milliseconds // float_4& sample_freq: (output) the sample frequency // logical_1& swap_byte: (output) whether or not the data is byte-swapped // int_4& lp_order: (output) the order of the linear predictor model // float_4& mid_time: (output) the center of the input window // char_1* input_file: (output) the name of the input file (memory is // pre-allocated) // int_4& debug_mode: (output) the debugging mode // // return value: a logical_1 indicating status // // this function parses command line arguments // logical_1 get_parameter_cc(int argc, char** argv, logical_1& use_hamming_a, logical_1& apply_pre_emphasis_a, float_4& pre_emph_coeff_a, float_4& window_dur_a, float_4& sample_freq_a, logical_1& swap_byte_a, int_4& lp_order_a, float_4& mid_time_a, char_1* input_file_a, int_4& debug_mode_a) { // loop over all of the arguments and set the appropriate variables // for (int_4 index = 1; index < argc; index++) { if (strcmp((char*)CLPC_OPT_USE_HAMMING, argv[index]) == (int)0) { // set the flag to true // use_hamming_a = ISIP_TRUE; } else if (strcmp((char*)CLPC_OPT_USE_PRE_EMPH, argv[index]) == (int)0) { // set the flag to true // apply_pre_emphasis_a = ISIP_TRUE; } else if (strcmp((char*)CLPC_OPT_PRE_EMPH_COEFF, argv[index]) == (int)0) { // set the flag to true // pre_emph_coeff_a = (float_4)atof(argv[++index]); } else if (strcmp((char*)CLPC_OPT_WINDOW_DUR, argv[index]) == (int)0) { // copy the output filename // window_dur_a = (float_4)atof(argv[++index]); } else if (strcmp((char*)CLPC_OPT_SF, argv[index]) == (int)0) { // copy the output filename // sample_freq_a = (float_4)atof(argv[++index]); } else if (strcmp((char*)CLPC_OPT_SWAP, argv[index]) == (int)0) { // copy the output filename // swap_byte_a = ISIP_TRUE; } else if (strcmp((char*)CLPC_OPT_LP_ORDER, argv[index]) == (int)0) { // copy the input filename // lp_order_a = (int_4)atoi(argv[++index]); } else if (strcmp((char*)CLPC_OPT_MID_TIME, argv[index]) == (int)0) { // copy the input filename // mid_time_a = (float_4)atof(argv[++index]); } else if (strcmp((char*)CLPC_OPT_FILE_IN, argv[index]) == (int)0) { // copy the input filename // strcpy((char*)input_file_a, argv[++index]); } else if (strcmp((char*)CLPC_OPT_DEBUG_MODE, argv[index]) == (int)0) { // copy the input filename // debug_mode_a = (int_4)atoi(argv[++index]); } // check for help: display the help screen // else if (strcmp((char*)CLPC_OPT_HELP, argv[index]) == 0) { // allocate memory for the command string // char_1 command_string[ISIP_MAX_STRING_LENGTH]; // create the command line to display the help file // sprintf((char*)command_string, (char*)ISIP_HELP_FORMAT, (char*)CLPC_HELP_FILE); // display the help file // system((char*)command_string); // exit gracefully // return ISIP_FALSE; } else { // return with failure // return ISIP_FALSE; } } // exit gracefully // return ISIP_TRUE; }