read_window

Digital Signal Processing Library

Voice Lab

Program name: read_window

Language: C

In file: window_lib.c

Objective: Read a window of data.

Usage: int read_window(int **window, int window_size, int data_length, int sample_rate, FILE *input_file) ;

Parameters:

  • window - Pointer to the window
  • window_size - The size of the window
  • data_length - The size of the data (typically 2 bytes)
  • sample_rate - The number of data samples per second (typically 25K)
  • input_file - The input file pointer.
Return
  • zero if read OK, -1 if error

Mathematical Description:

Comments: Routine used to read a window of data from the data file

User Comments

Code:

int read_window(int **window, int window_size, int data_length, int sample_rate, FILE *input_file)
{
int file_pos;
int i, data;

/* Read the next window */
for(i = 0; i < window_size; i++) {
/* The read_25 routine takes into account the data width (in our case 2 bytes per INT) */
if(read_25(input_file, data_length, sample_rate, &data) < data_length) {
return(-1);
}
/* fill window array */
(*window)[i] = data;
}
return(0);
}