%% Extract GTCC from Frequency-Domain Audio
% Read in an audio file and convert it to a frequency representation.

[audioIn,fs] = audioread("Rainbow-16-8-mono-114secs.wav");

win = hann(1024,"periodic");
S = stft(audioIn,"Window",win,"OverlapLength",512,"Centered",false);

%
% To extract the gammatone cepstral coefficients, call gtcc with the frequency-domain audio. Ignore the log-energy.

coeffs = gtcc(S,fs,"LogEnergy","Ignore");

%
% In many applications, GTCC observations are converted to summary statistics for use in classification tasks. Plot probability density functions of each of the gammatone cepstral coefficients to observe their distributions.

nbins = 60;
for i = 1:size(coeffs,2)
    figure
    histogram(coeffs(:,i),nbins,'Normalization','pdf')
    title(sprintf("Coefficient %d",i-1))
end

% Copyright 2019 The MathWorks, Inc.