music.silence

music.silence(duration=1.0, sample_rate=None, number_of_samples=None)[source]

Generate a silence of specified length.

Parameters:
durationint, optional

How many seconds will silence last, by default 1

sample_rateint or None, optional

The sample rate to use. None, the default, is the rate music.get_sample_rate() returns.

number_of_samplesinteger or None

The number of samples, taken instead of duration when given.

Returns:
array

An array with no sound. A duration too short to hold a sample, negative ones included, gives an empty one, as noise() and note() do; a negative one used to raise numpy’s “negative dimensions are not allowed”.

Parameters:
  • duration (float)

  • sample_rate (int | None)

  • number_of_samples (int | None)

Return type:

NDArray[float64]

Examples

>>> gap = silence(duration=0.25)
>>> len(gap), float(abs(gap).max())
(11025, 0.0)
>>> phrase = horizontal_stack(note(220, 0.2), silence(0.1), note(330, 0.2))