
%Octave:
% Scilab ja Matlab
A=[.8 .2 .1;.1 .7 .3; .1 .1 .6]
axis([0 1 0 1]);axis('square')
     plot(0,0);hold on
title('Markov');xlabel('a');ylabel('b');grid
nappula=1
while nappula==1
   [a,b,nappula] = ginput(1)
    u=[a;b;1-a-b];
    x=u; k=0:7;
    while length(x)<=7
      u=A*u; x=[x u];
    %endwhile
     end
      plot(x(1,:),x(2,:),x(1,:),x(2,:),'o')
%endwhile
end
hold off


x=linspace(0,1,8192);y=sin(440*2*pi*x);sound(y)

     pi=%pi;   // Scilab
   c1=261.6*2*pi;   
   d1=293.7*2*pi;   
   e1=329.6*2*pi;   
   f1=349.2*2*pi;  
   g1=392*2*pi;   
   a1=440*2*pi;   
   h1=493.9*2*pi;   
   c2=2*c1;   

   oktaavi=[c1 d1 e1 f1 g1 a1 h1 c2];
x=linspace(0,1,8192);
x=linspace(0,1,22050);
for k=1:length(oktaavi)
y=sin(oktaavi(k)*x);sound(y);
pause
end


x=linspace(0,1,8192);y=0.5*sin(c1*x)+0.5*sin(e1*x);sound(y)


     % Intervallit:
x=linspace(0,1,8192);y=0.5*sin(c1*x)+0.5*sin(e1*x);sound(y)
>> x=linspace(0,1,8192);y=0.5*sin(c1*x)+0.5*sin(c2*x);sound(y) % Okataavi
>> x=linspace(0,1,8192);y=0.5*sin(c1*x)+0.5*sin(d1*x);sound(y) % Priimi
>> x=linspace(0,1,8192);y=0.5*sin(c1*x)+0.5*sin(e1*x);sound(y) % Sekuntti
>> x=linspace(0,1,8192);y=0.5*sin(c1*x)+0.5*sin(f1*x);sound(y) % Terssi
>> x=linspace(0,1,8192);y=0.5*sin(c1*x)+0.5*sin(g1*x);sound(y) % Kvartti
>> x=linspace(0,1,8192);y=0.5*sin(c1*x)+0.5*sin(a1*x);sound(y) % Kvintti
>> x=linspace(0,1,8192);y=0.5*sin(c1*x)+0.5*sin(h1*x);sound(y) % Seksti
>> x=linspace(0,1,8192);y=0.5*sin(c1*x)+0.5*sin(c1*x);sound(y)
>> x=linspace(0,1,8192);y=0.5*sin(c1*x)+0.5*sin(c2*x);sound(y)

% Kolmisoinnut

   c1=261.6*2*pi;   
   d1=293.7*2*pi;   
   e1=329.6*2*pi;   
   f1=349.2*2*pi;  
   g1=392*2*pi;   
   a1=440*2*pi;   
   h1=493.9*2*pi;   
   c2=2*c1;   

 x=linspace(0,1,8192);kolmisointu=0.3*sin(e1*x)+0.3*sin(g1*x)+0.3*sin(h1*x);sound(kolmisointu);

>> x=linspace(0,1,2*8192);kolmisointu=0.3*sin(e1*x)+0.3*sin(g1*x)+0.3*sin(h1*x);sound(kolmisointu);
>> x=linspace(0,1,2*8192);kolmisointu=0.3*sin(e1*x)+0.3*sin(g1*x)+0.3*sin(h1*x);sound(kolmisointu,2*8192);
>> plot(x,kolmisointu)
>> xlim([0 0.04])
>> xlim([0 0.1])

x=linspace(0,1,8192);y=0.5*sin(c1*x)+0.5*sin(a1*x);sound(y) % Kvintti
plot(x,y); title('Kvintti'); xlim([0 0.04])

%

c1=261.6*2*pi;   
   d1=293.7*2*pi;   
   e1=329.6*2*pi;   
   f1=349.2*2*pi;  
   g1=392*2*pi;   
   a1=440*2*pi;   
   h1=493.9*2*pi;   
   c2=2*c1;   

tuiki=[c1,c1,g1,g1,a1,a1 g1 f1 f1 e1 e1 d1 d1 c1 g1 g1 f1 f1 e1 e1 d1];
tuiki=[tuiki g1 g1 f1 f1 e1 e1 d1 c1 c1 g1 g1 a1 a1 g1 f1 f1 e1 e1 d1 d1 c1];


   t=linspace(0,1,8192);

   for k=1:length(tuiki)
     y=sin(tuiki(k)*t);sound(y)   
     pause 
   end;
 

tuikit=[c1*t c1*t g1*t g1*t];
y=sin(tuikit); sound(y,4*8192)

     tuikit=[]; 
     for k=1:length(tuiki)
      tuikit=[tuikit tuiki(k)*t];
     end;

y=sin(tuikit); sound(y,8192)

     plot(T,y)

