function soundwrite(Signal, Filename)
%
%   soundwrite(Signal, Filename)
%
%   write a wav file of Signal (mono or stereo) into 
%              Filename (including path, otherwise current directory).
%   sampling frequency: 50 kHz
%
%
m=max(abs(Signal));

if max(m) >= 1.0 
   Signal=Signal/(max(m)+1e-6);
   end     % prevents overflow errors when writing wav files

     wavwrite(Signal, 50000, 16, Filename);

return