view signals/@sigconst/sigconst.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
classdef sigconst < signal
	properties (GetAccess=private, SetAccess=immutable)
		val
		fs
	end
	methods
		function s=sigconst(val,rate)
			if nargin<2, rate=nan; end
			s.val=reshape(val,size(val,1),1);
			s.fs=rate;
		end

		function s=tostring(sig), s=sprintf('sigconst(%s)',mat2str(sig.val)); end
		function c=channels(s), c=size(s.val,1); end
		function c=rate(s), c=s.fs; end
		function s=construct(sig)
			s.start   = @nop;
			s.stop    = @nop;
			s.dispose = @nop;
			s.reader = @reader;

			function r=reader(n)
				r = @next;
				buf=repmat(sig.val,1,double(n));
				function [x,rem]=next, x=buf; rem=0; end
			end
		end
	end
end