function singleFolderFeatureCompSpectral
% singleFolderFeatureComp
%
% Funkce pro vypocet MIR parametru
%
% Stepan Miklanek, 2018

DBpath = uigetdir;
DBinfo = dir(DBpath);
filenames = extractfield(DBinfo(3:end),'name');

nAudio = length(filenames);

% nAudio = 1;

mkdir(DBpath,'mirPar');
  

%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%% Spektralni statistika %%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%      

%% Spektrum

spectralCentroid = cell(nAudio,1);
spectralSpread = cell(nAudio,1);
spectralSkewness = cell(nAudio,1);
spectralKurtosis = cell(nAudio,1);
spectralFlatness = cell(nAudio,1);

for n = 1:nAudio
        
    currentFile = filenames{n};  
    filename = [DBpath,'\',currentFile];
    
    a = miraudio(filename,'Mono',1);
    
    spectrum = mirspectrum(a,'Frame');
    spectralCentroid{n,1} = mirgetdata(mircentroid(spectrum));
    spectralSpread{n,1} = mirgetdata(mirspread(spectrum));
    spectralSkewness{n,1} = mirgetdata(mirskewness(spectrum));
    spectralKurtosis{n,1} = mirgetdata(mirkurtosis(spectrum));
    spectralFlatness{n,1} = mirgetdata(mirflatness(spectrum));

end

savepathMIR = [DBpath,'\mirPar\spectralCentroid.mat'];
save(savepathMIR,'spectralCentroid');

savepathMIR = [DBpath,'\mirPar\spectralSpread.mat'];
save(savepathMIR,'spectralSpread');

savepathMIR = [DBpath,'\mirPar\spectralSkewness.mat'];
save(savepathMIR,'spectralSkewness');

savepathMIR = [DBpath,'\mirPar\spectralKurtosis.mat'];
save(savepathMIR,'spectralKurtosis');

savepathMIR = [DBpath,'\mirPar\spectralFlatness.mat'];
save(savepathMIR,'spectralFlatness');

clearvars spectralFlatnessCell
end


