music.modulated_noise

music.modulated_noise(noise_type='pink', modulation_freq=10.0, modulation_depth=1.0, duration=2.0, min_freq=15.0, max_freq=15000.0, modulation_waveform_table=array([0., 0.0003835, 0.00076699, ..., -0.00115049, -0.00076699, -0.0003835], shape=(16384,)), number_of_samples=0, sample_rate=44100)[source]

Modulate a band of noise: sstim-v:techBroadbandNoise.

Broadband noise of a chosen colour, optionally amplitude-modulated at a target rate. Unmodulated it is the continuous broadband stimulus SSTIM catalogues as techBroadbandNoise [2], the vehicle for stochastic resonance and for masking. Modulated it is also sstim-v:techAmplitudeModulation [3], whose definition names a carrier tone or noise; the noise carries no pitch of its own, so the rate is all the listener has to lock to.

Parameters:
noise_typestr or scalar

The colour of the noise, as music.noise() takes it: one of "white", "pink", "brown", "blue", "violet", "black", or a number of decibels of gain per octave. The default is pink, which has equal energy per octave and is the usual choice where a spectrum is meant to be even to the ear rather than even in Hertz.

modulation_freqscalar

The rate at which the amplitude is modulated, in Hertz. Zero leaves the noise unmodulated, which is the plain broadband stimulus.

modulation_depthscalar

How deep the modulation goes, in [0, 1], as in amplitude_modulation().

durationscalar

The duration in seconds.

min_freqscalar

The lowest frequency present, in Hertz.

max_freqscalar

The highest frequency present, in Hertz.

modulation_waveform_tablearray_like

The table the modulator is looked up in, so the modulation need not be sinusoidal.

number_of_samplesinteger

The number of samples of the sound, taken instead of duration when it is given.

sample_rateinteger

The sampling frequency in Hertz.

Returns:
ndarray

A mono sequence of PCM samples.

Raises:
ValueError

If modulation_depth is outside [0, 1], where the envelope would go negative and invert the noise rather than deepening the modulation.

ValueError

If modulation_freq is negative. A negative rate is the same modulation as its absolute value for a symmetric table and a different one otherwise, which makes it a mistake rather than a choice.

Parameters:
  • noise_type (str | float)

  • modulation_freq (float)

  • modulation_depth (float)

  • duration (float)

  • min_freq (float)

  • max_freq (float)

  • modulation_waveform_table (ArrayLike)

  • number_of_samples (int)

  • sample_rate (int)

Return type:

NDArray[float64]

See also

amplitude_modulation

the same envelope on a pitched carrier.

music.noise

the underlying colored noise, unshaped.

Notes

The modulation is physically present when there is one. With modulation_freq at zero there is no modulation to be present or absent, and the stimulus is a spectral one rather than a temporal one: SSTIM types techBroadbandNoise as a non-entrainment technique for exactly that reason, and nothing here entrains until a rate is given.

The noise is synthesized once at full length and then shaped, rather than being built per modulation period, so its spectrum is the one music.noise() describes and the modulation does not repeat a single block of samples.

References

[1]

Fabbri, Renato, et al. “Musical elements in the discrete-time representation of sound.” arXiv preprint arXiv:abs/1412.6853 (2017)

[2]

SSTIM, techBroadbandNoise. https://w3id.org/sstim/vocab#techBroadbandNoise

[3]

SSTIM, techAmplitudeModulation. https://w3id.org/sstim/vocab#techAmplitudeModulation

Examples

>>> stimulus = modulated_noise(noise_type='pink', modulation_freq=10)
>>> stimulus.ndim
1