% file: homework_05.m
%
% this function computes the SNR (signal to noise ratio) of a raw data file
%
% arguments:
%  sample_freq		frequency of the input data in kHz
%  emphasis_val		parameter used in pre-emphasis
%  window_duration	duration of the window in secs
%  window_center	center time for the window in secs
%  window_type		string containing either: hamming, rectangular
%  lpc_order		the linear prediction order
%  bins			number of bins to use for the histogram
%  in_file		binary input file
%
% return value: 
%
% output: 
%

function out = homework_05(sample_freq,emphasis_val,window_duration,window_center,window_type,lpc_order,in_file)

% open the raw data file
%
fp = fopen(in_file,'r');

% determine the number of samples per window and per frame
%
num_samp_window = window_duration*sample_freq;

% create window function to window the raw data
%
upper(window_type);
if (strcmp(window_type,'HAMMING'))
   window = hamming(num_samp_window+1);
else
   window = ones(1,num_samp_window+1);
end

% read in the raw data (16-bit int)
%
[data,count] = fread(fp,inf,'int16');

window_center_index = window_center/(1/sample_freq);
window_left_index = window_center_index - num_samp_window/2;
window_right_index = window_center_index + num_samp_window/2;

data = data(window_left_index:window_right_index);

% pre-emphasize the data
%
pe_data = pre_emphasis(data,emphasis_val);

% apply window to the data
%
windowed_data = window .* transpose(pe_data);

signal_spectrum=fft(data);

plot(signal_spectrum);

% close the raw data file
%
fclose(fp);




