%% Spectral Centroid of Time-Domain Audio
% Read in an audio file, calculate the centroid using default parameters, and then plot the results.

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

t = linspace(0,size(audioIn,1)/fs,size(centroid,1));
plot(t,centroid)
xlabel('Time (s)')
ylabel('Centroid (Hz)')

%
% Copyright 2018 The MathWorks, Inc.