S=load('gong');
Fs=44e3;
t0=45*60;
st=clock;
while(1)
  N=fix(stdchoose(10,15));
  dn=abs(randn)/2+.2;
  dx=2*abs(randn)/2+1;
  g1=2^(.25+3.75*rand);
  dir1=double(rand>.5);
  r1=1+rand;
  
  fn=440+abs(randn)*100;
  fx=440-abs(randn)*100;
  g2=2^(.25+3.75*rand);
  dir2=double(rand>.5);
  r2=1+rand;
  
  n=0:N;
  s1=(dir1+(-1)^(dir1)*n/N);
  d=dn+(dx-dn)*sin(pi/r1*s1.^g1);
  off=d/2;
  s2=(dir2+(-1)^(dir2)*n/N);
  f=fn+(fx-fn)*sin(pi/r2*s2.^g2);
  plot(n/N,[d;f/440],'o-');
  drawnow;
  
  et=etime(clock,st);
  if(rand<.01+tanh(10*(et/t0-1))/4+.25)
    d=.5;
    t=0:1/Fs:d;
    wavplay(A*sin(2*pi*300*((t/d)).^2),Fs);
    d=stdchoose(15,10);
    f=440;
    A=1;
    t=0:1/Fs:d;
    wavplay(A*(.3+.7*t./d).*exp(-(sin(2*pi*t.*(1+4*t/d)/2)/.2).^2).*sin(2*pi*f*t)/2,Fs);
    wavplay(S.y/2,S.Fs*2);
  else
    for n=0:N
      s1=(dir1+(-1)^(dir1)*n/N);
      d=dn+(dx-dn)*sin(pi/r1*s1.^g1);
      off=d*(.5+randn/10);
      s2=(dir2+(-1)^(dir2)*n/N);
      f=fn+(fx-fn)*sin(pi/r2*s2.^g2);
      A=1;
      t=0:1/Fs:d;
      wavplay(A*exp(-((t-off)/.04).^2).*sin(2*pi*f*t)/2,Fs);
    end
%     d=.5;
%     t=0:1/Fs:d;
%     wavplay(A*sin(2*pi*300*(1-(t/d)).^2),Fs);
  end
%   pause(stdchoose(15,20));
end

