music.amplitude_modulation¶
- music.amplitude_modulation(carrier_freq=200.0, modulation_freq=10.0, modulation_depth=1.0, duration=2.0, waveform_table=array([0., 0.0003835, 0.00076699, ..., -0.00115049, -0.00076699, -0.0003835], shape=(16384,)), 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]¶
Sinusoidally modulate a carrier:
sstim-v:techAmplitudeModulation.A carrier tone whose amplitude is sinusoidally modulated at a target rate; the canonical stimulus for evoking auditory steady-state responses at the modulation frequency [2].
- Parameters:
- carrier_freqscalar
The frequency of the carrier, in Hertz.
- modulation_freqscalar
The rate at which its amplitude is modulated, in Hertz.
- modulation_depthscalar
How deep the modulation goes, in
[0, 1]. At 1 the envelope reaches zero once per modulation period; at 0 the carrier is left alone.- durationscalar
The duration in seconds.
- waveform_tablearray_like
The table the carrier is looked up in.
- modulation_waveform_tablearray_like
The table the modulator is looked up in, so the modulation need not be sinusoidal.
- number_of_samples
integer The number of samples of the sound, taken instead of
durationwhen it is given.- sample_rate
integer The sampling frequency in Hertz.
- Returns:
ndarrayA mono sequence of PCM samples.
- Raises:
ValueErrorIf
modulation_depthis outside[0, 1], where the envelope would go negative and invert the carrier’s phase rather than deepening the modulation.
- Parameters:
- Return type:
NDArray[float64]
See also
monaural_beatsan equivalent envelope arising from two tones rather than imposed on one.
Notes
The modulation is physically present, and it is the modulation rate rather than the carrier that sets the frequency of the evoked response, which is the whole point of the stimulus.
References
[1]Fabbri, Renato, et al. “Musical elements in the discrete-time representation of sound.” arXiv preprint arXiv:abs/1412.6853 (2017)
[2]SSTIM,
techAmplitudeModulation. https://w3id.org/sstim/vocab#techAmplitudeModulationExamples
>>> stimulus = amplitude_modulation(carrier_freq=200, ... modulation_freq=40) >>> stimulus.ndim 1