view audio/rawpipe.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 62e31e7980e6
children
line wrap: on
line source
% 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