function noise = tvnoise2(Neff,tdep,tarr,fcdep,fcarr,B) ;

% - input  : - Neff : signal length
%            - [tdep:tarr] : signal support indices
%            - fcdep : (reduced) central frequency at tdep (<1/2)
%            - fcarr : (reduced) central frequency at tarr (<1/2)
%            - B : (reduced) bandwidth (<1/2)
%
% - output : - noise : time-varying bandpass noise
%
% needs  - WaveLab http://www-stat.stanford.edu/~wavelab/

N = 2*Neff ;
Nfft = N ;

spb = zeros(Nfft,N) ;

fcdep = fix(4*Neff*fcdep) ;
fcarr = fix(4*Neff*fcarr) ;
B = fix(4*Neff*B) ;

for m = tdep:tarr

    A = (fcarr-fcdep)/(tarr-tdep) ;
    Binf = fcdep-B/2 ;
    Bsup = fcdep+B/2 ;
    spb(fix(Binf+(m-tdep)*A):fix(Bsup+(m-tdep)*A),m) = ones(length(fix(Bsup+(m-tdep)*A)-fix(Binf+(m-tdep)*A)),1) ;

end

spb = spb.*exp(i*2*pi*rand(size(spb))) ;
spb(N+1:2*N,:) = flipud(conj(spb(1:N,:))) ;

w = fix(sqrt(Neff)) ;
Name = 'Hanning' ;

bb = real(IWindowFT(spb,w,Name)) ;
bbeff = bb(1:Neff) ;
noise = bbeff/std(bbeff) ;
