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{:}),'sizecheck',1); 

	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
	
