% rawpipe - audio signal from raw stream from shell pipe 
%
% rawpipe ::
%    string     ~'shell pipe',
%    AudioFormat~'stream format',
%    options(sndstream)
% -> signal(C,R).
%
% If channels or rate are not nan, audio format will be converted to match.
% If either of them are nan, the corresponding value from the audio file will
% be left unchanged.
function s=rawpipe(cmd,fmt,varargin)
	s=sndstream(@pipestream,'stringfn',@()sprintf('rawpipe(''%s'')',cmd),varargin{:});

	function [str,cleanup]=pipestream(q)
		[str,cleanup]=pipein(cmd,q);
		str=javax.sound.sampled.AudioInputStream(str,fmt,-1);
	end
end



