function mov_summary()
%--------------------------------------------------------------------------
% Moving Spectral Average Summary Of Average And Maximum Error
%
% Cooper Baker - 2014
%--------------------------------------------------------------------------

close all;

name = 'Moving Spectral Average Summary';

% set path
p = genpath( '../../analyze' );
addpath( p );

% algorithm names for plot labels
algos = { 'Classic', 'Lock', 'Peak', 'Bank', 'Sola', 'Ola' };

% file names for plot labels
fileAname = 'Sine';
fileBname = 'Square';
fileCname = 'Sweep';
fileDname = 'Amen';
fileEname = 'Autumn';
fileFname = 'Peaches';

% file names for csvread
fileA = 'sine';
fileB = 'square';
fileC = 'sweep';
fileD = 'amen';
fileE = 'autumn';
fileF = 'peaches';

% read the error plot data
rawAdata = csvread( [ fileA, '.classic.mov.err.csv' ] );
rawBdata = csvread( [ fileB, '.classic.mov.err.csv' ] );
rawCdata = csvread( [ fileC, '.classic.mov.err.csv' ] );
rawDdata = csvread( [ fileD, '.classic.mov.err.csv' ] );
rawEdata = csvread( [ fileE, '.classic.mov.err.csv' ] );
rawFdata = csvread( [ fileF, '.classic.mov.err.csv' ] );

lockAdata = csvread( [ fileA, '.lock.mov.err.csv' ] );
lockBdata = csvread( [ fileB, '.lock.mov.err.csv' ] );
lockCdata = csvread( [ fileC, '.lock.mov.err.csv' ] );
lockDdata = csvread( [ fileD, '.lock.mov.err.csv' ] );
lockEdata = csvread( [ fileE, '.lock.mov.err.csv' ] );
lockFdata = csvread( [ fileF, '.lock.mov.err.csv' ] );

peakAdata = csvread( [ fileA, '.peak.mov.err.csv' ] );
peakBdata = csvread( [ fileB, '.peak.mov.err.csv' ] );
peakCdata = csvread( [ fileC, '.peak.mov.err.csv' ] );
peakDdata = csvread( [ fileD, '.peak.mov.err.csv' ] );
peakEdata = csvread( [ fileE, '.peak.mov.err.csv' ] );
peakFdata = csvread( [ fileF, '.peak.mov.err.csv' ] );

bankAdata = csvread( [ fileA, '.bank.mov.err.csv' ] );
bankBdata = csvread( [ fileB, '.bank.mov.err.csv' ] );
bankCdata = csvread( [ fileC, '.bank.mov.err.csv' ] );
bankDdata = csvread( [ fileD, '.bank.mov.err.csv' ] );
bankEdata = csvread( [ fileE, '.bank.mov.err.csv' ] );
bankFdata = csvread( [ fileF, '.bank.mov.err.csv' ] );

solaAdata = csvread( [ fileA, '.sola.mov.err.csv' ] );
solaBdata = csvread( [ fileB, '.sola.mov.err.csv' ] );
solaCdata = csvread( [ fileC, '.sola.mov.err.csv' ] );
solaDdata = csvread( [ fileD, '.sola.mov.err.csv' ] );
solaEdata = csvread( [ fileE, '.sola.mov.err.csv' ] );
solaFdata = csvread( [ fileF, '.sola.mov.err.csv' ] );

olaAdata = csvread( [ fileA, '.ola.mov.err.csv' ] );
olaBdata = csvread( [ fileB, '.ola.mov.err.csv' ] );
olaCdata = csvread( [ fileC, '.ola.mov.err.csv' ] );
olaDdata = csvread( [ fileD, '.ola.mov.err.csv' ] );
olaEdata = csvread( [ fileE, '.ola.mov.err.csv' ] );
olaFdata = csvread( [ fileF, '.ola.mov.err.csv' ] );

% find max values
rawAmax = max( rawAdata );
rawBmax = max( rawBdata );
rawCmax = max( rawCdata );
rawDmax = max( rawDdata );
rawEmax = max( rawEdata );
rawFmax = max( rawFdata );

