function [x,phi]=block(o,phi0,N,f0,f1)
% block - Generate block of hardsync signal data
%
% block :: 
%    hardsync,
%    0--1       ~'initial phase of master'
%    N:natural  ~'number of samples to compute',
%    0--1       ~'normalised frequency of master (1=sampling freq)',
%    0--1       ~'normalised frequency of slave (1=sampling freq)',
% -> [[1,N]]    ~'signal data',
%    0--1       ~'initial phase for next block'.

	x=zeros(1,N); 
	l0=round(1/f0);
	
	j=1; T=round(l0*(1-mod(phi0,1))); 
	phi1=f1*mod(phi0,1);

	while j<=N && T<=N
		M=T-j+1;
		x(j:T)=phi1+f1*(0:M-1);
		j=T+1;
		T=T+l0;
		phi1=0;
	end
	phi0=0;

	M=N-j+1;
	x(j:N)=phi1+f1*(0:M-1);
	phi1=phi1+f1*M;
	phi0=f0*M;


