annotate 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
rev   line source
samer@10 1 % sinkdata - write sequence of arrays to sink
samer@10 2 %
samer@10 3 % sinkdata ::
samer@10 4 % seq [[C,N]] ~'sequence of arrays of C channel signal',
samer@10 5 % sigsink(C,R) ~'sink'
samer@10 6 % natural ~'maximum size of arrays in input'
samer@10 7 % -> action.
samer@10 8 %
samer@10 9 % Third argument defaults to maximum dimension of signal arrays.
samer@10 10 % This function does not control the timing of the writes and
samer@10 11 % so is suitable for non-real-time writes to eg audio files.
samer@10 12
samer@10 13 function res=sinkdata(Y,S,maxbuf)
samer@10 14 if nargin<3, maxbuf=max(size(Y)); end
samer@10 15 u=construct(S);
samer@10 16 try
samer@10 17 W=u.writer(maxbuf);
samer@10 18 u.start(); foreach(@write,Y); u.stop();
samer@10 19 catch ex
samer@10 20 u.dispose();
samer@10 21 rethrow(ex);
samer@10 22 end
samer@10 23 u.dispose();
samer@10 24
samer@10 25 function write(x)
samer@10 26 rem=W(x);
samer@10 27 if rem>0, error('Sink is full'); end
samer@10 28 end
samer@10 29 end
samer@10 30
samer@10 31