lockAmax = max( lockAdata );
lockBmax = max( lockBdata );
lockCmax = max( lockCdata );
lockDmax = max( lockDdata );
lockEmax = max( lockEdata );
lockFmax = max( lockFdata );

lockAavg = sum( lockAdata ) / length( lockAdata );
lockBavg = sum( lockBdata ) / length( lockBdata );
lockCavg = sum( lockCdata ) / length( lockCdata );
lockDavg = sum( lockDdata ) / length( lockDdata );
lockEavg = sum( lockEdata ) / length( lockEdata );
lockFavg = sum( lockFdata ) / length( lockFdata );

peakAmax = max( peakAdata );
peakBmax = max( peakBdata );
peakCmax = max( peakCdata );
peakDmax = max( peakDdata );
peakEmax = max( peakEdata );
peakFmax = max( peakFdata );

bankAmax = max( bankAdata );
bankBmax = max( bankBdata );
bankCmax = max( bankCdata );
bankDmax = max( bankDdata );
bankEmax = max( bankEdata );
bankFmax = max( bankFdata );

solaAmax = max( solaAdata );
solaBmax = max( solaBdata );
solaCmax = max( solaCdata );
solaDmax = max( solaDdata );
solaEmax = max( solaEdata );
solaFmax = max( solaFdata );

olaAmax = max( olaAdata );
olaBmax = max( olaBdata );
olaCmax = max( olaCdata );
olaDmax = max( olaDdata );
olaEmax = max( olaEdata );
olaFmax = max( olaFdata );

% calculate averages
rawAavg = sum( rawAdata ) / length( rawAdata );
rawBavg = sum( rawBdata ) / length( rawBdata );
rawCavg = sum( rawCdata ) / length( rawCdata );
rawDavg = sum( rawDdata ) / length( rawDdata );
rawEavg = sum( rawEdata ) / length( rawEdata );
rawFavg = sum( rawFdata ) / length( rawFdata );

peakAavg = sum( peakAdata ) / length( peakAdata );
peakBavg = sum( peakBdata ) / length( peakBdata );
peakCavg = sum( peakCdata ) / length( peakCdata );
peakDavg = sum( peakDdata ) / length( peakDdata );
peakEavg = sum( peakEdata ) / length( peakEdata );
peakFavg = sum( peakFdata ) / length( peakFdata );

bankAavg = sum( bankAdata ) / length( bankAdata );
bankBavg = sum( bankBdata ) / length( bankBdata );
bankCavg = sum( bankCdata ) / length( bankCdata );
bankDavg = sum( bankDdata ) / length( bankDdata );
bankEavg = sum( bankEdata ) / length( bankEdata );
bankFavg = sum( bankFdata ) / length( bankFdata );

solaAavg = sum( solaAdata ) / length( solaAdata );
solaBavg = sum( solaBdata ) / length( solaBdata );
solaCavg = sum( solaCdata ) / length( solaCdata );
solaDavg = sum( solaDdata ) / length( solaDdata );
solaEavg = sum( solaEdata ) / length( solaEdata );
solaFavg = sum( solaFdata ) / length( solaFdata );

olaAavg = sum( olaAdata ) / length( olaAdata );
olaBavg = sum( olaBdata ) / length( olaBdata );
olaCavg = sum( olaCdata ) / length( olaCdata );
olaDavg = sum( olaDdata ) / length( olaDdata );
olaEavg = sum( olaEdata ) / length( olaEdata );
olaFavg = sum( olaFdata ) / length( olaFdata );

% find max of each audio file
maxAmax = max( [ rawAmax lockAmax peakAmax bankAmax solaAmax olaAmax ] );
maxBmax = max( [ rawBmax lockBmax peakBmax bankBmax solaBmax olaBmax ] );
maxCmax = max( [ rawCmax lockCmax peakCmax bankCmax solaCmax olaCmax ] );
maxDmax = max( [ rawDmax lockDmax peakDmax bankDmax solaDmax olaDmax ] );
maxEmax = max( [ rawEmax lockEmax peakEmax bankEmax solaEmax olaEmax ] );
maxFmax = max( [ rawFmax lockFmax peakFmax bankFmax solaFmax olaFmax ] );

