function [S,Amps] = genSignal(T,dt,rms,bandwidth,randomSeed)

N = 2*floor(T/(2*dt))+1;
domega = 2*pi/T;
omega = domega*[0:(N-1)/2];

N = length(omega);
Amps = zeros(1,N)+i*zeros(1,N);
index = find((abs(omega)<=bandwidth(2))&(abs(omega)>=bandwidth(1)));
num = length(index);
randn('seed',randomSeed);
Amps(index) = (randn(1,num)+i*randn(1,num));

Amps = [Amps,fliplr(conj(Amps(2:end)))];
S = real(ifft(Amps));

rmsS = sqrt(sum(S.^2)/length(S));
S = S*(rms/rmsS);

Amps = Amps*(rms/rmsS);