%% Specify Nondefault Parameters
% Read in an audio file.

[audioIn,fs] = audioread('Counting-16-44p1-mono-15secs.wav');

%
% Calculate the entropy of the power spectrum over time. Calculate the entropy for 50 ms Hamming windows of data with 25 ms overlap. Use the range from 62.5 Hz to fs/2 for the entropy calculation. Plot the results.

entropy = spectralEntropy(audioIn,fs, ...
                          'Window',hamming(round(0.05*fs)), ...
                          'OverlapLength',round(0.025*fs), ...
                          'Range',[62.5,fs/2]);
                        
t = linspace(0,size(audioIn,1)/fs,size(entropy,1));
plot(t,entropy)
xlabel('Time (s)')
ylabel('Entropy')

%
% Copyright 2018 The MathWorks, Inc.