function SE = SpectralEntropy(signal,winSize,OverlapStep)


if nargin < 4
    OverlapStep = 0;
end

n_samples = length(signal);


if OverlapStep > 0
    
    Overlap = floor((OverlapStep*winSize) / 100);
    nFrames=floor(n_samples/Overlap)-1;
elseif nargin < 3
    nFrames = 1;
    winSize = n_samples;
    Overlap= winSize;
else
    Overlap= winSize;
    nFrames=floor(n_samples/Overlap)-1;
end

Entropy = zeros(nFrames,1);

k=1;
inc=1;

while ( (k+winSize-1) <= n_samples )
    
    FrameSignal = signal(k:k+winSize-1);
    
    v = FrameSignal .* hann(length(FrameSignal));
    
    N = length(v);
    
    Y=fft(v);
    
    % Compute the Power Spectrum
    sqrtPyy = ((sqrt(abs(Y).*abs(Y)) * 2 )/N);
    sqrtPyy = sqrtPyy(1:floor(winSize/2));
    
    
    
    %Normalization
    d=sqrtPyy(:);
    d=d/sum(d+ 1e-12);
    
    %Entropy Calculation
    logd = log2(d + 1e-12);
    SE(inc) = -sum(d.*logd)/log2(length(d));
    
    
    k=k+Overlap;
    inc=inc+1;
end