% filesink - sink which writes a signal to a WAV file
% filesink :: C:natural, R:real, path, options {...} -> sink(C,R).
function s=filesink(ch,rate,file,varargin)
	str=sprintf('filesink(''%s'')',file);
	s=wavsink(ch,rate,@()filestream(file),@()str,varargin{:});
end

function [str,disp]=filestream(file)
	import  java.io.*;
	str=BufferedOutputStream(FileOutputStream(jfile(file)));
	disp=@nop;
end
