// file: clpc_cal_1.cc // // this function finds the end sample in the file // // system include file // #include // local include file // #include "global_constants.h" #include "calculate_lpc_constants.h" #include "calculate_lpc.h" // function: calculate_end_sample_cc // // arguments: // char* input_file_a: (input) name of input file // float sample_freq_a: (input) sample frequency // int num_chans_a: (input) number of channels // // return: the end time of the file // // this function finds the end sample in the file // // int calculate_end_sample_cc (char* input_file_a, float sample_freq_a, int num_chans_a) { if (input_file_a == (char*)NULL) { fprintf(stdout, "NULL buffer\n"); return FALSE; } // open the file // FILE* fp = fopen (input_file_a, "r"); if (fp == (FILE*)NULL) { fprintf(stdout, "Unable to open %s\n", input_file_a); return FALSE; } // rewind the file to the beginning of the file // rewind(fp); // compute the length of file in bytes // fseek(fp, 0, SEEK_END); int total_bytes = ftell(fp); // close the file // fclose (fp); // return number of frames in the file // return (int (total_bytes / (num_chans_a * CLPC_BYTES_PER_SAMPLE)) ); }