function [] = F_audioSummary(inputAudioFile)

% Main function for computing audio summary using [Cooper,Foote,2002] summary score method
% This function is provided for the TP ATIAM 2015
% Author: Geoffroy Peeters, 2015/12
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if ~nargin
	%inputAudioFile	= 'audio_gammepno.wav';
	inputAudioFile	= 'audio_bep.wav';
end

FILE_s.EXPE1_OBS    = [inputAudioFile '_observation.mat'];
FILE_s.EXPE1_SIM    = [inputAudioFile '_similarite.mat'];
FILE_s.EXPE1_SIMF   = [inputAudioFile '_similarite_filtre.mat'];

L_sec					= 0.2;		% --- window duration in seconds
STEP_sec				= L_sec/3;	% --- hop size in seconds
param_summarylength_sec	= 20;
outputAudioFile			= [inputAudioFile '.sum.wav'];

[data_v, sr_hz] = audioread(inputAudioFile);
L_n				= round(L_sec*sr_hz);
STEP_n			= round(STEP_sec*sr_hz);


%% -------------------------------------------------
fprintf(1, 'Computing chroma observation matrix\n')
if 1
	% === obs_m (nbDim, nbFrame)
	obs_m	= F_extractChroma(data_v, sr_hz, L_n, STEP_n);
	save(FILE_s.EXPE1_OBS);
else
	load(FILE_s.EXPE1_OBS);
end

a = 1
fft= 1

%% -------------------------------------------------
fprintf(1, 'Computing similarity matrix\n')
if 1
	% === SSM_m (nbFrame, nbFrame)
	SSM_m	= F_computeSelfSimilarity(obs_m);
	save(FILE_s.EXPE1_SIM);
else
	load(FILE_s.EXPE1_SIM);
end

clf, imagesc(SSM_m), pause

%% -------------------------------------------------
fprintf(1, 'Filtering similarity matrix\n');
if 1
	% === SSMfiltered_m (nbFrame, nbFrame)
	SSMfiltered_m = F_filterSelfSimilarity(SSM_m, STEP_sec);
	save(FILE_s.EXPE1_SIMF);
else
	load(FILE_s.EXPE1_SIMF);
end


%% -------------------------------------------------
fprintf(1, 'Computing summary score\n');
L_frame				= round(param_summarylength_sec/STEP_sec);
start_frame			= F_computeSummaryScore(SSMfiltered_m+SSMfiltered_m.', L_frame)
start_n				= round(start_frame*STEP_sec*sr_hz);
L_n					= round(param_summarylength_sec*sr_hz);

audiowrite(outputAudioFile, data_v(start_n:start_n+L_n), sr_hz);
