// file: csrn_gp_1.cc // // this is the function that checks the validity of the command line arguments // // system include file // #include // local include file // #include "global_constants.h" #include "calculate_lpc_constants.h" #include "calculate_lpc.h" // function: check_parameters_cc // // arguments: // char* datafile_a: (input) file that contains the signal // float frame_size_a: (output) duration of frame // float win_size_a: (output) duration of window // float win_center_time_a: (output) center time of window // float sample_freq_a: (input) sample frequency // int num_chans_a: (input) number of channels // float preemp_val_a: (output) preemphasis value // int win_type_a: (output) type of window // int lp_order_a: (output) order of linear prediction // int fft_order_a: (output) order of fft // int debug_mode_a: (output) debug mode // // return: an int to indicate status // // this function parses the command line arguments // // int check_parameters_cc (char* datafile_a, float frame_size_a,float win_size_a, float win_center_time_a, float sample_freq_a, int num_chans_a, float preemp_val_a, int win_type_a, int lp_order_a, int dft_order_a, int debug_mode_a) { // check if buffer is not allocated // if (datafile_a == (char*)NULL) { fprintf(stdout, "Error: Input file is empty\n"); return FALSE; } // check if parameters are negative // if ( ( (frame_size_a <= 0) || (win_size_a <= 0) || (win_center_time_a < 0) || (sample_freq_a <= 0) || (num_chans_a <= 0) || (lp_order_a < 0) || (dft_order_a < 0) || (debug_mode_a < 0) ) ) { fprintf(stdout, "Error: Parameter value is negative\n"); return FALSE; } // make sure that window center time is within the span of the file // int center_sample = calculate_num_samples_cc(win_center_time_a, sample_freq_a); int end_file_sample = calculate_end_sample_cc(datafile_a, sample_freq_a, num_chans_a); if (center_sample > end_file_sample) { fprintf(stdout, "Error: Center time of window is out of bound\n"); return FALSE; } // check if order of dft is at least equal the number of samples in // the window (better resolution) // if (dft_order_a < win_size_a * sample_freq_a * CLPC_MSEC_TO_SEC) { fprintf(stdout, "Error: Dft order is lower than number of samples in a window\n"); return FALSE; } if (debug_mode_a > DEBUG_FULL) { fprintf(stdout, "signal file: %s\n", datafile_a); fprintf(stdout, "frame size: %.2f\n", frame_size_a); fprintf(stdout, "window size: %.2f\n", win_size_a); fprintf(stdout, "window center time: %.2f\n", win_center_time_a); fprintf(stdout, "sample frequency: %.2f\n", sample_freq_a); fprintf(stdout, "number of channels: %d\n", num_chans_a); fprintf(stdout, "pre-emphasis value: %.2f\n", preemp_val_a); fprintf(stdout, "window type: %d\n", win_type_a); fprintf(stdout, "lp order: %d\n", lp_order_a); fprintf(stdout, "dft order: %d\n", dft_order_a); } // exit gracefully // return TRUE; }