% create matricies of max values for plots
maxA = [ rawAmax lockAmax peakAmax bankAmax solaAmax olaAmax ];
maxB = [ rawBmax lockBmax peakBmax bankBmax solaBmax olaBmax ];
maxC = [ rawCmax lockCmax peakCmax bankCmax solaCmax olaCmax ];
maxD = [ rawDmax lockDmax peakDmax bankDmax solaDmax olaDmax ];
maxE = [ rawEmax lockEmax peakEmax bankEmax solaEmax olaEmax ];
maxF = [ rawFmax lockFmax peakFmax bankFmax solaFmax olaFmax ];

% create matrices of avg values for plots
avgA = [ rawAavg lockAavg peakAavg bankAavg solaAavg olaAavg ];
avgB = [ rawBavg lockBavg peakBavg bankBavg solaBavg olaBavg ];
avgC = [ rawCavg lockCavg peakCavg bankCavg solaCavg olaCavg ];
avgD = [ rawDavg lockDavg peakDavg bankDavg solaDavg olaDavg ];
avgE = [ rawEavg lockEavg peakEavg bankEavg solaEavg olaEavg ];
avgF = [ rawFavg lockFavg peakFavg bankFavg solaFavg olaFavg ];

% Plot
%--------------------------------------------------------------------------

% graph formatting
fontName   = 'Times New Roman';
fontSize   = 12;
xTxt = 0.125;
yTxt = 1.2;
yOff = 0.13;

% set up plot window
fig = figure( 1 );
set( fig, 'Name', sprintf( '%s', name ) );
set( fig, 'Position', [ 0 0 800 1000 ] );
set( fig, 'defaultAxesFontName', fontName );
set( fig, 'defaultTextFontName', fontName );
% set( fig, 'defaultlinelinewidth', 3 );
set( fig, 'defaultaxescolororder', [ 0.8 0.2 0.2 ] );

