Waveform.resample()¶
- Waveform.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 Waveform >>> >>> waveform = Waveform.from_frames_of_silence( ... frame_rate_hz=44100, ... num_channels=2, ... num_frames=1000, ... ) >>> waveform <babycat.Waveform: 1000 frames, 2 channels, 44100 hz> >>> resampled = waveform.resample(11025) <babycat.Waveform: 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
- Raises
babycat.exceptions.FeatureNotCompiled – Raised when you are trying to use a feature at runtime that as not included in Babycat at compile-time.
babycat.exceptions.ResamplingError – Raised when we failed to encode an audio stream into an output format.