FloatWaveform.resample()

FloatWaveform.resample()

Resamples the waveform using the default resampler.

By default, Babycat resamples audio using libsamplerate at its highest-quality setting.

Example

Resample from 44,100 hz to 88,200 hz.

>>> from babycat import FloatWaveform
>>>
>>> waveform = FloatWaveform.from_frames_of_silence(
...     frame_rate_hz=44100,
...     num_channels=2,
...     num_frames=1000,
... )
>>> waveform
<babycat.FloatWaveform: 1000 frames, 2 channels, 44100 hz>
>>> resampled = waveform.resample(11025)
<babycat.FloatWaveform: 250 frames, 2 channels, 11025 hz>
Parameters

frame_rate_hz (int) – The target frame rate to resample the waveform to.

Returns

A new waveform resampled at the given frame rate.

Return type

FloatWaveform

Raises