%script to plot the accuracy of Rectangular and Hann window for different windowshapes against spectral spread of audio file

%Developer:  - Alice Clifford (alice.clifford@eecs.qmul.ac.uk)

clear all
close all


load 'Results/accuracyData_290512_frameSize2048'
load 'SpectralAnalysis/specSpreadData'


figWidth=7;
figHeight=4;

fid=fopen('analysisInstNames_041112.txt');
tempNames=textscan(fid,'%s');
numNames=length(tempNames{1});

instNames=cell(numNames,1);


for n=1:numNames
    instNames{n}=tempNames{1}{n};
end





percHits_rect=percHitsMat(:,7); %extract data for rectangular window

figure

set(gcf, 'units', 'inches', 'pos', [0 1000 figWidth figHeight])

scatter(spreadData,percHits_rect,'k.')

set(gca,'FontSize',8)
ylim([0 100])
xlim([min(spreadData)-100 max(spreadData)+100])



%PLOT TEXT LABELS
for n=1:length(percHits_rect)
    if n==11 %Electric Guitar
        text(spreadData(n)-600,percHits_rect(n),instNames{n},'FontSize',8);
        
    elseif n==17 %Bass Recorder
        
        text(spreadData(n)+50,percHits_rect(n),instNames{n},'FontSize',8);
    elseif n==1 %Female Vocal
        
        text(spreadData(n)+50,percHits_rect(n),instNames{n},'FontSize',8);
    elseif n==14 %Shaker
        
        text(spreadData(n)-350,percHits_rect(n)-2,instNames{n},'FontSize',8);
        
    elseif n==15 %Tambourine
        
        text(spreadData(n)-550,percHits_rect(n),instNames{n},'FontSize',8);
        
        
    elseif n==4 %Snare
        
        text(spreadData(n)+50,percHits_rect(n),instNames{n},'FontSize',8);
        
        
    elseif n==12 %Male Vocal
        
        text(spreadData(n)-450,percHits_rect(n),instNames{n},'FontSize',8);
        
    elseif n==8 %Violin
        
        text(spreadData(n)+50,percHits_rect(n)-2,instNames{n},'FontSize',8);
    elseif n==13 %Rhodes
        
        text(spreadData(n)+50,percHits_rect(n)+2,instNames{n},'FontSize',8);
        
    elseif n==16 %Acoustic Guitar
        
        text(spreadData(n)-625,percHits_rect(n),instNames{n},'FontSize',8);
        
    else
        text(spreadData(n)+50,percHits_rect(n),instNames{n},'FontSize',8);
    end
end


lsline


ylabel('Accuracy (%)')
xlabel('Spectral Spread')














%HANN WINDOW



percHits_hann=percHitsMat(:,6); %set data for hann window


figure
set(gcf, 'units', 'inches', 'pos', [1000 300 figWidth figHeight])

scatter(spreadData,percHits_hann,'k.')
set(gca,'FontSize',8)

ylim([99.3 100])
xlim([min(spreadData)-100 max(spreadData)+100])

%PLOT TEXT LABELS

for n=1:length(percHits_hann)
    if n==13 %Rhodes
        text(spreadData(n)+50,percHits_hann(n),instNames{n},'FontSize',8);      
    elseif n==11 %Electric Guitar
        text(spreadData(n)-550,percHits_hann(n),instNames{n},'FontSize',8);
    elseif n==16 %Acoustic Guitar
        text(spreadData(n)-600,percHits_hann(n),instNames{n},'FontSize',8);        
    else   
        text(spreadData(n)+50,percHits_hann(n),instNames{n},'FontSize',8);
    end
end

lsline

ylabel('Accuracy (%)')
xlabel('Spectral Spread')
