function wf(y, Fs, ng)
% waterfall 0.01 made by ha1flx
if nargin<2
  Fs = 44100;
end
if size(y, 2) > 1
  ymix = sum(y, 2) ./ size(y, 2);
else
  ymix = y;
end
step=ceil(5*Fs/1000);   
window=ceil(25*Fs/1000); 
n = 2^nextpow2(window);
k = floor((length(ymix)-n) / step);
wfall = zeros(k,n);

for i=1:k
  part = abs(fft(hanning(n).*(ymix(i*step:i*step+n-1)),n));
  wfall(i, :) = [part(n/2+1:n) ; part(1:n/2)];
end

axis_f = (-n/2:n/2-1)*(Fs/n);
axis_t = (0:k-1)*(step/Fs);


if nargin>2
  image (axis_f, axis_t, wfall(:,:));% minden
else
  image (axis_f(n/2:n), axis_t, wfall(:,n/2:n));% csak pozitiv frekitartomany
end
%[w_f, w_t] = meshgrid(axis_f, axis_t);
%waterfall(w_f, w_t, wfall);

colormap default;
 
xlabel("Frekvencia (Hz)");
ylabel("Idő (s)");
title (strcat('Vízesés diagram, Fs=',num2str(Fs),'Hz'));
