function y=shepardtone(N,C,prof,H)
% shepardtone - Shepard tone by additive synthesis
%
% shepardtone ::
%    N:natural    ~'size of buffers to produce',
%    seq(real)    ~'sequence of chroma values, 0--1 is one octave',
% -> seq([[1,N]]) ~'sum of components'.
%
% Note: the number of components must remain constant

if nargin<3, 
	prof=@(z)betapdf(2*z,2,9); 
elseif isvector(prof),
	a=prof(1); b=prof(2);
	prof=@(z)betapdf(2*z,a,b);
end

fc=0.25;
if nargin<4, H=(-10:1)'; else H=H(:); end
F=fndata(@(c)fc*2.^(H+mod(c,1)),C);  % frequencies
A=fndata(prof,F); % component amplitudes
y=addsynth(N,A,F,0);

