Mercurial > hg > ishara
view signals/@signal/length.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | 289445d368a7 |
children |
line wrap: on
line source
% length - length of finite signal function n=length(sig,varargin) opts=prefs('chunk',1024,'init',2,'grow',2,'max',1e12,varargin{:}); s=construct(sig); try % to make sure we dispose of s once opened chunk=uint64(opts.chunk); n=uint64(0); CHUNK=1:chunk; r=s.reader(opts.chunk); dummy=[]; rem=0; while rem==0 [dummy,rem]=r(); n=n+chunk; if n>opts.max, error('maximum length exceeded'); end end n=n-uint64(rem); % remove rem samples from end catch ex s.dispose(); rethrow(ex); end s.dispose(); n=double(n); end