## How to synthesize band-limited noise?

Started by 3 years ago●15 replies●latest reply 3 years ago●1191 viewsHello everyone,

My goal is to generate band-limited noise. Simply: user defines BW and my task is to generate time domain complex samples to imitate defined band nosie. I have to implement this in C/C++ and I don't have an access to any DSP library. Question to you: what would be the simplest approach to generate band-limited noise? There is no special requirements if it comes to the "shape" of the spectrum. Lets say that 95% of the generated noise has to reside in user-defined bandwidth.

Any suggestions how to deal with that problem?

Or maybe someone have already had this kind of problem and could share the source code or at least share the idea?

Best regards,

Marcin

It would help to know more about what you want. Do you want to generate one indefinite length stream of random numbers? Or do you want to generate a finite length sequence of given length? Do you want the program to run as fast as possible, or to be the fewest lines of code? Do you care if the probability distribution is gaussian or could it be arbitrary?

For a single finite length sequence, least code, generate N uniformly distributed random numbers and zero out some of them, the frequencies you want to be missing. Then compute the DFT for your answer. This is probably a least-code approach.

For a sequence of indefinite length, you want a digital filter which can be applied to a noise source. If the bandwidth is small compared to the sampling rate, the filter will make the output gaussian. Otherwise, or for great accuracy, you can transform a uniform random sequence to gaussian and then filter that. Note, since this is an indefinite length sequence, what you are really providing to the user is a subroutine which he can call to get the next sample of the band limited sequence. This is pretty few time cycled between the first call and the first sample. In IIR filter design is probably appropriate.

If the probability distribution is to be arbitrary, the problem is much much harder. But this isn't too likely to be what your user wants.

Dear CharlieRader,

First of all, thank you for your answer. Replying to your questions:

- its going to be definite length of samples,

- its not have to be fast cause samples are going to be calculated once at the beginning of the simulation,

- I dont care about probability function, I just need to have a noise which instantaneous power would be equal to 1W but its not a problem since it can be done using apropriate scaling.

Do you mean IFFT?

Marcin,

The most common approach is to take wide bandwidth white noise sequence and filter its bandwidth down to the desired bandwidth with a, IRR filter. That's actually not the best approach. What you want to do is generate the noise at the bandwidth you want with a low sample rate commensurate with the low bandwidth and then interpolate up with a resampling filter to the sample rate you want. See attached paper

fred h

Hello Marcinstein. You should feel honored to receive replies from both fharris and Charlie Rader. You should tell your family about this.

Hello Mr Lyons!

Yeah thats true, I feel honored cause so many living legends wrote under my question, including you! Thank you all, problem was resolved using IFFT for that purpose!

Best regards,

Marcin

Hello Marcinstein.

Oh no no! I'm not in the same league as Charles Rader and fred harris.

Charles Rader, among his other accomplishments, is literally one of inventors of IIR digital filters. His seminal 1967 paper titled: "Digital Filter Design Techniques In the Frequency Domain" was ground-breaking. He was also the co-author of the very first DSP book ("Digital Processing of Signals"). To understand Charlie's influence on the world of DSP, have a look at:

http://citeseerx.ist.psu.edu/viewdoc/download?doi=...

fred harris (who holds the record for the most number of years teaching university-level DSP classes) must surely be the most prolific writer of DSP technical papers. I'll bet fred's influential and famous 1978 paper titled: "On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform" is the most referenced paper EVER published in a signal process journal. fred is a recognized world leader in multirate signal processing and software defined radios. The thing I like about fred is that he builds systems--he knows which end of the soldering iron is hot.

Generate random noise then filter it off to the band limits you target.

In Ocatve I can use filter functions(fir1...filter) to generate random complex noise of any power level, design filter and filter the noise vector. Your problem would be to design a user defined filter which may vary...

Yeah! Thats was my idea also! I know that in Octave or Matlab there are plenty of usefull functions but as I mentioned, I need to write it in C/C++. Question is, how to generate proper filter factors?

That takes us to lower level filter design methods. Plenty around.

Windowed sinc example:

M = 39; %number of taps

Fc = .2; %cutoff relative to Fs of 1

x = linspace(-(M-1)/2,(M-1)/2,M);

h = ones(1,M);%default

i = find(x); %avoid division by zero

h(i) = sin(x(i)*2*pi*Fc)./(x(i)*2*pi*Fc);

%h = h .* hamming(M)'; %apply a window

h = h/sum(h);%dc power unity

Thanks!

What do you think about using FFT? By zeroing bins for each subcarries and put random complex numbers in place where noise has to occur?

I have an access to FFT/IFFT algorithms in my compiler.

yes that is ok if you afford ifft and then you don't need any filter (ifft stopband acts as filter) but is frame based and might suffer discontinuity between frames.

Discontinuity is not a problem, generated samples will act as a noise. I have already implemented this algorithm in Matlab. Works like a charm.

Thank you :)

Marcin

Hello Marcin: If you do not have access to C/C++ libraries (like fft/ifft), the simplest method to generate a noise time series of length N, between frequencies fa and fb, is to sum up a bunch of random magnitude cosines and sines between lying between fa and fb, in the time domain.. You can make it 'more noisy' by randomising both amplitudes and phases.

That doesn't make any sense at all, and sounds very indefinite. Unless you did this with a very large number of components, you'd have a spectrum that is characterized by spikes.

The whole point of specifying noise precisely (in the power spectral density sense) is to ensure it has a certain frequency characteristic that cannot be predicted.

I guess if this is something that just looks/sounds "noise-like" to a person who isn't very discerning, then ok, sure, maybe. But the human ear/mind is surprisingly good at discerning frequency content. I'd be willing to bet a moderate amount of money that if I heard true noise with a uniform power spectral density over a certain band, and noise generated by the method you suggest, that I could discern the difference.

jms_nh, it took me years to understand what you just wrote about. What is white noise? My initial idea of a spectrum was rather simple. You start with a time function (or a sequence) and you compute its Fourier transform (or its DFT) and that is what you call its spectrum. The squared magnitude of that is its power spectrum. But that simple view is not what people are talking about when they talk about noise.

The problem is that vanishingly few sequences have a power spectrum which is what you want. What the noise spectrum really means is more complex. Imagine a whole pile of different waveforms (or sequences), infinitely many. If you draw one waveform (or sequence) from the pile it is almost completely unlikely to have the desired spectrum. What we talk about in noise spectral estimation is the *expected value *of the magnitude of a spectrum if the waveform (or sequence) is drawn at random from that hypothetical pile.

That's just math, and you are talking about hearing, how something sounds. I don't want to oversimplify but surely our ears do not respond to a spectrum in my original sense. You can't even think about a spectrum of a time waveform because it requires the whole infinite duration of the waveform to compute a spectrum. Our ears respond to a short-time spectrum. Roughly that means that a waveform is multiplied by a sliding finite length window and for each position of the window, the product of the waveform and the window is Fourier transformed and the ear responds to that. So every instant, the window in in a new position and the ear responds to a new spectrum. Almost none of these infinitely many spectra are what you want. But taken together, we can think of the set of infinitely many window-multiplied waveforms as if they constitute the "whole pile of different waveforms" in the last paragraph.

Of course, the term "noise spectrum" is never applicable in practice for waveforms.

You are right that generating one instance of a noise waveform will not sound like another instance of a noise waveform. It may sound like clicks, or like scratchy sandpaper, etc. By calling it noise, we really mean that the sound is *unpredictable* in detail.