% fileA
%--------------------------------------------------------------------------
plotL = avgA;
plotR = maxA;
fileName = fileAname;
sp = subplot( 6, 2, 1 );
bar( plotL, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.1, 5.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxAmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotL( i ) + maxAmax * yOff, num2str( plotL( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
temp = get( gca );
yticks = get( gca, 'YTick' );
set( gca, 'YTickLabel', yticks );
text( xTxt, yTxt * maxAmax, [ ' ' fileName ' ' ], 'BackgroundColor', 'w', 'EdgeColor', 'k' );
title( 'Average', 'FontSize', fontSize );

sp = subplot( 6, 2, 2 );
bar( plotR, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.5, 5.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxAmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotR( i ) + maxAmax * yOff, num2str( plotR( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
set( gca, 'YTickLabel', [] );
title( 'Maximum', 'FontSize', fontSize );

% fileB
%--------------------------------------------------------------------------
plotL = avgB;
plotR = maxB;
fileName = fileBname;
sp = subplot( 6, 2, 3 );
bar( plotL, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.1, 4.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxBmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotL( i ) + maxBmax * yOff, num2str( plotL( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
temp = get( gca );
yticks = get( gca, 'YTick' );
set( gca, 'YTickLabel', yticks );
text( xTxt, yTxt * maxBmax, [ ' ' fileName ' ' ], 'BackgroundColor', 'w', 'EdgeColor', 'k' );

sp = subplot( 6, 2, 4 );
bar( plotR, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.5, 4.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxBmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotR( i ) + maxBmax * yOff, num2str( plotR( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
set( gca, 'YTickLabel', [] );

% fileC
%--------------------------------------------------------------------------
plotL = avgC;
plotR = maxC;
fileName = fileCname;
sp = subplot( 6, 2, 5 );
bar( plotL, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.1, 3.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxCmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotL( i ) + maxCmax * yOff, num2str( plotL( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
temp = get( gca );
yticks = get( gca, 'YTick' );
set( gca, 'YTickLabel', yticks );
text( xTxt, yTxt * maxCmax, [ ' ' fileName ' ' ], 'BackgroundColor', 'w', 'EdgeColor', 'k' );

sp = subplot( 6, 2, 6 );
bar( plotR, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.5, 3.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxCmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotR( i ) + maxCmax * yOff, num2str( plotR( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
set( gca, 'YTickLabel', [] );

% fileD
%--------------------------------------------------------------------------
plotL = avgD;
plotR = maxD;
fileName = fileDname;
sp = subplot( 6, 2, 7 );
bar( plotL, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.1, 2.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxDmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotL( i ) + maxDmax * yOff, num2str( plotL( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
temp = get( gca );
yticks = get( gca, 'YTick' );
set( gca, 'YTickLabel', yticks );
text( xTxt, yTxt * maxDmax, [ ' ' fileName ' ' ], 'BackgroundColor', 'w', 'EdgeColor', 'k' );

sp = subplot( 6, 2, 8 );
bar( plotR, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.5, 2.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxDmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotR( i ) + maxDmax * yOff, num2str( plotR( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
set( gca, 'YTickLabel', [] );

% fileE
%--------------------------------------------------------------------------
plotL = avgE;
plotR = maxE;
fileName = fileEname;
sp = subplot( 6, 2, 9 );
bar( plotL, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.1, 1.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxEmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotL( i ) + maxEmax * yOff, num2str( plotL( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
temp = get( gca );
yticks = get( gca, 'YTick' );
set( gca, 'YTickLabel', yticks );
text( xTxt, yTxt * maxEmax, [ ' ' fileName ' ' ], 'BackgroundColor', 'w', 'EdgeColor', 'k' );

sp = subplot( 6, 2, 10 );
bar( plotR, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.5, 1.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxEmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotR( i ) + maxEmax * yOff, num2str( plotR( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', [] );
set( gca, 'YTickLabel', [] );

% fileF
%--------------------------------------------------------------------------
plotL = avgF;
plotR = maxF;
fileName = fileFname;
sp = subplot( 6, 2, 11 );
bar( plotL, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.1, 0.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxFmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotL( i ) + maxFmax * yOff, num2str( plotL( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
set( gca, 'XTickLabel', algos );
yLab = ylabel( 'Sones' );
temp = get( gca );
yticks = get( gca, 'YTick' );
set( gca, 'YTickLabel', yticks );
text( xTxt, yTxt * maxFmax, [ ' ' fileName ' ' ], 'BackgroundColor', 'w', 'EdgeColor', 'k' );

sp = subplot( 6, 2, 12 );
bar( plotR, 'FaceColor', [ 0.8 0.2 0.2 ] );
set( sp, 'Position', [ 0.5, 0.5/7, 0.39, 1/7.333 ] );
axis( [ 0 7 0 ( maxFmax * 1.3 ) ] );
for( i = 1 : 6 )
    text( i, plotR( i ) + maxFmax * yOff, num2str( plotR( i ), '%2.5f' ), 'HorizontalAlignment', 'center', 'BackgroundColor', 'w', 'EdgeColor', 'k', 'FontSize', 9 );
end
set( gca, 'TickLength', [ 0 0 ] );
set( gca, 'XTickLabel', algos );
set( gca, 'YTickLabel', [] );
set( gca, 'YGrid', 'on', 'XGrid', 'off' );
xLab = xlabel( 'Algorithms' );

% tighen up figure borders
tightfig();

% move x and y labels
set( xLab, 'Position', [ -0.1 ( maxFmax * -0.16 ) ] );
set( yLab, 'Position', [ -0.625 ( ( maxFmax * 1.3 * 6.25 ) / 2 ) ] );

% write plot to file
hgexport( fig, [ 'summary.mov.eps' ] );

% EOF
