PNoiseGenerator#

class acoular.signals.PNoiseGenerator

Bases: NoiseGenerator

Generate pink noise signal.

The PNoiseGenerator class generates pink noise signals, which exhibit a \(1/f\) power spectral density. Pink noise is characterized by equal energy per octave, making it useful in various applications such as audio testing, sound synthesis, and environmental noise simulations.

The pink noise simulation is based on the Voss-McCartney algorithm, which iteratively adds noise with increasing wavelength to achieve the desired \(1/f\) characteristic.

See also

WNoiseGenerator

For white noise generation.

UncorrelatedNoiseSource

For per-channel noise generation.

References

depth

“Octave depth” of the pink noise generation. Higher values result in a better approximation of the \(1/f\) spectrum at low frequencies but increase computation time. The maximum allowable value depends on the number of samples. Default is 16.

digest

A unique checksum identifier based on the object properties. (read-only)

signal()

Generate and deliver the pink noise signal.

The signal is computed using the Voss-McCartney algorithm, which generates noise with a \(1/f\) power spectral density. The method ensures that the output has the desired RMS amplitude and spectrum.

Returns:
numpy.ndarray

A 1D array of floats containing the generated pink noise signal. The length of the array is equal to num_samples.

Notes

  • The “depth” parameter controls the number of octaves included in the pink noise simulation. If the specified depth exceeds the maximum possible value based on the number of samples, it is automatically adjusted, and a warning is printed.

  • The output signal is scaled to have the same overall level as white noise by dividing the result by np.sqrt(depth + 1.5).

usignal(factor)

Resample the signal at a higher sampling frequency.

This method uses Fourier transform-based resampling to deliver the signal at a sampling frequency that is a multiple of the original sample_freq. The resampled signal has a length of factor * num_samples.

Parameters:
factorint

The resampling factor. Defines how many times larger the new sampling frequency is compared to the original sample_freq.

Returns:
numpy.ndarray

The resampled signal as a 1D array of floats.

Notes

This method relies on the scipy.signal.resample() function for resampling.

Examples

Resample a signal by a factor of 4:

>>> from acoular import SineGenerator  # Class extending SignalGenerator
>>> sg = SineGenerator(sample_freq=100.0, num_samples=1000)
>>> resampled_signal = sg.usignal(4)
>>> len(resampled_signal)
4000
rms

Root mean square (RMS) amplitude of the signal. For a point source, this corresponds to the RMS amplitude at a distance of 1 meter. Default is 1.0.

seed

Seed for random number generator. Default is 0. This parameter should be set differently for different instances to guarantee statistically independent (non-correlated) outputs.

sample_freq

Sampling frequency of the signal in Hz. Default is 1.0.

num_samples

The number of samples to generate for the signal.