librosa.effects.vibrato#
- librosa.effects.vibrato(y, *, sr, rate=5.0, depth=0.5, mode='sine', phase=0.0, kind='linear', n_fft=2048, hop_length=None, win_length=None, window='hann', center=True, pad_mode='constant')[source]#
Apply vibrato (pitch modulation) to an audio signal.
- Parameters:
- ynp.ndarray [shape=(…, n)]
Audio time series. Multi-channel is supported.
- srnumber > 0 [scalar]
Audio sampling rate of
y.- ratefloat > 0 [scalar]
Modulation frequency in Hertz (Hz). Defaults to 5.0 Hz.
- depthfloat > 0 [scalar]
Modulation depth in semitones (e.g. 0.5 corresponds to +-0.5 semitones deviation).
- mode{‘sine’, ‘triangle’}
The LFO waveform shape used for frequency modulation: - ‘sine’ : Sinusoidal modulation - ‘triangle’ : Triangular modulation
- phasefloat
Initial phase offset of the LFO in radians.
- kindstr
Specifies the type of interpolation used when re-aligning time warping. Passed to
scipy.interpolate.interp1d. Defaults to “linear”.- n_fftint > 0 [scalar]
Length of the windowed signal after padding with zeros. The number of rows in the STFT matrix is
(1 + n_fft/2).- hop_lengthint or None
Number of audio samples between adjacent STFT columns. If unspecified, defaults to
win_length // 4.- win_lengthint or None
Each frame of audio is windowed by
windowof lengthwin_lengthand then padded with zeros to matchn_fft. If unspecified, defaults towin_length = n_fft.- windowstr, tuple, number, function, or np.ndarray [shape=(n_fft,)]
Window specification. See
scipy.signal.get_windowfor supported values.- centerbool
If
True, the signal is padded so that frametis centered aty[t * hop_length].- pad_modestr
Padding mode used when
center=True. Seenumpy.padfor available modes.
- Returns:
- y_vibratonp.ndarray [shape=(…, n)]
The pitch-modulated audio time series.
See also
Examples
Apply vibrato to a pure tone and plot the spectrograms before and after.
>>> import matplotlib.pyplot as plt >>> sr = 22050 >>> y = librosa.tone(440, sr=sr, duration=2.0) >>> y_vib = librosa.effects.vibrato(y, sr=sr, rate=5.0, depth=1.0) >>> S_orig = librosa.stft(y) >>> S_vib = librosa.stft(y_vib) >>> fig, ax = plt.subplots(nrows=2, sharex=True, sharey=True) >>> librosa.display.specshow( ... S_orig, sr=sr, vscale="dBFS", x_axis="time", y_axis="log", ax=ax[0] ... ) >>> ax[0].set(title="Original tone spectrogram") >>> ax[0].label_outer() >>> librosa.display.specshow( ... S_vib, sr=sr, vscale="dBFS", x_axis="time", y_axis="log", ax=ax[1] ... ) >>> ax[1].set(title="Vibrato tone spectrogram")