view dsp/synth/srdata.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 9e7be347b3a0
children
line wrap: on
line source
function x=srdata(gen,s0,varargin)
% srdata - Signal as a sequence of blocks from signal generator object
%
% srdata :: 
%    gen(A,B{1:N})  ~'signal generator object',
%    A              ~'initial state',
%    seq(B{1}       ~'sequence of 1st param values',
%    ...   
%    seq(B{N}       ~'sequence of Nst param values',
% -> seq([[1,_]]).
%
% The main point of this construct is to maintain state
% between calls to the block method of the signal generator, and
% also to supply the generator with a sequence of parameter
% values.

	x=mapaccum(@blockgen,s0,zip(varargin{:})); 

	function [y,state]=blockgen(theta,state)
		% this is weird - for some reason Matlab crashes if I call block
		% directly from here, but is ok if I go via the non-nested bblock
		[y,state]=bblock(gen,state,theta);
	end
end

function [y,s]=bblock(gen,s,theta)
	[y,s]=block_sr(gen,s,theta{:});
end