% Demo2
%
% This demonstration how to compute and compare 'auditory spectrograms'
% of a clean and a distorted signal.
%

% Model is defined here. It could be also defined in a separate file,
% e.g., Profile_demo2.m. In this case it could called by
% A=AudMod(sig,'Profile_demo2.m').
model.fs=44100;
model.outmid.file='demo1_oem.mat'; % An ELC correction filter
model.cochlea.fb.file='gt64.mat'; % A 64-channel gammatone filterbank
model.haircell.rcf.r='half';       % Half-wave rectification
model.haircell.rcf.c='Plack98';    % A non-linear compr. function
model.haircell.rcf.f='no';         % No smoothing
model.neural.function='Plack98';   % Use temporal window model 
model.pp.mapping='decibel';        % Conversion to dB scale

% Signal
load Soprano;       % The original signal 
dsig=min(sig,2500); % A slightly distorted version of the original sig
% Processing
A=AudMod(sig,model);
dA=AudMod(dsig,model);

load gt64.mat; % This file also has the center frequencies of the filters
               
% Figure
t=linspace(0,10000/44.1,10000);ch=1:64;cf=round(CentFreqs(1:10:64));
subplot(2,1,1),imagesc(t,ch,A'),axis('xy');
xlabel('Time [ms]');ylabel('Frequency [Hz]');
title('Original TF-representation');set(gca,'Yticklabel',cf);
subplot(2,1,2),imagesc(t,ch,max(abs(A'-dA'),1)),axis('xy');
set(gca,'Yticklabel',cf);xlabel('Time [ms]');ylabel('Frequency [Hz]');
title('Difference between original and distorted auditory spectrograms');

