annotate sinks/@sinkcat/construct.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 672052bd81f8
children
rev   line source
samer@0 1 function s=construct(sig)
samer@0 2 sc=construct(sig.sinks{1});
samer@0 3 sx=sig.sinks(2:end);
samer@0 4
samer@0 5 s.start = @start;
samer@0 6 s.stop = @stop;
samer@0 7 s.dispose = @dispose;
samer@0 8 s.writer = @writer;
samer@0 9
samer@0 10 function start, sc.start(); end
samer@0 11 function stop, sc.stop(); end
samer@0 12 function dispose, sc.dispose(); end
samer@0 13
samer@0 14 function r=writer(n)
samer@0 15 rc=sc.writer(n);
samer@0 16 r = @next;
samer@0 17 function rem=next(x)
samer@0 18 rem=rc(x);
samer@0 19 while rem>0 && ~isempty(sx) % current signal exhausted, try next
samer@0 20 sc.dispose();
samer@0 21 sc=construct(sx{1}); sx=sx(2:end);
samer@0 22 rem=sinkwriten(sc,n,x(end-rem+1:end));
samer@0 23 rc=sc.writer(n);
samer@0 24 end
samer@0 25 end
samer@0 26 end
samer@0 27 end