annotate sinks/@sinkmap/sinkmap.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 % sinkmap - sink that applies arbitrart function before sending to subsink.
samer@0 2 %
samer@0 3 % sinkmap ::
samer@0 4 % ([[C1,N]] -> [[C2,N]]) ~'function to tranform samples',
samer@0 5 % (C2:natural -> C1:natural) ~'function to compute number of channels',
samer@0 6 % sink(C2,R)
samer@0 7 % -> sink(C1,R).
samer@0 8 classdef sinkmap < sink
samer@0 9 properties (GetAccess=private,SetAccess=immutable)
samer@0 10 fun
samer@0 11 dest
samer@0 12 chans
samer@0 13 end
samer@0 14 methods
samer@0 15 function s=sinkmap(f,chf,sig)
samer@0 16 s.fun=f;
samer@0 17 s.sig=sig;
samer@0 18 s.chans=chf(channels(dest));
samer@0 19 end
samer@0 20
samer@0 21 function c=channels(s), c=s.chans; end
samer@0 22 function c=rate(s), c=rate(s.dest); end
samer@0 23 function s=construct(sig)
samer@0 24
samer@0 25 f=sig.fun;
samer@0 26 s1=construct(sig.dest);
samer@0 27 s.start = s1.start;
samer@0 28 s.stop = s1.stop;
samer@0 29 s.dispose = s1.dispose;
samer@0 30 s.writer = @writer;
samer@0 31
samer@0 32 function r=writer(n)
samer@0 33 r1=s1.writer(n);
samer@0 34 r =@(x)r1(f(x));
samer@0 35 end
samer@0 36 end
samer@0 37 function s=tostring(sig)
samer@0 38 s=sprintf('map(%s,%s)',tostring(sig.fun),tostring(sig.dest));
samer@0 39 end
samer@0 40 end
samer@0 41 end
samer@0 42 end