This module contains functions for generating common deterministic and
stochastic audio signals such as impulses, sine sweeps, and noise signals.
All signal lengths are given in samples. The value for the length is casted to
an integer number in all cases. This makes it possible to pass float numbers.
For example:
the duration in seconds, the sampling points in
seconds, and the frequency limits and
.
Parameters:
n_samples (int) – The length of the sweep in samples
frequency_range (array like) – Frequency range of the sweep given by the lower and upper cut-off
frequency in Hz.
n_fade_out (int, optional) – The length of the squared cosine fade-out in samples. This is done to
avoid discontinuities at the end of the sweep. The default is 90,
which equals approximately 2 ms at sampling rates of 44.1 and 48 kHz.
amplitude (double, optional) – The amplitude of the signal. The default is 1.
sweep_rate (double, optional) – Rate at which the sine frequency increases over time. If this is given,
n_samples is calculated according to the sweep rate. The default is
None, which uses n_samples without modifications.
sampling_rate (int, optional) – The sampling rate in Hz. The default is 44100.
Returns:
sweep – The sweep signal. The Signal is in the time domain and has the none
FFT normalization (see normalization). The
sweep type, frequency range, and length of the fade our are written to
comment.
Generate a single or multi channel impulse signal, also known as the
Dirac delta function.
Parameters:
n_samples (int) – Length of the impulse in samples
delay (double, array like, optional) – Delay in samples. The default is 0.
amplitude (double, optional) – The peak amplitude of the impulse. The default is 1.
sampling_rate (int, optional) – The sampling rate in Hz. The default is 44100.
Returns:
signal – The impulse signal. The Signal is in the time domain and has the
none FFT normalization (see
normalization). The delay and amplitude
are written to comment.
The parameters delay and amplitude are
broadcasted
to the parameter that contains the most elements. For example delay
could be of shape (2,4), amplitude of shape (2,1) or a scalar.
In this case all parameters would be broadcasted to a shape of (2,4).
with the duration in seconds, the sampling points in
seconds, and the frequency limits and
.
Parameters:
n_samples (int) – The length of the sweep in samples
frequency_range (array like) – Frequency range of the sweep given by the lower and upper cut-off
frequency in Hz.
n_fade_out (int, optional) – The length of the squared cosine fade-out in samples. This is done to
avoid discontinuities at the end of the sweep. The default is 90,
which equals approximately 2 ms at sampling rates of 44.1 and 48 kHz.
amplitude (double, optional) – The amplitude of the signal. The default is 1.
sampling_rate (int, optional) – The sampling rate in Hz. The default is 44100.
Returns:
sweep – The sweep signal. The Signal is in the time domain and has the none
FFT normalization (see normalization). The
sweep type, frequency range, and length of the fade our are written to
comment.
Generate single or multi channel normally distributed white or pink noise.
The pink noise is generated by applying a sqrt(1/f) filter to the
spectrum.
Parameters:
n_samples (int) – The length of the signal in samples
spectrum (str, optional) – white to generate noise with constant energy across frequency.
pink to generate noise with constant energy across filters with
constant relative bandwith. The default is white.
rms (double, array like, optional) – The route mean square (RMS) value of the noise signal. A multi channel
noise signal is generated if an array of RMS values is passed.
The default is 1.
sampling_rate (int, optional) – The sampling rate in Hz. The default is 44100.
seed (int, None, optional) – The seed for the random generator. Pass a seed to obtain identical
results for multiple calls. The default is None, which will yield
different results with every call.
Returns:
signal – The noise signal. The signal is in the time domain and has the rms
FFT normalization (see normalization). The
type of the spectrum (white, pink) and the RMS amplitude are
written to comment.
Generate single channel normally distributed pulsed white or pink noise.
The pink noise is generated by applying a sqrt(1/f) filter to the
spectrum.
Parameters:
n_pulse (int) – The length of the pulses in samples
n_pause (int) – The length of the pauses between the pulses in samples.
n_fade (int, optional) – The length of the squared sine/cosine fade-in and fade outs in samples.
The default is 90, which equals approximately 2 ms at sampling
rates of 44.1 and 48 kHz.
repetitions (int, optional) – Specifies the number of noise pulses. The default is 5.
rms (double, array like, optional) – The RMS amplitude of the white signal. The default is 1.
spectrum (string, optional) – The noise spectrum, which can be pink or white. The default is
pink.
frozen (boolean, optional) – If True, all noise pulses are identical. If False each noise
pulse is a separate stochastic process. The default is True.
sampling_rate (int, optional) – The sampling rate in Hz. The default is 44100.
seed (int, None, optional) – The seed for the random generator. Pass a seed to obtain identical
results for multiple calls. The default is None, which will yield
different results with every call.
Returns:
signal – The noise signal. The Signal is in the time domain and has the rms
FFT normalization (see normalization).
comment contains information about the selected parameters.
frequency (double, array like) – Frequency of the sine in Hz (0 <= frequency <= sampling_rate/2).
n_samples (int) – Length of the signal in samples.
amplitude (double, array like, optional) – The amplitude. The default is 1.
phase (double, array like, optional) – The phase in radians. The default is 0.
sampling_rate (int, optional) – The sampling rate in Hz. The default is 44100.
full_period (boolean, optional) – Make sure that the returned signal contains an integer number of
periods resulting in a periodic signal. This is done by adjusting the
frequency of the sine. The default is False.
Returns:
signal – The sine signal. The Signal is in the time domain and has the rms
FFT normalization (see normalization).
The exact frequency, amplitude and phase are written to comment.
The parameters frequency, amplitude, and phase are
broadcasted
to the parameter that contains the most elements. For example frequency
could be of shape (2,4), amplitude of shape (2,1), and phase
could be a scalar. In this case all parameters would be broadcasted to a
shape of (2,4).