Skip to content

Commit

Permalink
Merge pull request #863 from tae898/resample_option
Browse files Browse the repository at this point in the history
resample type option added in pitch_shift()
  • Loading branch information
bmcfee committed Apr 18, 2019
2 parents d3beb5e + a92172a commit 6df3316
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions librosa/effects.py
Expand Up @@ -239,7 +239,7 @@ def time_stretch(y, rate):
return y_stretch


def pitch_shift(y, sr, n_steps, bins_per_octave=12):
def pitch_shift(y, sr, n_steps, bins_per_octave=12, res_type='kaiser_best'):
'''Pitch-shift the waveform by `n_steps` half-steps.
Expand All @@ -257,6 +257,10 @@ def pitch_shift(y, sr, n_steps, bins_per_octave=12):
bins_per_octave : float > 0 [scalar]
how many steps per octave
res_type : string
Resample type.
Possible options: 'kaiser_best', 'kaiser_fast', and 'scipy'.
By default, 'kaiser_best' is used. Refer to core.resample for details.
Returns
-------
Expand Down Expand Up @@ -293,7 +297,7 @@ def pitch_shift(y, sr, n_steps, bins_per_octave=12):
rate = 2.0 ** (-float(n_steps) / bins_per_octave)

# Stretch in time, then resample
y_shift = core.resample(time_stretch(y, rate), float(sr) / rate, sr)
y_shift = core.resample(time_stretch(y, rate), float(sr) / rate, sr, res_type=res_type)

# Crop to the same dimension as the input
return util.fix_length(y_shift, len(y))
Expand Down

0 comments on commit 6df3316

Please sign in to comment.