
% segment audio data into overlapping frames and take fft of each frame

function [fftframes,info] = bigframefft(audiodata, info)

fprintf(1,'framefft\n');
    
info.undertest = [info.undertest '\nfft'];

% set window length
win = info.windowlength;


% Pad audio with zeros so that first analysis frame corresponds with first
% audio sample

pad = zeros((win/2),1);

%audiodata = [pad; audiodata; pad];

% find size of input
ilength = length(audiodata);


%pad audio data
audiodata = [pad; audiodata; pad]; 

% set hop size
hop = fix(win.*info.overlap); 

info.hopsize = hop;

% set number of windows
num_win = ceil((ilength+1)/hop);

info.numberframes = num_win;

start=1;

fftframes = zeros(win,num_win);

check = ceil(num_win/10);


% do fft analysis for each window:
for i = 1 : num_win;
  
    segment = audiodata(start:(start + win - 1));
    
    fftframes(:,i) = fft(segment, win)';
  
    start = start + hop;
    
    if mod(i,check)  == 0
        fprintf(1,'.');
    end
    
end;
fprintf(1,'\n');


