// file: csnr_cal_1.cc // // this function calculates the number of frames in a file // // system include file // #include #include // local include file // #include "global_constants.h" #include "calculate_snr_constants.h" #include "calculate_snr.h" // function: calculate_num_frames_cc // // arguments: // char* input_file_a: (input) name of input file // int samples_per_frame_a: (input) number of samples per frame // int num_chans_a: (input) number of channels // // return: the number of frames in this file // // this function calculates the number of frames in a file // // int calculate_num_frames_cc (char* input_file_a, int samples_per_frame_a, int num_chans_a) { // open the file // FILE* fp = fopen (input_file_a, "r"); // check for NULL file pointer // if (fp == (FILE*)NULL) { 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 end = ftell(fp); // return number of frames in the file // return (int ( rint (end / (samples_per_frame_a * num_chans_a * CSNR_BYTES_PER_SAMPLE) ) + 1)); }