load('test_0.mat');
s_length = length(AudioSnip);
nframes = 1 + floor((s_length - frameSize)/double(Hop ));
UsableSigLength = frameSize + floor(Hop *floor((s_length - frameSize)/double(Hop )));
sampleTime = ( 1: UsableSigLength )/fs;
[B,f,T] = specgram(AudioSnip,frameSize*2,fs,hanning(frameSize), Hop);
B = 20*log10(abs(B));
TheFig = figure;
h = gcf ;
h.Units = 'centimeters';
h.PaperType= 'A4';
h.PaperUnits = 'centimeters';
h.PaperOrientation= 'landscape';
h.PaperPositionMode= 'auto';
h.InvertHardcopy = 'on';
h.Renderer = 'painter';
margin = 4.; width = 29.7; height = 21.;
h.Position = [margin margin width-2*margin height-2*margin];
h.PaperSize = [29.7 21.0];
subplot(2,1,1);
plot(sampleTime, AudioSnip(1: UsableSigLength));
xlabel('Time (s)','FontSize', 10, 'FontName' ,'Times', 'FontWeight', 'bold');
ylabel('Amplitude', 'FontSize', 12, 'FontName' ,'Times', 'FontWeight', 'bold');
set(get(gca, 'xlabel'), 'Position', [ 21.,-0.21,-1]);
h1 = gcf;
h1.Units = 'centimeters';
atx1= gca;
atx1.Position = [0.1300 0.7099 0.6949 0.1635];
atx1.FontSize = 10 ; atx1.FontName = 'Times'; atx1.FontWeight = 'bold';
atx1.Units='normalized';
Tt0=text('Units','normalized','Position',[ 0.0009 1.4599 0 ],...
'VerticalAlignment', 'Bottom', 'FontName', 'Times', 'FontSize',14 , 'FontWeight', 'bold', 'String', 'text1');
Tt1=text('Units','normalized','Position',[ 0.0009 1.260, 0 ],...
'VerticalAlignment', 'Bottom', 'FontName', 'Times', 'FontSize',14 , 'FontWeight', 'bold', 'FontAngle', 'italic','String', 'text2');
Tt2=text('Units','normalized','Position',[0.0009 1.0509 0],...
'VerticalAlignment', 'Bottom', 'FontName', 'Times', 'FontSize',12 , 'FontWeight', 'bold', 'String', 'text3');
subplot(2,1,2);
h2 = gcf;
h2.Units = 'centimeters';
atx2= gca;
atx2.FontSize = 10; atx2.FontName= 'Times' ; atx2.FontWeight = 'bold';
atx2.Units='normalized';
atx2.Position = [0.1300 0.0720 0.7334 0.5965 ];
imagesc(T,f,B);axis xy;colorbar;
ylabel('Frequency (Hz)','FontSize', 12, 'FontName' ,'Times', 'FontWeight', 'bold');
xlabel('','FontSize', 12, 'FontName' ,'Times', 'FontWeight', 'bold');
colormap jet
exportgraphics(TheFig, 'outputTest.pdf');