→ Index

Signal generator for cyclic noise patterns

Release: 0.1.1

Parameters How it works File formats Download History Todo Build


This program noise generates cyclic noise patterns with adjustable properties, like energy distribution and relatively prime frequencies. The cyclic nature of the patterns makes the spectrum discrete which is ideal for FFT analysis without the need of a window function.

The program does not handle the platform dependent output of the data to an DAC like a sound device. This is up to your environment. In general you should pipe the output to some device or application that can play PCM data.

Use cases

Reference signal for measurements of impedance or transfer functions.

Program sequence

The program writes 16-Bit PCM encoded audio data with two channels to stdout or a destination file in RIFF wave format.

Command line options

bnsamples - cycle length
This is the number of samples in one period of the signal. This should be the same as the FFT length used for analysis. So powers of 2 should be preferred.
fminfreq and fmaxfreq - frequency range
Minimum and maximum frequency where the output contains energy.
fincchannels and flogincrement - linear and logarithmic increment for used frequencies
This is creates a discrete energy distribution. Subsequent used frequencies have at least the distance fn+1 = fn · channels + increment rounded to the closest multiple of the cycle frequency. All frequencies in between have no intensity.
This could be used to create support points in an approximately logarithmic frequency axis.
fsampfreq - sampling frequency
48000 Hz by default.
harmn - use harmonics
With this option the first n harmonics of any used frequency are reserved and do not contain energy. Instead the next free frequency will be used. This could be used to do very fast measurements of harmonics of loudspeakers. See dealing with harmonics.
lncount - number of cycles
Number of cycles to generate until the program completes. The loop count only applies to PCM output1 by default.
loop - infinite output
Switches the program to continuous mode. It can only be terminated by either sending a interrupt signal or when the output stream gets closed. You should not use this mode with file output, because it will not terminate until the disk is full.
mst - two channel mode
In two channel mode the used frequencies are alternately used for as channel 1 and channel 2.
scalepower - noise type
Exponent of the energy distribution. 0 := white noise, -1 := pink noise. 0 by default.
wdfile - write design data
Writes the design coefficients into a text file. See @@@@@
wrfile - write reference signal
Writes one cycle of the reference signal to a text file. For each sample exactly one line is written.
wwfile - write PCM data
Writes the binary data as RIFF wave format. If file is -, the output is written to stdout. The Output is always normalized to 0 dB FSR. You could use a transient stream like a character device or a pipe (fifo) as destination too.


noise bn65536 fmin20 fmax20000 ln100 wwnoise.wav
Creates a file noise.wav with 100 cycles of a 65536 samples white noise pattern with 48 kHz sampling rate (about 2½ minutes). Frequencies below 20 Hz and above 20 kHz are suppressed.
noise bn65536 fmin50 fmax20000 loop scale-.5 | some output device
This creates an infinite repetition of 65536 samples noise, weighted with f-0,5 at 48 kHz sampling rate. Frequencies below 50 Hz and above 20 kHz are suppressed. The output is written to stdout where a appropriate program or device handles the DAC output.

How does it work?

The program creates the noise reference by inverse Discrete Fourier Transform. The amplitudes of the Fourier coefficients are calculated by:

ri = fiκ

The phase angles are chosen randomly.

The exponent κ controls the energy distribution. An homogeneous distribution (κ = 0) represents white noise. Positive values prefer high frequencies, negative values prefer low frequencies. κ = -1 creates pink noise.

All coefficients, outside the frequency range [fmin, fmax], are zeroed. This is particularly required when κ < 0, because otherwise the amplitude of the DC component gets singular.

After the inverse Fourier Transform the wave form is normalized to 0dB FSR.

Dealing with harmonics

The harmonics option excludes frequencies from the resulting spectrum if

Because of the second condition it is strongly recommended to set the minimum frequency at least higher than the nth harmonic of the ground frequency of the generated pattern. Otherwise a large gap would occur after the first used frequency.

The graph shows an example of the generated frequencies for a 64 sample noise pattern with 3 harmonics and a minimum frequency of 4:
noise fsamp64 fmin3 fmax32 harm3 wdnoise.dat


In effect the noise pattern contains only energy at the frequencies with red circles. While all the frequencies with red or pink circles are used for analysis. See 'The Art of Noise' for further information.

File formats

design.dat - design coefficients

Column Symbol Description
[1] f Frequency
[2] |R| Magnitude
[3] arg R Phase angle in degrees
[4] re R Real part (ai)
[5] im R Imaginary part (bi)
[6] hamonic Ordinal of the harmonic. Negative values indicate the second channel in case two channel mode is activated

ref.dat - reference waveform

Column Symbol Description
line no. i sample index
[1] Σsij sample value (sum over all channels)
[2], two channel mode only si1 sample value of first channel
[3], two channel mode only si2 sample value of second channel

pcm.dat - PCM output

In single channel mode the output is still stereo. The two channels are used symmetrically: si1 = -si2. This could be used for an improved SNR. But if you don't need this, simply use only one of them.

In two channel mode the two channels contain distinct data as you might suggest.

The output will always be normalized to the maximum sample value ±32767. In two channel mode they are normalized simultaneously.

Change log

Version 0.1.1

Version 0.1

TODOs, known issues

RIFF format and endianess
Currently only PCM data in RIFF wave format is supported for binary output and the endianess is always the platforms native one.