function [pps,syn,t,npoints,dt] = sine_to_psd_spec_TH(f1,f2,dur,start_rms)
%
sr=f2*20;
dt=1/sr;
npoints=round(dur/dt)+1;
%
n=501;
df=(f2-f1)/(n-1);
for(i=1:n)
    f(i)=f1+(i-1)*df;
    a(i)=1;
    phase(i)=2*pi*rand();
end
%
t=linspace(0,dur,npoints);
%
clear syn;
syn=zeros(npoints,1);
%
omega=2*pi*f;
t=t';
for(i=1:n)
    syn=syn+sin(omega(i)*t+phase(i));
end
%
dt=(t(npoints)-t(1))/(npoints-1);
%
as=std(syn);
syn=syn*start_rms/as;
%
%%% figure(1);
%%% plot(t,syn);
pps=[t syn];