librosa.shepard_tone#

librosa.shepard_tone(frequency, *, sr=22050, length=None, duration=None, weighting='A', taper=False)[source]#

Construct a single Shepard tone signal.

A Shepard tone is a sound consisting of a superposition of sine waves separated by octaves, covering the audible range (30 Hz to Nyquist).

Parameters:
frequencyfloat > 0 or str

Base frequency of the tone (in Hz) or note name in SPN format (e.g., ‘A4’).

srnumber > 0

Desired sampling rate of the output signal.

lengthint > 0 or None

Desired number of samples in the output signal. When both duration and length are defined, length takes priority.

durationfloat > 0 or None

Desired duration in seconds. When both duration and length are defined, length takes priority.

weightingstr or None

Type of perceptual weighting to apply (e.g., 'A', 'B', 'C', 'D', 'Z'). If None, no weighting is applied.

taperbool

If True, taper the edges of the individual tone components.

Returns:
shepard_signalnp.ndarray [shape=(length,), dtype=float64]

Synthesized Shepard tone signal.

Examples

Generate a single Shepard tone at 440 Hz:

>>> y = librosa.shepard_tone(440.0, duration=1.0, sr=22050)

Or using a note name:

>>> y = librosa.shepard_tone("A4", duration=1.0, sr=22050)