clear all
clear
clc

%Pitch and number correlation
f=1;
g=2;
a=3;
b=4;
c=5;
d=6;
e=7;
F=8;
G=9;
A=10;
B=11;
C=12;

%Number generation
for i=1:12
    r(i)=rand();
    if 0<r(i) && r(i)<1/12
        r(i)=1;
    end
    if 1/12<r(i) && r(i)<1/6
        r(i)=2;
    end
    if 1/6<r(i) && r(i)<1/4
        r(i)=3;
    end
    if 1/4<r(i) && r(i)<1/3
        r(i)=4;
    end
    if 1/3<r(i) && r(i)<5/12
        r(i)=5;
    end
    if 5/12<r(i) && r(i)<1/2
        r(i)=6;
    end
    if 1/2<r(i) && r(i)<7/12
        r(i)=7;
    end
    if 7/12<r(i) && r(i)<2/3
        r(i)=8;
    end
    if 2/3<r(i) && r(i)<3/4
        r(i)=9;
    end
    if 3/4<r(i) && r(i)<5/6
        r(i)=10;
    end
    if 5/6<r(i) && r(i)<11/12
        r(i)=11;
    end
    if 11/12<r(i) && r(i)<1
        r(i)=12;
    end
end

%Generating Staff and dashed lines for below staff
x=1:12;

Fline = x;
Fline(:) = 15;

Dline= x;
Dline(:) = 13;

Bline = x;
Bline(:) = 11;

Gline = x;
Gline(:) = 9;

Eline = x;
Eline(:) = 7;

Cline = x;
Cline(:) = 5;

Aline = x;
Aline(:) = 3;

fline = x;
fline(:) = 1;

%Graph dimensions and Axes labels
figure()

axis([1,12,0,16])

xlim([1,12])
ylim([0,16])

pitches = ['E';'F';'G';'A';'B';'C';'D'];

set(gca,'XTick',1:12)
set(gca,'YTick',0:16) 

set(gca,'YTickLabel',pitches)
set(gca,'XTickLabel',1:12)

set(0,'DefaultAxesColorOrder',[0,0,0])

%Plot iteratively
for k = 1:12
    
    hold on
    set(0,'DefaultAxesColorOrder',[0,0,0])
    plot(x,Fline,x,Dline,x,Bline,x,Gline,x,Eline,x,Cline,'--',x,Aline,'--',x,fline,'--',x(k),r(k),'o','MarkerSize',30)
    f=f+1;
    saveas(gcf, ['randomseq3_',sprintf('%02d',f),'.png'])
    pause(.5)
    
end







            
        
        
        
        
        
        
