clear

pkg load ltfat

a1 = [2,4,6];
a2 = [3,5,7];
a3 = [1,2,3,4,5,6,7];
%fs = 22050;
fs = 44100;
t = linspace(0,1,fs);
f0 = 130;
fmax = 1500;
for j = 1:3,
    y1(:,j) = 0.15*sin(2*pi*f0*t*a1(j));
end

for j = 1:3,
    y2(:,j) = 0.15*sin(2*pi*f0*t*a2(j));
end

for j = 1:7,
    y3(:,j) = 0.45/7*sin(2*pi*f0*t*a3(j));
end



while (1==1)
  k = input("Please press 1 to 4 or q\n","s");
  k
  if( k == '1' )
   
        sound(sum(y1,2).*tukeywin(fs),fs);
	subplot(2,2,1)
	sgram(sum(y1,2).*tukeywin(fs),fs,'fmax',fmax,'wlen',512);
    end
    
    if ( k == '2' )
      subplot(2,2,2)
      sound(sum(y2,2).*tukeywin(fs),fs);
      sgram(sum(y2,2).*tukeywin(fs),fs,'fmax',fmax,'wlen',512);
    end

    if ( k == '3' )
      subplot(2,2,3)
      tone = 0.5*(sum(y1,2)+sum(y2,2));
      sound(tone.*tukeywin(fs),fs);
      sgram(tone.*tukeywin(fs),fs,'fmax',fmax,'wlen',512);
	
    end
    if( k == '4' )
      subplot(2,2,4)
      sound(sum(y3,2).*tukeywin(fs),fs);
      sgram(sum(y3,2).*tukeywin(fs),fs,'fmax',fmax,'wlen',512);
    end
    if( k == 'q' )
        break;
    end


end


% you can try to match y1 and y2 to the right and left channels,
% respectively
% play it then, and see what happens
