view sinks/sinkseq.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents f7fb679637ff
children
line wrap: on
line source
% sinkdata - write sequence of arrays to sink
%
% sinkdata :: 
%    seq [[C,N]]  ~'sequence of arrays of C channel signal',
%    sigsink(C,R) ~'sink'
%    natural      ~'maximum size of arrays in input'
% -> action.
%
% Third argument defaults to maximum dimension of signal arrays.
% This function does not control the timing of the writes and
% so is suitable for non-real-time writes to eg audio files.

function res=sinkdata(Y,S,maxbuf)
	if nargin<3, maxbuf=max(size(Y)); end
	u=construct(S);
	try
		W=u.writer(maxbuf);
		u.start(); foreach(@write,Y); u.stop();
	catch ex
		u.dispose();
		rethrow(ex);
	end
	u.dispose();

	function write(x)
		rem=W(x);
		if rem>0, error('Sink is full'); end
	end
end