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

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

nAudio = length(filenames);

mkdir(DBpath,'mirPar');

%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% Dynamika %%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% RMS

rms = cell(nAudio,1);

for n = 1:nAudio
        
    currentFile = filenames{n};  
    filename = [DBpath,'\',currentFile];
    
    a = miraudio(filename,'Mono',1);
    
    rmsTemp = mirgetdata(mirrms(a,'Frame'));
    rms{n,1} = rmsTemp;   
    
end
savepathMIR = [DBpath,'\mirPar\rms.mat'];
save(savepathMIR,'rms');

clearvars rms

%% Low Energy
% 
% lowEnergyCell = cell(nAudio,1);
% 
% for n = 1:nAudio
%         
%     currentFile = filenames{n};  
%     filename = [DBpath,'\',currentFile];
%     
%     a = miraudio(filename,'Mono',1);
%     
%     lowEnergy = mirgetdata(mirlowenergy(a,'Frame'));
%     lowEnergyCell{n,1} = lowEnergy;    
%     
% end
% savepathMIR = [DBpath,'\mirPar\lowEnergyCell.mat'];
% save(savepathMIR,'lowEnergyCell');
% 
% 
% clearvars lowEnergyCell

%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%% Rytmus %%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Event Density

eventDensity = cell(nAudio,1);

for n = 1:nAudio
        
    currentFile = filenames{n};  
    filename = [DBpath,'\',currentFile];
    
    a = miraudio(filename,'Mono',1);
    
    eventDensityTemp = mirgetdata(mireventdensity(a,'Frame'));
    eventDensity{n,1} = eventDensityTemp;    
    
end
savepathMIR = [DBpath,'\mirPar\eventDensity.mat'];
save(savepathMIR,'eventDensity');

clearvars eventDensity

%% Tempo

tempo = cell(nAudio,1);


for n = 1:nAudio
        
    currentFile = filenames{n};  
    filename = [DBpath,'\',currentFile];
    
    a = miraudio(filename,'Mono',1);
    
    tempoTemp = mirgetdata(mirtempo(a,'Frame'));
    tempo{n,1} = tempoTemp;    
    
end
savepathMIR = [DBpath,'\mirPar\tempo.mat'];
save(savepathMIR,'tempo');

clearvars tempo

%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% Barva zvuku %%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Events

EventsCell = cell(nAudio,1);

for n = 1:nAudio
        
    currentFile = filenames{n};  
    filename = [DBpath,'\',currentFile];
    
    a = miraudio(filename,'Mono',1);
    
    Events = mirevents(a);
    EventsCell{n,1} = Events;
    
end

%% Attack time

attackTime = cell(nAudio,1);

for n = 1:nAudio
    
    attackTimeTemp = mirgetdata(mirattacktime(EventsCell{n,1}));
    attackTime{n,1} = attackTimeTemp;    
    
end
savepathMIR = [DBpath,'\mirPar\attackTime.mat'];
save(savepathMIR,'attackTime');

clearvars attackTime

%% Attack slope

attackSlope = cell(nAudio,1);

for n = 1:nAudio
    
    attackSlopeTemp = mirgetdata(mirattackslope(EventsCell{n,1}));
    attackSlope{n,1} = attackSlopeTemp;    
    
end
savepathMIR = [DBpath,'\mirPar\attackSlope.mat'];
save(savepathMIR,'attackSlope');

clearvars attackSlope

%% Attack leap

attackLeap = cell(nAudio,1);

for n = 1:nAudio
    
    attackLeapTemp = mirgetdata(mirattackslope(EventsCell{n,1}));
    attackLeap{n,1} = attackLeapTemp; 
    
end
savepathMIR = [DBpath,'\mirPar\attackLeap.mat'];
save(savepathMIR,'attackLeap');

clearvars attackLeapCell

%% Decay time

decayTime = cell(nAudio,1);

for n = 1:nAudio
    
    decayTimeTemp = mirgetdata(mirdecaytime(EventsCell{n,1}));
    decayTime{n,1} = decayTimeTemp;    
    
end
savepathMIR = [DBpath,'\mirPar\decayTime.mat'];
save(savepathMIR,'decayTime');

clearvars decayTime

%% Decay leap

decayLeap = cell(nAudio,1);

for n = 1:nAudio
    
    decayLeapTemp = mirgetdata(mirdecayleap(EventsCell{n,1}));
    decayLeap{n,1} = decayLeapTemp;    
    
end
savepathMIR = [DBpath,'\mirPar\decayLeap.mat'];
save(savepathMIR,'decayLeap');

clearvars decayLeap

%% Decay slope

decaySlope = cell(nAudio,1);

for n = 1:nAudio
    
    decaySlopeTemp = mirgetdata(mirdecayslope(EventsCell{n,1}));
    decaySlope{n,1} = decaySlopeTemp;    
    
end
savepathMIR = [DBpath,'\mirPar\decaySlope.mat'];
save(savepathMIR,'decaySlope');

clearvars decaySlope

%% Duration

duration = cell(nAudio,1);

for n = 1:nAudio
           
    durationTemp = mirgetdata(mirduration(EventsCell{n,1}));
    duration{n,1} = durationTemp;
    
end
savepathMIR = [DBpath,'\mirPar\duration.mat'];
save(savepathMIR,'duration');

clearvars duration

%% Zero cross rate

zcr = cell(nAudio,1);

for n = 1:nAudio
        
    currentFile = filenames{n};  
    filename = [DBpath,'\',currentFile];
    
    a = miraudio(filename,'Mono',1);
    
    zcrTemp = mirgetdata(mirzerocross(a,'Frame'));
    zcr{n,1} = zcrTemp;    
    
end
savepathMIR = [DBpath,'\mirPar\zcr.mat'];
save(savepathMIR,'zcr');

clearvars zcr

%% Roll Off

rollOff = cell(nAudio,1);

for n = 1:nAudio
        
    currentFile = filenames{n};  
    filename = [DBpath,'\',currentFile];
    
    a = miraudio(filename,'Mono',1);
    
    rollOffTemp = mirgetdata(mirrolloff(a,'Frame'));
    rollOff{n,1} = rollOffTemp;    
    
end
savepathMIR = [DBpath,'\mirPar\rollOff.mat'];
save(savepathMIR,'rollOff');

clearvars rollOff

%% Brightness

brightness = cell(nAudio,1);

for n = 1:nAudio
        
    currentFile = filenames{n};  
    filename = [DBpath,'\',currentFile];
    
    a = miraudio(filename,'Mono',1);
    
    brightnessTemp = mirgetdata(mirbrightness(a,'Frame'));
    brightness{n,1} = brightnessTemp;    
    
end
savepathMIR = [DBpath,'\mirPar\brightness.mat'];
save(savepathMIR,'brightness');

clearvars brightness

%% MFCC

mfcc = cell(nAudio,13);

for n = 1:nAudio
        
    currentFile = filenames{n};  
    filename = [DBpath,'\',currentFile];
    
    a = miraudio(filename,'Mono',1);
    
    mfccTemp = mirgetdata(mirmfcc(a,'Frame','Rank',1:13));
    mfcc{n,1} = mfccTemp(1,:);
    mfcc{n,2} = mfccTemp(2,:);
    mfcc{n,3} = mfccTemp(3,:);  
    mfcc{n,4} = mfccTemp(4,:);
    mfcc{n,5} = mfccTemp(5,:);
    mfcc{n,6} = mfccTemp(6,:);
    mfcc{n,7} = mfccTemp(7,:);  
    mfcc{n,8} = mfccTemp(8,:);
    mfcc{n,9} = mfccTemp(9,:);
    mfcc{n,10} = mfccTemp(10,:);
    mfcc{n,11} = mfccTemp(11,:);
    mfcc{n,12} = mfccTemp(12,:);
    mfcc{n,13} = mfccTemp(13,:);
    
        
end
savepathMIR = [DBpath,'\mirPar\mfcc.mat'];
save(savepathMIR,'mfcc');

clearvars mfcc

      
%% Roughness

roughness = cell(nAudio,1);

for n = 1:nAudio
        
    currentFile = filenames{n};  
    filename = [DBpath,'\',currentFile];
    
    a = miraudio(filename,'Mono',1);
    
    roughnessTemp = mirgetdata(mirroughness(a,'Frame'));
    roughness{n,1} = roughnessTemp;    
    
end
savepathMIR = [DBpath,'\mirPar\roughness.mat'];
save(savepathMIR,'roughness');

clearvars roughness

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

% %% Spektrum
% 
% spectrumCell = cell(nAudio,1);
% 
% for n = 1:nAudio
%         
%     currentFile = filenames{n};  
%     filename = [DBpath,'\',currentFile];
%     
%     a = miraudio(filename,'Mono',1);
%     
%     spectrum = mirspectrum(a,'Frame');
%     spectrumCell{n,1} = spectrum;    
% 
% end
% 
% %% Spectral centroid
% 
% spectralCentroid = cell(nAudio,1);
% 
% for n = 1:nAudio
%     
%     spectralCentroidTemp = mirgetdata(mircentroid(spectrumCell{n,1}));
%     spectralCentroid{n,1} = spectralCentroidTemp;    
%     
% end
% savepathMIR = [DBpath,'\mirPar\spectralCentroid.mat'];
% save(savepathMIR,'spectralCentroid');
% 
% clearvars spectralCentroid
% 
% %% Spectral spread
% 
% spectralSpread = cell(nAudio,1);
% 
% for n = 1:nAudio
%         
%     spectralSpreadTemp = mirgetdata(mirspread(spectrumCell{n,1}));
%     spectralSpread{n,1} = spectralSpreadTemp;    
%     
% end
% savepathMIR = [DBpath,'\mirPar\spectralSpread.mat'];
% save(savepathMIR,'spectralSpread');
% 
% clearvars spectralSpread
% 
% %% Spectral skewness
% 
% spectralSkewness = cell(nAudio,1);
% 
% for n = 1:nAudio
%         
%     spectralSkewnessTemp = mirgetdata(mirskewness(spectrumCell{n,1}));
%     spectralSkewness{n,1} = spectralSkewnessTemp;    
%     
% end
% savepathMIR = [DBpath,'\mirPar\spectralSkewness.mat'];
% save(savepathMIR,'spectralSkewness');
% 
% clearvars spectralSkewness
% 
% %% Spectral kurtosis
% 
% spectralKurtosis = cell(nAudio,1);
% 
% for n = 1:nAudio
%         
%     spectralKurtosisTemp = mirgetdata(mirkurtosis(spectrumCell{n,1}));
%     spectralKurtosis{n,1} = spectralKurtosisTemp;    
%     
% end
% savepathMIR = [DBpath,'\mirPar\spectralKurtosis.mat'];
% save(savepathMIR,'spectralKurtosis');
% 
% clearvars spectralKurtosis
% 
% %% Spectral flatness
% 
% spectralFlatness = cell(nAudio,1);
% 
% for n = 1:nAudio
%         
%     spectralFlatnessTemp = mirgetdata(mirflatness(spectrumCell{n,1}));
%     spectralFlatness{n,1} = spectralFlatnessTemp;    
%     
% end
% savepathMIR = [DBpath,'\mirPar\spectralFlatness.mat'];
% save(savepathMIR,'spectralFlatness');
% 
% clearvars spectralFlatnessCell
end


