view audio/sndpipe.m @ 42:ae596261e75f

Various fixes and development to audio handling
author samer
date Tue, 02 Dec 2014 14:51:13 +0000
parents 672052bd81f8
children 62e31e7980e6
line wrap: on
line source
% sndpipe - pipe reader implementation of sndstream
%
% sndpipe ::
%    string     ~'shell pipe'
%    options {
%       channels :: natural/nan ~'desired number of channels';
%       rate     :: nonneg/nan ~'desired sampling rate';
%       bits     :: natural/16 ~'desired bits per sample';
%    }
% -> 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=sndpipe(cmd,varargin)
	s=sndstream(@pipestream,'stringfn',@()sprintf('sndpipe(''%s'')',cmd),varargin{:});

	function [str,cleanup]=pipestream(q)
		[str,cleanup]=pipein(cmd,q);
		str=austream(str);
	end
end