Mercurial > hg > ishara
view sinks/@sink/sink.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | 672052bd81f8 |
children |
line wrap: on
line source
% sink - Base class for sink % % sink :: sink(C:natural,R:nonneg). % % The sink(C,R) type denotes the type of a sink with C % channels and a sampling rate of R. % % The base sink class cannot be used without subclassing since % any attempt to instantiate the live sink will throw % an exception. % % METHODS % channels :: sink(C,R) -> natural. % rate :: sink(C,R) -> nonneg. % construct:: sink(C,R) -> livesink(C,_). % capacity :: sink(C,R) -> natural. % % livesink(C,Z) :== struct { % start :: void->void; % stop :: void->void; % dispose :: void->Z; % writer :: N:natural -> ([[C,N]] -> natural); % } classdef sink methods function o=sink, end function s=and(s1,s2), s=sinkcat(s1,s2); end function r=rate(s), error('sampling rate undefined'); end function c=channels(s), error('number of channels undefined'); end function s=construct(sig), error('Cannot construct base sink class'); end function display(a) disp(sprintf(' %s :: sink(%s,%s)',tostring(a),fmt(channels(a)),fmt(rate(a)))); function s=fmt(x), if isnan(x), s='_'; else s=num2str(x); end; end end function y=map(f,chf,x), y=sinkmap(f,chf,x); end function y=drop(n,x), y=sinkdrop(n,x); end function y=take(n,x), y=sinktake(n,x); end function y=dropt(t,x), if isnan(rate(x)), error('Cannot dropt without definite sampling rate'); end y=sinkdropt(round(t*rate(x)),x); end function y=taket(t,x), if isnan(rate(x)), error('Cannot taket without definite sampling rate'); end y=sinktake(round(t*rate(x)),x); end end end