%% Spectral Crest of Frequency-Domain Audio Data
% Read in an audio file and then calculate the mel spectrogram using the melSpectrogram function.

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

%
% Calculate the crest of the mel spectrogram over time. Plot the results.

crest = spectralCrest(s,cf);

t = linspace(0,size(audioIn,1)/fs,size(crest,1));
plot(t,crest)
xlabel('Time (s)')
ylabel('Crest')

%
% Copyright 2018 The MathWorks, Inc.